5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-01-25 06:03:52 +03:00

collect device list for nested pci-bridges

when using q35 as machine type, there are nested pci-bridges,
but we only checked the first layer

this resulted in not being able to hotplug scsi devices,
because scsihw0 was deeper in the pci-bridge construct, we did not see
it and tried to add it (which fails of course)

this patch checks all bridges, regardless how deeply nested they are

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2018-04-12 17:04:56 +02:00 committed by Wolfgang Bumiller
parent 3807f3e4ee
commit f721624b8e

View File

@ -3601,21 +3601,22 @@ sub vm_devices_list {
my ($vmid) = @_;
my $res = vm_mon_cmd($vmid, 'query-pci');
my $devices_to_check = [];
my $devices = {};
foreach my $pcibus (@$res) {
foreach my $device (@{$pcibus->{devices}}) {
next if !$device->{'qdev_id'};
if ($device->{'pci_bridge'}) {
$devices->{$device->{'qdev_id'}} = 1;
foreach my $bridge_device (@{$device->{'pci_bridge'}->{devices}}) {
next if !$bridge_device->{'qdev_id'};
$devices->{$bridge_device->{'qdev_id'}} = 1;
$devices->{$device->{'qdev_id'}}++;
}
} else {
$devices->{$device->{'qdev_id'}} = 1;
}
push @$devices_to_check, @{$pcibus->{devices}},
}
while (@$devices_to_check) {
my $to_check = [];
for my $d (@$devices_to_check) {
$devices->{$d->{'qdev_id'}} = 1 if $d->{'qdev_id'};
next if !$d->{'pci_bridge'};
$devices->{$d->{'qdev_id'}} += scalar(@{$d->{'pci_bridge'}->{devices}});
push @$to_check, @{$d->{'pci_bridge'}->{devices}};
}
$devices_to_check = $to_check;
}
my $resblock = vm_mon_cmd($vmid, 'query-block');