From nobody Sun Feb 8 23:23:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1590009158; cv=none; d=zohomail.com; s=zohoarc; b=St3MHzB6syng5I0L8FLH9UeXULgw3utV2PaPgJZy8YCaja40UR4WXlp2rmMBUbyH4DPHY43nfb9vzVi8d/DRp+DzSvqGTFAvphMZ+4RXyexIu+n+4SWj2wMSmwhsilClbo1vwvka/kyD89qlLFBTv9FrjQSTPmuR1QDKUOjF3Ow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590009158; 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=OwfOhI0MHIRadxqA+fjtZM+TsEyvsgIiwMsq7Kwudbg=; b=XZYk3Q8L7rylAwJ5gqaUFAYW0mvhmLfOflLtVX2AhUCBrmEaT0LDR88Aep+LuDya4upoNYwpPb4eILy4irgqNl+NiK+dG8M0lTAhGFFLOt9n4nbSC7Uoor4CAhRPdtKluIB8xupMLOifdj/iGsx3rlRRLcOhDEKMXVK97rebuvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1590009158477755.5292746811172; Wed, 20 May 2020 14:12:38 -0700 (PDT) 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-46-rpc_U0-BPD2U0PQob5j_Ig-1; Wed, 20 May 2020 17:12:34 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0878487300F; Wed, 20 May 2020 21:12:28 +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 D98C64EEC3; Wed, 20 May 2020 21:12:27 +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 A9E64180BACF; Wed, 20 May 2020 21:12:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04KLCEZP002031 for ; Wed, 20 May 2020 17:12:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id C35355AB85; Wed, 20 May 2020 21:12:14 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8F3511317 for ; Wed, 20 May 2020 21:12:12 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 BCA22185A78B for ; Wed, 20 May 2020 21:12:12 +0000 (UTC) Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-162-Y2BO2vtWPbyyI52NG3NEkg-1; Wed, 20 May 2020 17:12:10 -0400 Received: by mail-qt1-f193.google.com with SMTP id z18so3840794qto.2 for ; Wed, 20 May 2020 14:12:10 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:fbf2:bc5e:c314:af31:7070]) by smtp.gmail.com with ESMTPSA id z14sm2992031qki.83.2020.05.20.14.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2020 14:12:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590009157; 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=OwfOhI0MHIRadxqA+fjtZM+TsEyvsgIiwMsq7Kwudbg=; b=KUpLdlHzC2NdvCIFBB7PZsrHChnYNRKylqF1uZlJDrV06hRsmvL0f+/9HvlL1aOXRePyKO 9MVcpcTQ5AHaZE0QZuyfqCzH4Kj5G79nVo76Y/mO9yylHocB3G5sUSX8WMoIx8CO0MOTJQ mJrAQytUoWgJvUiyO3Bbz7/UTYeoO1w= X-MC-Unique: rpc_U0-BPD2U0PQob5j_Ig-1 X-MC-Unique: Y2BO2vtWPbyyI52NG3NEkg-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=OwfOhI0MHIRadxqA+fjtZM+TsEyvsgIiwMsq7Kwudbg=; b=F7jpME9uR2OUGNMPpqc19L1cxaXgmVBotpuViEvDkC0G8DxihW3VeakNA5+NPWHvwW KZcI5Gvw3/QcUwx4wYAAd+RXVaFFq9FNg9b31/eGI7XwVNwUhzcqeZ6OmvdFeaRjgu6p jFvOGdlIUuxdTHuqVVg259JEOa0jb47mSWa/QwCKaWIvLvNYzXhf/wjlZtQAUpKjExRr K1xG9ahdR7RStDzxuih8wriFyGH9K/CHUwG4/OZfXkYfVluWMWSKXHqaTuKRLwniuWi0 uNoATHiL8PedeuG2Ph+KzWUcymWJarsJG7yS8JijJoI43EV0DpSvmI88JQxdZpBZm1Wr sS9A== X-Gm-Message-State: AOAM5306z1uOHwMqrnJrVPmB3dAxv/yDekOhWB6t7J9ZDAqXbTrtN+Cv A7i5jpwgbG4nqXU9GxIfgo2zODSh X-Google-Smtp-Source: ABdhPJyylfLVPM4Jw1GexCckwm6rlfMLFO8EjEOho8wwnYahyQ4cjN06FPQ56FB0HzedamUdMR9XsA== X-Received: by 2002:ac8:7586:: with SMTP id s6mr6853908qtq.96.1590009129660; Wed, 20 May 2020 14:12:09 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 03/21] virhostdev: Introduce virHostdevPCIDevicesBelongToSameSlot Date: Wed, 20 May 2020 18:11:25 -0300 Message-Id: <20200520211143.2980117-4-danielhb413@gmail.com> In-Reply-To: <20200520211143.2980117-1-danielhb413@gmail.com> References: <20200520211143.2980117-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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.84 on 10.5.11.23 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/hypervisor/virhostdev.c | 29 +++++++++++++++++++++++++++++ src/hypervisor/virhostdev.h | 2 ++ src/libvirt_private.syms | 1 + 3 files changed, 32 insertions(+) diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index 9017cc3be8..03e0c5b470 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/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/hypervisor/virhostdev.h b/src/hypervisor/virhostdev.h index 811bda40ed..84515d83fd 100644 --- a/src/hypervisor/virhostdev.h +++ b/src/hypervisor/virhostdev.h @@ -202,6 +202,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, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c143264382..e74174ffbd 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -726,6 +726,7 @@ virHostdevIsMdevDevice; virHostdevIsPCIMultifunctionDevice; virHostdevIsSCSIDevice; virHostdevIsVFIODevice; +virHostdevPCIDevicesBelongToSameSlot; =20 =20 # conf/domain_nwfilter.h --=20 2.26.2