From 9dee5f450fba6b084aaef5a46b112942e6efd913 Mon Sep 17 00:00:00 2001 Message-Id: <9dee5f450fba6b084aaef5a46b112942e6efd913@dist-git> From: Peter Krempa Date: Tue, 23 Jun 2020 12:24:10 +0200 Subject: [PATCH] qemuBackupDiskDataCleanupOne: Don't exit early when the job has started MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Originally the function was cleaning up a failed job only but now there's other stuff that needs to be cleared too. Make only steps which clean up after a failed job depend on the 'started' field and execute the rest of the code always. This fixes a leak of the backup job tracking object and the blockdev-add helper data. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko (cherry picked from commit 165b430eb9a1213ef32f14ace14d8377e9e71446) https://bugzilla.redhat.com/show_bug.cgi?id=1804593 Message-Id: <2cd881ed2059b64293b32b42fbe942cc2e147f81.1592906423.git.pkrempa@redhat.com> Reviewed-by: Ján Tomko --- src/qemu/qemu_backup.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index fdc75d3160..c68227f029 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -124,26 +124,25 @@ qemuBackupDiskDataCleanupOne(virDomainObjPtr vm, { qemuDomainObjPrivatePtr priv = vm->privateData; - if (dd->started) - return; + if (!dd->started) { + if (dd->added) { + qemuDomainObjEnterMonitor(priv->driver, vm); + qemuBlockStorageSourceAttachRollback(priv->mon, dd->crdata->srcdata[0]); + ignore_value(qemuDomainObjExitMonitor(priv->driver, vm)); + } - if (dd->added) { - qemuDomainObjEnterMonitor(priv->driver, vm); - qemuBlockStorageSourceAttachRollback(priv->mon, dd->crdata->srcdata[0]); - ignore_value(qemuDomainObjExitMonitor(priv->driver, vm)); - } + if (dd->created) { + if (virStorageFileUnlink(dd->store) < 0) + VIR_WARN("Unable to remove just-created %s", NULLSTR(dd->store->path)); + } - if (dd->created) { - if (virStorageFileUnlink(dd->store) < 0) - VIR_WARN("Unable to remove just-created %s", NULLSTR(dd->store->path)); + if (dd->labelled) + qemuDomainStorageSourceAccessRevoke(priv->driver, vm, dd->store); } if (dd->initialized) virStorageFileDeinit(dd->store); - if (dd->labelled) - qemuDomainStorageSourceAccessRevoke(priv->driver, vm, dd->store); - if (dd->blockjob) qemuBlockJobStartupFinalize(vm, dd->blockjob); -- 2.27.0