]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: migration_params: Add infrastructure for 'dirty-bitmaps' migration feature
authorPeter Krempa <pkrempa@redhat.com>
Mon, 8 Feb 2021 09:42:28 +0000 (10:42 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Sat, 20 Feb 2021 12:21:21 +0000 (13:21 +0100)
Add the migration capability flag and the propagation of the
corresponding mapping configuration. The mapping will be produced from
the bitmaps on disk depending on both sides of the migration and the
necessity to perform merges.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_migration_params.c
src/qemu/qemu_migration_params.h

index 510dad783a21d21bb68f32addf7530dd952ec726..e9b4601510078bb20105fbb6e44bef9139cdcae5 100644 (file)
@@ -63,6 +63,7 @@ struct _qemuMigrationParams {
     unsigned long long compMethods; /* bit-wise OR of qemuMigrationCompressMethod */
     virBitmapPtr caps;
     qemuMigrationParamValue params[QEMU_MIGRATION_PARAM_LAST];
+    virJSONValuePtr blockDirtyBitmapMapping;
 };
 
 typedef enum {
@@ -89,6 +90,7 @@ VIR_ENUM_IMPL(qemuMigrationCapability,
               "pause-before-switchover",
               "late-block-activate",
               "multifd",
+              "dirty-bitmaps",
 );
 
 
@@ -265,6 +267,7 @@ qemuMigrationParamsFree(qemuMigrationParamsPtr migParams)
     }
 
     virBitmapFree(migParams->caps);
+    virJSONValueFree(migParams->blockDirtyBitmapMapping);
     g_free(migParams);
 }
 
@@ -524,6 +527,20 @@ qemuMigrationParamsSetCompression(virTypedParameterPtr params,
 }
 
 
+void
+qemuMigrationParamsSetBlockDirtyBitmapMapping(qemuMigrationParamsPtr migParams,
+                                              virJSONValuePtr *params)
+{
+    virJSONValueFree(migParams->blockDirtyBitmapMapping);
+    migParams->blockDirtyBitmapMapping = g_steal_pointer(params);
+
+    if (migParams->blockDirtyBitmapMapping)
+        ignore_value(virBitmapSetBit(migParams->caps, QEMU_MIGRATION_CAP_BLOCK_DIRTY_BITMAPS));
+    else
+        ignore_value(virBitmapClearBit(migParams->caps, QEMU_MIGRATION_CAP_BLOCK_DIRTY_BITMAPS));
+}
+
+
 qemuMigrationParamsPtr
 qemuMigrationParamsFromFlags(virTypedParameterPtr params,
                              int nparams,
@@ -747,6 +764,17 @@ qemuMigrationParamsToJSON(qemuMigrationParamsPtr migParams)
             return NULL;
     }
 
+    if (migParams->blockDirtyBitmapMapping) {
+        g_autoptr(virJSONValue) mapping = virJSONValueCopy(migParams->blockDirtyBitmapMapping);
+
+        if (!mapping)
+            return NULL;
+
+        if (virJSONValueObjectAppend(params, "block-bitmap-mapping", mapping) < 0)
+            return NULL;
+        mapping = NULL;
+    }
+
     return g_steal_pointer(&params);
 }
 
@@ -1202,6 +1230,7 @@ qemuMigrationParamsReset(virQEMUDriverPtr driver,
         goto cleanup;
 
     qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams, apiFlags);
+    /* We don't reset 'block-bitmap-mapping' as it can't be unset */
 
  cleanup:
     virErrorRestore(&err);
index 9876101bfc4a2960cc28149011920678cf47b1e5..f1db42ce94408a5b9e839e97da3154b64c4bc330 100644 (file)
@@ -39,6 +39,7 @@ typedef enum {
     QEMU_MIGRATION_CAP_PAUSE_BEFORE_SWITCHOVER,
     QEMU_MIGRATION_CAP_LATE_BLOCK_ACTIVATE,
     QEMU_MIGRATION_CAP_MULTIFD,
+    QEMU_MIGRATION_CAP_BLOCK_DIRTY_BITMAPS,
 
     QEMU_MIGRATION_CAP_LAST
 } qemuMigrationCapability;
@@ -132,6 +133,10 @@ qemuMigrationParamsGetULL(qemuMigrationParamsPtr migParams,
                           qemuMigrationParam param,
                           unsigned long long *value);
 
+void
+qemuMigrationParamsSetBlockDirtyBitmapMapping(qemuMigrationParamsPtr migParams,
+                                              virJSONValuePtr *params);
+
 int
 qemuMigrationParamsCheck(virQEMUDriverPtr driver,
                          virDomainObjPtr vm,