From nobody Sun Feb 8 23:03:45 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=1610999692; cv=none; d=zohomail.com; s=zohoarc; b=Hdgg3+jx53Gni71Z57V0YaiVlWbVdu01MVD86ijFIJQKeJtxaOhNvrWTcI1u7no/aYhkFoFgRT0f/uHawoihB3iECB5+9N0tus0z0PCZk219xBzFBuRHgNKtlDf3T8/vFjxvNYzQGPfahIS/neYoIBqGbYEYMNkBCos49fJwrWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610999692; 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=AGS754Fcl6tTJ1DAiiiCVizLey0bqGvMTusOYCKAojo=; b=Xy22CP19GWmMday6ZoL45Utd5RCXZ/V0FymLl0l5W/WoIUyoTSB9fqRFbrUOj8SNqDi/YbuDwgNlWBsoPF9Wwq5W2qt7MBqAtnL5AR3srCQathrOtNrFcMHdU3XqK1ipGZWrNdDh/fNqDxTTgMEbThrQaM3Iae0YCenOr6/+unA= 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 1610999692266356.33206175629505; Mon, 18 Jan 2021 11:54:52 -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-263-iBsy5vLoOwW6mjR3T3aUWg-1; Mon, 18 Jan 2021 14:54:49 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BD7B6E757; Mon, 18 Jan 2021 19:54:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 96B516A8E9; Mon, 18 Jan 2021 19:54:42 +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 5778D5004A; Mon, 18 Jan 2021 19:54:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10IJsFaI032596 for ; Mon, 18 Jan 2021 14:54:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8ECDF2026D11; Mon, 18 Jan 2021 19:54:15 +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 89DC12026D49 for ; Mon, 18 Jan 2021 19:54:14 +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 38E3A858280 for ; Mon, 18 Jan 2021 19:54:14 +0000 (UTC) Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-356-xvelToM0PUqo34fME6xavg-1; Mon, 18 Jan 2021 14:54:12 -0500 Received: by mail-qt1-f171.google.com with SMTP id j26so12115576qtq.8 for ; Mon, 18 Jan 2021 11:54:12 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:a75a:cb34:ba60:6de6:be1d]) by smtp.gmail.com with ESMTPSA id 16sm11309085qkf.112.2021.01.18.11.54.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 11:54:10 -0800 (PST) X-MC-Unique: iBsy5vLoOwW6mjR3T3aUWg-1 X-MC-Unique: xvelToM0PUqo34fME6xavg-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=AGS754Fcl6tTJ1DAiiiCVizLey0bqGvMTusOYCKAojo=; b=CbSg3+gZhTeGTFSuCfGxEGhaQrq0aN/2vzizKa9xRrrqyKUr28yvMZTROw/knT2tmz RPp4OSY2XZ+Ant5uG+LlRqkYnucWNSpvMlTXsL8h+haCe7iAI10FZVX6k6fTjx4LMADj vDJiI45CU1qw4lbzztWJ52uruQau2xlMnkFEPBNefkFjdPVjBLW1EmCsphE6wD0U9QQ4 qRvCgIXLwEU7+PZE1qoWFAZcLr1gbN0Www9AdSZeKMPSCataE8iPsl8UxiLOUe/QVZYG WwSsprLzoMxXlV2DjpGWYqy/VI1GVd60VcaTEzlCYwKPYFWn4fqbxrkqymHbkGqpRWCB IL1A== X-Gm-Message-State: AOAM532OkiAW6Osa6kLaDi8pchWkwuj1XYTsdl5zTsdyw6aDc93S/glP GmMq8pCMKHq9lk8GPOKqfENiIkuAvxT2hw== X-Google-Smtp-Source: ABdhPJzAhWG4FQb2u5xRnd2pSiVqwxly4GKj7Wdu7Z9TWLzX78o98VRuH8Fe6GmpPFu9Pqre3PyOgw== X-Received: by 2002:ac8:7655:: with SMTP id i21mr1146815qtr.315.1610999651562; Mon, 18 Jan 2021 11:54:11 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH RESEND 16/20] virpci.c: use virPCIDeviceAddressPtr in virPCIDeviceListFindIndex() Date: Mon, 18 Jan 2021 16:53:32 -0300 Message-Id: <20210118195336.2090823-17-danielhb413@gmail.com> In-Reply-To: <20210118195336.2090823-1-danielhb413@gmail.com> References: <20210118195336.2090823-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.4 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.15 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" We're going to need a way to remove a PCI Device from a list without having a valid virPCIDevicePtr, because the device is missing from the host. This means that virPCIDevicesListDel() must operate with a PCI Device address instead. Turns out that virPCIDevicesListDel() and its related functions only use the virPCIDeviceAddressPtr of the virPCIDevicePtr, so this change is simple to do and will not cause hassle in all other callers. Let's start adapting virPCIDeviceListFindIndex() and crawl our way up to virPCIDevicesListDel(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Laine Stump --- src/util/virpci.c | 15 ++++++++------- src/util/virpci.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index 7143380348..1554acffb6 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -1745,7 +1745,7 @@ virPCIDevicePtr virPCIDeviceListSteal(virPCIDeviceListPtr list, virPCIDevicePtr dev) { - return virPCIDeviceListStealIndex(list, virPCIDeviceListFindIndex(list= , dev)); + return virPCIDeviceListStealIndex(list, virPCIDeviceListFindIndex(list= , &dev->address)); } =20 void @@ -1756,16 +1756,17 @@ virPCIDeviceListDel(virPCIDeviceListPtr list, } =20 int -virPCIDeviceListFindIndex(virPCIDeviceListPtr list, virPCIDevicePtr dev) +virPCIDeviceListFindIndex(virPCIDeviceListPtr list, + virPCIDeviceAddressPtr devAddr) { size_t i; =20 for (i =3D 0; i < list->count; i++) { virPCIDevicePtr other =3D list->devs[i]; - if (other->address.domain =3D=3D dev->address.domain && - other->address.bus =3D=3D dev->address.bus && - other->address.slot =3D=3D dev->address.slot && - other->address.function =3D=3D dev->address.function) + if (other->address.domain =3D=3D devAddr->domain && + other->address.bus =3D=3D devAddr->bus && + other->address.slot =3D=3D devAddr->slot && + other->address.function =3D=3D devAddr->function) return i; } return -1; @@ -1798,7 +1799,7 @@ virPCIDeviceListFind(virPCIDeviceListPtr list, virPCI= DevicePtr dev) { int idx; =20 - if ((idx =3D virPCIDeviceListFindIndex(list, dev)) >=3D 0) + if ((idx =3D virPCIDeviceListFindIndex(list, &dev->address)) >=3D 0) return list->devs[idx]; else return NULL; diff --git a/src/util/virpci.h b/src/util/virpci.h index a9c597a428..8c6776da21 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -175,7 +175,7 @@ virPCIDeviceListFindByIDs(virPCIDeviceListPtr list, unsigned int slot, unsigned int function); int virPCIDeviceListFindIndex(virPCIDeviceListPtr list, - virPCIDevicePtr dev); + virPCIDeviceAddressPtr devAddr); =20 /* * Callback that will be invoked once for each file --=20 2.26.2