]>
git.proxmox.com Git - qemu-server.git/blob - test/run_pci_addr_checks.pl
5 use experimental
'smartmatch';
11 use PVE
::Tools
qw(file_get_contents);
12 use PVE
::QemuServer
::PCI
;
14 # not our format but that what QEMU gets passed with '-readconfig'
15 sub slurp_qemu_config
{
18 my $raw = file_get_contents
($fn);
23 my $skip_to_next_group;
24 while ($raw =~ /^\h*(.*?)\h*$/gm) {
27 next if !$line || $line =~ /^#/;
29 # tried to follow qemu's qemu_config_parse function
30 if ($line =~ /\[(\S{1,63}) "([^"\]]{1,63})"\]/) {
32 $skip_to_next_group = 0;
35 $skip_to_next_group = 1;
37 } elsif ($line =~ /\[([^\]]{1,63})\]/) {
39 $skip_to_next_group = 1;
41 if ($line =~ /(\S{1,63}) = "([^\"]{1,1023})"/) {
42 my ($k, $v) = ($1, $2);
43 $cfg->{$group}->{$k} = $v;
45 print "ignoring $fn:$lineno: $line\n";
48 warn "ignore $fn:$lineno, currently no group\n" if !$skip_to_next_group;
53 #print Dumper($cfg) . "\n";
55 # FIXME: TODO! read those configs and check for conflicts!
56 # q35 stuff with PCIe and others with PCI
57 # slurp_qemu_config("../pve-q35.cfg");
59 print "testing PCI(e) address conflicts\n";
63 #FIXME: make cross PCI <-> PCIe check sense at all??
65 my ($fail, $ignored) = (0, 0);
69 my ($bus, $addr) = $what->@{qw(bus addr)};
70 my $full_addr = "$bus:$addr";
72 if (defined(my $conflict = $addr_map->{$full_addr})) {
73 if (my @ignores = $what->{conflict_ok
}) {
74 if ($conflict ~~ @ignores) {
75 note
("OK: ignore conflict for '$full_addr' between '$id' and '$conflict'");
80 note
("ERR: conflict for '$full_addr' between '$id' and '$conflict'");
83 $addr_map->{$full_addr} = $id;
88 my $pci_map = PVE
::QemuServer
::PCI
::get_pci_addr_map
();
89 while (my ($id, $what) = each %$pci_map) {
90 check_conflict
($id, $what);
93 my $pcie_map = PVE
::QemuServer
::PCI
::get_pcie_addr_map
();
94 while (my ($id, $what) = each %$pcie_map) {
95 check_conflict
($id, $what);
99 fail
("PCI(e) address conflict check, ignored: $ignored, conflicts: $fail");
101 pass
("PCI(e) address conflict check, ignored: $ignored");