On a Thursday in 2021, Peter Krempa wrote:
qemu's qcow2 driver allows control of the metadata cache of qcow2
driver
by the 'cache-size' property. Wire it up to the recently introduced
elements.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_block.c | 11 ++++
src/qemu/qemu_domain.c | 15 +++++
src/qemu/qemu_snapshot.c | 14 +++++
.../disk-metadata-cache.x86_64-latest.args | 57 +++++++++++++++++++
tests/qemuxml2argvtest.c | 1 +
5 files changed, 98 insertions(+)
create mode 100644 tests/qemuxml2argvdata/disk-metadata-cache.x86_64-latest.args
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 4640e339c0..857c5aa8d0 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -1343,6 +1343,17 @@ qemuBlockStorageSourceGetFormatQcow2Props(virStorageSourcePtr src,
if (qemuBlockStorageSourceGetFormatQcowGenericProps(src, "qcow2", props)
< 0)
return -1;
+ /* 'cache-size' controls the maximum size of l2 and refcount caches.
s/l2/L2/
+ * see: qemu.git/docs/qcow2-cache.txt
+ *
https://git.qemu.org/?p=qemu.git;a=blob;f=docs/qcow2-cache.txt
+ */
+ if (src->metadataCacheMaxSize > 0) {
+ if (virJSONValueObjectAdd(props,
+ "U:cache-size",
src->metadataCacheMaxSize,
+ NULL) < 0)
+ return -1;
+ }
+
return 0;
}
Jano