[PATCH 0/2] lib: appliance: qemu 2.9.0 supports TCG with -cpu host on x86 (RHBZ#1277744).
NB: This requires a qemu patch by Eduardo which is currently awaiting review: https://www.mail-archive.com/qemu-devel@nongnu.org/msg422959.html So not to be applied yet unless that qemu change goes upstream. Rich.
Pass the qemu version struct to this function so that in future we can make decisions here based on the version of qemu. --- src/appliance-cpu.c | 2 +- src/guestfs-internal.h | 2 +- src/launch-direct.c | 3 ++- src/launch-libvirt.c | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/appliance-cpu.c b/src/appliance-cpu.c index 6a9fb0d..a7cf1eb 100644 --- a/src/appliance-cpu.c +++ b/src/appliance-cpu.c @@ -68,7 +68,7 @@ * =back */ const char * -guestfs_int_get_cpu_model (int kvm) +guestfs_int_get_cpu_model (int kvm, const struct version *qemu_version) { #if defined(__aarch64__) /* With -M virt, the default -cpu is cortex-a15. Stupid. */ diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 40dad35..6e314ea 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -833,7 +833,7 @@ extern const char *guestfs_int_drive_protocol_to_string (enum drive_protocol pro extern int guestfs_int_build_appliance (guestfs_h *g, char **kernel, char **initrd, char **appliance); /* appliance-cpu.c */ -const char *guestfs_int_get_cpu_model (int kvm); +const char *guestfs_int_get_cpu_model (int kvm, const struct version *qemu_version); /* appliance-kcmdline.c */ extern char *guestfs_int_appliance_command_line (guestfs_h *g, const char *appliance_dev, int flags); diff --git a/src/launch-direct.c b/src/launch-direct.c index efedf92..a12fa8b 100644 --- a/src/launch-direct.c +++ b/src/launch-direct.c @@ -391,7 +391,8 @@ launch_direct (guestfs_h *g, void *datav, const char *arg) #endif !force_tcg ? "kvm:tcg" : "tcg"); - cpu_model = guestfs_int_get_cpu_model (has_kvm && !force_tcg); + cpu_model = guestfs_int_get_cpu_model (has_kvm && !force_tcg, + &data->qemu_version); if (cpu_model) { ADD_CMDLINE ("-cpu"); ADD_CMDLINE (cpu_model); diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c index 168bba6..b32efd8 100644 --- a/src/launch-libvirt.c +++ b/src/launch-libvirt.c @@ -1139,7 +1139,8 @@ construct_libvirt_xml_cpu (guestfs_h *g, string_format ("%d", g->memsize); } end_element (); - cpu_model = guestfs_int_get_cpu_model (params->data->is_kvm); + cpu_model = guestfs_int_get_cpu_model (params->data->is_kvm, + ¶ms->data->qemu_version); if (cpu_model) { start_element ("cpu") { if (STREQ (cpu_model, "host")) { -- 2.10.2
Starting with version 2.9.0, qemu can use: qemu-system-x86_64 -M accel=tcg -cpu host without breaking. This only applies to x86 (i386 or x86_64) at the moment. If we detect these conditions, pass -cpu host unconditionally. This should hopefully address problems where other hypervisors (eg. VirtualBox) are running, which breaks KVM in a way that we cannot detect, and consequently breaks libguestfs. --- src/appliance-cpu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/appliance-cpu.c b/src/appliance-cpu.c index a7cf1eb..fa7e941 100644 --- a/src/appliance-cpu.c +++ b/src/appliance-cpu.c @@ -63,7 +63,7 @@ * * We don't know for sure if KVM will work, but C<-cpu host> is broken * with TCG, so we almost always pass a broken C<-cpu> flag if KVM is - * semi-broken in any way. + * semi-broken in any way. (This is fixed in qemu 2.9, thanks Eduardo!) * * =back */ @@ -77,6 +77,14 @@ guestfs_int_get_cpu_model (int kvm, const struct version *qemu_version) else return "cortex-a57"; #else +#if defined(__i386__) || defined(__x86_64__) + /* Eduardo added the ability to use -cpu host with TCG on x86 in + * qemu 2.9. + */ + if (guestfs_int_version_ge (qemu_version, 2, 9, 0)) + return "host"; + /* otherwise fallthrough */ +#endif /* On most architectures, it is faster to pass the CPU host model to * the appliance, allowing maximum speed for things like checksums * and encryption. Only do this with KVM. It is broken in subtle -- 2.10.2
participants (1)
-
Richard W.M. Jones