public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Alexandre Derumier <aderumier@odiso.com>
Subject: Re: [pve-devel] [PATCH v3 qemu-server 08/13] memory: don't use foreach_reversedimm for unplug
Date: Fri, 3 Feb 2023 14:45:34 +0100	[thread overview]
Message-ID: <b20fe8b6-a63a-979d-512d-a89f745a5078@proxmox.com> (raw)
In-Reply-To: <20230202110344.840195-9-aderumier@odiso.com>

Thanks for looking into this! The new way is more straightforward for
sure :)

Am 02.02.23 um 12:03 schrieb Alexandre Derumier:
> @@ -316,30 +284,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);

Looking at qemu_dimm_list(), I feel like we should start filtering to
only return dimms (based on the id or is there something better?), since
we now also iterate over them and not only check for existence.
Currently, qemu_dimm_list() returns all memory objects which would
include the virtiomem devices. The function is not called if virtiomem
is used, but this would make it future-proof (and avoid breakage if
people have manually attached non-dimm memory devices, although I'd say
that's not supported from our perspective ;)).

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

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

>  
> -		return if $current_size >= get_current_memory($conf->{memory});
> +	    my $dimm_size = $dimms->{$name}->{size} / 1024 / 1024;
>  
> -		print "try to unplug memory dimm $name\n";
> +	    last if $current_size <= $value || $current_size <= $static_memory;

Nit: the second half of the condition is not really needed. We already
assert at the start of qemu_memory_hotplug() that $value >=
$static_memory and if we didn't somehow end up with values not matching
reality in the config, we should reach $static_memory only after
unplugging everything, or not?

>  
> -		my $retry = 0;
> -		while (1) {
> -		    eval { PVE::QemuServer::qemu_devicedel($vmid, $name) };
> -		    sleep 3;
> -		    my $dimm_list = qemu_dimm_list($vmid);
> -		    last if !$dimm_list->{$name};
> -		    raise_param_exc({ $name => "error unplug memory module" }) if $retry > 5;
> -		    $retry++;
> -		}
> +	    print "try to unplug memory dimm $name\n";
>  
> -		#update conf after each succesful module unplug
> -		$newmem->{current} = $current_size;
> -		$conf->{memory} = print_memory($newmem);
> +	    my $retry = 0;
> +	    while (1) {
> +		eval { PVE::QemuServer::qemu_devicedel($vmid, $name) };
> +		sleep 3;
> +		my $dimm_list = qemu_dimm_list($vmid);
> +		last if !$dimm_list->{$name};
> +		raise_param_exc({ $name => "error unplug memory module" }) if $retry > 5;
> +		$retry++;
> +	    }
> +	    $current_size -= $dimm_size;
> +	    #update conf after each succesful module unplug
> +	    $newmem->{current} = $current_size;
> +	    $conf->{memory} = print_memory($newmem);
>  
> -		eval { PVE::QemuServer::qemu_objectdel($vmid, "mem-$name"); };
> -		PVE::QemuConfig->write_config($vmid, $conf);
> -	});
> +	    eval { PVE::QemuServer::qemu_objectdel($vmid, "mem-$name"); };
> +	    PVE::QemuConfig->write_config($vmid, $conf);
> +	}
>      }
>      return $conf->{memory};
>  }




  reply	other threads:[~2023-02-03 13:46 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 11:03 [pve-devel] [PATCH v3 qemu-server 00/13] rework memory hotplug + virtiomem Alexandre Derumier
2023-02-02 11:03 ` [pve-devel] [PATCH v3 qemu-server 01/13] memory: extract some code to their own sub for mocking Alexandre Derumier
2023-02-03 13:44   ` Fiona Ebner
2023-02-02 11:03 ` [pve-devel] [PATCH v3 qemu-server 02/13] tests: add memory tests Alexandre Derumier
2023-02-03 13:44   ` Fiona Ebner
2023-02-02 11:03 ` [pve-devel] [PATCH v3 qemu-server 03/13] qemu_memory_hotplug: remove unused $opt arg Alexandre Derumier
2023-02-03 13:56   ` [pve-devel] applied: " Fiona Ebner
2023-02-02 11:03 ` [pve-devel] [PATCH v3 qemu-server 04/13] add memory parser Alexandre Derumier
2023-02-03 13:44   ` Fiona Ebner
2023-02-02 11:03 ` [pve-devel] [PATCH v3 qemu-server 05/13] memory: add get_static_mem && remove parse_hotplug_features Alexandre Derumier
2023-02-03 13:44   ` Fiona Ebner
2023-02-02 11:03 ` [pve-devel] [PATCH v3 qemu-server 06/13] config: memory: add 'max' option Alexandre Derumier
2023-02-03 13:44   ` Fiona Ebner
2023-02-02 11:03 ` [pve-devel] [PATCH v3 qemu-server 07/13] memory: get_max_mem: use config memory max Alexandre Derumier
2023-02-02 11:03 ` [pve-devel] [PATCH v3 qemu-server 08/13] memory: don't use foreach_reversedimm for unplug Alexandre Derumier
2023-02-03 13:45   ` Fiona Ebner [this message]
2023-02-02 11:03 ` [pve-devel] [PATCH v3 qemu-server 09/13] memory: use 64 slots && static dimm size when max is defined Alexandre Derumier
2023-02-03 13:45   ` Fiona Ebner
2023-02-02 11:03 ` [pve-devel] [PATCH v3 qemu-server 10/13] test: add memory-max tests Alexandre Derumier
2023-02-02 11:03 ` [pve-devel] [PATCH v3 qemu-server 11/13] memory: add virtio-mem support Alexandre Derumier
2023-02-03 13:46   ` Fiona Ebner
2023-02-03 15:48     ` DERUMIER, Alexandre
2023-02-02 11:03 ` [pve-devel] [PATCH v3 qemu-server 12/13] memory: virtio-mem : implement redispatch retry Alexandre Derumier
2023-02-02 11:03 ` [pve-devel] [PATCH v3 qemu-server 13/13] tests: add virtio-mem tests Alexandre Derumier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b20fe8b6-a63a-979d-512d-a89f745a5078@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=aderumier@odiso.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal