]> git.proxmox.com Git - qemu-server.git/commitdiff
usb: Add USB3 capabilities to Spice USB devices
authorAaron Lauterer <a.lauterer@proxmox.com>
Wed, 11 Sep 2019 12:43:32 +0000 (14:43 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 21 Sep 2019 11:22:17 +0000 (13:22 +0200)
To not change current behaviour and thus breaking live migration USB3
for a Spice USB device requires Qemu v4.1.

The old behavior was that even though technically it was possible to
the set `usb3=1` setting, it was ignored. The bus was hardcoded to
ehci. If another USB2 device was added or the machine type was set to
Q35 an ehci controller was present and the VM was able to boot.

With this patch the behaviour is changing and the bus is set to xhci if
USB3 is set for the Spice USB device and the VM is running under Qemu
v4.1.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
PVE/QemuServer.pm
PVE/QemuServer/USB.pm

index d5bdf7c480a33a0e419d48fdfb627597571680ff..1260cc033352be60c5bc71248f2350498c93062a 100644 (file)
@@ -3829,7 +3829,10 @@ sub config_to_command {
     }
 
     # usb devices
-    my @usbdevices = PVE::QemuServer::USB::get_usb_devices($conf, $usbdesc->{format}, $MAX_USB_DEVICES);
+    my $usb_dev_features = {};
+    $usb_dev_features->{spice_usb3} = 1 if qemu_machine_feature_enabled($machine_type, $kvmver, 4, 1);
+
+    my @usbdevices = PVE::QemuServer::USB::get_usb_devices($conf, $usbdesc->{format}, $MAX_USB_DEVICES, $usb_dev_features);
     push @$devices, @usbdevices if @usbdevices;
     # serial devices
     for (my $i = 0; $i < $MAX_SERIAL_PORTS; $i++)  {
index 2c09490e4225b10f78e699ba0c1a9b562c008b26..d328148539fc9245a2ac58fb442e5e307578b7bd 100644 (file)
@@ -74,7 +74,7 @@ sub get_usb_controllers {
 }
 
 sub get_usb_devices {
-    my ($conf, $format, $max_usb_devices) = @_;
+    my ($conf, $format, $max_usb_devices, $features) = @_;
 
     my $devices = [];
 
@@ -87,9 +87,12 @@ sub get_usb_devices {
            my $hostdevice = parse_usb_device($d->{host});
            $hostdevice->{usb3} = $d->{usb3};
            if ($hostdevice->{spice}) {
-               # usb redir support for spice, currently no usb3
+               # usb redir support for spice
+               my $bus = 'ehci';
+               $bus = 'xhci' if $hostdevice->{usb3} && $features->{spice_usb3};
+
                push @$devices, '-chardev', "spicevmc,id=usbredirchardev$i,name=usbredir";
-               push @$devices, '-device', "usb-redir,chardev=usbredirchardev$i,id=usbredirdev$i,bus=ehci.0";
+               push @$devices, '-device', "usb-redir,chardev=usbredirchardev$i,id=usbredirdev$i,bus=$bus.0";
            } else {
                push @$devices, '-device', print_usbdevice_full($conf, "usb$i", $hostdevice);
            }