From nobody Sat Feb 7 11:05:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1609764946; cv=none; d=zohomail.com; s=zohoarc; b=lByZgI9R0l1BoyRiu1DJ7MyWfv80lAcFxy+v058vthGmCxs8e4luR6zRKgEGg9iUTV4MwDiEKNvfdcDmH5ctX5rszf0iLFRfTirrk8LcZjhZnB0HdwciMlNSHbEGl8TfzavTySPBHtIC5DjaDb6U8IidOYKWwwivc8geLGAifsY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609764946; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TxbvS2AAKI40FZuVgfS5VeN2bqpOPkOB9E5C9jzLg0Y=; b=ZYMPBPKdj+fnjn9nspV4gpq1lOlNeYBdSiSJ5IdlWWvICAtykX6FpFjN0jtWM/XwB2DFhnk9zLKeodvVorfTNjxY4ihkOd/b58JgRgCX1hvK7dribkNKLhHMQJQJfqXw3x9uuJ4h69NipIkZGc/QUu62s26KjOorzulkBK5Pnoo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1609764946278216.30562086853172; Mon, 4 Jan 2021 04:55:46 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-149-VbkP0LQ0MGed3K7Oc4Lv8w-1; Mon, 04 Jan 2021 07:55:43 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 05482190A7A5; Mon, 4 Jan 2021 12:55:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0CB3119CBC; Mon, 4 Jan 2021 12:55:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CC2331809CB5; Mon, 4 Jan 2021 12:55:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 104CtNs0014293 for ; Mon, 4 Jan 2021 07:55:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 272DF112D405; Mon, 4 Jan 2021 12:55:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 23348112D404 for ; Mon, 4 Jan 2021 12:55:23 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11232858281 for ; Mon, 4 Jan 2021 12:55:23 +0000 (UTC) Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-dV95g83MPOi8jDxYR0_JDw-1; Mon, 04 Jan 2021 07:55:21 -0500 Received: by mail-qk1-f173.google.com with SMTP id p14so23218747qke.6 for ; Mon, 04 Jan 2021 04:55:21 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:ca55:7a5d:da5b:906f:bedd]) by smtp.gmail.com with ESMTPSA id m64sm2342866qkb.90.2021.01.04.04.55.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jan 2021 04:55:20 -0800 (PST) X-MC-Unique: VbkP0LQ0MGed3K7Oc4Lv8w-1 X-MC-Unique: dV95g83MPOi8jDxYR0_JDw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TxbvS2AAKI40FZuVgfS5VeN2bqpOPkOB9E5C9jzLg0Y=; b=CWa6zWK4FKQulci4JX+Ree4ldlb69GefUbGm0K8JRU21sF+YB2MMuEfbP43SQyIAG8 qXsnYhDmOREVcecHBJT8j0lNMxmhQoqvT16jG3izLG4ZbZH2KrGUp3/A7Hd/SQW+dDiw 3m0kp1Z0aZEgzmCDEzy/hbsU/CHL0moRmoI0DUz6GMjQSXrHXH4zV+UYDV1+V0lcZoEn X9NbfNW1HMMCtFY81ujOR8IOs1GnFNv352WEymjiURZP9n/kpTugADsKa/P4DJh3Q6aW CSNEtfXed8G6rfyIQJepC5eyFvLyBbYrklOEsPm5BrlcqD3pdGWC1CqeMb+C8dpTefFf Xizg== X-Gm-Message-State: AOAM533bg9UXUmZ6vfSdfOFu8OfYNlUuq9xfNTVkrCzerMOMAyhx2B43 B1i7iY9DPUQYdW5NkfIfWiawQItuc1lwAw== X-Google-Smtp-Source: ABdhPJyJ2xh79FAywTteUw9vViFNOL8XhyZMMwTWwoMj84O7x86SM4zllnQFajQJF8eRwYpfDoDNew== X-Received: by 2002:a37:88c2:: with SMTP id k185mr56618337qkd.474.1609764920486; Mon, 04 Jan 2021 04:55:20 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 14/20] virhostdev.c: add virHostdevIsPCIDevice() helper Date: Mon, 4 Jan 2021 09:54:38 -0300 Message-Id: <20210104125444.200536-15-danielhb413@gmail.com> In-Reply-To: <20210104125444.200536-1-danielhb413@gmail.com> References: <20210104125444.200536-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a helper to quickly determine if a hostdev is a PCI device, instead of doing a tedius 'if' check with hostdev mode and subsys type. Signed-off-by: Daniel Henrique Barboza --- src/hypervisor/virhostdev.c | 12 +++++++++--- src/hypervisor/virhostdev.h | 2 ++ src/libvirt_private.syms | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index 18373deb41..16a21f240b 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -347,12 +347,18 @@ virHostdevNetDevice(virDomainHostdevDefPtr hostdev, } =20 =20 +bool +virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev) +{ + return hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && + hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= PCI; +} + + static bool virHostdevIsPCINetDevice(const virDomainHostdevDef *hostdev) { - return hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && - hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= PCI && - hostdev->parentnet !=3D NULL; + return virHostdevIsPCIDevice(hostdev) && hostdev->parentnet !=3D NULL; } =20 =20 diff --git a/src/hypervisor/virhostdev.h b/src/hypervisor/virhostdev.h index 811bda40ed..b9407cd837 100644 --- a/src/hypervisor/virhostdev.h +++ b/src/hypervisor/virhostdev.h @@ -235,3 +235,5 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManagerPtr = hostdev_mgr, const char *dom_name, virDomainDiskDefPtr *disks, size_t ndisks); + +bool virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 81ce142635..ac72a384ed 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1461,6 +1461,7 @@ virCloseCallbacksUnset; =20 # hypervisor/virhostdev.h virHostdevFindUSBDevice; +virHostdevIsPCIDevice; virHostdevManagerGetDefault; virHostdevPCINodeDeviceDetach; virHostdevPCINodeDeviceReAttach; --=20 2.26.2