From 18705b03c68a0637ca9d7a0351903e7dee128951 Mon Sep 17 00:00:00 2001 From: Kristina Hanicova Date: Fri, 25 Aug 2023 14:50:32 +0200 Subject: [PATCH] qemu: add support for discard_granularity This commit adds building of `discard_granularity` disk option for qemu commandline. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1849570 Signed-off-by: Kristina Hanicova Reviewed-by: Peter Krempa --- src/qemu/qemu_command.c | 2 + .../disk-blockio.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/disk-blockio.xml | 2 +- .../disk-blockio.x86_64-latest.xml | 48 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 5 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2xmloutdata/disk-blockio.x86_64-latest.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6bcf2fdadd..b228820b5f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1760,6 +1760,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, unsigned int bootindex = 0; unsigned int logical_block_size = disk->blockio.logical_block_size; unsigned int physical_block_size = disk->blockio.physical_block_size; + unsigned int discard_granularity = disk->blockio.discard_granularity; g_autoptr(virJSONValue) wwn = NULL; g_autofree char *serial = NULL; virTristateSwitch removable = VIR_TRISTATE_SWITCH_ABSENT; @@ -1939,6 +1940,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, "p:bootindex", bootindex, "p:logical_block_size", logical_block_size, "p:physical_block_size", physical_block_size, + "p:discard_granularity", discard_granularity, "A:wwn", &wwn, "p:rotation_rate", disk->rotation_rate, "S:vendor", disk->vendor, diff --git a/tests/qemuxml2argvdata/disk-blockio.x86_64-latest.args b/tests/qemuxml2argvdata/disk-blockio.x86_64-latest.args index 7270613573..15f31ae60d 100644 --- a/tests/qemuxml2argvdata/disk-blockio.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-blockio.x86_64-latest.args @@ -32,7 +32,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \ -device '{"driver":"ide-cd","bus":"ide.0","unit":1,"drive":"libvirt-2-format","id":"ide0-0-1"}' \ -blockdev '{"driver":"file","filename":"/tmp/idedisk.img","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ --device '{"driver":"ide-hd","bus":"ide.0","unit":2,"drive":"libvirt-1-format","id":"ide0-0-2","bootindex":1,"logical_block_size":512,"physical_block_size":512}' \ +-device '{"driver":"ide-hd","bus":"ide.0","unit":2,"drive":"libvirt-1-format","id":"ide0-0-2","bootindex":1,"logical_block_size":512,"physical_block_size":512,"discard_granularity":4096}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x2"}' \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/disk-blockio.xml b/tests/qemuxml2argvdata/disk-blockio.xml index 170728371f..84943719d4 100644 --- a/tests/qemuxml2argvdata/disk-blockio.xml +++ b/tests/qemuxml2argvdata/disk-blockio.xml @@ -23,7 +23,7 @@
- + diff --git a/tests/qemuxml2xmloutdata/disk-blockio.x86_64-latest.xml b/tests/qemuxml2xmloutdata/disk-blockio.x86_64-latest.xml new file mode 100644 index 0000000000..82ee552068 --- /dev/null +++ b/tests/qemuxml2xmloutdata/disk-blockio.x86_64-latest.xml @@ -0,0 +1,48 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + + +
+ + + + + + +
+ + +
+ + +
+ + + + +