Implement the transaction actions generator for blockdev-backup.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_monitor.c | 13 +++++++++++++
src/qemu/qemu_monitor.h | 15 +++++++++++++++
src/qemu/qemu_monitor_json.c | 29 +++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 8 ++++++++
tests/qemumonitorjsontest.c | 8 +++++++-
5 files changed, 72 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 57229a68c0..6fd2c72769 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4579,3 +4579,16 @@ qemuMonitorTransactionSnapshotBlockdev(virJSONValuePtr actions,
{
return qemuMonitorJSONTransactionSnapshotBlockdev(actions, node, overlay);
}
+
+
+int
+qemuMonitorTransactionBackup(virJSONValuePtr actions,
+ const char *device,
+ const char *jobname,
+ const char *target,
+ const char *bitmap,
+ qemuMonitorTransactionBackupSyncMode syncmode)
+{
+ return qemuMonitorJSONTransactionBackup(actions, device, jobname, target,
+ bitmap, syncmode);
+}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index a1c980e40e..51c421d6ee 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1379,3 +1379,18 @@ int
qemuMonitorTransactionSnapshotBlockdev(virJSONValuePtr actions,
const char *node,
const char *overlay);
+
+typedef enum {
+ QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_NONE = 0,
+ QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_INCREMENTAL,
+ QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_FULL,
+ QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_LAST,
+} qemuMonitorTransactionBackupSyncMode;
+
+int
+qemuMonitorTransactionBackup(virJSONValuePtr actions,
+ const char *device,
+ const char *jobname,
+ const char *target,
+ const char *bitmap,
+ qemuMonitorTransactionBackupSyncMode syncmode);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 545911069e..51603d2631 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -9254,6 +9254,35 @@ qemuMonitorJSONTransactionSnapshotBlockdev(virJSONValuePtr
actions,
NULL);
}
+VIR_ENUM_DECL(qemuMonitorTransactionBackupSyncMode);
+VIR_ENUM_IMPL(qemuMonitorTransactionBackupSyncMode,
+ QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_LAST,
+ "none",
+ "incremental",
+ "full");
+
+int
+qemuMonitorJSONTransactionBackup(virJSONValuePtr actions,
+ const char *device,
+ const char *jobname,
+ const char *target,
+ const char *bitmap,
+ qemuMonitorTransactionBackupSyncMode syncmode)
+{
+ const char *syncmodestr =
qemuMonitorTransactionBackupSyncModeTypeToString(syncmode);
+
+ return qemuMonitorJSONTransactionAdd(actions,
+ "blockdev-backup",
+ "s:device", device,
+ "s:job-id", jobname,
+ "s:target", target,
+ "s:sync", syncmodestr,
+ "S:bitmap", bitmap,
+ "T:auto-finalize",
VIR_TRISTATE_BOOL_YES,
+ "T:auto-dismiss",
VIR_TRISTATE_BOOL_NO,
+ NULL);
+}
+
static qemuMonitorJobInfoPtr
qemuMonitorJSONGetJobInfoOne(virJSONValuePtr data)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 6617783797..dc291fa53f 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -667,3 +667,11 @@ int
qemuMonitorJSONTransactionSnapshotBlockdev(virJSONValuePtr actions,
const char *node,
const char *overlay);
+
+int
+qemuMonitorJSONTransactionBackup(virJSONValuePtr actions,
+ const char *device,
+ const char *jobname,
+ const char *target,
+ const char *bitmap,
+ qemuMonitorTransactionBackupSyncMode syncmode);
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index cefa0f08cf..0ea4579866 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2992,7 +2992,13 @@ testQemuMonitorJSONTransaction(const void *opaque)
qemuMonitorTransactionBitmapDisable(actions, "node4",
"bitmap4") < 0 ||
qemuMonitorTransactionBitmapMerge(actions, "node5",
"bitmap5", &mergebitmaps) < 0 ||
qemuMonitorTransactionSnapshotLegacy(actions, "dev6", "path",
"qcow2", true) < 0 ||
- qemuMonitorTransactionSnapshotBlockdev(actions, "node7",
"overlay7") < 0)
+ qemuMonitorTransactionSnapshotBlockdev(actions, "node7",
"overlay7") < 0 ||
+ qemuMonitorTransactionBackup(actions, "dev8", "job8",
"target8", "bitmap8",
+ QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_NONE) <
0 ||
+ qemuMonitorTransactionBackup(actions, "dev9", "job9",
"target9", "bitmap9",
+
QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_INCREMENTAL) < 0 ||
+ qemuMonitorTransactionBackup(actions, "devA", "jobA",
"targetA", "bitmapA",
+ QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_FULL) <
0)
return -1;
if (qemuMonitorTestAddItem(test, "transaction",
"{\"return\":{}}") < 0)
--
2.21.0