[libvirt] [PATCH 0/2] Another set of fixes for snapshots

This series contains two small patches for a few nits in the snapshot code. Peter Krempa (2): qemu: snapshot: Don't leak XML definition if restarting of CPUs fails qemu: snapshot: Remove memory image if external checkpoint fails src/qemu/qemu_driver.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 1.8.0

In case the snapshot code isn't able to restart CPUs after an external checkpoint we would leak a copy of the domains XML definition. This patch fixes the cleanup path. --- src/qemu/qemu_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8fb0000..0a801f3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11490,7 +11490,8 @@ endjob: _("resuming after snapshot failed")); } - return -1; + ret = -1; + goto cleanup; } if (vm && thaw != 0 && qemuDomainSnapshotFSThaw(driver, vm, thaw > 0) < 0) { -- 1.8.0

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. --- src/qemu/qemu_driver.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0a801f3..acbb556 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11368,6 +11368,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn, qemuDomainObjPrivatePtr priv = vm->privateData; char *xml = NULL; bool memory = snap->def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; + bool memory_unlink = false; bool atomic = !!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC); bool transaction = qemuCapsGet(priv->caps, QEMU_CAPS_TRANSACTION); int thaw = 0; /* 1 if freeze succeeded, -1 if freeze failed */ @@ -11439,6 +11440,9 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn, QEMU_ASYNC_JOB_SNAPSHOT)) < 0) goto endjob; + /* the memory image was created, remove it on errors */ + memory_unlink = true; + /* forbid any further manipulation */ qemuDomainObjSetAsyncJobMask(vm, DEFAULT_JOB_MASK); } @@ -11509,6 +11513,8 @@ endjob: cleanup: VIR_FREE(xml); + if (memory_unlink && ret < 0) + unlink(snap->def->file); return ret; } -- 1.8.0

On Tue, Dec 11, 2012 at 12:10:50 +0100, Peter Krempa wrote:
This series contains two small patches for a few nits in the snapshot code.
Peter Krempa (2): qemu: snapshot: Don't leak XML definition if restarting of CPUs fails qemu: snapshot: Remove memory image if external checkpoint fails
src/qemu/qemu_driver.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
ACK both. Jirka

On 12/11/12 13:45, Jiri Denemark wrote:
On Tue, Dec 11, 2012 at 12:10:50 +0100, Peter Krempa wrote:
This series contains two small patches for a few nits in the snapshot code.
Peter Krempa (2): qemu: snapshot: Don't leak XML definition if restarting of CPUs fails qemu: snapshot: Remove memory image if external checkpoint fails
src/qemu/qemu_driver.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
ACK both.
Thanks, pushed. Peter
participants (2)
-
Jiri Denemark
-
Peter Krempa