[PATCH 1/7] qemu: monitor: Track inactive state of block nodes in 'qemuBlockNamedNodeData'

Peter Krempa via Devel posted 7 patches 2 weeks ago
[PATCH 1/7] qemu: monitor: Track inactive state of block nodes in 'qemuBlockNamedNodeData'
Posted by Peter Krempa via Devel 2 weeks ago
From: Peter Krempa <pkrempa@redhat.com>

New qemus report if given block node is active. We'll be using this data
to decide if we need to reactivate them prior to blockjobs. Extract the
data as 'inactive' as it's simpler to track and we care only about
inactive nodes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_monitor.h      | 4 ++++
 src/qemu/qemu_monitor_json.c | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 8ef85ceb0a..b257c19c89 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -751,6 +751,10 @@ struct _qemuBlockNamedNodeData {

     /* qcow2 data file 'raw' feature is enabled */
     bool qcow2dataFileRaw;
+
+    /* node is deactivated in qemu (reported as 'active' but may be missing,
+     * thus the flag is asserted only when we know it's inactive) */
+    bool inactive;
 };

 GHashTable *
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 9caade7bc9..d44f5d94ed 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2714,6 +2714,7 @@ qemuMonitorJSONBlockGetNamedNodeDataWorker(size_t pos G_GNUC_UNUSED,
     virJSONValue *bitmaps;
     virJSONValue *snapshots;
     virJSONValue *format_specific;
+    bool active;
     const char *nodename;
     g_autoptr(qemuBlockNamedNodeData) ent = NULL;

@@ -2736,6 +2737,10 @@ qemuMonitorJSONBlockGetNamedNodeDataWorker(size_t pos G_GNUC_UNUSED,
     if ((bitmaps = virJSONValueObjectGetArray(val, "dirty-bitmaps")))
         qemuMonitorJSONBlockGetNamedNodeDataBitmaps(bitmaps, ent);

+    /* stored as negative as the value may be missing from some qemus */
+    if (virJSONValueObjectGetBoolean(val, "active", &active) == 0)
+        ent->inactive = !active;
+
     if ((snapshots = virJSONValueObjectGetArray(img, "snapshots"))) {
         size_t nsnapshots = virJSONValueArraySize(snapshots);
         size_t i;
-- 
2.51.0