提交 a912977a 编写于 作者: P Peter Krempa

qemu: snapshot: Remove memory image if external checkpoint fails

When the disk snapshot part of an external system checkpoint fails the
memory image is retained. This patch adds code to remove the image in
such case.
上级 d5b28287
...@@ -11376,6 +11376,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn, ...@@ -11376,6 +11376,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
char *xml = NULL; char *xml = NULL;
bool memory = snap->def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; bool memory = snap->def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
bool memory_unlink = false;
bool atomic = !!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC); bool atomic = !!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC);
bool transaction = qemuCapsGet(priv->caps, QEMU_CAPS_TRANSACTION); bool transaction = qemuCapsGet(priv->caps, QEMU_CAPS_TRANSACTION);
int thaw = 0; /* 1 if freeze succeeded, -1 if freeze failed */ int thaw = 0; /* 1 if freeze succeeded, -1 if freeze failed */
...@@ -11443,6 +11444,9 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn, ...@@ -11443,6 +11444,9 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
QEMU_ASYNC_JOB_SNAPSHOT)) < 0) QEMU_ASYNC_JOB_SNAPSHOT)) < 0)
goto endjob; goto endjob;
/* the memory image was created, remove it on errors */
memory_unlink = true;
/* forbid any further manipulation */ /* forbid any further manipulation */
qemuDomainObjSetAsyncJobMask(vm, DEFAULT_JOB_MASK); qemuDomainObjSetAsyncJobMask(vm, DEFAULT_JOB_MASK);
} }
...@@ -11513,6 +11517,8 @@ endjob: ...@@ -11513,6 +11517,8 @@ endjob:
cleanup: cleanup:
VIR_FREE(xml); VIR_FREE(xml);
if (memory_unlink && ret < 0)
unlink(snap->def->file);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册