From nobody Mon Feb 9 00:27:06 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=1565783908; cv=none; d=zoho.com; s=zohoarc; b=iGCVpo99MiZA5cCNf1qeXOayHPp7XEqvg51aPf3qgkwXAScrruWGQwea52uKCw1rlmpWNcN8WYCb7Cc22MmXvPu6MtEZMjt66tNudUyXgQ43VE0YAiZG6ggE5GLQSuOcJNiVJvPNSf/csxubN18OIc174SVMVg7esqSNug5FBf8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565783908; 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=KnKbVLo/iIFkNIxhv87zZv5eZ8fhoG/Edu1T50XDHRI=; b=RiLB3YvciGeQiYtUIuF3/SXTTClSwZP0D0rk9sUO3XdE9WDeohPEi+zyaxWFvoFqGjpKHQttI1Jr6QfwCdyisvZzsCp05dNnRitWqR8R+PGjUwJ3vFPPoJ4u+vUx7jag4r9cPP3PtrG3CoPdyXuwkyxMk0W5KIIZEPOGL41tpLk= 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 1565783908414183.65059333155727; Wed, 14 Aug 2019 04:58:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 534BE30607E1; Wed, 14 Aug 2019 11:58:27 +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 2727F81C17; Wed, 14 Aug 2019 11:58: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 E1F2C1806134; Wed, 14 Aug 2019 11:58:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7EBwHAU015600 for ; Wed, 14 Aug 2019 07:58:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id A0901348C3; Wed, 14 Aug 2019 11:58:17 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B09134940 for ; Wed, 14 Aug 2019 11:58:15 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 14 Aug 2019 13:57:41 +0200 Message-Id: <14233cd614f83451207744a1f04d244d4d2ac17d.1565777704.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/18] virpcimock: Create PCI devices under /sys/devices/pci* 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 14 Aug 2019 11:58:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" So far, we are creating devices directly under /sys/bus/pci/devices/*. There is not much problem with it, but if we really want to model kernel behaviour we need to create them under /sys/devices/pciDDDD:BB and then only symlink them from the old location. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- tests/virpcimock.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index c10764dcdd..0774bf62d9 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -383,12 +383,17 @@ pci_device_get_path(const struct pciDevice *dev, if (!(devid =3D pci_address_format(&dev->addr))) return NULL; =20 + /* PCI devices really do live under /sys/devices/pciDDDD:BB + * and then they are just symlinked to /sys/bus/pci/devices/ + */ if (file) { - ignore_value(virAsprintfQuiet(&ret, "%s" SYSFS_PCI_PREFIX "devices= /%s/%s", - prefix, devid, file)); + ignore_value(virAsprintfQuiet(&ret, "%s/sys/devices/pci%04x:%02x/%= s/%s", + prefix, dev->addr.domain, dev->addr.= bus, + devid, file)); } else { - ignore_value(virAsprintfQuiet(&ret, "%s" SYSFS_PCI_PREFIX "devices= /%s", - prefix, devid)); + ignore_value(virAsprintfQuiet(&ret, "%s/sys/devices/pci%04x:%02x/%= s", + prefix, dev->addr.domain, dev->addr.= bus, + devid)); } =20 return ret; @@ -400,6 +405,7 @@ pci_device_new_from_stub(const struct pciDevice *data) { struct pciDevice *dev; VIR_AUTOFREE(char *) devpath =3D NULL; + VIR_AUTOFREE(char *) devsympath =3D NULL; VIR_AUTOFREE(char *) id =3D NULL; VIR_AUTOFREE(char *) devid =3D NULL; char *c; @@ -488,6 +494,17 @@ pci_device_new_from_stub(const struct pciDevice *data) } make_symlink(devpath, "iommu_group", tmp); =20 + if (snprintf(tmp, sizeof(tmp), + "../../../devices/pci%04x:%02x/%s", + dev->addr.domain, dev->addr.bus, devid) < 0) { + ABORT("@tmp overflow"); + } + + if (virAsprintfQuiet(&devsympath, "%s" SYSFS_PCI_PREFIX "devices", fak= erootdir) < 0) + ABORT_OOM(); + + make_symlink(devsympath, devid, tmp); + if (pci_device_autobind(dev) < 0) ABORT("Unable to bind: %s", devid); =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list