From: Peter Krempa <pkrempa@redhat.com>
We don't actually look at any of the information in 'backing-image'
field so we can ask qemu not to send it to us.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
src/qemu/qemu_monitor.c | 1 +
src/qemu/qemu_monitor_json.c | 12 ++++++++++--
src/qemu/qemu_monitor_priv.h | 3 +++
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 1434da7f70..ffd8a281b9 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -585,6 +585,7 @@ qemuMonitorOpenInternal(virDomainObj *vm,
if (priv) {
mon->blockjobMaskProtocol = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKJOB_BACKING_MASK_PROTOCOL);
+ mon->queryBlockFlat = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_BLOCK_FLAT);
}
if (virSetCloseExec(mon->fd) < 0) {
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 971e8dd63f..6eff95f44a 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2243,7 +2243,9 @@ qemuMonitorJSONQueryNamedBlockNodes(qemuMonitor *mon)
* @mon: Monitor pointer
*
* This helper will attempt to make a "query-block" call and check for
- * errors before returning with the reply.
+ * errors before returning with the reply. If qemu supports 'flat' mode
+ * (which ommits 'backing-image' field in the reply objects) we will enable
+ * it as no callers need that information.
*
* Returns: NULL on error, reply on success
*/
@@ -2252,8 +2254,14 @@ qemuMonitorJSONQueryBlock(qemuMonitor *mon)
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
+ virTristateBool flat = VIR_TRISTATE_BOOL_ABSENT;
+
+ if (mon->queryBlockFlat)
+ flat = VIR_TRISTATE_BOOL_YES;
- if (!(cmd = qemuMonitorJSONMakeCommand("query-block", NULL)))
+ if (!(cmd = qemuMonitorJSONMakeCommand("query-block",
+ "T:flat", flat,
+ NULL)))
return NULL;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0 ||
diff --git a/src/qemu/qemu_monitor_priv.h b/src/qemu/qemu_monitor_priv.h
index 198105007e..ee644123ca 100644
--- a/src/qemu/qemu_monitor_priv.h
+++ b/src/qemu/qemu_monitor_priv.h
@@ -90,6 +90,9 @@ struct _qemuMonitor {
/* use the backing-mask-protocol flag of block-commit/stream */
bool blockjobMaskProtocol;
+
+ /* 'query-block' supports flat mode */
+ bool queryBlockFlat;
};
--
2.53.0