The qcow2 driver allows passing discards to the storage while keeping
the reference of the block, and just marking it as zeroed. This can
decrease the levels of fragmentation of the qcow2 metadata when
discards are enabled.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 2 ++
src/qemu/qemu_capabilities.h | 1 +
tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml | 1 +
3 files changed, 4 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 0552486805..7dad7231ee 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -693,6 +693,7 @@ VIR_ENUM_IMPL(virQEMUCaps,
"virtio-gpu.blob", /* QEMU_CAPS_VIRTIO_GPU_BLOB */
"rbd-encryption-layering", /* QEMU_CAPS_RBD_ENCRYPTION_LAYERING
*/
"rbd-encryption-luks-any", /* QEMU_CAPS_RBD_ENCRYPTION_LUKS_ANY
*/
+ "qcow2-discard-no-unref", /* QEMU_CAPS_QCOW2_DISCARD_NO_UNREF */
);
@@ -1536,6 +1537,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] =
{
{ "blockdev-add/arg-type/+rbd/encrypt/parent",
QEMU_CAPS_RBD_ENCRYPTION_LAYERING },
{ "blockdev-add/arg-type/+rbd/encrypt/format/^luks-any",
QEMU_CAPS_RBD_ENCRYPTION_LUKS_ANY },
{ "blockdev-add/arg-type/+nbd/tls-hostname",
QEMU_CAPS_BLOCKDEV_NBD_TLS_HOSTNAME },
+ { "blockdev-add/arg-type/+qcow2/discard-no-unref",
QEMU_CAPS_QCOW2_DISCARD_NO_UNREF },
{ "blockdev-snapshot/$allow-write-only-overlay",
QEMU_CAPS_BLOCKDEV_SNAPSHOT_ALLOW_WRITE_ONLY },
{ "chardev-add/arg-type/backend/+socket/data/reconnect",
QEMU_CAPS_CHARDEV_RECONNECT },
{ "device_add/$json-cli-hotplug", QEMU_CAPS_DEVICE_JSON },
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 3b55aed07a..ce545cb2cc 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -672,6 +672,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check
*/
QEMU_CAPS_VIRTIO_GPU_BLOB, /* -device virtio-gpu-*.blob= */
QEMU_CAPS_RBD_ENCRYPTION_LAYERING, /* layered encryption support for Ceph RBD */
QEMU_CAPS_RBD_ENCRYPTION_LUKS_ANY, /* luks-any (LUKS and LUKS2) encryption format for
Ceph RBD */
+ QEMU_CAPS_QCOW2_DISCARD_NO_UNREF, /* qcow2 block driver allows discards without
unrefing the sector */
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml
b/tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml
index 50ed122fa4..58bb206f79 100644
--- a/tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml
@@ -206,6 +206,7 @@
<flag name='virtio-gpu.blob'/>
<flag name='rbd-encryption-layering'/>
<flag name='rbd-encryption-luks-any'/>
+ <flag name='qcow2-discard-no-unref'/>
<version>8000050</version>
<microcodeVersion>43100245</microcodeVersion>
<package>v8.0.0-1619-g369081c455</package>
--
2.40.1