qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 3/3] monitor: add usb_attach and usb_detach


From: Alon Levy
Subject: [Qemu-devel] [PATCH 3/3] monitor: add usb_attach and usb_detach
Date: Tue, 19 Oct 2010 12:33:31 +0200

---
 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
address@hidden usb_attach @var{devname}
address@hidden 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
address@hidden usb_detach @var{devname}
address@hidden 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]