From: Alon Levy <alevy@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/3] monitor: add usb_attach and usb_detach (v2)
Date: Thu, 21 Oct 2010 08:36:31 +0200 [thread overview]
Message-ID: <1287642991-21114-4-git-send-email-alevy@redhat.com> (raw)
In-Reply-To: <1287642991-21114-1-git-send-email-alevy@redhat.com>
v1->v2 changes:
* fixed help text (consistent name for parameter)
* added configure flag, also enabled with --enable-debug
---
configure | 9 +++++++++
hmp-commands.hx | 38 ++++++++++++++++++++++++++++++++++++++
sysemu.h | 4 ++++
vl.c | 33 +++++++++++++++++++++++++++++++++
4 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
index a869777..229a71a 100755
--- a/configure
+++ b/configure
@@ -292,6 +292,7 @@ gprof="no"
debug_tcg="no"
debug_mon="no"
debug="no"
+usb_monitor_attach_detach="no"
strip_opt="yes"
bigendian="no"
mingw32="no"
@@ -590,8 +591,11 @@ for opt do
debug_tcg="yes"
debug_mon="yes"
debug="yes"
+ usb_monitor_attach_detach="yes"
strip_opt="no"
;;
+ --enable-usb-mon-detach) usb_monitor_attach_detach="yes"
+ ;;
--enable-sparse) sparse="yes"
;;
--disable-sparse) sparse="no"
@@ -854,6 +858,7 @@ echo " --sysconfdir=PATH install config in PATH/qemu"
echo " --enable-debug-tcg enable TCG debugging"
echo " --disable-debug-tcg disable TCG debugging (default)"
echo " --enable-debug enable common debug build options"
+echo " --enable-usb-mon-detach enable usb monitor attach & detach commands"
echo " --enable-sparse enable sparse checker"
echo " --disable-sparse disable sparse checker (default)"
echo " --disable-strip disable stripping binaries"
@@ -2311,6 +2316,7 @@ echo "host big endian $bigendian"
echo "target list $target_list"
echo "tcg debug enabled $debug_tcg"
echo "Mon debug enabled $debug_mon"
+echo "usb mon detach $usb_monitor_attach_detach"
echo "gprof enabled $gprof"
echo "sparse enabled $sparse"
echo "strip binaries $strip_opt"
@@ -2402,6 +2408,9 @@ fi
if test "$debug" = "yes" ; then
echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
fi
+if test "$usb_monitor_attach_detach" = yes ; then
+ echo "CONFIG_USB_MONITOR_ATTACH_DETACH=y" >> $config_host_mak
+fi
if test "$strip_opt" = "yes" ; then
echo "STRIP=${strip}" >> $config_host_mak
fi
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 81999aa..3014b17 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -516,6 +516,44 @@ hub. @var{devname} has the syntax @code{bus.addr}. Use the monitor
command @code{info usb} to see the devices you can remove.
ETEXI
+#ifdef CONFIG_USB_MONITOR_ATTACH_DETACH
+ {
+ .name = "usb_attach",
+ .args_type = "id:s",
+ .params = "device",
+ .help = "attach USB device by id",
+ .mhandler.cmd = do_usb_attach,
+ },
+
+STEXI
+@item usb_attach @var{id}
+@findex usb_attach
+
+Attach the USB device with id @var{id} to the QEMU virtual USB
+hub. @var{id} should be a previously detached usb device. Use
+@code{info qtree} to see devices that can be attached. This
+command is for debugging usage only.
+ETEXI
+
+ {
+ .name = "usb_detach",
+ .args_type = "id:s",
+ .params = "device",
+ .help = "remove USB device by id",
+ .mhandler.cmd = do_usb_detach,
+ },
+
+STEXI
+@item usb_detach @var{id}
+@findex usb_detach
+
+Detach the USB device @var{id} from the QEMU virtual USB
+hub. Use the monitor command @code{info usb} to see the
+devices you can detach. This command is for debugging usage
+only.
+ETEXI
+#endif // CONFIG_USB_MONITOR_ATTACH_DETACH
+
{
.name = "device_add",
.args_type = "device:O",
diff --git a/sysemu.h b/sysemu.h
index b81a70e..2e1df04 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -182,6 +182,10 @@ extern struct soundhw soundhw[];
void do_usb_add(Monitor *mon, const QDict *qdict);
void do_usb_del(Monitor *mon, const QDict *qdict);
+#ifdef CONFIG_USB_MONITOR_ATTACH_DETACH
+void do_usb_attach(Monitor *mon, const QDict *qdict);
+void do_usb_detach(Monitor *mon, const QDict *qdict);
+#endif
void usb_info(Monitor *mon);
void rtc_change_mon_event(struct tm *tm);
diff --git a/vl.c b/vl.c
index df414ef..f233c84 100644
--- a/vl.c
+++ b/vl.c
@@ -894,6 +894,39 @@ void do_usb_del(Monitor *mon, const QDict *qdict)
}
}
+#ifdef CONFIG_USB_MONITOR_ATTACH_DETACH
+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);
+ }
+}
+#endif // CONFIG_USB_MONITOR_ATTACH_DETACH
+
/***********************************************************/
/* PCMCIA/Cardbus */
--
1.7.3.1
next prev parent reply other threads:[~2010-10-21 6:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-21 6:36 [Qemu-devel] [PATCH 0/3] add usb_detach and usb_attach (v3) Alon Levy
2010-10-21 6:36 ` [Qemu-devel] [PATCH 1/3] qdev: make qdev_find_recursive public Alon Levy
2010-10-21 6:36 ` [Qemu-devel] [PATCH 2/3] usb: add public usb_device_by_id Alon Levy
2010-10-21 6:36 ` Alon Levy [this message]
2010-10-21 13:03 ` [Qemu-devel] [PATCH 0/3] add usb_detach and usb_attach (v3) Gerd Hoffmann
2010-10-21 13:13 ` Anthony Liguori
2010-10-21 13:24 ` Alon Levy
2010-10-22 3:16 ` Ryan Harper
2010-11-10 15:49 ` Markus Armbruster
2010-11-10 20:41 ` Alon Levy
2010-11-11 10:29 ` Markus Armbruster
2010-11-11 12:56 ` Alon Levy
2010-11-11 15:03 ` Markus Armbruster
2010-11-11 17:01 ` Alon Levy
2010-10-21 13:27 ` Alon Levy
2010-10-22 12:48 ` Luiz Capitulino
2010-10-22 12:55 ` Anthony Liguori
2010-10-22 13:17 ` Luiz Capitulino
2010-10-22 13:43 ` Anthony Liguori
2010-10-22 13:45 ` Luiz Capitulino
2010-10-25 8:44 ` Alon Levy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1287642991-21114-4-git-send-email-alevy@redhat.com \
--to=alevy@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).