[pve-devel] [PATCH qemu-server] fix #1405: sort pci ids by functions

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Jun 8 09:18:25 CEST 2017


QemuServer::lspci() iterates over /sys/bus/pci/devices which
doesn't guarantee any order which means functions sometimes
ended up in the wrong order and it was never clear which
one would get the additional options such as x-vga passed
to them.
---
 PVE/QemuServer.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 7e91ac6..0efab21 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6304,6 +6304,12 @@ sub lspci {
 	    push @{$devices->{$id}}, $res;
     });
 
+    # Entries should be sorted by functions.
+    foreach my $id (keys %$devices) {
+	my $dev = $devices->{$id};
+	$devices->{$id} = [ sort { $a->{function} <=> $b->{function} } @$dev ];
+    }
+
     return $devices;
 }
 
-- 
2.11.0





More information about the pve-devel mailing list