qemu: snapshot: Check earlier if memory snapshot is possible

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>
This commit is contained in:
Nikolay Shirokovskiy authored and Peter Krempa committed 2026-01-07 13:48:20 +01:00
1 parent ac8d241620
commit ccf008b85f
1 file changed
+6 -4
+6 -4
View 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);