]> git.proxmox.com Git - qemu-server.git/commitdiff
memory: hotplug: sort by numerical ID rather than slot when unplugging
authorFiona Ebner <f.ebner@proxmox.com>
Thu, 16 Mar 2023 09:31:59 +0000 (10:31 +0100)
committerFiona Ebner <f.ebner@proxmox.com>
Fri, 17 Mar 2023 13:05:02 +0000 (14:05 +0100)
While, usually, the slot should match the ID, it's not explicitly
guaranteed and relies on QEMU internals. Using the numerical ID is
more future-proof and more consistent with plugging, where no slot
information (except the maximum limit) is relied upon.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
PVE/QemuServer/Memory.pm

index 0f4229c5e497543773c748479be19fe2aa835db6..0601dd6c446c5e28ce94eb98f64237960af34d3f 100644 (file)
@@ -201,7 +201,7 @@ sub qemu_memory_hotplug {
        my $dimms = qemu_memdevices_list($vmid, 'dimm');
 
        my $current_size = $memory;
-       for my $name (sort { $dimms->{$b}->{slot} <=> $dimms->{$a}->{slot} } keys %$dimms) {
+       for my $name (sort { ($b =~ /^dimm(\d+)$/)[0] <=> ($a =~ /^dimm(\d+)$/)[0] } keys %$dimms) {
 
            my $dimm_size = $dimms->{$name}->{size} / 1024 / 1024;