From 06f75ff2cb292e2658b4f2f6949c700550006272 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Fri, 30 Jun 2017 16:55:20 +0200 Subject: [PATCH] qemu: Don't update CPU when formatting live def Since commit v2.2.0-199-g7ce711a30e libvirt stores an updated guest CPU in domain's live definition and there's no need to update it every time we want to format the definition. The commit itself tried to address this in qemuDomainFormatXML, but forgot to fix qemuDomainDefFormatLive. Not to mention that masking a previously set flag is only acceptable if the flag was set by a public API user. Internally, libvirt should have never set the flag in the first place. https://bugzilla.redhat.com/show_bug.cgi?id=1485022 Signed-off-by: Jiri Denemark --- src/qemu/qemu_domain.c | 2 -- src/qemu/qemu_domain.h | 3 +-- src/qemu/qemu_driver.c | 7 +++++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a5fe468f67..ee66418473 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4765,8 +4765,6 @@ char *qemuDomainFormatXML(virQEMUDriverPtr driver, } else { def = vm->def; origCPU = priv->origCPU; - if (virDomainObjIsActive(vm)) - flags &= ~VIR_DOMAIN_XML_UPDATE_CPU; } return qemuDomainDefFormatXMLInternal(driver, def, origCPU, flags); diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index b291dc3082..09201b1a40 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -40,8 +40,7 @@ # include "logging/log_manager.h" # define QEMU_DOMAIN_FORMAT_LIVE_FLAGS \ - (VIR_DOMAIN_XML_SECURE | \ - VIR_DOMAIN_XML_UPDATE_CPU) + (VIR_DOMAIN_XML_SECURE) # if ULONG_MAX == 4294967295 /* QEMU has a 64-bit limit, but we are limited by our historical choice of diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index da98770dc1..1b271792db 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6997,6 +6997,13 @@ static char if ((flags & VIR_DOMAIN_XML_MIGRATABLE)) flags |= QEMU_DOMAIN_FORMAT_LIVE_FLAGS; + /* The CPU is already updated in the domain's live definition, we need to + * ignore the VIR_DOMAIN_XML_UPDATE_CPU flag. + */ + if (virDomainObjIsActive(vm) && + !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) + flags &= ~VIR_DOMAIN_XML_UPDATE_CPU; + ret = qemuDomainFormatXML(driver, vm, flags); cleanup: -- 2.39.5