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

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 | 11 ++++++ 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 | 3 ++ src/qemu/qemu_capabilities.h | 3 ++ src/qemu/qemu_command.c | 11 ++++++ 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, 155 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 | 11 ++++++ 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, 101 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 e737e39d384f..199900963938 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2574,6 +2574,17 @@ <code>bus</code> and "pci" or "ccw" <code>address</code> types. <span class='since'>Since 1.2.8 (QEMU 2.1)</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. Detecting such writes can take some time, however it + can save space for spare images, 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"). + <span class='since'>Since 1.3.6</span> + </li> </ul> </dd> <dt><code>backenddomain</code></dt> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index d14c1c5ecffd..da8de14a8afd 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 9f9fdf24190e..dbff1cfa0399 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -806,6 +806,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", @@ -7203,6 +7209,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: @@ -19368,6 +19382,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, @@ -19422,7 +19437,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) @@ -19446,6 +19461,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 b1953b31431a..f44daa0b6b2e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -527,6 +527,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; @@ -605,6 +614,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 */ }; @@ -2910,6 +2920,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 333bf7c8b2db..b07e90bf9fec 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -266,6 +266,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 e9d1f938360d..d8810f791f27 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -558,6 +558,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

On 06/04/2016 08:46 PM, Martin Kletzander wrote:
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 | 11 ++++++ 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, 101 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 e737e39d384f..199900963938 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2574,6 +2574,17 @@ <code>bus</code> and "pci" or "ccw" <code>address</code> types. <span class='since'>Since 1.2.8 (QEMU 2.1)</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. Detecting such writes can take some time, however it + can save space for spare images, 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"). + <span class='since'>Since 1.3.6</span> + </li>
Do we really want to get in to the two space debate? ~/~ I would move the description right after discard since they're related. Also I was wondering what a spare image was until I reread it as "sparse"... So I know I'm "late" with this thought, but since it's optional (e.g. off is not supplied), there are really only two methods that would need to be described. If the attribute is not there, then it's off! So.... The optional detect_zeroes attribute controls how to detect the writing of zero filled blocks for sparse images. If the attribute is not supplied, it can be considered as "off" and there will be no detection. If the attribute is set to "on", each block will will be scanned and ... If the attribute is set to "unmap" and the discard attribute is set to "unmap", then ... NB, enabling the detection is a compute intensive operation, but can save file space. FWIW: Looking at the qemu code there seems to be a requirement that discard is also set to unmap One other thought would be to provide "suggestions" for usage... I'm honestly not clear what the advantage is beyond perhaps saving file space or perhaps coupled with Michal's sparse streams work be able to move images much faster (perhaps offsetting the performance hit of zero block detection!)
</ul> </dd> <dt><code>backenddomain</code></dt> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index d14c1c5ecffd..da8de14a8afd 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 9f9fdf24190e..dbff1cfa0399 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -806,6 +806,12 @@ VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST, "unmap", "ignore")
+VIR_ENUM_IMPL(virDomainDiskDetectZeroes, VIR_DOMAIN_DISK_DETECT_ZEROES_LAST, + "default", + "off",
see note below
+ "on", + "unmap") + VIR_ENUM_IMPL(virDomainDiskMirrorState, VIR_DOMAIN_DISK_MIRROR_STATE_LAST, "none", "yes", @@ -7203,6 +7209,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: @@ -19368,6 +19382,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, @@ -19422,7 +19437,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) @@ -19446,6 +19461,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 b1953b31431a..f44daa0b6b2e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -527,6 +527,15 @@ typedef enum { VIR_DOMAIN_DISK_DISCARD_LAST } virDomainDiskDiscard;
+typedef enum { + VIR_DOMAIN_DISK_DETECT_ZEROES_DEFAULT = 0, + VIR_DOMAIN_DISK_DETECT_ZEROES_OFF,
I know this follows discard essentially, buy why even have a default? If OFF were zero then it wouldn't be written and things would be "as is" today. The qemu impl doesn't have a default value and it seems as if OFF is the default. Hope it's worth than 1 korun's worth of advice ;-) (it's how wikipedia spells it - what do I know... I'm more familiar with cents) Code wise, I think things are fine - it's the description of the functionality that still needs some tweaks. John
+ 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; @@ -605,6 +614,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 */ };
@@ -2910,6 +2920,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 333bf7c8b2db..b07e90bf9fec 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -266,6 +266,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 e9d1f938360d..d8810f791f27 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -558,6 +558,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");

