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(a)redhat.com>
---
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 ec586b9036..3dd3d12dc3 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 a9133793f6..d7bb98f068 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4035,6 +4035,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,
@@ -4045,6 +4049,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;
@@ -4314,6 +4319,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,
@@ -4323,6 +4332,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