]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuSnapshotCreateActiveInternal: Fix error logic
authorPeter Krempa <pkrempa@redhat.com>
Wed, 2 Apr 2025 07:39:03 +0000 (09:39 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 2 Apr 2025 14:51:40 +0000 (16:51 +0200)
The 'ret' variable is set to 0 before a call which can theoretically
fail. Not in practice really as the failure scenarion includes only
object initialization.

Since the code already has another variable for checking monitor returns
use that one properly so that the code makes sense.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_snapshot.c

index ac05156e1717ddc7901903a29fecb5cd7632fed0..4f914b385c23d62d565cb58b5ad51b3a34d06e42 100644 (file)
@@ -592,16 +592,15 @@ qemuSnapshotCreateActiveInternal(virQEMUDriver *driver,
                 goto cleanup;
         }
 
-        ret = 0;
     } else {
         if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_SNAPSHOT) < 0) {
             resume = false;
             goto cleanup;
         }
 
-        ret = qemuMonitorCreateSnapshot(priv->mon, snap->def->name);
+        rv = qemuMonitorCreateSnapshot(priv->mon, snap->def->name);
         qemuDomainObjExitMonitor(vm);
-        if (ret < 0)
+        if (rv < 0)
             goto cleanup;
     }
 
@@ -617,6 +616,8 @@ qemuSnapshotCreateActiveInternal(virQEMUDriver *driver,
         resume = false;
     }
 
+    ret = 0;
+
  cleanup:
     if (resume && virDomainObjIsActive(vm) &&
         qemuProcessStartCPUs(driver, vm,