[PATCH v2 qemu-server 04/10] pci: add get_pci_addr
Alexandre Derumier
alexandre.derumier at groupe-cyllene.com
Wed Jul 16 18:34:09 CEST 2025
return a hash with pci bus && pci address
Signed-off-by: Alexandre Derumier <alexandre.derumier at groupe-cyllene.com>
---
src/PVE/QemuServer/PCI.pm | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/PVE/QemuServer/PCI.pm b/src/PVE/QemuServer/PCI.pm
index e7a9a610..94fd10bd 100644
--- a/src/PVE/QemuServer/PCI.pm
+++ b/src/PVE/QemuServer/PCI.pm
@@ -16,6 +16,7 @@ use PVE::QemuServer::Machine;
use base 'Exporter';
our @EXPORT_OK = qw(
+ get_pci_addr
print_pci_addr
print_pcie_addr
print_pcie_root_port
@@ -288,12 +289,12 @@ my $get_addr_mapping_from_id = sub {
return { bus => $d->{bus}, addr => sprintf("0x%x", $d->{addr}) };
};
-sub print_pci_addr {
+sub get_pci_addr {
my ($id, $bridges, $arch) = @_;
die "aarch64 cannot use IDE devices\n" if $arch eq 'aarch64' && $id =~ /^ide/;
- my $res = '';
+ my $res = {};
my $map = get_pci_addr_map();
if (my $d = $get_addr_mapping_from_id->($map, $id)) {
@@ -301,13 +302,23 @@ sub print_pci_addr {
# virt machine has an initial pcie.0. The other pci bridges that get added are called pci.N.
my $busname = $arch eq 'aarch64' && $d->{bus} eq 0 ? 'pcie' : 'pci';
- $res = ",bus=$busname.$d->{bus},addr=$d->{addr}";
+ $res = { bus => "$busname.$d->{bus}", addr => $d->{addr} };
$bridges->{ $d->{bus} } = 1 if $bridges;
}
return $res;
}
+sub print_pci_addr {
+ my ($id, $bridges, $arch) = @_;
+
+ my $pci = get_pci_addr($id, $bridges, $arch);
+ my $res = "";
+ $res .= ",bus=$pci->{bus}" if $pci->{bus};
+ $res .= ",addr=$pci->{addr}" if $pci->{addr};
+ return $res;
+}
+
my $pcie_addr_map;
sub get_pcie_addr_map {
--
2.39.5
More information about the pve-devel
mailing list