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=1609764944; cv=none; d=zohomail.com; s=zohoarc; b=iTYKzcMrqcMqln33FBCDm4UnqrEYBwkgCmIVxoMu8ZDMf3Bkh5oLae0yiuD8RT5aYwaLUGjUfJJYoUJ40ElnHQf6P9aI/KuP4A1aUJtmZFDWNY55RwFAX4iIuG0Mtwd4oxYlC1xKKfjcvgCkTl75B3JuesT8BObEjMQedsxkNVw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609764944; 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=cnwV2MyDhVntT4+1lWYmzLYkOrj5jaHTbeB35GuRHTk=; b=Xvs4sVP+0boYk5GoWLmmZBkg0cC2niWiJVu2J7wGWEt3j0Y9CzlfFUlmBo+MnpuOvcG59jJuQHBJa66XhCCJkoUc1GaOCrdGHvnfgNynDyyUbphgjYn+tSTnP9izppKzWxDCYO1CF2c/WFeqP51bKEeunLm5toLSoK1wd+VBges= 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 1609764944397453.0977840018252; Mon, 4 Jan 2021 04:55:44 -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-391-km8R7y8_P2OkfD40zH5NBA-1; Mon, 04 Jan 2021 07:55:41 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 021F087952E; Mon, 4 Jan 2021 12:55:35 +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 CF190106D5B6; Mon, 4 Jan 2021 12:55:34 +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 9A14A50040; Mon, 4 Jan 2021 12:55:34 +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 104CtSNd014425 for ; Mon, 4 Jan 2021 07:55:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id DD2412026DE8; Mon, 4 Jan 2021 12:55:28 +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 D4A6A2026D11 for ; Mon, 4 Jan 2021 12:55:26 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 49CC2186E125 for ; Mon, 4 Jan 2021 12:55:26 +0000 (UTC) Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-257-aET2ytYdPMum8AACNlSs1A-1; Mon, 04 Jan 2021 07:55:24 -0500 Received: by mail-qk1-f178.google.com with SMTP id v126so23149419qkd.11 for ; Mon, 04 Jan 2021 04:55:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jan 2021 04:55:23 -0800 (PST) X-MC-Unique: km8R7y8_P2OkfD40zH5NBA-1 X-MC-Unique: aET2ytYdPMum8AACNlSs1A-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=cnwV2MyDhVntT4+1lWYmzLYkOrj5jaHTbeB35GuRHTk=; b=NYIZdJhN4zqfF76l1SJOXSCaRtgh8W0Q0BEVfYTBPmOGrOKq+Dmiv9Y3hvRg1tjdM/ 4LrS/yG9L7jFBlMVO/bw2spYWCdzvTUSFsv6vmbjrjWW/vZEC2Y824NPLsYB8TdpEUaV L38uPtfwTiNNM8Tip3JwVgDeqGX0Vyo+cytB8CKg5HVYa47e43VOC9SG14lmQIhSx8NP g1gSpKUOrM55ZJUI2kmNnu/F/Zj471V3GRuaj01D5gvHiluo87yG/NtROel+KVRxdZSH lSjmMZjGzx1/isKd6/I5NSQ3WhC+Q2cGvQORm9OIPiOB5cChto6PFCAKSh3/oEeMS0A+ lC4w== X-Gm-Message-State: AOAM5334180yxiVplhhJOwNAAzlFCxhHlCJemp0uxA/jcWrt/uRaGzOg P2c+kAA2ypNvcWoQjr1LegHmnRiSdr1Gwg== X-Google-Smtp-Source: ABdhPJyCFY6JSyb7z8kQkqzH8BoGp2SpPUiBwnkv7R2kQ0L70RH3z38LAlI8MvHLna+XVcLsOJg9hA== X-Received: by 2002:a37:a516:: with SMTP id o22mr72320478qke.17.1609764923761; Mon, 04 Jan 2021 04:55:23 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 16/20] virpci.c: use virPCIDeviceAddressPtr in virPCIDeviceListFindIndex() Date: Mon, 4 Jan 2021 09:54:40 -0300 Message-Id: <20210104125444.200536-17-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.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.84 on 10.5.11.22 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 --- 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 1a542b18b6..122056dbe0 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