* [Qemu-devel] [PATCH] Return contorl to host on usb_del monitor command
@ 2010-04-19 18:55 Shahar Havivi
2010-05-18 18:26 ` Aurelien Jarno
0 siblings, 1 reply; 2+ messages in thread
From: Shahar Havivi @ 2010-04-19 18:55 UTC (permalink / raw)
To: qemu-devel
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 <shaharh@redhat.com>
---
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;
--
1.6.3.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] Return contorl to host on usb_del monitor command
2010-04-19 18:55 [Qemu-devel] [PATCH] Return contorl to host on usb_del monitor command Shahar Havivi
@ 2010-05-18 18:26 ` Aurelien Jarno
0 siblings, 0 replies; 2+ messages in thread
From: Aurelien Jarno @ 2010-05-18 18:26 UTC (permalink / raw)
To: Shahar Havivi; +Cc: qemu-devel
On Mon, Apr 19, 2010 at 09:55:58PM +0300, Shahar Havivi wrote:
> 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 <shaharh@redhat.com>
> ---
> 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;
> +}
> +
This function should also be added on usb-bsd.c and usb-stub.c, or at
least an empty function.
> static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration)
> {
> int dev_descr_len, config_descr_len;
> --
> 1.6.3.3
>
>
>
>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-05-18 18:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-19 18:55 [Qemu-devel] [PATCH] Return contorl to host on usb_del monitor command Shahar Havivi
2010-05-18 18:26 ` Aurelien Jarno
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).