[pve-devel] [PATCH v4 qemu-server 11/16] memory: don't use foreach_reversedimm for unplug

Fiona Ebner f.ebner at proxmox.com
Wed Feb 22 16:19:34 CET 2023


Am 13.02.23 um 13:00 schrieb Alexandre Derumier:
> @@ -322,30 +290,33 @@ sub qemu_memory_hotplug {
>  
>      } else {
>  
> -	foreach_reverse_dimm($conf, $vmid, $value, $sockets, sub {
> -	    my ($conf, $vmid, $name, $dimm_size, $numanode, $current_size, $memory) = @_;
> +	my $dimms = qemu_dimm_list($vmid);

Has been renamed in the last patch ;) Ideally, this and the last patch
would be ordered first in the series. Then I would've applied them right
away (fixing up the renamed call), because they fix an existing bug, see
below.

> +	my $current_size = $memory;
> +	for my $name (sort { $dimms->{$b}{slot} <=> $dimms->{$a}{slot} } keys %$dimms) {

Style nit: Please use $dimms->{$b}->{slot}

Turns out the current code with foreach_reverse_dimm() is actually buggy
(not only when reaching $dimm_id==254). With qemu-server 7.3-3:
> root at pve701 ~ # grep memory: /etc/pve/qemu-server/135.conf
> memory: 1536
> root at pve701 ~ # perl memory-qmp.pm 135
> dimm0 (node 0): 536870912
> $VAR1 = {
>           'base-memory' => 1073741824,
>           'plugged-memory' => 536870912
>         };
> root at pve701 ~ # qm set 135 --memory 20480                           
> update VM 135: -memory 20480
> root at pve701 ~ # grep memory: /etc/pve/qemu-server/135.conf
> memory: 20480
> root at pve701 ~ # perl memory-qmp.pm 135
> dimm0 (node 0): 536870912
> dimm1 (node 1): 536870912
> ...
> dimm33 (node 1): 1073741824
> dimm34 (node 0): 1073741824
> $VAR1 = {
>           'base-memory' => 1073741824,
>           'plugged-memory' => '20401094656'
>         };
> root at pve701 ~ # qm set 135 --memory 1536 
> update VM 135: -memory 1536
> try to unplug memory dimm dimm33
> try to unplug memory dimm dimm32
> ...
> try to unplug memory dimm dimm2
> try to unplug memory dimm dimm1
> root at pve701 ~ # grep memory: /etc/pve/qemu-server/135.conf
> memory: 1536
> root at pve701 ~ # perl memory-qmp.pm 135
> dimm0 (node 0): 536870912
> dimm34 (node 0): 1073741824
> $VAR1 = {
>           'base-memory' => 1073741824,
>           'plugged-memory' => 1610612736
>         };

And this patch fixes that :)





More information about the pve-devel mailing list