From nobody Sun Feb 8 20:17:32 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=1566311456; cv=none; d=zoho.com; s=zohoarc; b=lKsqJtXiwgLQ5h8Q/VPmrmRffIOMT6FFdt9Cuq2tvv/8aTrd4p+ocfCmaACjoPMiNLhR04jjWn898x4zJu5eOQzTupYdLuVieYVpEd1K8wPFe985Yor6wCCp05f9cJPipxgUUZC7r5sgET/5eUzw9JHiBcggzNhe+MARRwXimzY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566311456; 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=utqpNtGB20JT9z0R9hPnh9sBMdYevpYh8DU68ueYKhc=; b=jmR0zpe209zJJPJOCSqRcnPfl1iTas5DlHbkcBWxLV26BDyyGrme07dwqyrr/8zUF+1WrTGyxlCuwMyytVVlBLRbWzvyXcV7ZaNj8mznCd/QfsCxLnmS+Yw3+Cj8paifVhITtNkVpFlmiVDIlJalqgKC8gBRnwLF50KcYwfNrMg= 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 1566311456789840.0367080685228; Tue, 20 Aug 2019 07:30:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6FE8810F23EF; Tue, 20 Aug 2019 14:30:55 +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 4811E5C686; Tue, 20 Aug 2019 14:30:55 +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 0807224F32; Tue, 20 Aug 2019 14:30:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7KEUoIh028825 for ; Tue, 20 Aug 2019 10:30:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id B145E438B; Tue, 20 Aug 2019 14:30:50 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 384EA1F0 for ; Tue, 20 Aug 2019 14:30:50 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 20 Aug 2019 16:30:27 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/12] virpci: Remove unused virPCIDeviceWaitForCleanup 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Tue, 20 Aug 2019 14:30:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This function is no longer used after previous commit. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko Tested-by: Daniel Henrique Barboza --- src/libvirt_private.syms | 1 - src/util/virpci.c | 108 --------------------------------------- src/util/virpci.h | 1 - 3 files changed, 110 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9db4ac7933..6c57351866 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2696,7 +2696,6 @@ virPCIDeviceSetStubDriver; virPCIDeviceSetUnbindFromStub; virPCIDeviceSetUsedBy; virPCIDeviceUnbind; -virPCIDeviceWaitForCleanup; virPCIEDeviceInfoFree; virPCIELinkSpeedTypeFromString; virPCIELinkSpeedTypeToString; diff --git a/src/util/virpci.c b/src/util/virpci.c index 9c9ffa55c2..ea5be62033 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -1552,114 +1552,6 @@ virPCIDeviceReattach(virPCIDevicePtr dev, return 0; } =20 -/* Certain hypervisors (like qemu/kvm) map the PCI bar(s) on - * the host when doing device passthrough. This can lead to a race - * condition where the hypervisor is still cleaning up the device while - * libvirt is trying to re-attach it to the host device driver. To avoid - * this situation, we look through /proc/iomem, and if the hypervisor is - * still holding on to the bar (denoted by the string in the matcher - * variable), then we can wait around a bit for that to clear up. - * - * A typical /proc/iomem looks like this (snipped for brevity): - * 00010000-0008efff : System RAM - * 0008f000-0008ffff : reserved - * ... - * 00100000-cc9fcfff : System RAM - * 00200000-00483d3b : Kernel code - * 00483d3c-005c88df : Kernel data - * cc9fd000-ccc71fff : ACPI Non-volatile Storage - * ... - * d0200000-d02fffff : PCI Bus #05 - * d0200000-d021ffff : 0000:05:00.0 - * d0200000-d021ffff : e1000e - * d0220000-d023ffff : 0000:05:00.0 - * d0220000-d023ffff : e1000e - * ... - * f0000000-f0003fff : 0000:00:1b.0 - * f0000000-f0003fff : kvm_assigned_device - * - * Returns 0 if we are clear to continue, and 1 if the hypervisor is still - * holding on to the resource. - */ -int -virPCIDeviceWaitForCleanup(virPCIDevicePtr dev, const char *matcher) -{ - FILE *fp; - char line[160]; - char *tmp; - unsigned long long start, end; - unsigned int domain, bus, slot, function; - bool in_matching_device; - int ret; - size_t match_depth; - - fp =3D fopen("/proc/iomem", "r"); - if (!fp) { - /* If we failed to open iomem, we just basically ignore the error.= The - * unbind might succeed anyway, and besides, it's very likely we h= ave - * no way to report the error - */ - VIR_DEBUG("Failed to open /proc/iomem, trying to continue anyway"); - return 0; - } - - ret =3D 0; - in_matching_device =3D false; - match_depth =3D 0; - while (fgets(line, sizeof(line), fp) !=3D 0) { - /* the logic here is a bit confusing. For each line, we look to - * see if it matches the domain:bus:slot.function we were given. - * If this line matches the DBSF, then any subsequent lines indent= ed - * by 2 spaces are the PCI regions for this device. It's also - * possible that none of the PCI regions are currently mapped, in - * which case we have no indented regions. This code handles all - * of these situations - */ - if (in_matching_device && (strspn(line, " ") =3D=3D (match_depth += 2))) { - /* expected format: - : */ - if (/* start */ - virStrToLong_ull(line, &tmp, 16, &start) < 0 || *tmp !=3D = '-' || - /* end */ - virStrToLong_ull(tmp + 1, &tmp, 16, &end) < 0 || - (tmp =3D STRSKIP(tmp, " : ")) =3D=3D NULL) - continue; - - if (STRPREFIX(tmp, matcher)) { - ret =3D 1; - break; - } - } else { - in_matching_device =3D false; - - /* expected format: - : ::. */ - if (/* start */ - virStrToLong_ull(line, &tmp, 16, &start) < 0 || *tmp !=3D = '-' || - /* end */ - virStrToLong_ull(tmp + 1, &tmp, 16, &end) < 0 || - (tmp =3D STRSKIP(tmp, " : ")) =3D=3D NULL || - /* domain */ - virStrToLong_ui(tmp, &tmp, 16, &domain) < 0 || *tmp !=3D '= :' || - /* bus */ - virStrToLong_ui(tmp + 1, &tmp, 16, &bus) < 0 || *tmp !=3D = ':' || - /* slot */ - virStrToLong_ui(tmp + 1, &tmp, 16, &slot) < 0 || *tmp !=3D= '.' || - /* function */ - virStrToLong_ui(tmp + 1, &tmp, 16, &function) < 0 || *tmp = !=3D '\n') - continue; - - if (domain !=3D dev->address.domain || bus !=3D dev->address.b= us || - slot !=3D dev->address.slot || function !=3D dev->address.= function) - continue; - in_matching_device =3D true; - match_depth =3D strspn(line, " "); - } - } - - VIR_FORCE_FCLOSE(fp); - - return ret; -} - static char * virPCIDeviceReadID(virPCIDevicePtr dev, const char *id_name) { diff --git a/src/util/virpci.h b/src/util/virpci.h index 4ac0d230a4..dc20f91710 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -197,7 +197,6 @@ char *virPCIDeviceGetIOMMUGroupDev(virPCIDevicePtr dev); =20 int virPCIDeviceIsAssignable(virPCIDevicePtr dev, int strict_acs_check); -int virPCIDeviceWaitForCleanup(virPCIDevicePtr dev, const char *matcher); =20 virPCIDeviceAddressPtr virPCIGetDeviceAddressFromSysfsLink(const char *device_link); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list