From patchwork Tue Oct 19 10:33:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 68311 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 35168B70DE for ; Tue, 19 Oct 2010 21:43:46 +1100 (EST) Received: from localhost ([127.0.0.1]:56571 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P89fS-0002X0-Tr for incoming@patchwork.ozlabs.org; Tue, 19 Oct 2010 06:43:42 -0400 Received: from [140.186.70.92] (port=33073 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P89Vs-0005Yb-81 for qemu-devel@nongnu.org; Tue, 19 Oct 2010 06:34:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P89Vh-0004oC-Pp for qemu-devel@nongnu.org; Tue, 19 Oct 2010 06:33:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P89Vh-0004o5-Ic for qemu-devel@nongnu.org; Tue, 19 Oct 2010 06:33:37 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9JAXa85032295 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 19 Oct 2010 06:33:37 -0400 Received: from playa.tlv.redhat.com (dhcp-2-227.tlv.redhat.com [10.35.2.227]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9JAXW5r010122 for ; Tue, 19 Oct 2010 06:33:36 -0400 From: Alon Levy To: qemu-devel@nongnu.org Date: Tue, 19 Oct 2010 12:33:31 +0200 Message-Id: <1287484411-13611-4-git-send-email-alevy@redhat.com> In-Reply-To: <1287484411-13611-1-git-send-email-alevy@redhat.com> References: <1287484411-13611-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 3/3] monitor: add usb_attach and usb_detach 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 --- hmp-commands.hx | 34 ++++++++++++++++++++++++++++++++++ sysemu.h | 2 ++ vl.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 0 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 81999aa..660205c 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -517,6 +517,40 @@ command @code{info usb} to see the devices you can remove. ETEXI { + .name = "usb_attach", + .args_type = "id:s", + .params = "device", + .help = "attach USB device 'bus.addr'", + .mhandler.cmd = do_usb_attach, + }, + +STEXI +@item usb_attach @var{devname} +@findex usb_attach + +Attach the USB device @var{devname} to the QEMU virtual USB +hub. @var{devname} has the syntax @code{bus.addr}. Use the monitor +command @code{info usb} to see the devices you can attach. +ETEXI + + { + .name = "usb_detach", + .args_type = "id:s", + .params = "device", + .help = "remove USB device 'bus.addr'", + .mhandler.cmd = do_usb_detach, + }, + +STEXI +@item usb_detach @var{devname} +@findex usb_detach + +Detach the USB device @var{devname} from the QEMU virtual USB +hub. @var{devname} has the syntax @code{bus.addr}. Use the monitor +command @code{info usb} to see the devices you can detach. +ETEXI + + { .name = "device_add", .args_type = "device:O", .params = "driver[,prop=value][,...]", diff --git a/sysemu.h b/sysemu.h index b81a70e..1dc0e58 100644 --- a/sysemu.h +++ b/sysemu.h @@ -182,6 +182,8 @@ extern struct soundhw soundhw[]; void do_usb_add(Monitor *mon, const QDict *qdict); void do_usb_del(Monitor *mon, const QDict *qdict); +void do_usb_attach(Monitor *mon, const QDict *qdict); +void do_usb_detach(Monitor *mon, const QDict *qdict); void usb_info(Monitor *mon); void rtc_change_mon_event(struct tm *tm); diff --git a/vl.c b/vl.c index df414ef..35db6c8 100644 --- a/vl.c +++ b/vl.c @@ -894,6 +894,37 @@ void do_usb_del(Monitor *mon, const QDict *qdict) } } +void do_usb_attach(Monitor *mon, const QDict *qdict) +{ + const char *id = qdict_get_str(qdict, "id"); + USBDevice *dev; + + dev = usb_device_by_id(id); + + if (dev == NULL) { + error_report("no such USB device '%s'", id); + return; + } + if (usb_device_attach(dev) < 0) { + error_report("could not attach USB device '%s'", id); + } +} + +void do_usb_detach(Monitor *mon, const QDict *qdict) +{ + const char *id = qdict_get_str(qdict, "id"); + USBDevice *dev; + + dev = usb_device_by_id(id); + if (dev == NULL) { + error_report("no such USB device '%s'", id); + return; + } + if (usb_device_detach(dev) < 0) { + error_report("could not detach USB device '%s'", id); + } +} + /***********************************************************/ /* PCMCIA/Cardbus */