[pve-devel] [PATCH qemu-server 5/7] add qemu_usb_hotplug
Dominik Csapak
d.csapak at proxmox.com
Tue Jun 14 10:50:39 CEST 2016
this adds a function for hotplugging usb devices
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
this function has to be in here, since i did not
refactor the monitor functions yet
PVE/QemuServer.pm | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index f12e587..6834b33 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3592,6 +3592,31 @@ sub qemu_netdevdel {
vm_mon_cmd($vmid, "netdev_del", id => $deviceid);
}
+sub qemu_usb_hotplug {
+ my ($storecfg, $conf, $vmid, $deviceid, $device) = @_;
+
+ return if !$device;
+
+ # remove the old one first
+ vm_deviceunplug($vmid, $conf, $deviceid);
+
+ # check if xhci controller is necessary and available
+ if ($device->{usb3}) {
+
+ my $devicelist = vm_devices_list($vmid);
+
+ if (!$devicelist->{xhci}) {
+ my $pciaddr = print_pci_addr("xhci");
+ qemu_deviceadd($vmid, "nec-usb-xhci,id=xhci$pciaddr");
+ }
+ }
+ my $d = parse_usb_device($device->{host});
+ $d->{usb3} = $device->{usb3};
+
+ # add the new one
+ vm_deviceplug($storecfg, $conf, $vmid, $deviceid, $d);
+}
+
sub qemu_cpu_hotplug {
my ($vmid, $conf, $vcpus) = @_;
--
2.1.4
More information about the pve-devel
mailing list