[virt-tools-list] [virt-manager] [PATCH 7/7] cli: Add --disk driver.discard_no_unref=on option
Lin Ma
lma at suse.de
Tue Jul 11 00:26:52 UTC 2023
E.g.
virt-install \
... \
--disk /tmp/disk0.qcow2,size=16,driver.type=qcow2,driver.discard=unmap,\
driver.discard_no_unref=on
It results in the following domain xml:
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' discard='unmap' discard_no_unref='on'/>
<source file='/tmp/disk0.qcow2'/>
<target dev='vda' bus='virtio'/>
</disk>
Signed-off-by: Lin Ma <lma at suse.de>
---
tests/data/cli/compare/virt-install-many-devices.xml | 5 +++++
tests/test_cli.py | 1 +
virtinst/cli.py | 1 +
virtinst/devices/disk.py | 1 +
4 files changed, 8 insertions(+)
diff --git a/tests/data/cli/compare/virt-install-many-devices.xml b/tests/data/cli/compare/virt-install-many-devices.xml
index 77e916f2..52bcc0ea 100644
--- a/tests/data/cli/compare/virt-install-many-devices.xml
+++ b/tests/data/cli/compare/virt-install-many-devices.xml
@@ -434,6 +434,11 @@
<source file="/tmp/disk1.qcow2"/>
<target dev="vdv" bus="virtio"/>
</disk>
+ <disk type="file" device="disk">
+ <driver name="qemu" type="qcow2" discard="unmap" discard_no_unref="on"/>
+ <source file="/tmp/disk2.qcow2"/>
+ <target dev="vdw" bus="virtio"/>
+ </disk>
<controller type="usb" index="0" model="ich9-ehci1">
<address type="pci" domain="0" bus="0" slot="4" function="7"/>
</controller>
diff --git a/tests/test_cli.py b/tests/test_cli.py
index eb3fad51..edc7c425 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -619,6 +619,7 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
--disk source.dir=/
--disk type=nvme,source.type=pci,source.managed=no,source.namespace=2,source.address.domain=0x0001,source.address.bus=0x02,source.address.slot=0x00,source.address.function=0x0
--disk /tmp/disk1.qcow2,size=16,driver.type=qcow2,driver.metadata_cache.max_size=2048,driver.metadata_cache.max_size.unit=KiB
+--disk /tmp/disk2.qcow2,size=16,driver.type=qcow2,driver.discard=unmap,driver.discard_no_unref=on
--network user,mac=12:34:56:78:11:22,portgroup=foo,link_state=down,rom_bar=on,rom_file=/tmp/foo
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 3d554ee7..5c033910 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -3700,6 +3700,7 @@ class ParserDisk(VirtCLIParser):
cls.add_arg("driver.iothread", "driver_iothread")
cls.add_arg("driver.queues", "driver_queues")
cls.add_arg("driver.error_policy", "error_policy")
+ cls.add_arg("driver.discard_no_unref", "driver_discard_no_unref", is_onoff=True)
cls.add_arg("driver.metadata_cache.max_size",
"driver_metadata_cache_max_size")
diff --git a/virtinst/devices/disk.py b/virtinst/devices/disk.py
index 9609ebac..629c6417 100644
--- a/virtinst/devices/disk.py
+++ b/virtinst/devices/disk.py
@@ -480,6 +480,7 @@ class DeviceDisk(Device):
driver_io = XMLProperty("./driver/@io")
driver_iothread = XMLProperty("./driver/@iothread", is_int=True)
driver_queues = XMLProperty("./driver/@queues", is_int=True)
+ driver_discard_no_unref = XMLProperty("./driver/@discard_no_unref", is_onoff=True)
driver_metadata_cache_max_size = XMLProperty(
"./driver/metadata_cache/max_size", is_int=True)
--
2.41.0
More information about the virt-tools-list
mailing list