提交 dfd70ca1 编写于 作者: M Maxiwell S. Garcia 提交者: Michal Privoznik

qemu: Do not override config XML in case of snapshot revert

Snapshot create operation saves the live XML and uses it to replace the
domain definition in case of revert. But the VM config XML is not saved
and the revert operation does not address this issue. This commit
prevents the config XML from being overridden by snapshot definition.

An active domain stores both current and new definitions. The current
definition (vm->def) stores the live XML and the new definition
(vm->newDef) stores the config XML. In an inactive domain, only the
config XML is persistent, and it's saved in vm->def.

The revert operation uses the virDomainObjAssignDef() to set the
snapshot definition in vm->newDef, if domain is active, or in vm->def
otherwise. But before that, it saves the old value to return to
caller. This return is used here to restore the config XML after
all snapshot startup process finish.
Signed-off-by: NMaxiwell S. Garcia <maxiwell@linux.ibm.com>
上级 6d3ac4f7
...@@ -16243,6 +16243,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, ...@@ -16243,6 +16243,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
qemuDomainObjPrivatePtr priv; qemuDomainObjPrivatePtr priv;
int rc; int rc;
virDomainDefPtr config = NULL; virDomainDefPtr config = NULL;
virDomainDefPtr inactiveConfig = NULL;
virQEMUDriverConfigPtr cfg = NULL; virQEMUDriverConfigPtr cfg = NULL;
virCapsPtr caps = NULL; virCapsPtr caps = NULL;
bool was_stopped = false; bool was_stopped = false;
...@@ -16457,7 +16458,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, ...@@ -16457,7 +16458,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
goto endjob; goto endjob;
} }
if (config) { if (config) {
virDomainObjAssignDef(vm, config, false, NULL); virDomainObjAssignDef(vm, config, false, &inactiveConfig);
virCPUDefFree(priv->origCPU); virCPUDefFree(priv->origCPU);
VIR_STEAL_PTR(priv->origCPU, origCPU); VIR_STEAL_PTR(priv->origCPU, origCPU);
} }
...@@ -16466,7 +16467,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, ...@@ -16466,7 +16467,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
load: load:
was_stopped = true; was_stopped = true;
if (config) if (config)
virDomainObjAssignDef(vm, config, false, NULL); virDomainObjAssignDef(vm, config, false, &inactiveConfig);
/* No cookie means libvirt which saved the domain was too old to /* No cookie means libvirt which saved the domain was too old to
* mess up the CPU definitions. * mess up the CPU definitions.
...@@ -16525,6 +16526,9 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, ...@@ -16525,6 +16526,9 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
detail); detail);
} }
} }
if (inactiveConfig)
VIR_STEAL_PTR(vm->newDef, inactiveConfig);
break; break;
case VIR_DOMAIN_SNAPSHOT_SHUTDOWN: case VIR_DOMAIN_SNAPSHOT_SHUTDOWN:
...@@ -16552,8 +16556,11 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, ...@@ -16552,8 +16556,11 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
qemuProcessEndJob(driver, vm); qemuProcessEndJob(driver, vm);
goto cleanup; goto cleanup;
} }
if (config) if (config) {
virDomainObjAssignDef(vm, config, false, NULL); virDomainObjAssignDef(vm, config, false, &inactiveConfig);
if (inactiveConfig)
VIR_STEAL_PTR(vm->newDef, inactiveConfig);
}
if (flags & (VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING | if (flags & (VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING |
VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED)) { VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册