From nobody Sun Feb 8 05:40:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580402743769946.5071981575079; Thu, 30 Jan 2020 08:45:43 -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-206-BIH6kctQM225sXPySaGxqQ-1; Thu, 30 Jan 2020 11:45:36 -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 A2162800D5E; Thu, 30 Jan 2020 16:45:29 +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 7B23F8882D; Thu, 30 Jan 2020 16:45:29 +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 3341518089D6; Thu, 30 Jan 2020 16:45:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00UGiwap031900 for ; Thu, 30 Jan 2020 11:44:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id D4FFF2166B29; Thu, 30 Jan 2020 16:44:58 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D09722166B27 for ; Thu, 30 Jan 2020 16:44:56 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 C2AF180328A for ; Thu, 30 Jan 2020 16:44:56 +0000 (UTC) Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-340-Modpt7J1P-Ga1g9umC4p3A-1; Thu, 30 Jan 2020 11:44:54 -0500 Received: by mail-qk1-f195.google.com with SMTP id x1so3497985qkl.12 for ; Thu, 30 Jan 2020 08:44:53 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:c177:887c:ce1b:6a44:15ec]) by smtp.gmail.com with ESMTPSA id 135sm3007157qkj.55.2020.01.30.08.44.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 08:44:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580402742; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=k6XD3rhl51XIjv8WC23Ek5ON4BpV8Wtx4xFf2fRMFNM=; b=UdXGwvshL8DI3lJKh1NXIgHKwQHnoB85JXXm45ataNLkBP5pgTbypmW4NRDFT01bTwftsq 9Fodu8bqpzZplm4qXaiYHWz1SoqAmGWaNPLw+qreKsaIzhFCEyXo5D1bDk9TNyAGEL/7tG xH1fkWJy+EWqKCWkM9bm4TERrqfLFVY= 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=uJjdvMT3CvRvRCR86exl1no8jb0BtQPlfxc61hP8Fmc=; b=ojFJgQNMYpXgAxaCVI1T/f9+8ef4pBmmJ1hANe3MbsUdUp/vpDuiA9q57TRBHHIWxz sbgafz1b8dJK+uKBIesplKiXHZIAmTb8ZX8l9NorxtBeTv/Bu9Gz04SCXbbcrDstrR1h yqAN/MkE6YcsQqe848eRyvR7sNw36pJuiUCnpd2kiDmUo0D5eQ+a57+q7TgARPmM74Hy 4JfOXYyjxtfYkW7gzrtflxAcvS9w8GP2IDGUhRnFTv/0G6llxPHBVULVDkuYzPW1TF6m wH/Wt0fe7Ddk4H1sgVr+dtWF55PT7Bay/1loYJJu5Sxcdlc63dMv71tH+2+V7eCLpaIi RLTA== X-Gm-Message-State: APjAAAUWVc1X66ISAKCeJ+dheVScHl2Gq5fKb0C5voNtBcurJ3nowtHH xvji44WyvjoWMe+VV09eyzbFkOLoOIQ= X-Google-Smtp-Source: APXvYqwGu+usJmw8/RlqyphjjY3Wh3cFb0y8efwty8NlwYSxq8qAnJ+Uk/cksC0g8NO0dyuIoKP92Q== X-Received: by 2002:a05:620a:80e:: with SMTP id s14mr5898158qks.136.1580402693375; Thu, 30 Jan 2020 08:44:53 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 03/21] virhostdev: Introduce virHostdevPCIDevicesBelongToSameSlot Date: Thu, 30 Jan 2020 13:44:15 -0300 Message-Id: <20200130164433.2694119-4-danielhb413@gmail.com> In-Reply-To: <20200130164433.2694119-1-danielhb413@gmail.com> References: <20200130164433.2694119-1-danielhb413@gmail.com> MIME-Version: 1.0 X-MC-Unique: Modpt7J1P-Ga1g9umC4p3A-1 X-MC-Unique: BIH6kctQM225sXPySaGxqQ-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 00UGiwap031900 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , sbhat@linux.ibm.com 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Shivaprasad G Bhat Signed-off-by: Shivaprasad G Bhat Signed-off-by: Daniel Henrique Barboza --- src/libvirt_private.syms | 1 + src/util/virhostdev.c | 29 +++++++++++++++++++++++++++++ src/util/virhostdev.h | 2 ++ 3 files changed, 32 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 962963a3ff..702cd958b1 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2166,6 +2166,7 @@ virHostdevIsPCIMultifunctionDevice; virHostdevIsSCSIDevice; virHostdevIsVFIODevice; virHostdevManagerGetDefault; +virHostdevPCIDevicesBelongToSameSlot; virHostdevPCINodeDeviceDetach; virHostdevPCINodeDeviceReAttach; virHostdevPCINodeDeviceReset; diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index f0526d97d0..d870ca6c49 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -312,6 +312,35 @@ virHostdevIsVirtualFunction(virDomainHostdevDefPtr hos= tdev) } =20 =20 +bool +virHostdevPCIDevicesBelongToSameSlot(virDomainHostdevDefPtr dev1, + virDomainHostdevDefPtr dev2) +{ + virPCIDeviceAddressPtr devAddr1 =3D NULL, devAddr2 =3D NULL; + + if (!dev1 || !dev2) + return false; + + devAddr1 =3D &dev1->source.subsys.u.pci.addr; + devAddr2 =3D &dev2->source.subsys.u.pci.addr; + if ((devAddr1->domain !=3D devAddr2->domain) || + (devAddr1->bus !=3D devAddr2->bus) || + (devAddr1->slot !=3D devAddr2->slot) || + (virPCIDeviceAddressEqual(devAddr1, devAddr2))) { + return false; + } + + /* The Virtual Functions have multifunction false even though they hav= e same + * domain:bus:slot as the Physical function. They are to be treated + * like non-multifunction devices + */ + if (virHostdevIsVirtualFunction(dev1) || virHostdevIsVirtualFunction(d= ev2)) + return false; + + return true; +} + + static int virHostdevNetDevice(virDomainHostdevDefPtr hostdev, int pfNetDevIdx, diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h index 80aea577ed..d6dfb0b388 100644 --- a/src/util/virhostdev.h +++ b/src/util/virhostdev.h @@ -214,6 +214,8 @@ int virHostdevPCINodeDeviceReAttach(virHostdevManagerPt= r mgr, int virHostdevPCINodeDeviceReset(virHostdevManagerPtr mgr, virPCIDevicePtr pci) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); +bool virHostdevPCIDevicesBelongToSameSlot(virDomainHostdevDefPtr dev1, + virDomainHostdevDefPtr dev2); =20 int virHostdevPrepareOneNVMeDevice(virHostdevManagerPtr hostdev_mgr, --=20 2.24.1