On Wed, Jun 08, 2016 at 07:27:47PM -0400, John Ferlan wrote:
On 06/04/2016 08:46 PM, Martin Kletzander wrote:
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 | 11 ++++++ 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, 101 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 e737e39d384f..199900963938 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2574,6 +2574,17 @@ <code>bus</code> and "pci" or "ccw" <code>address</code> types. <span class='since'>Since 1.2.8 (QEMU 2.1)</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. Detecting such writes can take some time, however it + can save space for spare images, 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"). + <span class='since'>Since 1.3.6</span> + </li>
Do we really want to get in to the two space debate? ~/~
Never again =) And since this is HTML, it will be rendered as a one space, no matter how many whitespaces there are ;)
I would move the description right after discard since they're related. Also I was wondering what a spare image was until I reread it as "sparse"...
Funny typo, thanks for catching that.
So I know I'm "late" with this thought, but since it's optional (e.g. off is not supplied), there are really only two methods that would need to be described. If the attribute is not there, then it's off! So....
I believe we discussed that already. I don't know with whom that was or in what version; maybe it was on another subject altogether. Nevertheless we can't say that not supplying the attribute means "off" and that's for one simple reason. For QEMU that would work, but if there is some other hypervisor (or maybe a new one in the future) that does zero detection when we don't specify anything, then we're screwed. Or when QEMU changes it's default behaviour (very unlikely, I know, but better safe than sorry). That's why not specifying anything means "let the hypervisor decide" and we can support that until eternity and be sure we won't break anything like that. If we decide that not specifying anything means "off", then we can always add that default value in the XML automatically.
The optional detect_zeroes attribute controls how to detect the writing of zero filled blocks for sparse images. If the attribute is not supplied, it can be considered as "off" and there will be no detection. If the attribute is set to "on", each block will will be scanned and ... If the attribute is set to "unmap" and the discard attribute is set to "unmap", then ...
NB, enabling the detection is a compute intensive operation, but can save file space.
I added this in the docs because I was unable to come up with such nicely worded explanation ;)
FWIW: Looking at the qemu code there seems to be a requirement that discard is also set to unmap
Differently than what I described in the documentation? I mentioned it there and we discussed whether we should follow that behaviour or not in previous round of patches I believe.
One other thought would be to provide "suggestions" for usage... I'm honestly not clear what the advantage is beyond perhaps saving file space or perhaps coupled with Michal's sparse streams work be able to move images much faster (perhaps offsetting the performance hit of zero block detection!)
I'm thinking about doing some write-ups about suggestions and explanation of scenarios that people ask about often. But that's a story for another day and it doesn't fit into documentation nor manuals (maybe some example section in the manual but I don't know who'd be looking for that there). [...]
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9f9fdf24190e..dbff1cfa0399 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -806,6 +806,12 @@ VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST, "unmap", "ignore")
+VIR_ENUM_IMPL(virDomainDiskDetectZeroes, VIR_DOMAIN_DISK_DETECT_ZEROES_LAST, + "default", + "off",
see note below
[...]
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b1953b31431a..f44daa0b6b2e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -527,6 +527,15 @@ typedef enum { VIR_DOMAIN_DISK_DISCARD_LAST } virDomainDiskDiscard;
+typedef enum { + VIR_DOMAIN_DISK_DETECT_ZEROES_DEFAULT = 0, + VIR_DOMAIN_DISK_DETECT_ZEROES_OFF,
I know this follows discard essentially, buy why even have a default? If OFF were zero then it wouldn't be written and things would be "as is" today. The qemu impl doesn't have a default value and it seems as if OFF is the default.
Bear in mind that there are freaking weird hypervisors out there and the fact that QEMU behaves "sanely" (in this particular scenario) doesn't mean others will follow. And libvirt being all about the abstraction should make sure we won't have bunch of new XML elements just to say the same thing (which happened way too many times already).
Hope it's worth than 1 korun's worth of advice ;-) (it's how wikipedia spells it - what do I know... I'm more familiar with cents)
Wow, 1 crown is double the amount of 2 cents ;)
Code wise, I think things are fine - it's the description of the functionality that still needs some tweaks.
John

