From: Peter Krempa Date: Wed, 2 Apr 2025 07:39:03 +0000 (+0200) Subject: qemuSnapshotCreateActiveInternal: Fix error logic X-Git-Tag: v11.3.0-rc1~89 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4d548a24585b455a8ee6d7874f45ed9c87b68a49;p=thirdparty%2Flibvirt.git qemuSnapshotCreateActiveInternal: Fix error logic 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 Reviewed-by: Pavel Hrdina Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index ac05156e17..4f914b385c 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -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,