[elbe-devel] [PATCH] libvirt.xml: Workaround for buggy qemu machine type in vmware/stretch
Torben Hohn
torben.hohn at linutronix.de
Mon Nov 26 11:00:16 CET 2018
On Mon, Nov 26, 2018 at 10:56:41AM +0100, Torben Hohn wrote:
> On Fri, Nov 23, 2018 at 05:42:25PM +0100, Andreas Messerschmid wrote:
> > 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.
>
> Please dont execute child processes in a mako template.
> Error handling in a mako template is sort of limited.
>
> Please move the detection code into
> elbepack/commands/init.py and then pass the
> machine_type into the mako template using "d"
oh... and also please use
from elbepack.shellhelper import system_out
instead of subprocess
>
> >
> > 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
> >
> >
> > _______________________________________________
> > elbe-devel mailing list
> > elbe-devel at linutronix.de
> > https://lists.linutronix.de/mailman/listinfo/elbe-devel
>
> --
> Torben Hohn
> Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
> Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
>
> Hinweise zum Datenschutz finden Sie hier (Informations on data privacy
> can be found here): https://linutronix.de/kontakt/Datenschutz.php
>
> Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen |
> Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700
> 806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel
--
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
Hinweise zum Datenschutz finden Sie hier (Informations on data privacy
can be found here): https://linutronix.de/kontakt/Datenschutz.php
Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen |
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20181126/dbfe2bce/attachment.sig>
More information about the elbe-devel
mailing list