From fd15ef11527807e3e80333585dc908f1c414bc06 Mon Sep 17 00:00:00 2001 Message-Id: From: Michal Privoznik Date: Mon, 17 Mar 2014 15:48:30 +0100 Subject: [PATCH] qemu: Introduce qemuDomainDefCheckABIStability https://bugzilla.redhat.com/show_bug.cgi?id=994364 https://bugzilla.redhat.com/show_bug.cgi?id=1076503 Whenever we check for ABI stability, we have new xml (e.g. provided by user, or obtained from snapshot, whatever) which we compare to old xml and see if ABI won't break. However, if the new xml was produced via virDomainGetXMLDesc(..., VIR_DOMAIN_XML_MIGRATABLE) it lacks some devices, e.g. 'pci-root' controller. Hence, the ABI stability check fails even though it is stable. Moreover, we can't simply fix virDomainDefCheckABIStability because removing the correct devices is task for the driver. For instance, qemu driver wants to remove the usb controller too, while LXC driver doesn't. That's why we need special qemu wrapper over virDomainDefCheckABIStability which removes the correct devices from domain XML, produces MIGRATABLE xml and calls the check ABI stability function. Signed-off-by: Michal Privoznik (cherry picked from commit 7d704812b9c50cd3804dd1e7f9e2ea3e75fdc847) Signed-off-by: Jiri Denemark --- src/qemu/qemu_domain.c | 22 ++++++++++++++++++++++ src/qemu/qemu_domain.h | 3 +++ src/qemu/qemu_driver.c | 10 ++-------- src/qemu/qemu_migration.c | 4 ++-- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 7f4d17d..0b57b6a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2327,3 +2327,25 @@ qemuDomainUpdateDeviceList(virQEMUDriverPtr driver, priv->qemuDevices = aliases; return 0; } + +bool +qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, + virDomainDefPtr src, + virDomainDefPtr dst) +{ + virDomainDefPtr migratableDefSrc = NULL; + virDomainDefPtr migratableDefDst = NULL; + const 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))) + goto cleanup; + + ret = virDomainDefCheckABIStability(migratableDefSrc, migratableDefDst); + +cleanup: + virDomainDefFree(migratableDefSrc); + virDomainDefFree(migratableDefDst); + return ret; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 9735761..91e9ade 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -370,4 +370,7 @@ extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig; int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver, virDomainObjPtr vm); +bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, + virDomainDefPtr src, + virDomainDefPtr dst); #endif /* __QEMU_DOMAIN_H__ */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cc6c133..89be90c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3090,7 +3090,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom, VIR_DOMAIN_XML_INACTIVE))) { goto endjob; } - if (!virDomainDefCheckABIStability(vm->def, def)) { + if (!qemuDomainDefCheckABIStability(driver, vm->def, def)) { virDomainDefFree(def); goto endjob; } @@ -13839,7 +13839,6 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, qemuDomainObjPrivatePtr priv; int rc; virDomainDefPtr config = NULL; - virDomainDefPtr migratableDef = NULL; virQEMUDriverConfigPtr cfg = NULL; virCapsPtr caps = NULL; @@ -13956,11 +13955,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, /* Transitions 5, 6, 8, 9 */ /* Check for ABI compatibility. We need to do this check against * the migratable XML or it will always fail otherwise */ - if (!(migratableDef = qemuDomainDefCopy(driver, vm->def, - VIR_DOMAIN_XML_MIGRATABLE))) - goto cleanup; - - if (config && !virDomainDefCheckABIStability(migratableDef, config)) { + if (config && !qemuDomainDefCheckABIStability(driver, vm->def, config)) { virErrorPtr err = virGetLastError(); if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) { @@ -14165,7 +14160,6 @@ cleanup: } if (vm) virObjectUnlock(vm); - virDomainDefFree(migratableDef); virObjectUnref(caps); virObjectUnref(cfg); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 03ae9e4..deacb66 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2088,7 +2088,7 @@ static char VIR_DOMAIN_XML_INACTIVE))) goto cleanup; - if (!virDomainDefCheckABIStability(vm->def, def)) + if (!qemuDomainDefCheckABIStability(driver, vm->def, def)) goto cleanup; rv = qemuDomainDefFormatLive(driver, def, false, true); @@ -2297,7 +2297,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, if (!newdef) goto cleanup; - if (!virDomainDefCheckABIStability(*def, newdef)) { + if (!qemuDomainDefCheckABIStability(driver, *def, newdef)) { virDomainDefFree(newdef); goto cleanup; } -- 1.9.0