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

bage at linutronix.de bage at linutronix.de
Fri Feb 22 11:58:44 CET 2019


From: Bastian Germann <bage at linutronix.de>

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 issue #183.
Original author: Andreas Messerschmid.

Signed-off-by: Bastian Germann <bage at linutronix.de>
---
 elbepack/commands/init.py      | 12 ++++++++++++
 elbepack/init/libvirt.xml.mako |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/elbepack/commands/init.py b/elbepack/commands/init.py
index 3bb36551..9c66e948 100644
--- a/elbepack/commands/init.py
+++ b/elbepack/commands/init.py
@@ -21,6 +21,7 @@ from elbepack.version import elbe_version
 from elbepack.templates import write_template, get_initvm_preseed
 from elbepack.directories import init_template_dir, elbe_dir
 from elbepack.config import cfg
+from elbepack.shellhelper import command_out
 
 
 def run_command(argv):
@@ -146,6 +147,16 @@ def run_command(argv):
     else:
         path = opt.directory
 
+    # this is a workaround for
+    # http://lists.linutronix.de/pipermail/elbe-devel/2017-July/000541.html
+    _, virt = command_out('test -x /usr/bin/systemd-detect-virt && /usr/bin/systemd-detect-virt');
+    _, dist = command_out('lsb_release -cs')
+
+    if 'vmware' in virt and 'stretch' in dist:
+        machine_type = 'pc-i440fx-2.6'
+    else:
+        machine_type = 'pc'
+
     try:
         os.makedirs(path)
     except OSError as e:
@@ -171,6 +182,7 @@ def run_command(argv):
          "http_proxy": http_proxy,
          "pkgs": xml.node("/initvm/pkg-list") or [],
          "preseed": get_initvm_preseed(xml),
+         "machine_type": machine_type,
          "cfg": cfg}
 
     if http_proxy != "":
diff --git a/elbepack/init/libvirt.xml.mako b/elbepack/init/libvirt.xml.mako
index dd422d6e..92e64b45 100644
--- a/elbepack/init/libvirt.xml.mako
+++ b/elbepack/init/libvirt.xml.mako
@@ -41,7 +41,7 @@ xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
   </cpu>
 % endif
   <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