From nobody Mon Feb 2 09:26:43 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; 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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1768229584; cv=none; d=zohomail.com; s=zohoarc; b=R5F471cd3RLrYw1USuyzPgRSM6EZupU3ExKpQuccsdLy/0nItqQZO0P6C5zGzx0PKo6rIrb8hk3Mcu6Rmk/OEvAB+COKIBWUUysO7zs8Bu7QD9TszS1lvqAz3MWxiafOGIZco+rKe06YuBMpskasZ4mjAe1spj8YhVW9UCUx/fQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768229584; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=bXBQ3cAhowP8Vk4dDt9cYIxGRqhjiUrrRNQe5WyITy8=; b=fPJgTZ2fHm/zELGR2OGmYMVo5x6FezEeqoTIdphO+eBZKCOug/200dBWbImdvIJWExasHT9i8wz4UqPtH7RFdO23SDzcA4Lt7AMccnAVJjRr3TU6E+F27wIrhgSRHbr11kdDT2QdpnGWnK5cico0EYlUrP61GSir3YRzdeW3/R8= ARC-Authentication-Results: i=1; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1768229584260182.97359259412656; Mon, 12 Jan 2026 06:53:04 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 1A9FA417EF; Mon, 12 Jan 2026 09:53:02 -0500 (EST) Received: from [172.19.199.83] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 2877641B2D; Mon, 12 Jan 2026 09:49:47 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 1C542417E8; Mon, 12 Jan 2026 09:49:28 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 68F163F86A for ; Mon, 12 Jan 2026 09:49:26 -0500 (EST) Received: from mx-prod-mc-03.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-306-9sQRimA7OkGJcw1FxtYrvw-1; Mon, 12 Jan 2026 09:49:24 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1F28F1955DC6 for ; Mon, 12 Jan 2026 14:49:24 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.90]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5CD4A30001A2 for ; Mon, 12 Jan 2026 14:49:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768229366; 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=bXBQ3cAhowP8Vk4dDt9cYIxGRqhjiUrrRNQe5WyITy8=; b=Xgy+VWFE1Ul48ilsQnMWLeVWhh/pHqj2Lh19f1WMdnqctgA6NmWDkqr26mDaZvrriAUSuQ Fm44CQ6ZtxK1M4dMv5InpJEiq/aYM/J5AeomTvA6ukiWWki0BHbqf3qWRiNI8ZlEbCqyyK /eQ0v85UpmLRej+W6BfFctisHEcbExc= X-MC-Unique: 9sQRimA7OkGJcw1FxtYrvw-1 X-Mimecast-MFC-AGG-ID: 9sQRimA7OkGJcw1FxtYrvw_1768229364 To: devel@lists.libvirt.org Subject: [PATCH 3/4] conf: Introduce virDomainDefHasUSBDevices() Date: Mon, 12 Jan 2026 15:49:15 +0100 Message-ID: <20260112144916.127295-4-abologna@redhat.com> In-Reply-To: <20260112144916.127295-1-abologna@redhat.com> References: <20260112144916.127295-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 3qOMIlzEg29ffnoFsXi51kzEk92oEHBK5bIW5Ilfsj8_1768229364 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VIMKGHZWV7YPBCS7TD532SND5PUSEDQQ X-Message-ID-Hash: VIMKGHZWV7YPBCS7TD532SND5PUSEDQQ X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Andrea Bolognani via Devel Reply-To: Andrea Bolognani X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1768229585862158500 Content-Type: text/plain; charset="utf-8"; x-default="true" This is similar to the existing virDomainDefHasUSBControllers() function, except that it looks for USB devices in the domain definition instead. Signed-off-by: Andrea Bolognani --- src/conf/domain_conf.c | 27 +++++++++++++++++++++++++++ src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 1 + 3 files changed, 29 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e7fa4cd769..61a3280e9e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5427,6 +5427,33 @@ virDomainDefHasUSBControllers(const virDomainDef *de= f) } =20 =20 +static int +virDomainDefHasUSBDevicesIter(virDomainDeviceInfo *info G_GNUC_UNUSED, + void *opaque) +{ + bool *found =3D (bool *) opaque; + + *found =3D true; + + return 0; +} + + +bool +virDomainDefHasUSBDevices(const virDomainDef *def) +{ + bool found =3D false; + + if (virDomainUSBDeviceDefForeach((virDomainDef *) def, + virDomainDefHasUSBDevicesIter, + &found, false) < 0) { + return false; + } + + return found; +} + + bool virDomainDefLifecycleActionAllowed(virDomainLifecycle type, virDomainLifecycleAction action) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a2684ea78d..448361ab95 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3683,6 +3683,7 @@ virDomainSCSIDriveAddressIsUsed(const virDomainDef *d= ef, const virDomainDeviceDriveAddress *addr); =20 bool virDomainDefHasUSBControllers(const virDomainDef *def); +bool virDomainDefHasUSBDevices(const virDomainDef *def); =20 bool virDomainDeviceAliasIsUserAlias(const char *aliasStr); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3fc97bd124..ce93a13216 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -350,6 +350,7 @@ virDomainDefHasOldStyleUEFI; virDomainDefHasPCIHostdev; virDomainDefHasTimer; virDomainDefHasUSBControllers; +virDomainDefHasUSBDevices; virDomainDefHasVcpusOffline; virDomainDefHasVDPANet; virDomainDefIDsParseString; --=20 2.52.0