From 5ee3847149bf2d2a13816613fb4101d4eb0c40c1 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 8 Jun 2017 09:18:25 +0200 Subject: [PATCH] fix #1405: sort pci ids by functions 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 7e91ac6e..0efab217 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; }