From nobody Tue Dec 16 16:28:28 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 1739550872784840.6612243705937; Fri, 14 Feb 2025 08:34:32 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 351691BDF; Fri, 14 Feb 2025 11:34:32 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id BF9B21C10; Fri, 14 Feb 2025 11:30:44 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id F3BA51BFD; Fri, 14 Feb 2025 11:30:34 -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 91CF41BB3 for ; Fri, 14 Feb 2025 11:30:12 -0500 (EST) Received: from mx-prod-mc-06.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-339-s7fwz8MoOluu4eH_zktFqA-1; Fri, 14 Feb 2025 11:30:11 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3EA1418009AC for ; Fri, 14 Feb 2025 16:30:10 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.22.26]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 00A8F1955DCE; Fri, 14 Feb 2025 16:30:08 +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=1739550612; 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=ph7fqncD+4LV/0bEcsqmsPNE6BD2zPOh8cq7Ictcsvk=; b=h5RHn5y0lUlZuU2WUGe5PmVJqRhwNeavYlqu0Jna7hpcCd83z7wwPhbek3AqfkcgGRFf0f NFmzYnRsvxzmXXQh71Nb0694dC6YVN9uxWlCsu13Q1Yj8eKLMjiDvJyG1qSilAX0hSuO3o 1NOphBa8ujsQXb6hFbL38C6MFb5GsNY= X-MC-Unique: s7fwz8MoOluu4eH_zktFqA-1 X-Mimecast-MFC-AGG-ID: s7fwz8MoOluu4eH_zktFqA_1739550610 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 11/13] conf: Add support for iothread to queue mapping config for 'virtio-scsi' Date: Fri, 14 Feb 2025 17:29:45 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ToCXsXqj7tlvmPp9NLYI90NrGA5l16N7Q8sMjgSnqd8_1739550610 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ELCRQQNRC4IWIABGJM657B4TKPJEXL4U X-Message-ID-Hash: ELCRQQNRC4IWIABGJM657B4TKPJEXL4U 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: 1739550874172019000 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 | 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 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.1.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-scsi + controller will use for I/O operations. Optionally the ``iothread`` ele= ment + 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 ``ct= rl`` + 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:: + + + + + + + + + + + + + + + + + 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(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; } @@ -23514,6 +23519,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); @@ -23532,9 +23538,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 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 =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 88e5f37651..967600581a 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 755a43e893..a8705b34ee 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -3070,6 +3070,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