[libvirt] [PATCH v5 0/2] Add support for zero-write detection

v5: - Reword documentation - Use detect_zeroes=on if it is unmap but discard=ignore - Use detect-zeroes on qemu cmdline instead of detect_zeroes v4: - Changed docs per Peter's review - https://www.redhat.com/archives/libvir-list/2016-June/msg00113.html v3: - I know Peter said he'll review it, but there are conflicts every once in a while, so rebased version will apply cleanly for a while - And it's actually not that big of a change to wait for some bigger things to be designed, I believe =) - https://www.redhat.com/archives/libvir-list/2016-April/msg01926.html v2: - use 'zeroes' instead of 'zeros' - https://www.redhat.com/archives/libvir-list/2016-February/msg01146.html v1: - https://www.redhat.com/archives/libvir-list/2015-December/msg00511.html Martin Kletzander (2): conf: Add support of zero-detection for disks qemu: Add support for zero-detection writes docs/formatdomain.html.in | 12 ++++++ docs/schemas/domaincommon.rng | 12 ++++++ src/conf/domain_conf.c | 19 ++++++++- src/conf/domain_conf.h | 11 ++++++ src/libvirt_private.syms | 2 + src/qemu/qemu_capabilities.c | 2 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 24 ++++++++++++ tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 + .../caps_2.6.0-gicv2.aarch64.xml | 1 + .../caps_2.6.0-gicv3.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 + .../qemuxml2argv-disk-drive-detect-zeroes.args | 27 +++++++++++++ .../qemuxml2argv-disk-drive-detect-zeroes.xml | 45 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 3 ++ .../qemuxml2xmlout-disk-drive-detect-zeroes.xml | 1 + tests/qemuxml2xmltest.c | 1 + 20 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-detect-zeroes.xml -- 2.8.3

