]> git.proxmox.com Git - qemu-server.git/commitdiff
memory: rename qemu_dimm_list to qemu_memdevices_list
authorAlexandre Derumier <aderumier@odiso.com>
Fri, 24 Feb 2023 12:09:04 +0000 (13:09 +0100)
committerFiona Ebner <f.ebner@proxmox.com>
Thu, 16 Mar 2023 08:53:53 +0000 (09:53 +0100)
current qemu_dimm_list can return any kind of memory devices.

make it more generic, with an optionnal type device

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/QemuServer/Memory.pm

index 8984821028361bad2fa7517134591fd4d5db84d8..7ad8fcbc82e280daa760318fb64efaccf43ab49b 100644 (file)
@@ -240,7 +240,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');
                    last if !$dimm_list->{$name};
                    raise_param_exc({ $name => "error unplug memory module" }) if $retry > 5;
                    $retry++;
@@ -255,14 +255,14 @@ sub qemu_memory_hotplug {
     }
 }
 
-sub qemu_dimm_list {
-    my ($vmid) = @_;
+sub qemu_memdevices_list {
+    my ($vmid, $type) = @_;
 
     my $dimmarray = mon_cmd($vmid, "query-memory-devices");
     my $dimms = {};
 
     foreach my $dimm (@$dimmarray) {
-
+        next if $type && $dimm->{data}->{id} !~ /^$type(\d+)$/;
         $dimms->{$dimm->{data}->{id}}->{id} = $dimm->{data}->{id};
         $dimms->{$dimm->{data}->{id}}->{node} = $dimm->{data}->{node};
         $dimms->{$dimm->{data}->{id}}->{addr} = $dimm->{data}->{addr};