From patchwork Sat Oct 8 09:02:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 118503 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0B098B70FF for ; Sat, 8 Oct 2011 20:03:09 +1100 (EST) Received: from localhost ([::1]:33004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RCSoD-0002R0-FY for incoming@patchwork.ozlabs.org; Sat, 08 Oct 2011 05:03:05 -0400 Received: from eggs.gnu.org ([140.186.70.92]:37428) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RCSo7-0002Qj-I6 for qemu-devel@nongnu.org; Sat, 08 Oct 2011 05:03:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RCSo6-0005Ic-FA for qemu-devel@nongnu.org; Sat, 08 Oct 2011 05:02:59 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:56357) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RCSo6-0005IX-AW for qemu-devel@nongnu.org; Sat, 08 Oct 2011 05:02:58 -0400 Received: by yxl11 with SMTP id 11so5234604yxl.4 for ; Sat, 08 Oct 2011 02:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=WJRwyFqeqiYT6h7w7amZbGjuKLWnhf4IkimnSsTQzq0=; b=k631f2GyDbme6eM4A5b86cDpNd7vuDfPqkaM4bQkAoFeRWincRETp15pJhHAdUT/DR c+AZW0i67hTGusxFoR9UzHc4+ge9ZTdzuFT30pqsWqN6jaKLe0L+KOQT0y06tHQea3yx k6d3gNKhJNTLaNJOss5Ccsnw3Rh7nLqPpQ7g0= MIME-Version: 1.0 Received: by 10.236.79.72 with SMTP id h48mr15074412yhe.4.1318064576928; Sat, 08 Oct 2011 02:02:56 -0700 (PDT) Received: by 10.146.168.17 with HTTP; Sat, 8 Oct 2011 02:02:56 -0700 (PDT) Date: Sat, 8 Oct 2011 10:02:56 +0100 Message-ID: From: Stefan Hajnoczi To: Gerd Hoffmann X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.213.173 Cc: Hans de Goede , qemu-devel Subject: [Qemu-devel] usb_packet_complete assert(p->owner != NULL) 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hi, I hit an assertion in hw/usb.c when passing through a host USB device on qemu.git/master (e4fc8781db7c49b0c5ac5d24762e17c59dfe0871). This device has never worked before and I was curious to see how qemu.git/master would do. The assertion is: void usb_packet_complete(USBDevice *dev, USBPacket *p) { /* Note: p->owner != dev is possible in case dev is a hub */ assert(p->owner != NULL); The problem seems to be that usb_packet_complete() is called on the hub device and the hub calls usb_packet_complete() again on the actual leaf device. Since usb_packet_complete() sets packet->owner to NULL we hit the assertion immediately when trying to invoke the leaf device .complete(). I don't understand how USB emulation hangs together, so I added this quick hack: static void usb_hub_handle_reset(USBDevice *dev) The hub is now directly invoking .complete() and not messing with packet->owner (which is already NULL). We don't hit the assertion anymore. Unfortunately the device does not work in my Windows guest - it must be another problem though. I'm not sending it as a patch because there's probably a better way of fixing this. Any ideas? Stefan diff --git a/hw/usb-hub.c b/hw/usb-hub.c index 286e3ad..277cb47 100644 --- a/hw/usb-hub.c +++ b/hw/usb-hub.c @@ -210,7 +210,7 @@ static void usb_hub_complete(USBPort *port, USBPacket *packet) * If we ever inplement usb 2.0 split transactions this will * become a little more complicated ... */ - usb_packet_complete(&s->dev, packet); + s->dev.port->ops->complete(s->dev.port, packet); }