cli: Add --disk driver.discard_no_unref=on|off

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>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Lin Ma <lma@suse.de>
This commit is contained in:
Lin Ma 2023-07-11 08:26:52 +08:00 committed by Cole Robinson
parent 6a65def684
commit 4782dd1cce
4 changed files with 8 additions and 0 deletions

View File

@ -445,6 +445,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>

View File

@ -639,6 +639,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

View File

@ -3711,6 +3711,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")

View File

@ -508,6 +508,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)