]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: monitor: Track inactive state of block nodes in 'qemuBlockNamedNodeData'
authorPeter Krempa <pkrempa@redhat.com>
Thu, 24 Jul 2025 12:49:55 +0000 (14:49 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 21 Oct 2025 13:32:39 +0000 (15:32 +0200)
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>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c

index 8ef85ceb0ae26a92b44e42509c2ecccafce2c16b..b257c19c8967c5b71f646bf63803576a4e355700 100644 (file)
@@ -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 *
index 9caade7bc9ae9905bdac32b0e189f064b3651516..d44f5d94ed043b10af52695adaa0808762606408 100644 (file)
@@ -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;