From 5a76947526023484d27b6f43853602e6e0510063 Mon Sep 17 00:00:00 2001 Message-Id: <5a76947526023484d27b6f43853602e6e0510063@dist-git> From: Jiri Denemark Date: Wed, 14 Jun 2017 14:56:21 +0200 Subject: [PATCH] qemu: Use qemuDomainCheckABIStability where needed Most places which want to check ABI stability for an active domain need to call this API rather than the original qemuDomainDefCheckABIStability. The only exception is in snapshots where we need to decide what to do depending on the saved image data. https://bugzilla.redhat.com/show_bug.cgi?id=1460952 Signed-off-by: Jiri Denemark Reviewed-by: Pavel Hrdina (cherry picked from commit f0a3fe1b0a2996272dd167501bb5de752d9d1956) Signed-off-by: Jiri Denemark --- src/qemu/qemu_driver.c | 71 +++++++++++++++++++++++++++-------------------- src/qemu/qemu_migration.c | 2 +- 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5567103c37..c7c5e28ca3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3326,7 +3326,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom, VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE))) { goto endjob; } - if (!qemuDomainDefCheckABIStability(driver, vm->def, def)) { + if (!qemuDomainCheckABIStability(driver, vm, def)) { virDomainDefFree(def); goto endjob; } @@ -15415,39 +15415,50 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, * to have finer control. */ if (virDomainObjIsActive(vm)) { /* Transitions 5, 6, 8, 9 */ - /* Replace the CPU in config and put the original one in priv - * once we're done. - */ - if (cookie && cookie->cpu && config->cpu) { - origCPU = config->cpu; - if (!(config->cpu = virCPUDefCopy(cookie->cpu))) - goto endjob; - } - /* Check for ABI compatibility. We need to do this check against * the migratable XML or it will always fail otherwise */ - if (config && - !qemuDomainDefCheckABIStability(driver, vm->def, config)) { - virErrorPtr err = virGetLastError(); + if (config) { + bool compatible; - if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) { - /* Re-spawn error using correct category. */ - if (err->code == VIR_ERR_CONFIG_UNSUPPORTED) - virReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY, "%s", - err->str2); - goto endjob; + /* Replace the CPU in config and put the original one in priv + * once we're done. When we have the updated CPU def in the + * cookie, we don't want to replace the CPU in migratable def + * when doing ABI checks to make sure the current CPU exactly + * matches the one used at the time the snapshot was taken. + */ + if (cookie && cookie->cpu && config->cpu) { + origCPU = config->cpu; + if (!(config->cpu = virCPUDefCopy(cookie->cpu))) + goto endjob; + + compatible = qemuDomainDefCheckABIStability(driver, vm->def, + config); + } else { + compatible = qemuDomainCheckABIStability(driver, vm, config); + } + + if (!compatible) { + virErrorPtr err = virGetLastError(); + + if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) { + /* Re-spawn error using correct category. */ + if (err->code == VIR_ERR_CONFIG_UNSUPPORTED) + virReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY, "%s", + err->str2); + goto endjob; + } + virResetError(err); + qemuProcessStop(driver, vm, + VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, + QEMU_ASYNC_JOB_START, 0); + virDomainAuditStop(vm, "from-snapshot"); + detail = VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT; + event = virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_STOPPED, + detail); + qemuDomainEventQueue(driver, event); + goto load; } - virResetError(err); - qemuProcessStop(driver, vm, - VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, - QEMU_ASYNC_JOB_START, 0); - virDomainAuditStop(vm, "from-snapshot"); - detail = VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT; - event = virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_STOPPED, - detail); - qemuDomainEventQueue(driver, event); - goto load; } priv = vm->privateData; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index a4540ce3c4..5eed933a3c 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2028,7 +2028,7 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver, VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE))) goto cleanup; - if (!qemuDomainDefCheckABIStability(driver, vm->def, def)) + if (!qemuDomainCheckABIStability(driver, vm, def)) goto cleanup; rv = qemuDomainDefFormatLive(driver, def, NULL, false, true); -- 2.13.1