qemu: monitor: Add helper for generating data for block bitmap merging

Introduce qemuMonitorTransactionBitmapMergeSourceAddBitmap which adds
the appropriate entry into a virJSONValue array to be used with
qemuMonitorTransactionBitmapMerge. Bitmap merging supports two possible
formats and this new helper implements the more universal one specifying
also the source node name.

In addition use the new helper in the testQemuMonitorJSONTransaction
test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-10-07 16:19:34 +02:00
parent cbaee2199b
commit bac02e396d
5 changed files with 41 additions and 2 deletions

View File

@ -4598,6 +4598,15 @@ qemuMonitorTransactionBitmapMerge(virJSONValuePtr actions,
}
int
qemuMonitorTransactionBitmapMergeSourceAddBitmap(virJSONValuePtr sources,
const char *sourcenode,
const char *sourcebitmap)
{
return qemuMonitorJSONTransactionBitmapMergeSourceAddBitmap(sources, sourcenode, sourcebitmap);
}
int
qemuMonitorTransactionSnapshotLegacy(virJSONValuePtr actions,
const char *device,

View File

@ -1383,6 +1383,10 @@ qemuMonitorTransactionBitmapMerge(virJSONValuePtr actions,
const char *node,
const char *target,
virJSONValuePtr *sources);
int
qemuMonitorTransactionBitmapMergeSourceAddBitmap(virJSONValuePtr sources,
const char *sourcenode,
const char *sourcebitmap);
int
qemuMonitorTransactionSnapshotLegacy(virJSONValuePtr actions,

View File

@ -9281,6 +9281,27 @@ qemuMonitorJSONTransactionBitmapMerge(virJSONValuePtr actions,
}
int
qemuMonitorJSONTransactionBitmapMergeSourceAddBitmap(virJSONValuePtr sources,
const char *sourcenode,
const char *sourcebitmap)
{
g_autoptr(virJSONValue) sourceobj = NULL;
if (virJSONValueObjectCreate(&sourceobj,
"s:node", sourcenode,
"s:name", sourcebitmap,
NULL) < 0)
return -1;
if (virJSONValueArrayAppend(sources, sourceobj) < 0)
return -1;
sourceobj = NULL;
return 0;
}
int
qemuMonitorJSONTransactionSnapshotLegacy(virJSONValuePtr actions,
const char *device,

View File

@ -669,6 +669,11 @@ qemuMonitorJSONTransactionBitmapMerge(virJSONValuePtr actions,
const char *target,
virJSONValuePtr *sources);
int
qemuMonitorJSONTransactionBitmapMergeSourceAddBitmap(virJSONValuePtr sources,
const char *sourcenode,
const char *sourcebitmap);
int
qemuMonitorJSONTransactionSnapshotLegacy(virJSONValuePtr actions,
const char *device,

View File

@ -3018,8 +3018,8 @@ testQemuMonitorJSONTransaction(const void *opaque)
!(mergebitmaps = virJSONValueNewArray()))
return -1;
if (virJSONValueArrayAppendString(mergebitmaps, "mergemap1") < 0 ||
virJSONValueArrayAppendString(mergebitmaps, "mergemap2") < 0)
if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(mergebitmaps, "node1", "bitmap1") < 0 ||
qemuMonitorTransactionBitmapMergeSourceAddBitmap(mergebitmaps, "node2", "bitmap2") < 0)
return -1;
if (qemuMonitorTransactionBitmapAdd(actions, "node1", "bitmap1", true, true) < 0 ||