[PATCH 12/21] qemu: monitor: Add support for blockdev-backup via 'transaction'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Implement the transaction actions generator for blockdev-backup.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 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 a48305b046..6e6678eb9b 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4615,3 +4615,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 e2bfc420bb..79e078fca4 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1392,3 +1392,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 391f39668a..00e1d3ce15 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -9198,6 +9198,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 25b568d6b0..5d05772fa2 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 21f17f42af..4f3bfad1d7 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2962,7 +2962,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.23.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux