From patchwork Thu Jan 28 17:15:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?gb18030?B?y9XG5NDb?= <916628390@qq.com> X-Patchwork-Id: 8152651 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BB5FB9F6DA for ; Thu, 28 Jan 2016 17:16:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0D5FF2035B for ; Thu, 28 Jan 2016 17:16:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 461C120138 for ; Thu, 28 Jan 2016 17:16:07 +0000 (UTC) Received: from localhost ([::1]:57784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOqAw-000424-Am for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Jan 2016 12:16:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <916628390@qq.com>) id 1aOqAm-00041P-42 for qemu-devel@nongnu.org; Thu, 28 Jan 2016 12:15:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <916628390@qq.com>) id 1aOqAi-0003vM-RH for qemu-devel@nongnu.org; Thu, 28 Jan 2016 12:15:55 -0500 Received: from smtpbg202.qq.com ([184.105.206.29]:40242) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <916628390@qq.com>) id 1aOqAi-0003v1-9W for qemu-devel@nongnu.org; Thu, 28 Jan 2016 12:15:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1454001346; bh=6JDjhShJhY/5SK3HL4BGKrjKCfEhqjOoe6X5F6FBAn8=; h=From:To:Subject:Mime-Version:Content-Type:Content-Transfer-Encoding:Date:Message-ID; b=Gu8cdMpoW71xbjDPpyUjz9Uj1AbVVua7okyuOSTPxcGaH7CQ5PdbP6Y+LWatvSQa/ NJzX1ced0MwVrSQqhnpUWLN7l82zXtMdYO8Z8Iv5pYTzms7iQG+DrWVzI+WioFSe/q G/epHUqY9EfTHft8pif/yOQLwZ0hGJP//hjEbdjs= X-QQ-FEAT: KC9GRaXB0GqP1tyTH5tBWivnCDq2nfxGOQ2UokqDR0IqkmHwWByNvmEsr/LWM LXCRsYXuqFQPNxoO4CkNeebYscnKxHrkvH2JpnMp0RvIPQZWFQoq6ZVE5gvT5A13OUWs7Rf /AHhQYok/vGBoLLHL3BlPD5HJus0+xXkE50AW9qrmvHjNsvCHxvQpazcBFk5l5zXQKxlAuu UzDHQVlkOBFtRw7EvBUdLcDROSoQ1rnL8sOZKZZphQZ9YcRLT+ym5K29yI8t36Qw= X-QQ-SSF: 000000000000005000000000000000V X-HAS-ATTACH: no X-QQ-BUSINESS-ORIGIN: 2 X-Originating-IP: 222.76.198.155 X-QQ-STYLE: X-QQ-mid: webmail569t1454001344t6918179 From: "=?ISO-8859-1?B?UWl4aW9uZyBTdQ==?=" <916628390@qq.com> To: "=?ISO-8859-1?B?cWVtdS1kZXZlbA==?=" Mime-Version: 1.0 Date: Fri, 29 Jan 2016 01:15:44 +0800 X-Priority: 3 Message-ID: X-QQ-MIME: TCMime 1.0 by Tencent X-Mailer: QQMail 2.x X-QQ-Mailer: QQMail 2.x X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 184.105.206.29 Subject: [Qemu-devel] [PATCH 1/1] redirect: change the state after attach usb 3.0 devices to xhci X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, FROM_EXCESS_BASE64, HTML_MESSAGE, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 <916628390@qq.com> --- hw/usb/redirect.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.1.3 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;