From nobody Mon Feb 9 00:56:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565783915; cv=none; d=zoho.com; s=zohoarc; b=mSJmORqlj/Z6YX+MzJiPR7NxttlPib1Aigl7UTsdGeCUqCPcaLUk3xOD3lt4U2NbywF8a+kNugSOt1YXOkKLI654SpoEMYn2DV0ZDG1rgFMlyQfd6rKk08h4R+bhPmxeCd3UzWHuo1a8f3JTvU69lsJqo4gkO0chaMxdjtq89XQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565783915; h=Content-Type:Content-Transfer-Encoding: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:ARC-Authentication-Results; bh=XyawkR6iod76s9537fCg0c8RDZ8QSj6bUXkbLdZuX7Q=; b=E8nNgTHRtRLXweBXN01L4Bs/+Zu+FmWC6MkduL0+dGN2TLc34q/D2295ym5kzsnG4/n1kfqBfokNHJ/LpV3wKhPEFZ+zDnfqBRcahuetG+fMC7jBp+USnm6jyqeEkGo9SwtSB8BFOyooLExSxxl0FIEbCebUdyEnZuWaIr6+UGo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565783915301839.3871243107394; Wed, 14 Aug 2019 04:58:35 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1CEF930A5A61; Wed, 14 Aug 2019 11:58:34 +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 E8D76891AE; Wed, 14 Aug 2019 11:58:33 +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 A859E180B536; Wed, 14 Aug 2019 11:58:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7EBwJBs015610 for ; Wed, 14 Aug 2019 07:58:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3A5FE34913; Wed, 14 Aug 2019 11:58:19 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8B7B348C3 for ; Wed, 14 Aug 2019 11:58:18 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 14 Aug 2019 13:57:43 +0200 Message-Id: <23af363b9ea0f8cd6bab0fb92927e3cc8db0068c.1565777704.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/18] virhostdev: Check driver name too in virHostdevIsPCINodeDeviceUsed() 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 14 Aug 2019 11:58:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" It may happen that there are two domains with the same name in two separate drivers (e.g. qemu and lxc). That is why for PCI devices we track both names of driver and domain combination which has taken the device. However, when we check if given PCI device is in use (or PCI devices from the same IOMMU group) we compare only domain name. This means that we can mistakenly claim device as free to use while in fact it isn't. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/util/virhostdev.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 75e44b5227..cb69582c21 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -51,6 +51,7 @@ static virHostdevManagerPtr virHostdevManagerNew(void); =20 struct virHostdevIsPCINodeDeviceUsedData { virHostdevManagerPtr mgr; + const char *driverName; const char *domainName; const bool usesVFIO; }; @@ -91,8 +92,8 @@ static int virHostdevIsPCINodeDeviceUsed(virPCIDeviceAddr= essPtr devAddr, void *o virPCIDeviceGetUsedBy(actual, &actual_drvname, &actual_domname); =20 if (helperData->usesVFIO && - (actual_domname && helperData->domainName) && - (STREQ(actual_domname, helperData->domainName))) + STREQ_NULLABLE(actual_drvname, helperData->driverName) && + STREQ_NULLABLE(actual_domname, helperData->domainName)) goto iommu_owner; =20 if (actual_drvname && actual_domname) @@ -706,7 +707,7 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr, virPCIDevicePtr pci =3D virPCIDeviceListGet(pcidevs, i); bool strict_acs_check =3D !!(flags & VIR_HOSTDEV_STRICT_ACS_CHECK); bool usesVFIO =3D (virPCIDeviceGetStubDriver(pci) =3D=3D VIR_PCI_S= TUB_DRIVER_VFIO); - struct virHostdevIsPCINodeDeviceUsedData data =3D { mgr, dom_name,= usesVFIO }; + struct virHostdevIsPCINodeDeviceUsedData data =3D {mgr, drv_name, = dom_name, usesVFIO}; int hdrType =3D -1; =20 if (virPCIGetHeaderType(pci, &hdrType) < 0) @@ -1995,7 +1996,7 @@ int virHostdevPCINodeDeviceDetach(virHostdevManagerPtr mgr, virPCIDevicePtr pci) { - struct virHostdevIsPCINodeDeviceUsedData data =3D { mgr, NULL, false }; + struct virHostdevIsPCINodeDeviceUsedData data =3D {mgr, NULL, NULL, fa= lse}; int ret =3D -1; =20 virObjectLock(mgr->activePCIHostdevs); @@ -2021,7 +2022,7 @@ int virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr mgr, virPCIDevicePtr pci) { - struct virHostdevIsPCINodeDeviceUsedData data =3D { mgr, NULL, false }; + struct virHostdevIsPCINodeDeviceUsedData data =3D {mgr, NULL, NULL, fa= lse}; int ret =3D -1; =20 virObjectLock(mgr->activePCIHostdevs); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list