Upcoming qemu release will support configuring mapping iothreads to
virtio queues for 'virtio-scsi' controllers in order to improve
performance.
Reuse the infrastructure we have from the same configuration for
'virti-blk' to implement the conf support for this feature.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
docs/formatdomain.rst | 33 +++++++++++++++++++++++++++++++
src/conf/domain_conf.c | 10 +++++++++-
src/conf/domain_conf.h | 1 +
src/conf/domain_validate.c | 10 +++++++++-
src/conf/schemas/domaincommon.rng | 3 +++
src/hypervisor/domain_driver.c | 3 ++-
6 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 83aeaa32c2..802c875808 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -4123,6 +4123,39 @@ An optional sub-element ``driver`` can specify the driver specific
options:
If a specific IOThread is desired for a specific SCSI ``disk``, then multiple
controllers must be defined each having a specific ``iothread`` value. The
``iothread`` value must be within the range 1 to the domain iothreads value.
+``iothreads``
+ Supported for ``virtio-scsi`` controllers using ``address`` types ``pci`` and
+ ``ccw``. :since:`since 11.1.0 (QEMU 10.0).` Mutually exclusive with ``iothread``.
+
+ The optional ``iothreads`` sub-element allows specifying multiple IOThreads
+ via the ``iothread`` sub-element with attribute ``id`` the virtio-scsi
+ controller will use for I/O operations. Optionally the ``iothread`` element
+ can have multiple ``queue`` subelements specifying that given iothread
+ should be used to handle given queues.
+
+ Note that the ``virtio-scsi`` device has two extra internal queues ``ctrl``
+ and ``event`` with indices ``0`` and ``1`` besides queues configured via
+ the ``queues`` attribute. They need to be covered by manual mapping if
+ provided.
+
+ Example::
+
+ <driver name='qemu' queues='3'>
+ <iothreads>
+ <iothread id='2'>
+ <queue id='1'/>
+ </iothread>
+ <iothread id='3'>
+ <queue id='0'/>
+ <queue id='2'/>
+ </iothread>
+ <iothread id='4'>
+ <queue id='3'/>
+ <queue id='4'/>
+ </iothread>
+ </iothreads>
+ </driver>
+
virtio options
For virtio controllers, `Virtio-related options`_ can
also be set. ( :since:`Since 3.5.0` )
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1a52cda62d..755f4cb537 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2557,6 +2557,8 @@ void virDomainControllerDefFree(virDomainControllerDef *def)
if (!def)
return;
+ g_slist_free_full(def->iothreads, (GDestroyNotify)
virDomainIothreadMappingDefFree);
+
virDomainDeviceInfoClear(&def->info);
g_free(def->virtio);
@@ -8618,6 +8620,9 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
&def->iothread) < 0)
return NULL;
+ if (virDomainIothreadMappingDefParse(driver, &def->iothreads) < 0)
+ return NULL;
+
if (virDomainVirtioOptionsParseXML(driver, &def->virtio) < 0)
return NULL;
}
@@ -23514,6 +23519,7 @@ virDomainControllerDriverFormat(virBuffer *buf,
virDomainControllerDef *def)
{
g_auto(virBuffer) driverBuf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) driverChildBuf = VIR_BUFFER_INIT_CHILD(buf);
if (def->queues)
virBufferAsprintf(&driverBuf, " queues='%u'",
def->queues);
@@ -23532,9 +23538,11 @@ virDomainControllerDriverFormat(virBuffer *buf,
if (def->iothread)
virBufferAsprintf(&driverBuf, " iothread='%u'",
def->iothread);
+ virDomainIothreadMappingDefFormat(&driverChildBuf, def->iothreads);
+
virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
- virXMLFormatElement(buf, "driver", &driverBuf, NULL);
+ virXMLFormatElement(buf, "driver", &driverBuf, &driverChildBuf);
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 10dd5497ac..8e75e3e04b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -764,6 +764,7 @@ struct _virDomainControllerDef {
unsigned int max_sectors;
virTristateSwitch ioeventfd;
unsigned int iothread; /* unused = 0, > 0 specific thread # */
+ GSList *iothreads; /* List of virDomainIothreadMappingDef */
union {
virDomainVirtioSerialOpts vioserial;
virDomainPCIControllerOpts pciopts;
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 88e5f37651..967600581a 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -1260,7 +1260,7 @@ virDomainControllerDefValidate(const virDomainControllerDef
*controller)
}
}
- if (controller->iothread != 0) {
+ if (controller->iothread != 0 || controller->iothreads) {
if (controller->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI ||
!(controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI ||
controller->model ==
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL ||
@@ -1269,6 +1269,14 @@ virDomainControllerDefValidate(const virDomainControllerDef
*controller)
_("iothreads are supported only by 'virtio-scsi'
controllers"));
return -1;
}
+
+ /* configuring both <driver iothread='n'> and it's
<iothreads> sub-element
+ * isn't supported */
+ if (controller->iothread && controller->iothreads) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("controller driver 'iothread' attribute
can't be used together with 'iothreads' subelement"));
+ return -1;
+ }
}
return 0;
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index 755a43e893..a8705b34ee 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -3070,6 +3070,9 @@
<optional>
<ref name="driverIOThread"/>
</optional>
+ <optional>
+ <ref name="iothreadMapping"/>
+ </optional>
<ref name="virtioOptions"/>
</element>
</optional>
diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c
index b7499a376f..29ba358477 100644
--- a/src/hypervisor/domain_driver.c
+++ b/src/hypervisor/domain_driver.c
@@ -585,7 +585,8 @@ virDomainDriverDelIOThreadCheck(virDomainDef *def,
}
for (i = 0; i < def->ncontrollers; i++) {
- if (def->controllers[i]->iothread == iothread_id) {
+ if (virDomainIothreadMappingDefHasIothread(def->controllers[i]->iothreads,
iothread_id) ||
+ def->controllers[i]->iothread == iothread_id) {
virReportError(VIR_ERR_INVALID_ARG,
_("cannot remove IOThread '%1$u' since it is
being used by controller"),
iothread_id);
--
2.48.1