mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-03-20 22:50:16 +03:00
devices: disk: Set discard=unmap by default for some cases
This recommendation came from an internal discussion. The cases are * For block storage. This means guest requests are passed through to the host device, which seems a more reasonable default than ignoring them * For sparse disk images we will create. discard=unmap helps preserve the sparseness of the disk image. If a user requests non-sparse, they are likely more concerned with performance than saving disk space, so we leave the default as is. We limit this to disk images we will create, since that's the easiest case to check, and it's less clear if we should change the behavior here for an arbitrary existing disk image. Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
1ab6dd50be
commit
381aa4050c
@ -22,7 +22,7 @@
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-aarch64</emulator>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<driver name="qemu" type="qcow2" discard="unmap"/>
|
||||
<source file="/var/lib/libvirt/images/disk.qcow2"/>
|
||||
<target dev="vda" bus="virtio"/>
|
||||
</disk>
|
||||
|
@ -28,7 +28,7 @@
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<driver name="qemu" type="qcow2" discard="unmap"/>
|
||||
<source file="/var/lib/libvirt/images/disk.qcow2"/>
|
||||
<target dev="sda" bus="sata"/>
|
||||
</disk>
|
||||
|
@ -31,7 +31,7 @@
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<driver name="qemu" type="qcow2" discard="unmap"/>
|
||||
<source file="/var/lib/libvirt/images/fedora26.qcow2"/>
|
||||
<target dev="vda" bus="virtio"/>
|
||||
</disk>
|
||||
|
@ -33,7 +33,7 @@
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<driver name="qemu" type="qcow2" discard="unmap"/>
|
||||
<source file="/tmp/.local/share/libvirt/images/disk.qcow2"/>
|
||||
<target dev="vda" bus="virtio"/>
|
||||
</disk>
|
||||
@ -105,7 +105,7 @@
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<driver name="qemu" type="qcow2" discard="unmap"/>
|
||||
<source file="/tmp/.local/share/libvirt/images/disk.qcow2"/>
|
||||
<target dev="vda" bus="virtio"/>
|
||||
</disk>
|
||||
|
@ -39,7 +39,7 @@
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||
<disk type="block" device="disk">
|
||||
<driver name="qemu" type="raw" cache="writeback" io="threads" iothread="3" queues="8"/>
|
||||
<driver name="qemu" type="raw" cache="writeback" discard="unmap" io="threads" iothread="3" queues="8"/>
|
||||
<source dev="/dev/default-pool/UPPER"/>
|
||||
<target dev="vda" bus="virtio"/>
|
||||
<serial>WD-WMAP9A966149</serial>
|
||||
@ -48,15 +48,15 @@
|
||||
<boot order="2"/>
|
||||
</disk>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2" discard="unmap" detect_zeroes="unmap" error_policy="enospace"/>
|
||||
<driver name="qemu" type="qcow2" detect_zeroes="unmap" error_policy="enospace"/>
|
||||
<source file="/dev/default-pool/new1.img"/>
|
||||
<target dev="vdb" bus="virtio"/>
|
||||
<address type="drive" controller="0" target="2" unit="0"/>
|
||||
<readonly/>
|
||||
</disk>
|
||||
<disk type="file" device="cdrom">
|
||||
<driver discard="ignore" copy_on_read="on"/>
|
||||
<target dev="sdaa" bus="sata"/>
|
||||
<driver copy_on_read="on"/>
|
||||
<iotune>
|
||||
<read_bytes_sec>1</read_bytes_sec>
|
||||
<write_bytes_sec>5</write_bytes_sec>
|
||||
@ -67,7 +67,7 @@
|
||||
<readonly/>
|
||||
</disk>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<driver name="qemu" type="qcow2" discard="unmap"/>
|
||||
<source file="/var/lib/libvirt/images/disk.qcow2"/>
|
||||
<target dev="vdc" bus="virtio"/>
|
||||
</disk>
|
||||
@ -186,12 +186,12 @@
|
||||
<target dev="fda" bus="fdc"/>
|
||||
</disk>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<driver name="qemu" type="qcow2" discard="unmap"/>
|
||||
<source file="/dev/default-pool/new2.img"/>
|
||||
<target dev="sdad" bus="usb" removable="on"/>
|
||||
</disk>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<driver name="qemu" type="qcow2" discard="unmap"/>
|
||||
<source file="/tmp/brand-new.img"/>
|
||||
<target dev="vdn" bus="virtio"/>
|
||||
<boot order="10" loadparm="5"/>
|
||||
@ -213,13 +213,13 @@
|
||||
<target dev="vdo" bus="virtio"/>
|
||||
</disk>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="raw"/>
|
||||
<driver name="qemu" type="raw" discard="unmap"/>
|
||||
<source file="/var/lib/libvirt/images/disk.img"/>
|
||||
<target dev="vdp" bus="virtio"/>
|
||||
<transient shareBacking="yes"/>
|
||||
</disk>
|
||||
<disk type="block" device="disk">
|
||||
<driver name="qemu" type="raw" cache="none" io="native"/>
|
||||
<driver name="qemu" type="raw" cache="none" discard="unmap" io="native"/>
|
||||
<source dev="/dev/disk-pool/disk"/>
|
||||
<target dev="vdq" bus="virtio"/>
|
||||
</disk>
|
||||
@ -229,7 +229,7 @@
|
||||
<target dev="vdr" bus="virtio"/>
|
||||
</disk>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<driver name="qemu" type="qcow2" discard="unmap"/>
|
||||
<source file="/fooroot.img"/>
|
||||
<target dev="vds" bus="virtio"/>
|
||||
<transient/>
|
||||
|
@ -31,7 +31,7 @@
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<driver name="qemu" type="qcow2" discard="unmap"/>
|
||||
<source file="/var/lib/libvirt/images/disk.qcow2"/>
|
||||
<target dev="hda" bus="ide"/>
|
||||
</disk>
|
||||
|
@ -38,7 +38,7 @@
|
||||
<target dev="vda" bus="virtio"/>
|
||||
</disk>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<driver name="qemu" type="qcow2" discard="unmap"/>
|
||||
<source file="/var/lib/libvirt/images/disk.qcow2"/>
|
||||
<target dev="vdb" bus="virtio"/>
|
||||
</disk>
|
||||
@ -96,7 +96,7 @@
|
||||
<target dev="vda" bus="virtio"/>
|
||||
</disk>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<driver name="qemu" type="qcow2" discard="unmap"/>
|
||||
<source file="/var/lib/libvirt/images/disk.qcow2"/>
|
||||
<target dev="vdb" bus="virtio"/>
|
||||
</disk>
|
||||
|
@ -605,8 +605,8 @@ vcpus.vcpu1.id=2,vcpus.vcpu1.enabled=yes
|
||||
--iothreads 5
|
||||
|
||||
--disk type=block,source.dev=/dev/default-pool/UPPER,cache=writeback,io=threads,perms=sh,serial=WD-WMAP9A966149,wwn=123456789abcdefa,boot_order=2,driver.iothread=3,driver.queues=8
|
||||
--disk source.file=%(NEWIMG1)s,sparse=false,size=.001,perms=ro,error_policy=enospace,discard=unmap,detect_zeroes=unmap,address.type=drive,address.controller=0,address.target=2,address.unit=0
|
||||
--disk device=cdrom,bus=sata,read_bytes_sec=1,read_iops_sec=2,write_bytes_sec=5,write_iops_sec=6,driver.copy_on_read=on,geometry.cyls=16383,geometry.heads=16,geometry.secs=63,geometry.trans=lba
|
||||
--disk source.file=%(NEWIMG1)s,sparse=false,size=.001,perms=ro,error_policy=enospace,detect_zeroes=unmap,address.type=drive,address.controller=0,address.target=2,address.unit=0
|
||||
--disk device=cdrom,bus=sata,read_bytes_sec=1,read_iops_sec=2,write_bytes_sec=5,write_iops_sec=6,driver.copy_on_read=on,geometry.cyls=16383,geometry.heads=16,geometry.secs=63,geometry.trans=lba,discard=ignore
|
||||
--disk size=1
|
||||
--disk /iscsi-pool/diskvol1,total_bytes_sec=10,total_iops_sec=20,bus=scsi,device=lun,sgio=unfiltered,rawio=yes
|
||||
--disk /dev/default-pool/iso-vol,seclabel.model=dac,seclabel1.model=selinux,seclabel1.relabel=no,seclabel0.label=foo,bar,baz,iotune.read_bytes_sec=1,iotune.read_iops_sec=2,iotune.write_bytes_sec=5,iotune.write_iops_sec=6
|
||||
|
@ -995,14 +995,27 @@ class DeviceDisk(Device):
|
||||
if self.is_cdrom():
|
||||
self.read_only = True
|
||||
|
||||
discard_unmap = False
|
||||
if (self.conn.is_qemu() and
|
||||
self.is_disk() and
|
||||
self._storage_backend.will_create_storage() and
|
||||
self._storage_backend.get_vol_install() and
|
||||
self._storage_backend.get_vol_install().allocation == 0):
|
||||
discard_unmap = True
|
||||
|
||||
if (self.conn.is_qemu() and
|
||||
self.is_disk() and
|
||||
self.type == self.TYPE_BLOCK):
|
||||
discard_unmap = True
|
||||
if not self.driver_cache:
|
||||
self.driver_cache = self.CACHE_MODE_NONE
|
||||
if not self.driver_io:
|
||||
self.driver_io = self.IO_MODE_NATIVE
|
||||
|
||||
if discard_unmap:
|
||||
if not self.driver_discard:
|
||||
self.driver_discard = "unmap"
|
||||
|
||||
if not self.target:
|
||||
used_targets = [d.target for d in guest.devices.disk if d.target]
|
||||
self.generate_target(used_targets)
|
||||
|
Loading…
x
Reference in New Issue
Block a user