qemu: migration_params: Add infrastructure for 'dirty-bitmaps' migration feature

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>
This commit is contained in:
Peter Krempa 2021-02-08 10:42:28 +01:00
parent b44e3ca306
commit b0104664c6
2 changed files with 34 additions and 0 deletions

View 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);

View 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,