From mboxrd@z Thu Jan 1 00:00:00 1970 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 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> Subject: [Qemu-devel] [PATCH 3/3] monitor: add usb_attach and usb_detach List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@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 */ -- 1.7.3.1