Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
docs/formatdomain.rst | 6 +++++-
src/conf/domain_conf.c | 12 +++++++++++-
src/conf/domain_conf.h | 1 +
src/conf/domain_validate.c | 3 ++-
src/conf/schemas/domaincommon.rng | 5 +++++
src/qemu/qemu_domain.c | 2 ++
6 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index cd9cb02bf8..0d0812f08c 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -2588,7 +2588,7 @@ paravirtualized driver is specified via the ``disk`` element.
<driver name='qemu' type='raw'/>
<source dev='/dev/sda'/>
<geometry cyls='16383' heads='16' secs='63'
trans='lba'/>
- <blockio logical_block_size='512'
physical_block_size='4096'/>
+ <blockio logical_block_size='512' physical_block_size='4096'
discard_granularity='4096'/>
<target dev='hdj' bus='ide'/>
</disk>
<disk type='volume' device='disk'>
@@ -3435,6 +3435,10 @@ paravirtualized driver is specified via the ``disk`` element.
this would be the value returned by the BLKPBSZGET ioctl and describes the
disk's hardware sector size which can be relevant for the alignment of
disk data.
+ ``discard_granularity``
+ The smallest amount of data that can be discarded in a single operation.
+ It impacts the unmap operations and it must be a multiple of a
+ ``logical_block_size``.
Filesystems
~~~~~~~~~~~
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5ac5c0b771..950c9049ba 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8055,6 +8055,10 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
if (virXMLPropUInt(blockioNode, "physical_block_size", 10,
VIR_XML_PROP_NONE,
&def->blockio.physical_block_size) < 0)
return NULL;
+
+ if (virXMLPropUInt(blockioNode, "discard_granularity", 10,
VIR_XML_PROP_NONE,
+ &def->blockio.discard_granularity) < 0)
+ return NULL;
}
if ((driverNode = virXPathNode("./driver", ctxt))) {
@@ -22035,7 +22039,8 @@ virDomainDiskBlockIoDefFormat(virBuffer *buf,
virDomainDiskDef *def)
{
if (def->blockio.logical_block_size > 0 ||
- def->blockio.physical_block_size > 0) {
+ def->blockio.physical_block_size > 0 ||
+ def->blockio.discard_granularity > 0) {
virBufferAddLit(buf, "<blockio");
if (def->blockio.logical_block_size > 0) {
virBufferAsprintf(buf,
@@ -22047,6 +22052,11 @@ virDomainDiskBlockIoDefFormat(virBuffer *buf,
" physical_block_size='%u'",
def->blockio.physical_block_size);
}
+ if (def->blockio.discard_granularity > 0) {
+ virBufferAsprintf(buf,
+ " discard_granularity='%u'",
+ def->blockio.discard_granularity);
+ }
virBufferAddLit(buf, "/>\n");
}
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c857ba556f..1621876a21 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -579,6 +579,7 @@ struct _virDomainDiskDef {
struct {
unsigned int logical_block_size;
unsigned int physical_block_size;
+ unsigned int discard_granularity;
} blockio;
virDomainBlockIoTuneInfo blkdeviotune;
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index ad383b604e..7e00b6451a 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -466,7 +466,8 @@ virDomainDiskVhostUserValidate(const virDomainDiskDef *disk)
}
if (disk->blockio.logical_block_size > 0 ||
- disk->blockio.physical_block_size > 0) {
+ disk->blockio.physical_block_size > 0 ||
+ disk->blockio.discard_granularity > 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("blockio is not supported with vhostuser disk"));
return -1;
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index c2f56b0490..ee9c408a21 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -2476,6 +2476,11 @@
<data type="integer"/>
</attribute>
</optional>
+ <optional>
+ <attribute name="discard_granularity">
+ <data type="integer"/>
+ </attribute>
+ </optional>
</element>
</define>
<!--
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 029238a9d7..3230bc281d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8387,6 +8387,8 @@ qemuDomainDiskChangeSupported(virDomainDiskDef *disk,
"blockio logical_block_size", false);
CHECK_EQ(blockio.physical_block_size,
"blockio physical_block_size", false);
+ CHECK_EQ(blockio.discard_granularity,
+ "blockio discard_granularity", false);
CHECK_EQ(blkdeviotune.total_bytes_sec,
"blkdeviotune total_bytes_sec",
--
2.41.0