From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 9D46E1FF13C for ; Thu, 30 Apr 2026 08:34:49 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3B01C1BD3F; Thu, 30 Apr 2026 08:34:48 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Subject: [PATCH common] SysFSTools: add phys/virtfns to verbose output Date: Thu, 30 Apr 2026 08:32:50 +0200 Message-ID: <20260430063443.89722-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.051 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: XAAJZDG6DF6VDMGHYEZYJLG2UNCJFI5X X-Message-ID-Hash: XAAJZDG6DF6VDMGHYEZYJLG2UNCJFI5X X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: with this we can show/detect devices that belong together, e.g. the virtfns of a vGPU device. This can be helpful in a tree style display of virtfns to physfns or when trying to determine which virtfns belong to a specific device, etc. Signed-off-by: Dominik Csapak --- Sending this as preparation for some things i want to do and though it can't harm to have that information already. Places where we'd use that info are: * A overview over pci devices per node (e.g. to simplify creating resource mappings) * Introducing vGPU/PCI allocation policies (e.g. dense or spread out), for this we need to know the correlation between vGPUs and their physical device src/PVE/SysFSTools.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/PVE/SysFSTools.pm b/src/PVE/SysFSTools.pm index a00fbcb..d6b92fb 100644 --- a/src/PVE/SysFSTools.pm +++ b/src/PVE/SysFSTools.pm @@ -138,6 +138,29 @@ sub lspci { $res->{subsystem_device} = $sub_device if defined($sub_device); $res->{subsystem_vendor_name} = $sub_vendor_name if defined($sub_vendor_name); $res->{subsystem_device_name} = $sub_device_name if defined($sub_device_name); + + my $physfn_device = readlink("$devdir/physfn"); + # usually this results in "../' + if ($physfn_device =~ m!/(${pciregex})$!) { + $res->{physfn} = $1; + } + + my $virtfns = []; + dir_glob_foreach( + $devdir, + 'virtfn\d+', + sub { + my ($virtfn) = @_; + my $virtfn_device = readlink("$devdir/$virtfn"); + # usually this results in "../' + if ($virtfn_device =~ m!/(${pciregex})$!) { + push $virtfns->@*, { $virtfn => $1 }; + } + + }, + ); + + $res->{virtfns} = $virtfns if scalar($virtfns->@*) > 0; } push @$devices, $res; -- 2.47.3