[PATCH v2 2/2] qemu: add support for discard_granularity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <khanicov@xxxxxxxxxx>
---
 src/qemu/qemu_command.c                                | 2 ++
 src/vz/vz_utils.c                                      | 3 ++-
 tests/qemuxml2argvdata/disk-blockio.x86_64-latest.args | 2 +-
 tests/qemuxml2argvdata/disk-blockio.xml                | 2 +-
 4 files changed, 6 insertions(+), 3 deletions(-)

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/src/vz/vz_utils.c b/src/vz/vz_utils.c
index 7db7dbd419..de707df883 100644
--- a/src/vz/vz_utils.c
+++ b/src/vz/vz_utils.c
@@ -279,7 +279,8 @@ vzCheckDiskUnsupportedParams(virDomainDiskDef *disk)
     }
 
     if (disk->blockio.logical_block_size ||
-        disk->blockio.physical_block_size) {
+        disk->blockio.physical_block_size ||
+        disk->blockio.discard_granularity) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("Setting disk block sizes is not "
                          "supported by vz driver."));
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 @@
       <source file='/tmp/idedisk.img'/>
       <target dev='hdc' bus='ide'/>
       <address type='drive' controller='0' bus='0' target='0' unit='2'/>
-      <blockio logical_block_size='512' physical_block_size='512'/>
+      <blockio logical_block_size='512' physical_block_size='512' discard_granularity='4096'/>
     </disk>
     <controller type='usb' index='0'/>
     <controller type='ide' index='0'/>
-- 
2.41.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux