From nobody Wed Mar 12 17:23:07 2025 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 1741016056625391.65825857675554; Mon, 3 Mar 2025 07:34:16 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7049E81F; Mon, 3 Mar 2025 10:34:15 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id AFBCE1499; Mon, 3 Mar 2025 10:31:28 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id B73FE1352; Mon, 3 Mar 2025 10:31:24 -0500 (EST) 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 599631225 for ; Mon, 3 Mar 2025 10:31:08 -0500 (EST) 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-401-ucmJYag3MVG83U_lKj2hQQ-1; Mon, 03 Mar 2025 10:31:06 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 C042C180056F for ; Mon, 3 Mar 2025 15:31:05 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.22.15]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 861451956094; Mon, 3 Mar 2025 15:31:04 +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=-1.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=1741015868; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0501Y7QFxVxL/Fc9oT5nmzOmSNn0r7DNvInS+9NvBfM=; b=ds8wzosdvQclO4M+oviQHj0BTCsR9QtbeCVL2UGDzwBrqrQUx9vjlvRq3Yt1osP4UjcTi+ DqyDYFIb4YzsL7TEELyHpKZT8EAWFlvYcFpvYz2zCRlxdk3wKcATJrw2dvyrfMaWdIdRmw fZXCpoMSXjX82Yeq04FRqDzjBMjK6M8= X-MC-Unique: ucmJYag3MVG83U_lKj2hQQ-1 X-Mimecast-MFC-AGG-ID: ucmJYag3MVG83U_lKj2hQQ_1741015865 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 08/11] conf: Add support for iothread to queue mapping config for 'virtio-scsi' Date: Mon, 3 Mar 2025 16:30:46 +0100 Message-ID: <2ca3d4c5f3e0e5c40fc7eaece79d7552415d62e1.1741015346.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: sSNCO_tVfXLkxTPoQQswstb6CPRC101wGQH5UQeHMQY_1741015865 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BJOWX7TRHX6CQGRWJHDLVRJ2RRAB3BCJ X-Message-ID-Hash: BJOWX7TRHX6CQGRWJHDLVRJ2RRAB3BCJ 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 CC: Stefan Hajnoczi 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: 1741016058245019100 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 | 41 +++++++++++++++++++++++++++++++ src/conf/domain_conf.c | 10 +++++++- src/conf/domain_conf.h | 1 + src/conf/domain_validate.c | 10 +++++++- src/conf/schemas/domaincommon.rng | 9 ++++++- src/hypervisor/domain_driver.c | 3 ++- 6 files changed, 70 insertions(+), 4 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 29f3c84780..d049f28a65 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -4146,6 +4146,47 @@ 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`` subelem= ents + with mandatory ``id`` atribute specifying that the iothread should be u= sed + to handle given virt queue. If queue mapping is present the ``queues`` + attribute of ``driver`` must be configured and all configured virt queu= es + must be included in the mapping. The ``virtio-scsi`` controller exposes= two + special queues named ``ctrl`` and ``event`` and request virt queues ``0= `` to + ``N-1`` where 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 bb82264758..def2ef7ae7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2557,6 +2557,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); @@ -8618,6 +8620,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; } @@ -23505,6 +23510,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); @@ -23523,9 +23529,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 d56a5a22e0..20cb058473 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -763,6 +763,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 ad3d17f0fd..f95316918d 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1260,7 +1260,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 || @@ -1269,6 +1269,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 824da9d066..7dea0f1b0c 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -2605,7 +2605,11 @@ - + + ctrl + event + + @@ -3059,6 +3063,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