]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: monitor: Detect image cluster size from 'query-named-block-nodes'
authorPeter Krempa <pkrempa@redhat.com>
Wed, 26 Aug 2020 14:41:17 +0000 (16:41 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 8 Sep 2020 06:48:53 +0000 (08:48 +0200)
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@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c

index 3e4ef7e821a64bb3f7819c8e072852ec43ae7f35..d3f7797085edd0e8f94bfa11673eb7c8db339fa0 100644 (file)
@@ -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
index 9cdf6c0f7f36d642a13d784bbbad64c8c0361e76..e6d2e7d4db7c373bde34980c587a0b7c58160d3d 100644 (file)
@@ -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);