From patchwork Mon Apr 19 18:55:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shahar Havivi X-Patchwork-Id: 50487 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5DEB8B7BEE for ; Tue, 20 Apr 2010 04:57:56 +1000 (EST) Received: from localhost ([127.0.0.1]:40971 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O3wAL-0007Ta-HN for incoming@patchwork.ozlabs.org; Mon, 19 Apr 2010 14:57:53 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O3w9j-0007TH-KY for qemu-devel@nongnu.org; Mon, 19 Apr 2010 14:57:15 -0400 Received: from [140.186.70.92] (port=46693 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O3w9h-0007T9-Ut for qemu-devel@nongnu.org; Mon, 19 Apr 2010 14:57:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O3w9g-0000vz-A6 for qemu-devel@nongnu.org; Mon, 19 Apr 2010 14:57:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34559) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O3w9g-0000vi-2t for qemu-devel@nongnu.org; Mon, 19 Apr 2010 14:57:12 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o3JIvAY9003614 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 19 Apr 2010 14:57:11 -0400 Received: from localhost (dhcp-1-229.tlv.redhat.com [10.35.1.229]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o3JIv9Ld000592 for ; Mon, 19 Apr 2010 14:57:10 -0400 Date: Mon, 19 Apr 2010 21:55:58 +0300 From: Shahar Havivi To: qemu-devel@nongnu.org Message-ID: <20100419185555.GA3914@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH] Return contorl to host on usb_del monitor command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When removing usb on guest via usb_del monitor command, qemu does not return the control to the host, the only solution user have is to unplug/plug the device again in order to get the device back to the host Signed-off-by: Shahar Havivi --- hw/usb-bus.c | 4 ++++ hw/usb.h | 1 + usb-linux.c | 11 +++++++++++ 3 files changed, 16 insertions(+), 0 deletions(-) diff --git a/hw/usb-bus.c b/hw/usb-bus.c index ee0e9e3..9781ac6 100644 --- a/hw/usb-bus.c +++ b/hw/usb-bus.c @@ -208,6 +208,10 @@ int usb_device_delete_addr(int busnr, int addr) return -1; dev = port->dev; + if (!strcmp(dev->info->usbdevice_name, "host")) { + usb_host_device_release(dev); + } + qdev_free(&dev->qdev); return 0; } diff --git a/hw/usb.h b/hw/usb.h index 00d2802..f6f7cc4 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -258,6 +258,7 @@ void usb_send_msg(USBDevice *dev, int msg); USBDevice *usb_host_device_open(const char *devname); int usb_host_device_close(const char *devname); void usb_host_info(Monitor *mon); +int usb_host_device_release(USBDevice *dev); /* usb-hid.c */ void usb_hid_datain_cb(USBDevice *dev, void *opaque, void (*datain)(void *)); diff --git a/usb-linux.c b/usb-linux.c index d0d7cff..9db94dd 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -284,6 +284,17 @@ static void async_cancel(USBPacket *unused, void *opaque) } } +/* release usb device, return control to host */ +int usb_host_device_release(USBDevice *dev) +{ + int ret; + + USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev); + ret = ioctl(s->fd, USBDEVFS_RESET); + + return ret; +} + static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration) { int dev_descr_len, config_descr_len;