[pve-devel] [PATCH guest-common 2/2] mapping: pci: optionally return the config in 'find_on_current_node'

Dominik Csapak d.csapak at proxmox.com
Mon Mar 18 12:18:29 CET 2024


this is useful to get to the config without having to parse it again

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PVE/Mapping/PCI.pm | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/PVE/Mapping/PCI.pm b/src/PVE/Mapping/PCI.pm
index 0866175..9d8a4a7 100644
--- a/src/PVE/Mapping/PCI.pm
+++ b/src/PVE/Mapping/PCI.pm
@@ -219,10 +219,11 @@ sub find_on_current_node {
 sub get_node_mapping {
     my ($cfg, $id, $nodename) = @_;
 
-    return undef if !defined($cfg->{ids}->{$id});
+    my $map_config = $cfg->{ids}->{$id};
+    return undef if !defined($map_config);
 
     my $res = [];
-    for my $map ($cfg->{ids}->{$id}->{map}->@*) {
+    for my $map ($map_config->{map}->@*) {
 	my $entry = eval { parse_property_string($map_fmt, $map) };
 	warn $@ if $@;
 	if ($entry && $entry->{node} eq $nodename) {
@@ -230,7 +231,7 @@ sub get_node_mapping {
 	}
     }
 
-    return $res;
+    return wantarray ? ($res, $map_config) : $res;
 }
 
 PVE::Mapping::PCI->register();
-- 
2.39.2





More information about the pve-devel mailing list