From 4d548a24585b455a8ee6d7874f45ed9c87b68a49 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 2 Apr 2025 09:39:03 +0200 Subject: [PATCH] qemuSnapshotCreateActiveInternal: Fix error logic MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/qemu/qemu_snapshot.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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, -- 2.47.3