On 06/09/2016 04:00 AM, Martin Kletzander wrote: [...]
So I know I'm "late" with this thought, but since it's optional (e.g. off is not supplied), there are really only two methods that would need to be described. If the attribute is not there, then it's off! So....
I believe we discussed that already. I don't know with whom that was or in what version; maybe it was on another subject altogether. Nevertheless we can't say that not supplying the attribute means "off" and that's for one simple reason. For QEMU that would work, but if there is some other hypervisor (or maybe a new one in the future) that does zero detection when we don't specify anything, then we're screwed. Or when QEMU changes it's default behaviour (very unlikely, I know, but better safe than sorry).
That's why not specifying anything means "let the hypervisor decide" and we can support that until eternity and be sure we won't break anything like that. If we decide that not specifying anything means "off", then we can always add that default value in the XML automatically.
Reading the description of the parameters is what led me down the path more than anything else. Going back to the v1 discussion pointer just now proves your point - short term memory gets shorter every day.
The optional detect_zeroes attribute controls how to detect the writing of zero filled blocks for sparse images. If the attribute is not supplied, it can be considered as "off" and there will be no detection. If the attribute is set to "on", each block will will be scanned and ... If the attribute is set to "unmap" and the discard attribute is set to "unmap", then ...
NB, enabling the detection is a compute intensive operation, but can save file space.
I added this in the docs because I was unable to come up with such nicely worded explanation ;)
And looking at the qemu docs didn't help much either did it! It seems this is one of those attribute/features that would have a more specific use case. Although given the rest of your response - perhaps "assuming" what a hypervisor would do with such a detect_zeroes option could be dangerous. I left the ellipses because it wasn't clear to me.
FWIW: Looking at the qemu code there seems to be a requirement that discard is also set to unmap
Differently than what I described in the documentation? I mentioned it there and we discussed whether we should follow that behaviour or not in previous round of patches I believe.
Suffice to say the qemu code wasn't clear enough for my quick read. There's some combination where if unmap is set, but the block flags doesn't have unmap, then qemu returns an error "setting detect-zeroes to unmap is not allowed without setting discard operation to unmap". (in blockdev.c) What would happen if "discard" is not set or is set to "ignore" and detect_zeroes to "unmap". I assume you've tried the various combinations. Does it make sense to "fail" XML config check if we determine that "detect_zeroes=unmap", but that "discard=none" or "discard=ignore"? It seems perhaps as generic as we try to make these options, it's still qemu specific (and even more so if we document it as a qemu/kvm option was was suggested in some previous review). That is would some other hypervisor call it "unmap"?
One other thought would be to provide "suggestions" for usage... I'm honestly not clear what the advantage is beyond perhaps saving file space or perhaps coupled with Michal's sparse streams work be able to move images much faster (perhaps offsetting the performance hit of zero block detection!)
I'm thinking about doing some write-ups about suggestions and explanation of scenarios that people ask about often. But that's a story for another day and it doesn't fit into documentation nor manuals (maybe some example section in the manual but I don't know who'd be looking for that there).
Fair enough - it wasn't a requirement. As I'm reading things I'm wondering what value does this provide. The comment about "detecting such writes can take some time" may lead one to believe it isn't good; however, depending on your operation e.g. creation of a large, empty disk where one could drastically speed up creation as shown in the commit message: http://git.qemu.org/?p=qemu.git;a=commitdiff;h=465bee1da82e43f18d10c43cc7566...
[...]
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9f9fdf24190e..dbff1cfa0399 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -806,6 +806,12 @@ VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST, "unmap", "ignore")
+VIR_ENUM_IMPL(virDomainDiskDetectZeroes, VIR_DOMAIN_DISK_DETECT_ZEROES_LAST, + "default", + "off",
see note below
[...]
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b1953b31431a..f44daa0b6b2e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -527,6 +527,15 @@ typedef enum { VIR_DOMAIN_DISK_DISCARD_LAST } virDomainDiskDiscard;
+typedef enum { + VIR_DOMAIN_DISK_DETECT_ZEROES_DEFAULT = 0, + VIR_DOMAIN_DISK_DETECT_ZEROES_OFF,
I know this follows discard essentially, buy why even have a default? If OFF were zero then it wouldn't be written and things would be "as is" today. The qemu impl doesn't have a default value and it seems as if OFF is the default.
Bear in mind that there are freaking weird hypervisors out there and the fact that QEMU behaves "sanely" (in this particular scenario) doesn't mean others will follow. And libvirt being all about the abstraction should make sure we won't have bunch of new XML elements just to say the same thing (which happened way too many times already).
OK - fair enough... Like 2 cents, it wasn't worth much! Keep the default, fix up the docs, rebase, and hope that it stays fresh in my mind when it's reposted! John
Hope it's worth than 1 korun's worth of advice ;-) (it's how wikipedia spells it - what do I know... I'm more familiar with cents)
Wow, 1 crown is double the amount of 2 cents ;)
Code wise, I think things are fine - it's the description of the functionality that still needs some tweaks.
John

