]> git.proxmox.com Git - qemu-server.git/commitdiff
implement usb hotplug
authorDominik Csapak <d.csapak@proxmox.com>
Tue, 14 Jun 2016 08:50:40 +0000 (10:50 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 22 Jun 2016 07:13:16 +0000 (09:13 +0200)
this patch introduces working usb hotplugging

you can now add a usb device while a vm is running

this does not work with spice at the moment, only
with usb passthrough

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

index 2dd00fdb380cb1b13dcde282e843776de210632d..b6ad27a6027dce6bdcbe008cde612846328a60e3 100644 (file)
@@ -3271,6 +3271,10 @@ sub vm_deviceplug {
 
        qemu_deviceadd($vmid, print_tabletdevice_full($conf));
 
+    } elsif ($deviceid =~ m/^usb(\d+)$/) {
+
+       qemu_deviceadd($vmid, PVE::QemuServer::USB::print_usbdevice_full($conf, $deviceid, $device));
+
     } elsif ($deviceid =~ m/^(virtio)(\d+)$/) {
 
        qemu_iothread_add($vmid, $deviceid, $device);
@@ -3366,6 +3370,11 @@ sub vm_deviceunplug {
 
        qemu_devicedel($vmid, $deviceid);
 
+    } elsif ($deviceid =~ m/^usb\d+$/) {
+
+       qemu_devicedel($vmid, $deviceid);
+       qemu_devicedelverify($vmid, $deviceid);
+
     } elsif ($deviceid =~ m/^(virtio)(\d+)$/) {
 
         qemu_devicedel($vmid, $deviceid);
@@ -3900,6 +3909,9 @@ sub vmconfig_hotplug_pending {
                } else {
                    vm_deviceunplug($vmid, $conf, $opt);
                }
+           } elsif ($opt =~ m/^usb\d+/) {
+               die "skip\n" if !$hotplug_features->{usb} || $conf->{$opt} =~ m/spice/i;
+               vm_deviceunplug($vmid, $conf, $opt);
            } elsif ($opt eq 'vcpus') {
                die "skip\n" if !$hotplug_features->{cpu};
                qemu_cpu_hotplug($vmid, $conf, undef);
@@ -3950,6 +3962,11 @@ sub vmconfig_hotplug_pending {
                } elsif ($value == 0) {
                    vm_deviceunplug($vmid, $conf, $opt);
                }
+           } elsif ($opt =~ m/^usb\d+$/) {
+               die "skip\n" if !$hotplug_features->{usb} || $value =~ m/spice/i;
+               my $d = eval { PVE::JSONSchema::parse_property_string($usbdesc->{format}, $value) };
+               die "skip\n" if !$d;
+               qemu_usb_hotplug($storecfg, $conf, $vmid, $opt, $d);
            } elsif ($opt eq 'vcpus') {
                die "skip\n" if !$hotplug_features->{cpu};
                qemu_cpu_hotplug($vmid, $conf, $value);