From 648b0ddb13f2adbabee5471c207ac82c4d20a4c6 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 24 Jul 2025 14:49:55 +0200 Subject: [PATCH] qemu: monitor: Track inactive state of block nodes in 'qemuBlockNamedNodeData' 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 Reviewed-by: Michal Privoznik --- 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.47.3