public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com, "aderumier@odiso.com" <aderumier@odiso.com>
Subject: Re: [pve-devel] [PATCH v3 qemu-server 06/13] config: memory: add 'max' option
Date: Fri, 3 Feb 2023 14:44:35 +0100	[thread overview]
Message-ID: <974597df-ae43-29ee-dfeb-b5441ab2f1c0@proxmox.com> (raw)
In-Reply-To: <20230202110344.840195-7-aderumier@odiso.com>

Am 02.02.23 um 12:03 schrieb Alexandre Derumier:
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 9db1d8e..1f73605 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -5042,7 +5042,7 @@ sub vmconfig_hotplug_pending {
>  		vm_deviceunplug($vmid, $conf, $opt);
>  		vmconfig_delete_or_detach_drive($vmid, $storecfg, $conf, $opt, $force);
>  	    } elsif ($opt =~ m/^memory$/) {
> -		die "skip\n" if !$hotplug_features->{memory};
> +		die "skip\n" if !PVE::QemuServer::Memory::can_hotplug($hotplug_features->{memory}, $conf);
>  		PVE::QemuServer::Memory::qemu_memory_hotplug($vmid, $conf);
>  	    } elsif ($opt eq 'cpuunits') {
>  		$cgroup->change_cpu_shares(undef);

(...)

> @@ -24,9 +26,23 @@ our $memory_fmt = {
>  	default_key => 1,
>  	minimum => 16,
>  	default => 512,
> +    },
> +    max => {
> +	type => 'integer',
> +	optional => 1,
> +	minimum => 65536,
> +	maximum => 4194304,
> +	format => 'pve-qm-memory-max',
>      }
>  };
>  
> +PVE::JSONSchema::register_format('pve-qm-memory-max', \&verify_qm_memory_max);
> +sub verify_qm_memory_max {
> +    my ($max, $noerr) = @_;
> +

If $noerr is set and the check fails, you need to return undef and not die.

> +    die "max memory need to be a multiple of 64GiB\n" if $max && $max % 65536 != 0;

return $max;

> +}
> +
>  sub print_memory {
>      my $memory = shift;
>  
> @@ -311,6 +327,19 @@ sub qemu_memory_hotplug {
>      return $conf->{memory};
>  }
>  
> +sub can_hotplug {
> +    my ($hotplug, $conf, $value) = @_;
> +
> +    return if !$hotplug || !$value;

We can hotplug if there is no value. Calling qemu_memory_hotplug()
without value is legal. That's the call in vmconfig_hotplug_pending()
when the 'memory' is deleted from the config. While it currently errors
out later (because the default of 512 MiB is less than the static memory
of 1024 MiB), that can change if the default value changes. So we should
still return 1 in this case.

> +
> +    my $oldmem = parse_memory($conf->{memory});
> +    my $newmem = parse_memory($value);
> +
> +    return if safe_num_ne($newmem->{max}, $oldmem->{max});
> +
> +    return 1;
> +}
> +
>  sub qemu_dimm_list {
>      my ($vmid) = @_;
>  




  reply	other threads:[~2023-02-03 13:44 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 [this message]
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
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=974597df-ae43-29ee-dfeb-b5441ab2f1c0@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