On Thu, Jun 09, 2016 at 07:33:30AM -0400, John Ferlan wrote:
On 06/09/2016 04:00 AM, Martin Kletzander wrote: [...]
So I know I'm "late" with this thought, but since it's optional (e.g. off is not supplied), there are really only two methods that would need to be described. If the attribute is not there, then it's off! So....
I believe we discussed that already. I don't know with whom that was or in what version; maybe it was on another subject altogether. Nevertheless we can't say that not supplying the attribute means "off" and that's for one simple reason. For QEMU that would work, but if there is some other hypervisor (or maybe a new one in the future) that does zero detection when we don't specify anything, then we're screwed. Or when QEMU changes it's default behaviour (very unlikely, I know, but better safe than sorry).
That's why not specifying anything means "let the hypervisor decide" and we can support that until eternity and be sure we won't break anything like that. If we decide that not specifying anything means "off", then we can always add that default value in the XML automatically.
Reading the description of the parameters is what led me down the path more than anything else. Going back to the v1 discussion pointer just now proves your point - short term memory gets shorter every day.
Especially since it's six months since I sent the first series to the list, right? =D
The optional detect_zeroes attribute controls how to detect the writing of zero filled blocks for sparse images. If the attribute is not supplied, it can be considered as "off" and there will be no detection. If the attribute is set to "on", each block will will be scanned and ... If the attribute is set to "unmap" and the discard attribute is set to "unmap", then ...
NB, enabling the detection is a compute intensive operation, but can save file space.
I added this in the docs because I was unable to come up with such nicely worded explanation ;)
And looking at the qemu docs didn't help much either did it! It seems this is one of those attribute/features that would have a more specific use case. Although given the rest of your response - perhaps "assuming" what a hypervisor would do with such a detect_zeroes option could be dangerous. I left the ellipses because it wasn't clear to me.
FWIW: Looking at the qemu code there seems to be a requirement that discard is also set to unmap
Differently than what I described in the documentation? I mentioned it there and we discussed whether we should follow that behaviour or not in previous round of patches I believe.
Suffice to say the qemu code wasn't clear enough for my quick read. There's some combination where if unmap is set, but the block flags doesn't have unmap, then qemu returns an error "setting detect-zeroes to unmap is not allowed without setting discard operation to unmap". (in blockdev.c)
And sure enough, you are right. I updated my qemu and found out that since the first posting some things have changed. It looks like it's hard keeping out-of-tree patches in sync across bunch of releases =)
What would happen if "discard" is not set or is set to "ignore" and detect_zeroes to "unmap". I assume you've tried the various combinations. Does it make sense to "fail" XML config check if we determine that "detect_zeroes=unmap", but that "discard=none" or "discard=ignore"? It seems perhaps as generic as we try to make these options, it's still qemu specific (and even more so if we document it as a qemu/kvm option was was suggested in some previous review). That is would some other hypervisor call it "unmap"?
I looked at the code, and at qemu and so on and I've found out that this needs few more changes. So I fixed that and also incorporated one small piece of logic in there which does not assume any hypervisor defaults.
One other thought would be to provide "suggestions" for usage... I'm honestly not clear what the advantage is beyond perhaps saving file space or perhaps coupled with Michal's sparse streams work be able to move images much faster (perhaps offsetting the performance hit of zero block detection!)
I'm thinking about doing some write-ups about suggestions and explanation of scenarios that people ask about often. But that's a story for another day and it doesn't fit into documentation nor manuals (maybe some example section in the manual but I don't know who'd be looking for that there).
Fair enough - it wasn't a requirement. As I'm reading things I'm wondering what value does this provide. The comment about "detecting such writes can take some time" may lead one to believe it isn't good; however, depending on your operation e.g. creation of a large, empty disk where one could drastically speed up creation as shown in the commit message:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=465bee1da82e43f18d10c43cc7566...
[...]
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9f9fdf24190e..dbff1cfa0399 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -806,6 +806,12 @@ VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST, "unmap", "ignore")
+VIR_ENUM_IMPL(virDomainDiskDetectZeroes, VIR_DOMAIN_DISK_DETECT_ZEROES_LAST, + "default", + "off",
see note below
[...]
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b1953b31431a..f44daa0b6b2e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -527,6 +527,15 @@ typedef enum { VIR_DOMAIN_DISK_DISCARD_LAST } virDomainDiskDiscard;
+typedef enum { + VIR_DOMAIN_DISK_DETECT_ZEROES_DEFAULT = 0, + VIR_DOMAIN_DISK_DETECT_ZEROES_OFF,
I know this follows discard essentially, buy why even have a default? If OFF were zero then it wouldn't be written and things would be "as is" today. The qemu impl doesn't have a default value and it seems as if OFF is the default.
Bear in mind that there are freaking weird hypervisors out there and the fact that QEMU behaves "sanely" (in this particular scenario) doesn't mean others will follow. And libvirt being all about the abstraction should make sure we won't have bunch of new XML elements just to say the same thing (which happened way too many times already).
OK - fair enough... Like 2 cents, it wasn't worth much!
Keep the default, fix up the docs, rebase, and hope that it stays fresh in my mind when it's reposted!
Have a look at the next version and see. But don't worry, it's not like something tragic will happen if it slips one more release. Or five =D I'll try to post is ASAP.
John
Hope it's worth than 1 korun's worth of advice ;-) (it's how wikipedia spells it - what do I know... I'm more familiar with cents)
Wow, 1 crown is double the amount of 2 cents ;)
Code wise, I think things are fine - it's the description of the functionality that still needs some tweaks.
John
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_capabilities.h | 3 +++ src/qemu/qemu_command.c | 11 +++++++++ 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 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 3 +++ 12 files changed, 54 insertions(+) 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 d32e71f12d24..79f7010fd3b1 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -329,6 +329,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "nec-usb-xhci-ports", "virtio-scsi-pci.iothread", "name-guest", + + "drive-detect-zeroes", /* 225 */ ); @@ -2644,6 +2646,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 368996ad29f1..341e00923699 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -361,6 +361,9 @@ typedef enum { QEMU_CAPS_VIRTIO_SCSI_IOTHREAD, /* virtio-scsi-{pci,ccw}.iothread */ QEMU_CAPS_NAME_GUEST, /* -name guest= */ + /* 225 */ + 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 368bd871f7e3..993e49f832cd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1499,6 +1499,17 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, } } + if (disk->detect_zeroes) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_DETECT_ZEROES)) { + virBufferAsprintf(&opt, ",detect_zeroes=%s", + virDomainDiskDetectZeroesTypeToString(disk->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 e56b7e58be85..cd544ca1394e 100644 --- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml @@ -178,6 +178,7 @@ <flag name='nec-usb-xhci-ports'/> <flag name='virtio-scsi-pci.iothread'/> <flag name='name-guest'/> + <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 4df48435c460..ba129776ca46 100644 --- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml @@ -182,6 +182,7 @@ <flag name='nec-usb-xhci-ports'/> <flag name='virtio-scsi-pci.iothread'/> <flag name='name-guest'/> + <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 8af08943693f..68d14b207be2 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml @@ -188,6 +188,7 @@ <flag name='nec-usb-xhci-ports'/> <flag name='virtio-scsi-pci.iothread'/> <flag name='name-guest'/> + <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..f55786458efe --- /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=off \ +-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/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index db42b7bd71be..67c1b0f71521 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_FAILURE("disk-same-targets", QEMU_CAPS_SCSI_LSI, -- 2.8.3

On 06/04/2016 08:46 PM, Martin Kletzander wrote:
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_capabilities.h | 3 +++ src/qemu/qemu_command.c | 11 +++++++++ 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 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 3 +++ 12 files changed, 54 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.args
Would not apply - merge conflicts too difficult for git am -3 to handle before falling flat on it's face. I'm not convinced we need a "detect_zeroes=off", but an "on" would be good. John
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index d32e71f12d24..79f7010fd3b1 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -329,6 +329,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "nec-usb-xhci-ports", "virtio-scsi-pci.iothread", "name-guest", + + "drive-detect-zeroes", /* 225 */ );
@@ -2644,6 +2646,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 368996ad29f1..341e00923699 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -361,6 +361,9 @@ typedef enum { QEMU_CAPS_VIRTIO_SCSI_IOTHREAD, /* virtio-scsi-{pci,ccw}.iothread */ QEMU_CAPS_NAME_GUEST, /* -name guest= */
+ /* 225 */ + 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 368bd871f7e3..993e49f832cd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1499,6 +1499,17 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, } }
+ if (disk->detect_zeroes) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_DETECT_ZEROES)) { + virBufferAsprintf(&opt, ",detect_zeroes=%s", + virDomainDiskDetectZeroesTypeToString(disk->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 e56b7e58be85..cd544ca1394e 100644 --- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml @@ -178,6 +178,7 @@ <flag name='nec-usb-xhci-ports'/> <flag name='virtio-scsi-pci.iothread'/> <flag name='name-guest'/> + <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 4df48435c460..ba129776ca46 100644 --- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml @@ -182,6 +182,7 @@ <flag name='nec-usb-xhci-ports'/> <flag name='virtio-scsi-pci.iothread'/> <flag name='name-guest'/> + <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 8af08943693f..68d14b207be2 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml @@ -188,6 +188,7 @@ <flag name='nec-usb-xhci-ports'/> <flag name='virtio-scsi-pci.iothread'/> <flag name='name-guest'/> + <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..f55786458efe --- /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=off \ +-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/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index db42b7bd71be..67c1b0f71521 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_FAILURE("disk-same-targets", QEMU_CAPS_SCSI_LSI,

On Wed, Jun 08, 2016 at 07:28:34PM -0400, John Ferlan wrote:
On 06/04/2016 08:46 PM, Martin Kletzander wrote:
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_capabilities.h | 3 +++ src/qemu/qemu_command.c | 11 +++++++++ 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 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 3 +++ 12 files changed, 54 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.args
Would not apply - merge conflicts too difficult for git am -3 to handle before falling flat on it's face.
I'm keeping rebased versions on my github github.com/nertpinx/libvirt in case something gets out of sync, but of course I'll post a rebased version after we reach a consensus in the 'default/off' case.
I'm not convinced we need a "detect_zeroes=off", but an "on" would be good.
I hope you will be after reading my comments ;)
John
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index d32e71f12d24..79f7010fd3b1 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -329,6 +329,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "nec-usb-xhci-ports", "virtio-scsi-pci.iothread", "name-guest", + + "drive-detect-zeroes", /* 225 */ );
@@ -2644,6 +2646,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 368996ad29f1..341e00923699 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -361,6 +361,9 @@ typedef enum { QEMU_CAPS_VIRTIO_SCSI_IOTHREAD, /* virtio-scsi-{pci,ccw}.iothread */ QEMU_CAPS_NAME_GUEST, /* -name guest= */
+ /* 225 */ + 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 368bd871f7e3..993e49f832cd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1499,6 +1499,17 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, } }
+ if (disk->detect_zeroes) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_DETECT_ZEROES)) { + virBufferAsprintf(&opt, ",detect_zeroes=%s", + virDomainDiskDetectZeroesTypeToString(disk->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 e56b7e58be85..cd544ca1394e 100644 --- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml @@ -178,6 +178,7 @@ <flag name='nec-usb-xhci-ports'/> <flag name='virtio-scsi-pci.iothread'/> <flag name='name-guest'/> + <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 4df48435c460..ba129776ca46 100644 --- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml @@ -182,6 +182,7 @@ <flag name='nec-usb-xhci-ports'/> <flag name='virtio-scsi-pci.iothread'/> <flag name='name-guest'/> + <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 8af08943693f..68d14b207be2 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml @@ -188,6 +188,7 @@ <flag name='nec-usb-xhci-ports'/> <flag name='virtio-scsi-pci.iothread'/> <flag name='name-guest'/> + <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..f55786458efe --- /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=off \ +-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/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index db42b7bd71be..67c1b0f71521 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_FAILURE("disk-same-targets", QEMU_CAPS_SCSI_LSI,
participants (2)
-
John Ferlan
-
Martin Kletzander