[RFC PATCH 1/3] qemu: monitor: Detect image cluster size from 'query-named-block-nodes'

Peter Krempa pkrempa at redhat.com
Wed Aug 26 14:56:18 UTC 2020


Configuring the cluster size of an image may have performance
implications. This patch allows us to detect cluster size for existing
images so that we will be able to propagate it to new images which are
based on existing images e.g. during snapshots/block-copy/etc.

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

diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index d20a15c202..369d63ce12 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -696,6 +696,9 @@ struct _qemuBlockNamedNodeData {

     qemuBlockNamedNodeDataBitmapPtr *bitmaps;
     size_t nbitmaps;
+
+    /* the cluster size of the image is valid only when > 0 */
+    unsigned long long clusterSize;
 };

 virHashTablePtr
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 9cdf6c0f7f..e6d2e7d4db 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2997,6 +2997,9 @@ qemuMonitorJSONBlockGetNamedNodeDataWorker(size_t pos G_GNUC_UNUSED,
     if (virJSONValueObjectGetNumberUlong(img, "actual-size", &ent->physical) < 0)
         ent->physical = ent->capacity;

+    /* try looking up the cluster size */
+    ignore_value(virJSONValueObjectGetNumberUlong(img, "cluster-size", &ent->clusterSize));
+
     if ((bitmaps = virJSONValueObjectGetArray(val, "dirty-bitmaps")))
         qemuMonitorJSONBlockGetNamedNodeDataBitmaps(bitmaps, ent);

-- 
2.26.2




More information about the libvir-list mailing list