Richard W.M. Jones
2011-May-17 12:59 UTC
[Libguestfs] [PATCH] appliance: Use qemu -machine option where available (RHBZ#700369).
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/ -------------- next part -------------->From dd76a0a3dd4904c9c031bd85000fc571157305f9 Mon Sep 17 00:00:00 2001From: Richard W.M. Jones <rjones at redhat.com> Date: Tue, 17 May 2011 13:58:20 +0100 Subject: [PATCH] appliance: Use qemu -machine option where available (RHBZ#700369). --- TODO | 5 ----- src/launch.c | 37 +++++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/TODO b/TODO index 6e69319..6579629 100644 --- a/TODO +++ b/TODO @@ -467,8 +467,3 @@ right range of data so that integration would be possible. The standards for CMDBs come from the DMTF, see eg: http://dmtf.org/news/pr/2009/7/dmtf-releases-cmdbf-standard-federating-configuration-management-data - -See if qemu -machine option can be used to select KVM, TCG acceleration ------------------------------------------------------------------------ - -See upstream qemu commit 303d4e865b74402b49f52e975c396c952f063e58 diff --git a/src/launch.c b/src/launch.c index ecc0464..0b15ce9 100644 --- a/src/launch.c +++ b/src/launch.c @@ -487,21 +487,30 @@ launch_appliance (guestfs_h *g) if (qemu_supports (g, "-nodefconfig")) add_cmdline (g, "-nodefconfig"); - /* qemu sometimes needs this option to enable hardware - * virtualization, but some versions of 'qemu-kvm' will use KVM - * regardless (even where this option appears in the help text). - * It is rumoured that there are versions of qemu where supplying - * this option when hardware virtualization is not available will - * cause qemu to fail, so we we have to check at least that - * /dev/kvm is openable. That's not reliable, since /dev/kvm - * might be openable by qemu but not by us (think: SELinux) in - * which case the user would not get hardware virtualization, - * although at least shouldn't fail. A giant clusterfuck with the - * qemu command line, again. + /* The qemu -machine option (added 2010-12) is a bit more sane + * since it falls back through various different acceleration + * modes, so try that first (thanks Markus Armbruster). */ - if (qemu_supports (g, "-enable-kvm") && - is_openable (g, "/dev/kvm", O_RDWR)) - add_cmdline (g, "-enable-kvm"); + if (qemu_supports (g, "-machine")) { + add_cmdline (g, "-machine"); + add_cmdline (g, "accel=kvm:tcg"); + } else { + /* qemu sometimes needs this option to enable hardware + * virtualization, but some versions of 'qemu-kvm' will use KVM + * regardless (even where this option appears in the help text). + * It is rumoured that there are versions of qemu where supplying + * this option when hardware virtualization is not available will + * cause qemu to fail, so we we have to check at least that + * /dev/kvm is openable. That's not reliable, since /dev/kvm + * might be openable by qemu but not by us (think: SELinux) in + * which case the user would not get hardware virtualization, + * although at least shouldn't fail. A giant clusterfuck with the + * qemu command line, again. + */ + if (qemu_supports (g, "-enable-kvm") && + is_openable (g, "/dev/kvm", O_RDWR)) + add_cmdline (g, "-enable-kvm"); + } /* Newer versions of qemu (from around 2009/12) changed the * behaviour of monitors so that an implicit '-monitor stdio' is -- 1.7.5
Apparently Analagous Threads
- Re: [PATCH] v2v: Further increase memory allocated to the appliance (RHBZ#1418283).
- [PATCH] Add test for qemu broken -machine option (RHBZ#748266).
- [PATCH] Enable coredumps to be captured from the appliance (RHBZ#619334).
- [PATCH] Fix broken qemu <= 0.10 which randomly adds a CD-ROM device to the appliance
- [PATCH] Revert "add_drive_ro adds readonly=on option if available." (RHBZ#617200).