Signed-off-by: Lin Ma <lma(a)suse.com>
---
docs/formatdomain.html.in | 12 ++++++++++++
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 26 +++++++++++++++++++++++++-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_domain.c | 2 ++
5 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 59ee50225a..c4c510ab5f 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3015,6 +3015,13 @@
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0'
target='3' unit='0'/>
</disk>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='qcow2'/>
+ <source file='/var/lib/libvirt/images/domain.qcow2'/>
+ <blockio max_unmap_size='1073741824'/>
+ <target dev='sdb' bus='scsi'/>
+ <address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+ </disk>
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/sda'/>
@@ -4071,6 +4078,11 @@
<dd>Its value impacts the Optimal Unmap Granularity field in
the block limits VPD page. <span class="since">Since
6.5.0</span>
</dd>
+ <dt><code>max_unmap_size</code></dt>
+ <dd>Available for scsi disks only. It impacts the Maximum
+ Unmap LBA count field in the block limits VPD page.
+ <span class="since">Since 6.5.0 (QEMU 2.0)</span>
+ </dd>
</dl>
</dd>
</dl>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 5206c4e246..8d037c4d07 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2182,6 +2182,11 @@
<data type="integer"/>
</attribute>
</optional>
+ <optional>
+ <attribute name="max_unmap_size">
+ <data type="integer"/>
+ </attribute>
+ </optional>
</element>
</define>
<!--
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7a6a124ffd..a546d9cc6f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6145,6 +6145,13 @@ virDomainDiskDefValidate(const virDomainDef *def,
return -1;
}
+ if (disk->blockio.max_unmap_size && disk->bus !=
VIR_DOMAIN_DISK_BUS_SCSI) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("max_unmap_size attribute is only supported by "
+ "scsi-hd or scsi-block"));
+ return -1;
+ }
+
if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO &&
(disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO ||
disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL ||
@@ -10426,6 +10433,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
g_autofree char *product = NULL;
g_autofree char *domain_name = NULL;
g_autofree char *discard_granularity = NULL;
+ g_autofree char *max_unmap_size = NULL;
if (!(def = virDomainDiskDefNew(xmlopt)))
return NULL;
@@ -10533,6 +10541,16 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
discard_granularity);
goto error;
}
+ max_unmap_size =
+ virXMLPropString(cur, "max_unmap_size");
+ if (max_unmap_size &&
+ virStrToLong_ui(max_unmap_size, NULL, 0,
+ &def->blockio.max_unmap_size) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("invalid unmap limits size '%s'"),
+ max_unmap_size);
+ goto error;
+ }
} else if (!virDomainDiskGetDriver(def) &&
virXMLNodeNameEqual(cur, "driver")) {
if (virDomainVirtioOptionsParseXML(cur, &def->virtio) < 0)
@@ -24970,7 +24988,8 @@ virDomainDiskBlockIoDefFormat(virBufferPtr buf,
{
if (def->blockio.logical_block_size > 0 ||
def->blockio.physical_block_size > 0 ||
- def->blockio.discard_granularity > 0) {
+ def->blockio.discard_granularity > 0 ||
+ def->blockio.max_unmap_size > 0) {
virBufferAddLit(buf, "<blockio");
if (def->blockio.logical_block_size > 0) {
virBufferAsprintf(buf,
@@ -24987,6 +25006,11 @@ virDomainDiskBlockIoDefFormat(virBufferPtr buf,
" discard_granularity='%u'",
def->blockio.discard_granularity);
}
+ if (def->blockio.max_unmap_size > 0) {
+ virBufferAsprintf(buf,
+ " max_unmap_size='%u'",
+ def->blockio.max_unmap_size);
+ }
virBufferAddLit(buf, "/>\n");
}
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9056e5e9b6..79bb30b666 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -550,6 +550,7 @@ struct _virDomainDiskDef {
unsigned int logical_block_size;
unsigned int physical_block_size;
unsigned int discard_granularity;
+ unsigned int max_unmap_size;
} blockio;
virDomainBlockIoTuneInfo blkdeviotune;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c582550def..28564f48ec 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8745,6 +8745,8 @@ qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
"blockio physical_block_size", false);
CHECK_EQ(blockio.discard_granularity,
"blockio discard_granularity", false);
+ CHECK_EQ(blockio.max_unmap_size,
+ "blockio max_unmap_size", false);
CHECK_EQ(blkdeviotune.total_bytes_sec,
"blkdeviotune total_bytes_sec",
--
2.26.0