Am 13.02.23 um 13:00 schrieb Alexandre Derumier:
> current qemu_dimm_list can return any kind of memory devices.
> 
> make it more generic, with a regex filter to choose kind of device
> from id.
> 
> Signed-off-by: Alexandre Derumier <aderum...@odiso.com>
> ---
>  PVE/QemuServer/Memory.pm | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/PVE/QemuServer/Memory.pm b/PVE/QemuServer/Memory.pm
> index c912e4f..a13b3a1 100644
> --- a/PVE/QemuServer/Memory.pm
> +++ b/PVE/QemuServer/Memory.pm
> @@ -333,7 +333,7 @@ sub qemu_memory_hotplug {
>               while (1) {
>                   eval { PVE::QemuServer::qemu_devicedel($vmid, $name) };
>                   sleep 3;
> -                 my $dimm_list = qemu_dimm_list($vmid);
> +                 my $dimm_list = qemu_memdevices_list($vmid, '^dimm(\d+)$');
>                   last if !$dimm_list->{$name};
>                   raise_param_exc({ $name => "error unplug memory module" }) 
> if $retry > 5;
>                   $retry++;
> @@ -363,14 +363,14 @@ sub can_hotplug {
>      return 1;
>  }
>  
> -sub qemu_dimm_list {
> -    my ($vmid) = @_;
> +sub qemu_memdevices_list {
> +    my ($vmid, $filter) = @_;

Nit: not sure if we really need/want a full-blown filter here. I'd just
start out with a $type and we can make sure to only use IDs of the form
$type\d+. If we ever need more, we can always change it to a filter.

>  
>      my $dimmarray = mon_cmd($vmid, "query-memory-devices");
>      my $dimms = {};
>  
>      foreach my $dimm (@$dimmarray) {
> -
> +        next if $filter && $dimm->{data}->{id} !~ /$filter/;
>          $dimms->{$dimm->{data}->{id}}->{id} = $dimm->{data}->{id};
>          $dimms->{$dimm->{data}->{id}}->{node} = $dimm->{data}->{node};
>          $dimms->{$dimm->{data}->{id}}->{addr} = $dimm->{data}->{addr};


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to