[pve-devel] [PATCH qemu-server 10/10] memory: fix hotplug with virtiomem && maxmem
Fiona Ebner
f.ebner at proxmox.com
Fri Dec 16 14:42:31 CET 2022
Am 09.12.22 um 20:27 schrieb Alexandre Derumier:
> diff --git a/PVE/QemuServer/Memory.pm b/PVE/QemuServer/Memory.pm
> index 70ab65a..84a9126 100644
> --- a/PVE/QemuServer/Memory.pm
> +++ b/PVE/QemuServer/Memory.pm
> @@ -9,6 +9,7 @@ use PVE::Exception qw(raise raise_param_exc);
> use PVE::QemuServer;
> use PVE::QemuServer::Monitor qw(mon_cmd);
> use PVE::QemuServer::PCI qw(print_pci_addr);
> +use PVE::GuestHelpers qw(safe_string_ne safe_num_ne safe_boolean_ne);
>
> use base qw(Exporter);
>
> @@ -230,24 +231,32 @@ sub foreach_reverse_dimm {
> }
>
> sub qemu_memory_hotplug {
> - my ($vmid, $conf, $defaults, $opt, $value) = @_;
> + my ($vmid, $conf, $new_mem) = @_;
>
> - return $value if !PVE::QemuServer::check_running($vmid);
> + return if !PVE::QemuServer::check_running($vmid);
Unrelated change not belonging in this patch
>
> - my $sockets = 1;
> - $sockets = $conf->{sockets} if $conf->{sockets};
> + my $confmem = PVE::QemuServer::parse_memory($conf->{memory});
> +
> + # skip non hotpluggable value
> + if (safe_string_ne($new_mem->{max}, $confmem->{max}) ||
> + safe_boolean_ne($new_mem->{virtio}, $confmem->{virtio})) {
> + die "skip\n";
This special error "return" value should really not be used here. It's
just too intransparent in the long run. This should be done by the
callers and actually belongs in the patches introducing 'virtio' and
'max' (handling) respectively.
> + }
> +
> + my $value = $new_mem->{current};
> + my $memory = $confmem->{current};
>
> - my $memory = get_current_memory($conf);
> return $value if $value == $memory;
>
> + my $sockets = 1;
> + $sockets = $conf->{sockets} if $conf->{sockets};
> +
> my $static_memory = get_static_mem($conf);
>
> die "memory can't be lower than $static_memory MB" if $value < $static_memory;
> my $MAX_MEM = get_max_mem($conf);
> die "you cannot add more memory than max mem $MAX_MEM MB!\n" if $value > $MAX_MEM;
>
> - my $confmem = PVE::QemuServer::parse_memory($conf->{memory});
> -
> if ($confmem->{virtio}) {
> my $blocksize = get_virtiomem_block_size($conf);
> my $requested_size = ($value - $static_memory) / $sockets * 1024 * 1024;
More information about the pve-devel
mailing list