mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-12-03 16:25:09 +03:00
conf: Add configuration option for timed disk statistics collection
QEMU supports collection of disk statistics in configurable time windows. Add support for enabling this feature to the conf parser. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
@@ -3597,6 +3597,23 @@ paravirtualized driver is specified via the ``disk`` element.
|
||||
</iothreads>
|
||||
</driver>
|
||||
|
||||
- The optional ``statistics`` sub-element allows configuring statistics
|
||||
collection in configurable intervals for the given disk. Intervals are
|
||||
configured by ``<statistic>`` sub-elements with ``interval`` attribute
|
||||
configuring the collection window duration in seconds. The statistics
|
||||
are available via the bulk statistics API.
|
||||
|
||||
Example::
|
||||
|
||||
<driver name='qemu'>
|
||||
<statistics>
|
||||
<statistic interval='1'/>
|
||||
<statistic interval='10'/>
|
||||
</statistics>
|
||||
</driver>
|
||||
|
||||
:since:`Since 11.9.0 (QEMU 10.2, virtio, ide, scsi disks only)`.
|
||||
|
||||
- The optional ``queues`` attribute specifies the number of virt queues for
|
||||
virtio-blk ( :since:`Since 3.9.0` ) or vhost-user-blk
|
||||
( :since:`Since 7.1.0` )
|
||||
|
||||
@@ -8297,6 +8297,8 @@ static int
|
||||
virDomainDiskDefDriverParseXML(virDomainDiskDef *def,
|
||||
xmlNodePtr cur)
|
||||
{
|
||||
xmlNodePtr statisticsNode;
|
||||
|
||||
def->driverName = virXMLPropString(cur, "name");
|
||||
|
||||
if (virXMLPropEnum(cur, "cache", virDomainDiskCacheTypeFromString,
|
||||
@@ -8346,6 +8348,26 @@ virDomainDiskDefDriverParseXML(virDomainDiskDef *def,
|
||||
if (virDomainIothreadMappingDefParse(cur, &def->iothreads) < 0)
|
||||
return -1;
|
||||
|
||||
if ((statisticsNode = virXMLNodeGetSubelement(cur, "statistics"))) {
|
||||
g_autoptr(GPtrArray) statisticNodes = NULL;
|
||||
|
||||
statisticNodes = virXMLNodeGetSubelementList(statisticsNode, "statistic");
|
||||
|
||||
if (statisticNodes->len > 0) {
|
||||
size_t i;
|
||||
|
||||
def->statistics = g_new0(unsigned int, statisticNodes->len + 1);
|
||||
|
||||
for (i = 0; i < statisticNodes->len; i++) {
|
||||
if (virXMLPropUInt(g_ptr_array_index(statisticNodes, i),
|
||||
"interval", 10,
|
||||
VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO,
|
||||
def->statistics + i) < 0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (virXMLPropEnum(cur, "detect_zeroes",
|
||||
virDomainDiskDetectZeroesTypeFromString,
|
||||
VIR_XML_PROP_NONZERO, &def->detect_zeroes) < 0)
|
||||
@@ -23864,6 +23886,18 @@ virDomainDiskDefFormatDriver(virBuffer *buf,
|
||||
|
||||
virDomainIothreadMappingDefFormat(&childBuf, disk->iothreads);
|
||||
|
||||
if (disk->statistics) {
|
||||
g_auto(virBuffer) statisticsChildBuf = VIR_BUFFER_INIT_CHILD(&childBuf);
|
||||
size_t i;
|
||||
|
||||
for (i = 0; disk->statistics[i] > 0; i++)
|
||||
virBufferAsprintf(&statisticsChildBuf, "<statistic interval='%u'/>\n",
|
||||
disk->statistics[i]);
|
||||
|
||||
virXMLFormatElement(&childBuf, "statistics", NULL, &statisticsChildBuf);
|
||||
}
|
||||
|
||||
|
||||
virXMLFormatElement(buf, "driver", &attrBuf, &childBuf);
|
||||
}
|
||||
|
||||
|
||||
@@ -592,6 +592,8 @@ struct _virDomainDiskDef {
|
||||
virDomainDiskDiscard discard;
|
||||
unsigned int iothread; /* unused = 0, > 0 specific thread # */
|
||||
GSList *iothreads; /* List of virDomainIothreadMappingDef */
|
||||
unsigned int *statistics; /* Optional, zero terminated list of intervals to
|
||||
collect statistics for */
|
||||
virDomainDiskDetectZeroes detect_zeroes;
|
||||
virTristateSwitch discard_no_unref;
|
||||
char *domain_name; /* backend domain name */
|
||||
|
||||
@@ -2742,6 +2742,17 @@
|
||||
<optional>
|
||||
<ref name="iothreadMapping"/>
|
||||
</optional>
|
||||
<optional>
|
||||
<element name="statistics">
|
||||
<zeroOrMore>
|
||||
<element name="statistic">
|
||||
<attribute name="interval">
|
||||
<ref name="unsignedInt"/>
|
||||
</attribute>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
</element>
|
||||
</optional>
|
||||
</interleave>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
Reference in New Issue
Block a user