<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'>
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``. This is usually properly configured by the
+ hypervisor.
Filesystems
~~~~~~~~~~~
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))) {
dst->blockio.physical_block_size, src->blockio.physical_block_size);
return false;
}
+
+ if (src->blockio.discard_granularity != dst->blockio.discard_granularity) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Target disk discard_granularity %1$u does not match source %2$u"),
+ dst->blockio.discard_granularity, src->blockio.discard_granularity);
+ return false;
+ }
return true;
}
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,
" 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");
}
}
struct {
unsigned int logical_block_size;
unsigned int physical_block_size;
+ unsigned int discard_granularity;
} blockio;
virDomainBlockIoTuneInfo blkdeviotune;
}
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;
<data type="integer"/>
</attribute>
</optional>
+ <optional>
+ <attribute name="discard_granularity">
+ <data type="integer"/>
+ </attribute>
+ </optional>
</element>
</define>
<!--
"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",
}
if (disk->blockio.logical_block_size ||
- disk->blockio.physical_block_size) {
+ disk->blockio.physical_block_size ||
+ disk->blockio.discard_granularity) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Setting disk block sizes is not "
"supported by vz driver."));