From 2cf203194ba8964cb308d16a680708645d2c03a6 Mon Sep 17 00:00:00 2001 From: Fiona Ebner Date: Thu, 16 Mar 2023 10:31:59 +0100 Subject: [PATCH] memory: hotplug: sort by numerical ID rather than slot when unplugging 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 --- PVE/QemuServer/Memory.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PVE/QemuServer/Memory.pm b/PVE/QemuServer/Memory.pm index 0f4229c5..0601dd6c 100644 --- a/PVE/QemuServer/Memory.pm +++ b/PVE/QemuServer/Memory.pm @@ -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;