* [PATCH common] SysFSTools: add phys/virtfns to verbose output
@ 2026-04-30 6:32 Dominik Csapak
0 siblings, 0 replies; only message in thread
From: Dominik Csapak @ 2026-04-30 6:32 UTC (permalink / raw)
To: pve-devel
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-30 6:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 6:32 [PATCH common] SysFSTools: add phys/virtfns to verbose output Dominik Csapak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox