From a7087c929e1e27c2eb47a773bed78590bc8860bb Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 5 Jun 2019 15:16:34 +0200 Subject: [PATCH] qemu: snapshot: Move all cleanup of snapshot disk data to qemuDomainSnapshotDiskDataFree MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit qemuDomainSnapshotDiskDataFree also removes the resources associated with the disk data. Move the unlinking of the just-created file so that we can unify the cleanup paths. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_driver.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f1886e37b6..1e1cb8d4ca 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15049,6 +15049,12 @@ qemuDomainSnapshotDiskDataCleanup(qemuDomainSnapshotDiskDataPtr data, /* on success of the snapshot the 'src' and 'persistsrc' properties will * be set to NULL by qemuDomainSnapshotUpdateDiskSources */ if (data[i].src) { + if (data[i].created && + virStorageFileUnlink(data[i].src) < 0) { + VIR_WARN("Unable to remove just-created %s", + NULLSTR(data[i].src->path)); + } + if (data[i].initialized) virStorageFileDeinit(data[i].src); @@ -15292,14 +15298,6 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver, error: if (ret < 0) { virErrorPreserveLast(&orig_err); - for (i = 0; i < ndiskdata; i++) { - if (diskdata[i].prepared) - qemuDomainStorageSourceAccessRevoke(driver, vm, diskdata[i].src); - - if (diskdata[i].created && - virStorageFileUnlink(diskdata[i].src) < 0) - VIR_WARN("Unable to remove just-created %s", diskdata[i].src->path); - } } else { /* on successful snapshot we need to remove locks from the now-old * disks and if the VM is paused release locks on the images since qemu -- 2.47.2