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(a)redhat.com>
---
src/qemu/qemu_monitor.c | 9 +++++++++
src/qemu/qemu_monitor.h | 4 ++++
src/qemu/qemu_monitor_json.c | 21 +++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 5 +++++
tests/qemumonitorjsontest.c | 4 ++--
5 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 8de386817b..57229a68c0 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4551,6 +4551,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,
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 45f2a5a7d2..a1c980e40e 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1364,6 +1364,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,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 0062816e3e..545911069e 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -9199,6 +9199,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,
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index d74ef91b83..6617783797 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -652,6 +652,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,
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 4f15d231f9..cefa0f08cf 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2982,8 +2982,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 ||
--
2.21.0