From 063b2b8788db204d0ac2e1d367fd0c5eb9b81451 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Wed, 14 Jun 2017 13:43:37 +0200 Subject: [PATCH] qemu: Add qemuDomainCheckABIStability When making ABI stability checks for an active domain, we need to make sure we use the same migratable definition which virDomainGetXMLDesc with the MIGRATABLE flag provides, otherwise the ABI check will fail. This is implemented in the new qemuDomainCheckABIStability which takes a domain object and generates the right migratable definition from it. Signed-off-by: Jiri Denemark Reviewed-by: Pavel Hrdina --- src/qemu/qemu_domain.c | 41 ++++++++++++++++++++++++++++++++++++----- src/qemu/qemu_domain.h | 4 ++++ 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 01644694ba..6838d2eaa4 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5919,6 +5919,10 @@ qemuDomainMigratableDefCheckABIStability(virQEMUDriverPtr driver, } +#define COPY_FLAGS (VIR_DOMAIN_XML_SECURE | \ + VIR_DOMAIN_XML_UPDATE_CPU | \ + VIR_DOMAIN_XML_MIGRATABLE) + bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, virDomainDefPtr src, @@ -5926,13 +5930,10 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, { virDomainDefPtr migratableDefSrc = NULL; virDomainDefPtr migratableDefDst = NULL; - const unsigned int flags = VIR_DOMAIN_XML_SECURE | - VIR_DOMAIN_XML_UPDATE_CPU | - VIR_DOMAIN_XML_MIGRATABLE; bool ret = false; - if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, flags)) || - !(migratableDefDst = qemuDomainDefCopy(driver, dst, flags))) + if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, COPY_FLAGS)) || + !(migratableDefDst = qemuDomainDefCopy(driver, dst, COPY_FLAGS))) goto cleanup; ret = qemuDomainMigratableDefCheckABIStability(driver, @@ -5945,6 +5946,36 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, return ret; } + +bool +qemuDomainCheckABIStability(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainDefPtr dst) +{ + virDomainDefPtr migratableSrc = NULL; + virDomainDefPtr migratableDst = NULL; + char *xml = NULL; + bool ret = false; + + if (!(xml = qemuDomainFormatXML(driver, vm, COPY_FLAGS)) || + !(migratableSrc = qemuDomainDefFromXML(driver, xml)) || + !(migratableDst = qemuDomainDefCopy(driver, dst, COPY_FLAGS))) + goto cleanup; + + ret = qemuDomainMigratableDefCheckABIStability(driver, + vm->def, migratableSrc, + dst, migratableDst); + + cleanup: + VIR_FREE(xml); + virDomainDefFree(migratableSrc); + virDomainDefFree(migratableDst); + return ret; +} + +#undef COPY_FLAGS + + bool qemuDomainAgentAvailable(virDomainObjPtr vm, bool reportError) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index ef3a33076c..a2cd155c33 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -666,6 +666,10 @@ bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, virDomainDefPtr src, virDomainDefPtr dst); +bool qemuDomainCheckABIStability(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainDefPtr dst); + bool qemuDomainAgentAvailable(virDomainObjPtr vm, bool reportError);