[PATCH 3/4] qemu: monitor: Use 'backing-mask-protocol' for blockjobs when available

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

 



Store whether qemu supports the appropriate option for block-stream and
block-commit commands and always use it if available.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_monitor.c      |  1 +
 src/qemu/qemu_monitor_json.c | 10 ++++++++++
 src/qemu/qemu_monitor_priv.h |  2 ++
 3 files changed, 13 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index a1773d86d4..7f3e4de329 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -624,6 +624,7 @@ qemuMonitorOpenInternal(virDomainObj *vm,
     if (priv) {
         mon->objectAddNoWrap = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_JSON);
         mon->queryNamedBlockNodesFlat = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QMP_QUERY_NAMED_BLOCK_NODES_FLAT);
+        mon->blockjobMaskProtocol = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKJOB_BACKING_MASK_PROTOCOL);
     }

     if (virSetCloseExec(mon->fd) < 0) {
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index e114b6bfb1..7aab34c7c4 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4036,6 +4036,10 @@ qemuMonitorJSONBlockCommit(qemuMonitor *mon,
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virTristateBool autodismiss = VIR_TRISTATE_BOOL_NO;
+    virTristateBool backingProtocol = VIR_TRISTATE_BOOL_ABSENT;
+
+    if (mon->blockjobMaskProtocol)
+        backingProtocol = VIR_TRISTATE_BOOL_YES;

     cmd = qemuMonitorJSONMakeCommand("block-commit",
                                      "s:device", device,
@@ -4046,6 +4050,7 @@ qemuMonitorJSONBlockCommit(qemuMonitor *mon,
                                      "S:backing-file", backingName,
                                      "T:auto-finalize", autofinalize,
                                      "T:auto-dismiss", autodismiss,
+                                     "T:backing-mask-protocol", backingProtocol,
                                      NULL);
     if (!cmd)
         return -1;
@@ -4315,6 +4320,10 @@ qemuMonitorJSONBlockStream(qemuMonitor *mon,
     g_autoptr(virJSONValue) reply = NULL;
     virTristateBool autofinalize = VIR_TRISTATE_BOOL_YES;
     virTristateBool autodismiss = VIR_TRISTATE_BOOL_NO;
+    virTristateBool backingProtocol = VIR_TRISTATE_BOOL_ABSENT;
+
+    if (mon->blockjobMaskProtocol)
+        backingProtocol = VIR_TRISTATE_BOOL_YES;

     if (!(cmd = qemuMonitorJSONMakeCommand("block-stream",
                                            "s:device", device,
@@ -4324,6 +4333,7 @@ qemuMonitorJSONBlockStream(qemuMonitor *mon,
                                            "S:backing-file", backingName,
                                            "T:auto-finalize", autofinalize,
                                            "T:auto-dismiss", autodismiss,
+                                           "T:backing-mask-protocol", backingProtocol,
                                            NULL)))
         return -1;

diff --git a/src/qemu/qemu_monitor_priv.h b/src/qemu/qemu_monitor_priv.h
index 0826a1da94..0c2098c456 100644
--- a/src/qemu/qemu_monitor_priv.h
+++ b/src/qemu/qemu_monitor_priv.h
@@ -92,6 +92,8 @@ struct _qemuMonitor {
     bool objectAddNoWrap;
     /* query-named-block-nodes supports the 'flat' option */
     bool queryNamedBlockNodesFlat;
+    /* use the backing-mask-protocol flag of block-commit/stream */
+    bool blockjobMaskProtocol;
 };


-- 
2.43.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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