[elbe-devel] [PATCH] libvirt.xml: Workaround for buggy qemu machine type in vmware/stretch

Andreas Messerschmid andreas at linutronix.de
Fri Nov 23 17:42:25 CET 2018


Add a heuristic to set a working qemu machine type when generating
libvirt.xml on initvm creation when running on a VMware setup
with Debian Stretch.

Solves https://github.com/Linutronix/elbe/issues/183

Signed-off-by: Andreas Messerschmid <andreas at linutronix.de>
---
 elbepack/init/libvirt.xml.mako | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/elbepack/init/libvirt.xml.mako b/elbepack/init/libvirt.xml.mako
index c2b3d077..02ad4d40 100644
--- a/elbepack/init/libvirt.xml.mako
+++ b/elbepack/init/libvirt.xml.mako
@@ -14,6 +14,7 @@ import uuid
 import multiprocessing
 import os
 from elbepack.filesystem import size_to_int
+import subprocess
 
 # Generate UUID
 uid = uuid.uuid4()
@@ -27,6 +28,21 @@ img = os.path.join(opt.directory, 'buildenv.img')
 
 emulator = prj.text('interpreter', default=defs, key='interpreter')
 
+# this is a workaround for
+# http://lists.linutronix.de/pipermail/elbe-devel/2017-July/000541.html
+virt = subprocess.Popen('test -x /usr/bin/systemd-detect-virt && /usr/bin/systemd-detect-virt',
+                        shell=True,
+                        stdin=subprocess.PIPE,
+                        stdout=subprocess.PIPE).communicate()[0];
+dist = subprocess.Popen('lsb_release -cs',
+                        shell=True,
+                        stdin=subprocess.PIPE,
+                        stdout=subprocess.PIPE).communicate()[0];
+
+if 'vmware' in virt and 'stretch' in dist:
+    machine_type = 'pc-i440fx-2.6'
+else:
+    machine_type = 'pc'
 %><domain type='kvm'
 xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
 <name>${name}</name>
@@ -35,7 +51,7 @@ xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
   <currentMemory unit='KiB'>${memory}</currentMemory>
   <vcpu placement='static'>${cpus}</vcpu>
   <os>
-    <type arch='x86_64' machine='pc'>hvm</type>
+    <type arch='x86_64' machine='${machine_type}'>hvm</type>
   </os>
   <features>
     <acpi />
-- 
2.11.0




More information about the elbe-devel mailing list