This option allows or disallows detection of zero-writes if it is set to "on" or "off", respectively. It can be also set to "unmap" in which case it will try discarding that part of image based on the value of the "discard" option. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- docs/formatdomain.html.in | 12 ++++++ docs/schemas/domaincommon.rng | 12 ++++++ src/conf/domain_conf.c | 19 ++++++++- src/conf/domain_conf.h | 11 ++++++ src/libvirt_private.syms | 2 + .../qemuxml2argv-disk-drive-detect-zeroes.xml | 45 ++++++++++++++++++++++ .../qemuxml2xmlout-disk-drive-detect-zeroes.xml | 1 + tests/qemuxml2xmltest.c | 1 + 8 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-detect-zeroes.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index fb3ec5ee3e29..0ad2bbcc90a2 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2565,6 +2565,18 @@ <span class='since'>Since 1.0.6 (QEMU and KVM only)</span> </li> <li> + The optional <code>detect_zeroes</code> attribute controls whether + to detect zero write requests. The value can be "off", "on" or + "unmap". First two values turn the detection off and on, + respectively. The third value ("unmap") turns the detection on + and additionally tries to discard such areas from the image based + on the value of <code>discard</code> above (it will act as "on" + if <code>discard</code> is set to "ignore"). NB enabling the + detection is a compute intensive operation, but can save file + space and/or time on slow media. + <span class='since'>Since 1.3.6</span> + </li> + <li> The optional <code>iothread</code> attribute assigns the disk to an IOThread as defined by the range for the domain <a href="#elementsIOThreadsAllocation"><code>iothreads</code></a> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 02078d73460a..2e07505b1a80 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1618,6 +1618,9 @@ <optional> <ref name="driverIOThread"/> </optional> + <optional> + <ref name="detect_zeroes"/> + </optional> <empty/> </element> </define> @@ -1702,6 +1705,15 @@ <ref name="unsignedInt"/> </attribute> </define> + <define name="detect_zeroes"> + <attribute name='detect_zeroes'> + <choice> + <value>off</value> + <value>on</value> + <value>unmap</value> + </choice> + </attribute> + </define> <define name="controller"> <element name="controller"> <optional> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 10e61daf6dd4..9504e5f63f4f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -807,6 +807,12 @@ VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST, "unmap", "ignore") +VIR_ENUM_IMPL(virDomainDiskDetectZeroes, VIR_DOMAIN_DISK_DETECT_ZEROES_LAST, + "default", + "off", + "on", + "unmap") + VIR_ENUM_IMPL(virDomainDiskMirrorState, VIR_DOMAIN_DISK_MIRROR_STATE_LAST, "none", "yes", @@ -7378,6 +7384,14 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def, VIR_FREE(tmp); } + if ((tmp = virXMLPropString(cur, "detect_zeroes")) && + (def->detect_zeroes = virDomainDiskDetectZeroesTypeFromString(tmp)) <= 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown driver detect_zeroes value '%s'"), tmp); + goto cleanup; + } + VIR_FREE(tmp); + ret = 0; cleanup: @@ -19631,6 +19645,7 @@ virDomainDiskDefFormat(virBufferPtr buf, const char *copy_on_read = virTristateSwitchTypeToString(def->copy_on_read); const char *sgio = virDomainDeviceSGIOTypeToString(def->sgio); const char *discard = virDomainDiskDiscardTypeToString(def->discard); + const char *detect_zeroes = virDomainDiskDetectZeroesTypeToString(def->detect_zeroes); if (!type || !def->src->type) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -19685,7 +19700,7 @@ virDomainDiskDefFormat(virBufferPtr buf, if (def->src->driverName || def->src->format > 0 || def->cachemode || def->error_policy || def->rerror_policy || def->iomode || def->ioeventfd || def->event_idx || def->copy_on_read || - def->discard || def->iothread) { + def->discard || def->iothread || def->detect_zeroes) { virBufferAddLit(buf, "<driver"); virBufferEscapeString(buf, " name='%s'", def->src->driverName); if (def->src->format > 0) @@ -19709,6 +19724,8 @@ virDomainDiskDefFormat(virBufferPtr buf, virBufferAsprintf(buf, " discard='%s'", discard); if (def->iothread) virBufferAsprintf(buf, " iothread='%u'", def->iothread); + if (def->detect_zeroes) + virBufferAsprintf(buf, " detect_zeroes='%s'", detect_zeroes); virBufferAddLit(buf, "/>\n"); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3792562f0983..15f9c80d019a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -528,6 +528,15 @@ typedef enum { VIR_DOMAIN_DISK_DISCARD_LAST } virDomainDiskDiscard; +typedef enum { + VIR_DOMAIN_DISK_DETECT_ZEROES_DEFAULT = 0, + VIR_DOMAIN_DISK_DETECT_ZEROES_OFF, + VIR_DOMAIN_DISK_DETECT_ZEROES_ON, + VIR_DOMAIN_DISK_DETECT_ZEROES_UNMAP, + + VIR_DOMAIN_DISK_DETECT_ZEROES_LAST +} virDomainDiskDetectZeroes; + typedef struct _virDomainBlockIoTuneInfo virDomainBlockIoTuneInfo; struct _virDomainBlockIoTuneInfo { unsigned long long total_bytes_sec; @@ -606,6 +615,7 @@ struct _virDomainDiskDef { int sgio; /* enum virDomainDeviceSGIO */ int discard; /* enum virDomainDiskDiscard */ unsigned int iothread; /* unused = 0, > 0 specific thread # */ + int detect_zeroes; /* enum virDomainDiskDetectZeroes */ char *domain_name; /* backend domain name */ }; @@ -2937,6 +2947,7 @@ VIR_ENUM_DECL(virDomainDiskIo) VIR_ENUM_DECL(virDomainDeviceSGIO) VIR_ENUM_DECL(virDomainDiskTray) VIR_ENUM_DECL(virDomainDiskDiscard) +VIR_ENUM_DECL(virDomainDiskDetectZeroes) VIR_ENUM_DECL(virDomainDiskMirrorState) VIR_ENUM_DECL(virDomainController) VIR_ENUM_DECL(virDomainControllerModelPCI) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 85b9cd14ae7c..a1273bf09f05 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -267,6 +267,8 @@ virDomainDiskDefForeachPath; virDomainDiskDefFree; virDomainDiskDefNew; virDomainDiskDefSourceParse; +virDomainDiskDetectZeroesTypeFromString; +virDomainDiskDetectZeroesTypeToString; virDomainDiskDeviceTypeToString; virDomainDiskDiscardTypeToString; virDomainDiskErrorPolicyTypeFromString; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.xml new file mode 100644 index 000000000000..8953f50f3f92 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.xml @@ -0,0 +1,45 @@ +<domain type='qemu'> + <name>test</name> + <uuid>92d7a226-cfae-425b-a6d3-00bbf9ec5c9e</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc-0.13'>hvm</type> + <boot dev='cdrom'/> + <boot dev='hd'/> + <bootmenu enable='yes'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2' discard='unmap' detect_zeroes='unmap'/> + <source file='/var/lib/libvirt/images/f14.img'/> + <target dev='vda' bus='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </disk> + <disk type='file' device='cdrom'> + <driver discard='ignore' detect_zeroes='off'/> + <source file='/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso'/> + <target dev='hdc' bus='ide'/> + <readonly/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-detect-zeroes.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-detect-zeroes.xml new file mode 120000 index 000000000000..afa3199d4a7e --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-detect-zeroes.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index ba559193478e..7db9cb793147 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -566,6 +566,7 @@ mymain(void) DO_TEST("disk-source-pool-mode"); DO_TEST("disk-drive-discard"); + DO_TEST("disk-drive-detect-zeroes"); DO_TEST("virtio-rng-random"); DO_TEST("virtio-rng-egd"); -- 2.8.3

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 24 +++++++++++++++++++ tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 + .../caps_2.6.0-gicv2.aarch64.xml | 1 + .../caps_2.6.0-gicv3.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 + .../qemuxml2argv-disk-drive-detect-zeroes.args | 27 ++++++++++++++++++++++ .../qemuxml2argv-disk-drive-detect-zeroes.xml | 2 +- tests/qemuxml2argvtest.c | 3 +++ 13 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.args diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index d9f04c8d3aad..3b875877f27e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -333,6 +333,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "qxl.max_outputs", /* 225 */ "qxl-vga.max_outputs", "spice-unix", + "drive-detect-zeroes", ); @@ -2650,6 +2651,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = { { "machine", "mem-merge", QEMU_CAPS_MEM_MERGE }, { "machine", "vmport", QEMU_CAPS_MACHINE_VMPORT_OPT }, { "drive", "discard", QEMU_CAPS_DRIVE_DISCARD }, + { "drive", "detect-zeroes", QEMU_CAPS_DRIVE_DETECT_ZEROES }, { "realtime", "mlock", QEMU_CAPS_MLOCK }, { "boot-opts", "strict", QEMU_CAPS_BOOT_STRICT }, { "boot-opts", "reboot-timeout", QEMU_CAPS_REBOOT_TIMEOUT }, diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index e273f2a44033..e284cfbcfb6b 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -365,6 +365,7 @@ typedef enum { QEMU_CAPS_QXL_MAX_OUTPUTS, /* -device qxl,max-outputs= */ QEMU_CAPS_QXL_VGA_MAX_OUTPUTS, /* -device qxl-vga,max-outputs= */ QEMU_CAPS_SPICE_UNIX, /* -spice unix */ + QEMU_CAPS_DRIVE_DETECT_ZEROES, /* -drive detect-zeroes= */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 490260f15e4f..e550c8ee6e50 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1391,6 +1391,30 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, } } + if (disk->detect_zeroes) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_DETECT_ZEROES)) { + int detect_zeroes = disk->detect_zeroes; + + /* + * As a convinience syntax, if discards are ignored and + * zero detection is set to 'unmap', then simply behave + * like zero detection is set to 'on'. But don't change + * it in the XML for easier adjustments. This behaviour + * is documented. + */ + if (disk->discard != VIR_DOMAIN_DISK_DISCARD_UNMAP && + detect_zeroes == VIR_DOMAIN_DISK_DETECT_ZEROES_UNMAP) + detect_zeroes = VIR_DOMAIN_DISK_DETECT_ZEROES_ON; + + virBufferAsprintf(&opt, ",detect-zeroes=%s", + virDomainDiskDetectZeroesTypeToString(detect_zeroes)); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("detect_zeroes is not supported by this QEMU binary")); + goto error; + } + } + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MONITOR_JSON)) { const char *wpolicy = NULL, *rpolicy = NULL; diff --git a/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml index 5e9b34d8a493..964b6f020483 100644 --- a/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml @@ -164,6 +164,7 @@ <flag name='device-tray-moved-event'/> <flag name='nec-usb-xhci-ports'/> <flag name='name-guest'/> + <flag name='drive-detect-zeroes'/> <version>2001001</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml index df1eb5ecd343..112ac95eabee 100644 --- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml @@ -181,6 +181,7 @@ <flag name='qxl.max_outputs'/> <flag name='qxl-vga.max_outputs'/> <flag name='spice-unix'/> + <flag name='drive-detect-zeroes'/> <version>2004000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml index 83f1e146d857..d7781cf215a1 100644 --- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml @@ -185,6 +185,7 @@ <flag name='qxl.max_outputs'/> <flag name='qxl-vga.max_outputs'/> <flag name='spice-unix'/> + <flag name='drive-detect-zeroes'/> <version>2005000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml index 8b68291aecb4..29f3b5ac3f11 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml @@ -155,6 +155,7 @@ <flag name='nec-usb-xhci-ports'/> <flag name='virtio-scsi-pci.iothread'/> <flag name='name-guest'/> + <flag name='drive-detect-zeroes'/> <version>2005094</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml index d65523ee285f..7c0dcf6b218b 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml @@ -155,6 +155,7 @@ <flag name='nec-usb-xhci-ports'/> <flag name='virtio-scsi-pci.iothread'/> <flag name='name-guest'/> + <flag name='drive-detect-zeroes'/> <version>2005094</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml index 771d20954387..8438deb3d6d4 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml @@ -149,6 +149,7 @@ <flag name='nec-usb-xhci-ports'/> <flag name='virtio-scsi-pci.iothread'/> <flag name='name-guest'/> + <flag name='drive-detect-zeroes'/> <version>2005094</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml index c9f296542dc1..442d5a7e4047 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml @@ -191,6 +191,7 @@ <flag name='qxl.max_outputs'/> <flag name='qxl-vga.max_outputs'/> <flag name='spice-unix'/> + <flag name='drive-detect-zeroes'/> <version>2006000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.args new file mode 100644 index 000000000000..ea651414f1e7 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.args @@ -0,0 +1,27 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name test \ +-S \ +-M pc-0.13 \ +-m 1024 \ +-smp 1 \ +-uuid 92d7a226-cfae-425b-a6d3-00bbf9ec5c9e \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-test/monitor.sock,server,nowait \ +-no-acpi \ +-boot dc \ +-usb \ +-drive file=/var/lib/libvirt/images/f14.img,format=qcow2,if=none,\ +id=drive-virtio-disk0,discard=unmap,detect-zeroes=unmap \ +-device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\ +id=virtio-disk0 \ +-drive file=/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso,format=raw,if=none,\ +media=cdrom,id=drive-ide0-1-0,readonly=on,discard=ignore,detect-zeroes=on \ +-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.xml index 8953f50f3f92..1546ac134f1a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.xml @@ -23,7 +23,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </disk> <disk type='file' device='cdrom'> - <driver discard='ignore' detect_zeroes='off'/> + <driver discard='ignore' detect_zeroes='unmap'/> <source file='/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso'/> <target dev='hdc' bus='ide'/> <readonly/> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 573162fc4cc0..c406b645313c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -875,6 +875,9 @@ mymain(void) QEMU_CAPS_VIRTIO_BLK_SCSI); DO_TEST("disk-drive-discard", QEMU_CAPS_DRIVE_DISCARD); + DO_TEST("disk-drive-detect-zeroes", + QEMU_CAPS_DRIVE_DISCARD, + QEMU_CAPS_DRIVE_DETECT_ZEROES); DO_TEST("disk-snapshot", NONE); DO_TEST_PARSE_ERROR("disk-same-targets", QEMU_CAPS_SCSI_LSI, -- 2.8.3

On 06/10/2016 06:12 PM, Martin Kletzander wrote:
v5: - Reword documentation - Use detect_zeroes=on if it is unmap but discard=ignore - Use detect-zeroes on qemu cmdline instead of detect_zeroes
v4: - Changed docs per Peter's review - https://www.redhat.com/archives/libvir-list/2016-June/msg00113.html
v3: - I know Peter said he'll review it, but there are conflicts every once in a while, so rebased version will apply cleanly for a while - And it's actually not that big of a change to wait for some bigger things to be designed, I believe =) - https://www.redhat.com/archives/libvir-list/2016-April/msg01926.html
v2: - use 'zeroes' instead of 'zeros' - https://www.redhat.com/archives/libvir-list/2016-February/msg01146.html
v1: - https://www.redhat.com/archives/libvir-list/2015-December/msg00511.html
Martin Kletzander (2): conf: Add support of zero-detection for disks qemu: Add support for zero-detection writes
docs/formatdomain.html.in | 12 ++++++ docs/schemas/domaincommon.rng | 12 ++++++ src/conf/domain_conf.c | 19 ++++++++- src/conf/domain_conf.h | 11 ++++++ src/libvirt_private.syms | 2 + src/qemu/qemu_capabilities.c | 2 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 24 ++++++++++++ tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 + .../caps_2.6.0-gicv2.aarch64.xml | 1 + .../caps_2.6.0-gicv3.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 + .../qemuxml2argv-disk-drive-detect-zeroes.args | 27 +++++++++++++ .../qemuxml2argv-disk-drive-detect-zeroes.xml | 45 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 3 ++ .../qemuxml2xmlout-disk-drive-detect-zeroes.xml | 1 + tests/qemuxml2xmltest.c | 1 + 20 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-detect-zeroes.xml
-- 2.8.3
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Comment NIT: In patch 2... s/convinience/convenience ACK series John
participants (2)
-
John Ferlan
-
Martin Kletzander