From deb091c5002304ebf8f5d8e5297b99dfb0f5a570 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 14 Jun 2016 10:50:38 +0200 Subject: [PATCH] get usbdevices in vm_devices_list 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 --- PVE/QemuServer.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index da60eee2..c97e6f11 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -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; }