v2: This version made some modifications. (include suggestion of Jonathon) - rebase on master - assume QEMU support discard and write-zeroes and drop the capability introduction and probe - add validation for options, only allowing attributes be configured for VIRTIO bus - enrich the test case - update NEWS Thanks Jonathon for pointing out the redundant commit in time. Please review! Yong DISCARD and WRITE_ZEROES commands has been implemented in virtio-blk protocol since qemu >= 4.2.0, may be it's time to introduce discard and write-zeroes options for virtio-blk device in libvirt so that the upper layer can enable this feature at disk granularity. To distinguish the discard option in block drive layer, use the 'virtio' prefix to indicate that these attributes are specific for virtio-blk disk. To try this out, three things has done in this patchset: 1. introduce capabilities of discard and write-zeroes for virtio-blk 2. add virtio_discard and virtio_write_zeroes attributes of driver in disk xml element 3. generate cmd line when launching vm Hyman Huang(黄勇) (3): conf: Add 'virtio_discard' and 'virtio_write_zeroes' attributes qemu_command: Generate cmd line for discard and write-zeroes properties NEWS: Mention support for discard and write_zeroes of virtio-blk device NEWS.rst | 8 +++ docs/formatdomain.rst | 8 +++ src/conf/domain_conf.c | 16 +++++ src/conf/domain_conf.h | 2 + src/conf/schemas/domaincommon.rng | 10 ++++ src/conf/storage_source_conf.c | 2 + src/conf/storage_source_conf.h | 2 + src/qemu/qemu_command.c | 2 + src/qemu/qemu_domain.c | 2 + src/qemu/qemu_driver.c | 4 +- src/qemu/qemu_validate.c | 9 +++ src/vz/vz_utils.c | 12 ++++ .../disk-virtio-discard.x86_64-latest.args | 45 ++++++++++++++ .../qemuxml2argvdata/disk-virtio-discard.xml | 45 ++++++++++++++ tests/qemuxml2argvtest.c | 1 + .../disk-virtio-discard.x86_64-latest.xml | 58 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 17 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/disk-virtio-discard.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/disk-virtio-discard.xml create mode 100644 tests/qemuxml2xmloutdata/disk-virtio-discard.x86_64-latest.xml -- 2.38.5