]> git.proxmox.com Git - qemu-server.git/commitdiff
get usbdevices in vm_devices_list
authorDominik Csapak <d.csapak@proxmox.com>
Tue, 14 Jun 2016 08:50:38 +0000 (10:50 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 22 Jun 2016 07:13:16 +0000 (09:13 +0200)
since usb devices do not have their own
"query" command in qmp, we have to use
qom-list /machines/peripheral

which essentially gets a list of peripheral devices of
the vm

there we only get the usb devices

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PVE/QemuServer.pm

index da60eee29f9c8dedc5d0b15be03a5958ceeeb280..c97e6f116f092a150e1c5bec5111d8bed484646f 100644 (file)
@@ -3244,6 +3244,16 @@ sub vm_devices_list {
        }
     }
 
+    # for usb devices there is no query-usb
+    # but we can iterate over the entries in
+    # qom-list path=/machine/peripheral
+    my $resperipheral = vm_mon_cmd($vmid, 'qom-list', path => '/machine/peripheral');
+    foreach my $per (@$resperipheral) {
+       if ($per->{name} =~ m/^usb\d+$/) {
+           $devices->{$per->{name}} = 1;
+       }
+    }
+
     return $devices;
 }