From nobody Tue Dec 16 16:42:24 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 1739550753226545.3206944463896; Fri, 14 Feb 2025 08:32:33 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id F3B981186; Fri, 14 Feb 2025 11:31:28 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6DC2F1BFC; Fri, 14 Feb 2025 11:30:19 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3F46E1BB2; Fri, 14 Feb 2025 11:30:15 -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 60AB71BB2 for ; Fri, 14 Feb 2025 11:29:59 -0500 (EST) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-569-6It8SOe5NueJWIvUbqswjg-1; Fri, 14 Feb 2025 11:29:57 -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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8EC1A193578F for ; Fri, 14 Feb 2025 16:29:56 +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 321291955DCE; Fri, 14 Feb 2025 16:29:54 +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=1739550598; 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=6fJ6bBLWl9j0FfPlLjoX/Y315LgiTY1EMliqWVlpMAk=; b=ThrxOtVl4GRQe8ktvhi5QfR/Jb7QBpcLF5Dp4H9N2K0L+SDp5cc8FozOIubNQx5NEeEsT+ BmoGM7DQgyO/vCjrte9tFeoJ39fl6gcyyiTW7Zyau25147q5+x5ASJoxBd9EQClO0hAXP8 gE9ft5lV89WcPcyz6dWplN8xisqkVqo= X-MC-Unique: 6It8SOe5NueJWIvUbqswjg-1 X-Mimecast-MFC-AGG-ID: 6It8SOe5NueJWIvUbqswjg_1739550596 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 03/13] hypervisor: domain: Extract code for checking iothread usage Date: Fri, 14 Feb 2025 17:29:37 +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: YEkEKBJoac55L6C3KtVDtAYa3neYcsNXWGXOs9W4QQU_1739550596 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UECWRDKOQJXZCYDXQNUMDV762ETBYNBJ X-Message-ID-Hash: UECWRDKOQJXZCYDXQNUMDV762ETBYNBJ 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: 1739550754165019100 Content-Type: text/plain; charset="utf-8" The code will be also needed for 'virtio-scsi' controller definitions. Signed-off-by: Peter Krempa --- src/hypervisor/domain_driver.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 9fbfec9f04..b7499a376f 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -537,6 +537,23 @@ virDomainDriverAddIOThreadCheck(virDomainDef *def, return 0; } + +static bool +virDomainIothreadMappingDefHasIothread(GSList *iothreads, + unsigned int iothread_id) +{ + GSList *n; + + for (n =3D iothreads; n; n =3D n->next) { + virDomainIothreadMappingDef *iothread =3D n->data; + + if (iothread->id =3D=3D iothread_id) + return true; + } + + return false; +} + /** * virDomainDriverDelIOThreadCheck: * @def: domain definition @@ -558,19 +575,7 @@ virDomainDriverDelIOThreadCheck(virDomainDef *def, } for (i =3D 0; i < def->ndisks; i++) { - GSList *n; - bool inuse =3D false; - - for (n =3D def->disks[i]->iothreads; n; n =3D n->next) { - virDomainIothreadMappingDef *iothread =3D n->data; - - if (iothread->id =3D=3D iothread_id) { - inuse =3D true; - break; - } - } - - if (inuse || + if (virDomainIothreadMappingDefHasIothread(def->disks[i]->iothread= s, iothread_id) || def->disks[i]->iothread =3D=3D iothread_id) { virReportError(VIR_ERR_INVALID_ARG, _("cannot remove IOThread %1$u since it is bein= g used by disk '%2$s'"), --=20 2.48.1