* [PATCH common] SysFSTools: add phys/virtfns to verbose output
@ 2026-04-30 6:32 Dominik Csapak
2026-05-12 22:50 ` Thomas Lamprecht
0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread
* Re: [PATCH common] SysFSTools: add phys/virtfns to verbose output
2026-04-30 6:32 [PATCH common] SysFSTools: add phys/virtfns to verbose output Dominik Csapak
@ 2026-05-12 22:50 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2026-05-12 22:50 UTC (permalink / raw)
To: pve-devel, Dominik Csapak
On Thu, 30 Apr 2026 08:32:50 +0200, Dominik Csapak wrote:
> 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.
>
>
> [...]
Applied with a few small fixups [0], thanks!
[0]:
* guard the physfn readlink, otherwise non-VF devices (i.e. most) spam
undef warnings
* reshape virtfns as a plain hash keyed by virtfn<N>, the array wrapper
didn't really buy us anything (readdir order isn't sorted anyway)
* document the new return fields in the lspci docstring
[1/1] SysFSTools: add phys/virtfns to verbose output
commit: 7486fcd6c8285a815fc9bd9d457aa11ec01457da
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-12 22:50 UTC | newest]
Thread overview: 2+ messages (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
2026-05-12 22:50 ` Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox