Why "discard":"unmap" is the default option for disks

Han Han hhan at redhat.com
Thu Oct 22 02:57:05 UTC 2020


Hello,
I find "discard":"unmap" is defaultly enabled in  qemu cmdline(libvirt
v6.6, qemu v5.1):
XML:
<disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
      <source file="/var/lib/libvirt/images/new.qcow2" index="2"/>
      <backingStore/>
      <target dev="sda" bus="scsi"/>
      <alias name="scsi0-0-0-0"/>
      <address type="drive" controller="0" bus="0" target="0" unit="0"/>
    </disk><disk type="network" device="disk">
      <driver name="qemu" type="raw" error_policy="report"/>
      <source protocol="nbd" name="new" tls="no" index="1">
        <host name="localhost" port="10809"/>
      </source>
      <target dev="vdb" bus="virtio"/>
      <alias name="virtio-disk1"/>
      <address type="pci" domain="0x0000" bus="0x02" slot="0x00"
function="0x0"/>
    </disk>

QEMU cmdline:
... -blockdev
{"driver":"file","filename":"/var/lib/libvirt/images/new.qcow2","node-name":"libvirt-2-storage","auto-read-only":true,
*"discard":"unmap"*} -blockdev
{"node-name":"libvirt-2-format","read-only":false,"driver":"qcow2","file":"libvirt-2-storage","backing":null}
-device
scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,device_id=drive-scsi0-0-0-0,drive=libvirt-2-format,id=scsi0-0-0-0,bootindex=1
-blockdev
{"driver":"nbd","server":{"type":"inet","host":"localhost","port":"10809"},"export":"new","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
virtio-blk-pci,bus=pci.2,addr=0x0,drive=libvirt-1-format,id=virtio-disk1,werror=report,rerror=report
...

I think it's from
https://gitlab.com/libvirt/libvirt/-/blob/master/src/qemu/qemu_block.c#L1211
But I cannot find the reason from commit msgs or documents.
Could you please explain it?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20201022/384c530b/attachment.htm>


More information about the libvirt-users mailing list