From nobody Mon Feb 9 14:52:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1741948077967821.9002063083619; Fri, 14 Mar 2025 03:27:57 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E2C091F07; Fri, 14 Mar 2025 06:27:56 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 77A491600; Fri, 14 Mar 2025 06:26:02 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id F3E181F23; Fri, 14 Mar 2025 06:25:57 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id F17BB1901 for ; Fri, 14 Mar 2025 06:25:51 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-379-Pi43fA5aPRqsNvUBjuRqeA-1; Fri, 14 Mar 2025 06:25:50 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 54F451801A00 for ; Fri, 14 Mar 2025 10:25:49 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.6]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 80AFE1801756 for ; Fri, 14 Mar 2025 10:25:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741947951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/jble4vLhl/ZVnczwS4w2blJm54liI+anENCIC+4B8I=; b=N6X4YRw7KHkTCRezSU9lqAQeWYX2NapOtcm1/yVdsA6FgC9qVXFzJIWVKposzdEvBw6Fj/ e5WRjd5VNz1U4dDAcO3OWsMVyS4PS4qWaCdYiVs5L4DfocWCWF+0LYB64rjNAQXcTToPHw 5XxgnHC1gZdhOLhkFj4wEDcSZfy1Fmg= X-MC-Unique: Pi43fA5aPRqsNvUBjuRqeA-1 X-Mimecast-MFC-AGG-ID: Pi43fA5aPRqsNvUBjuRqeA_1741947949 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 3/6] conf: Add support for iothread to queue mapping config for 'virtio-scsi' Date: Fri, 14 Mar 2025 11:25:39 +0100 Message-ID: <4108988ba8c6dc4bc634404f4c743cb3bfa6294e.1741947785.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 7hnlJ4uLzprth_CN7sj8FyhRPdpEuGszzqTi_Q2BfEs_1741947949 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: NIFQICVZGXPC6YJ36MLQWVRDCROBCFP3 X-Message-ID-Hash: NIFQICVZGXPC6YJ36MLQWVRDCROBCFP3 X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1741948079557019100 Content-Type: text/plain; charset="utf-8" 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 --- docs/formatdomain.rst | 39 +++++++++++++++++++++++++++++++ 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, 63 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index c1876ad467..92374ce2f3 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -4168,6 +4168,45 @@ An optional sub-element ``driver`` can specify the d= river specific options: If a specific IOThread is desired for a specific SCSI ``disk``, then mu= ltiple controllers must be defined each having a specific ``iothread`` value. = The ``iothread`` value must be within the range 1 to the domain iothreads v= alue. +``iothreads`` + Supported for ``virtio-scsi`` controllers using ``address`` types ``pci= `` and + ``ccw``. :since:`since 11.2.0 (QEMU 10.0).` Mutually exclusive with ``i= othread``. + + The optional ``iothreads`` sub-element allows specifying multiple IOThr= eads + via the ``iothread`` sub-element with attribute ``id`` the ``virtio-sc= si`` + controller will use for I/O operations. The virt queues (see ``queues`` + attribute of ``driver``) are automatically distributed among the config= ured + iothreads. + + Optionally the ``iothread`` element can have multiple ``queue`` + subelements with mandatory ``id`` atribute specifying that the iothread + should be used to handle given virt queue. If queue mapping is present + the ``queues`` attribute of ``driver`` must be configured and all + configured virt queues must be included in the mapping. The + ``virtio-scsi`` device exposes request virt queues ``0`` to ``N-1`` whe= re + N is the number of queues configured for the device. + + Example:: + + + + + + + + + + + + + + + + + + + + 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 b94cf99236..28d811de1f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2565,6 +2565,8 @@ void virDomainControllerDefFree(virDomainControllerDe= f *def) if (!def) return; + g_slist_free_full(def->iothreads, (GDestroyNotify) virDomainIothreadMa= ppingDefFree); + virDomainDeviceInfoClear(&def->info); g_free(def->virtio); @@ -8639,6 +8641,9 @@ virDomainControllerDefParseXML(virDomainXMLOption *xm= lopt, &def->iothread) < 0) return NULL; + if (virDomainIothreadMappingDefParse(driver, &def->iothreads) < 0) + return NULL; + if (virDomainVirtioOptionsParseXML(driver, &def->virtio) < 0) return NULL; } @@ -23486,6 +23491,7 @@ virDomainControllerDriverFormat(virBuffer *buf, virDomainControllerDef *def) { g_auto(virBuffer) driverBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) driverChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); if (def->queues) virBufferAsprintf(&driverBuf, " queues=3D'%u'", def->queues); @@ -23504,9 +23510,11 @@ virDomainControllerDriverFormat(virBuffer *buf, if (def->iothread) virBufferAsprintf(&driverBuf, " iothread=3D'%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 3a97fd866c..c8a8d17c91 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 =3D 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 f2a98f143d..33c3a3ffcc 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1267,7 +1267,7 @@ virDomainControllerDefValidate(const virDomainControl= lerDef *controller) } } - if (controller->iothread !=3D 0) { + if (controller->iothread !=3D 0 || controller->iothreads) { if (controller->type !=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI || !(controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VI= RTIO_SCSI || controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VI= RTIO_TRANSITIONAL || @@ -1276,6 +1276,14 @@ virDomainControllerDefValidate(const virDomainContro= llerDef *controller) _("iothreads are supported only by 'virtio-scsi= ' controllers")); return -1; } + + /* configuring both and it's s= ub-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/domaincom= mon.rng index 3276569325..e4f4626b33 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -3064,6 +3064,9 @@ + + + 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 =3D 0; i < def->ncontrollers; i++) { - if (def->controllers[i]->iothread =3D=3D iothread_id) { + if (virDomainIothreadMappingDefHasIothread(def->controllers[i]->io= threads, iothread_id) || + def->controllers[i]->iothread =3D=3D iothread_id) { virReportError(VIR_ERR_INVALID_ARG, _("cannot remove IOThread '%1$u' since it is be= ing used by controller"), iothread_id); --=20 2.48.1