]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Add function to get migration params for save
authorJim Fehlig <jfehlig@suse.com>
Wed, 29 May 2024 22:31:05 +0000 (16:31 -0600)
committerJim Fehlig <jfehlig@suse.com>
Thu, 20 Mar 2025 17:17:48 +0000 (11:17 -0600)
Introduce qemuMigrationParamsForSave() to create a
qemuMigrationParams object initialized with appropriate migration
capabilities and parameters for a save operation.

Note that mapped-ram capability also requires the multifd capability.
For now, the number of multifd channels is set to 1. Future work
to support parallel save/restore can set the number of channels to
a user-specified value.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/qemu/qemu_migration.c
src/qemu/qemu_migration_params.c
src/qemu/qemu_migration_params.h

index 75f5b0fa950ce5e3aa9018be9c7f17750222edb1..416a889d6a08b51c4fb7df99805b31efad4e24d5 100644 (file)
@@ -7134,7 +7134,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm,
 
     /* Increase migration bandwidth to unlimited since target is a file.
      * Failure to change migration speed is not fatal. */
-    if (!(migParams = qemuMigrationParamsNew()))
+    if (!(migParams = qemuMigrationParamsForSave(false)))
         return -1;
 
     if (qemuMigrationParamsSetULL(migParams,
index 4fc9199f1c76bfbae51546bb6d7ae9a3d7fc00b8..d48cdd5506fd0ddf27c635880598c8f592b14a22 100644 (file)
@@ -792,6 +792,27 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
 }
 
 
+qemuMigrationParams *
+qemuMigrationParamsForSave(bool sparse)
+{
+    g_autoptr(qemuMigrationParams) saveParams = NULL;
+
+    if (!(saveParams = qemuMigrationParamsNew()))
+        return NULL;
+
+    if (sparse) {
+        if (virBitmapSetBit(saveParams->caps, QEMU_MIGRATION_CAP_MAPPED_RAM) < 0)
+            return NULL;
+        if (virBitmapSetBit(saveParams->caps, QEMU_MIGRATION_CAP_MULTIFD) < 0)
+            return NULL;
+        saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].value.i = 1;
+        saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].set = true;
+    }
+
+    return g_steal_pointer(&saveParams);
+}
+
+
 int
 qemuMigrationParamsDump(qemuMigrationParams *migParams,
                         virTypedParameterPtr *params,
index 2379950ce9b22de86f898a33ec13ab0450af77c2..88a1bc1a6683bb7c71297696e436507370ebc99d 100644 (file)
@@ -87,6 +87,9 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
                              unsigned int flags,
                              qemuMigrationParty party);
 
+qemuMigrationParams *
+qemuMigrationParamsForSave(bool sparse);
+
 int
 qemuMigrationParamsDump(qemuMigrationParams *migParams,
                         virTypedParameterPtr *params,