]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuBackupDiskDataCleanupOne: Don't exit early when the job has started
authorPeter Krempa <pkrempa@redhat.com>
Tue, 23 Jun 2020 04:22:54 +0000 (06:22 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 23 Jun 2020 09:23:01 +0000 (11:23 +0200)
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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_backup.c

index ab9cd2689ff8efc1fe9634742f0000b82c6283ed..3bd59402dc486652097fc97063f8e57b58c49ac6 100644 (file)
@@ -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);