From: Dominik Csapak <d.csapak@proxmox.com>
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 [thread overview]
Message-ID: <20260430063443.89722-1-d.csapak@proxmox.com> (raw)
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 <d.csapak@proxmox.com>
---
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 "../<pci-id>'
+ 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 "../<pci-id>'
+ if ($virtfn_device =~ m!/(${pciregex})$!) {
+ push $virtfns->@*, { $virtfn => $1 };
+ }
+
+ },
+ );
+
+ $res->{virtfns} = $virtfns if scalar($virtfns->@*) > 0;
}
push @$devices, $res;
--
2.47.3
reply other threads:[~2026-04-30 6:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260430063443.89722-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.