QEMU crashes when redirect a usb 3.0 device which attached to a xHCI 
controller. The assertion of "dev->state == 3" in "usb_handle_packet" has 
failed.


Signed-off-by: Qixiong Su <916628...@qq.com>
---
 hw/usb/redirect.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)


diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 44522d9..cd29776 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -1437,6 +1437,17 @@ static void usbredir_handle_destroy(USBDevice *udev)
     free(dev->filter_rules);
 }
 
+static void usbredir_handle_attach(USBDevice *udev)
+{
+    assert(udev != NULL);
+    assert(udev->attached);
+    assert(udev->state == USB_STATE_ATTACHED);
+
+    if (udev->speed == USB_SPEED_SUPER && (udev->port->speedmask & 
USB_SPEED_MASK_SUPER)) {
+        udev->state = USB_STATE_DEFAULT;
+    }
+}
+
 static int usbredir_check_filter(USBRedirDevice *dev)
 {
     if (dev->interface_info.interface_count == NO_INTERFACE_INFO) {
@@ -2480,6 +2491,7 @@ static void usbredir_class_initfn(ObjectClass *klass, 
void *data)
     uc->init           = usbredir_initfn;
     uc->product_desc   = "USB Redirection Device";
     uc->handle_destroy = usbredir_handle_destroy;
+    uc->handle_attach = usbredir_handle_attach;
     uc->cancel_packet  = usbredir_cancel_packet;
     uc->handle_reset   = usbredir_handle_reset;
     uc->handle_data    = usbredir_handle_data;
--
2.1.3

Reply via email to