]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: snapshot: Check earlier if memory snapshot is possible
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Thu, 11 Nov 2021 08:55:46 +0000 (11:55 +0300)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 7 Jan 2026 12:48:20 +0000 (13:48 +0100)
Don't unnecessarily pause the VM if the snapshot can't be taken.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
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 0338641559a6bdd57dad0cb692cc33e53b4e0280..e738afffc315191e25b171382c2afbca03cc3757 100644 (file)
@@ -1665,6 +1665,12 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *driver,
     virQEMUSaveData *data = NULL;
     g_autoptr(GHashTable) blockNamedNodeData = NULL;
 
+    if (memory) {
+        /* When doing a snapshot with memory check if migration is possible */
+        if (!qemuMigrationSrcIsAllowed(vm, false, VIR_ASYNC_JOB_SNAPSHOT, 0))
+            return -1;
+    }
+
     /* If quiesce was requested, then issue a freeze command, and a
      * counterpart thaw command when it is actually sent to agent.
      * The command will fail if the guest is paused or the guest agent
@@ -1727,10 +1733,6 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *driver,
     if (memory) {
         g_autoptr(qemuMigrationParams) snap_params = NULL;
 
-        /* check if migration is possible */
-        if (!qemuMigrationSrcIsAllowed(vm, false, VIR_ASYNC_JOB_SNAPSHOT, 0))
-            goto cleanup;
-
         qemuDomainJobSetStatsType(vm->job->current,
                                   QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUMP);