usb-redir: An interface count of 0 is a valid value
PATCH 1/3 usb-redir: An interface count of 0 is a valid value
An interface-count of 0 happens when a device is in unconfigured state when it gets redirected. So we should not use 0 to detect not having received interface info from our peer.
Signed-off-by Hans de Goede <[email protected]>
--- hw/usb/redirect.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/usb/redirect.c +3 -2
@@ -39,6 +39,7 @@#include "hw/usb.h" #define MAX_ENDPOINTS 32 +#define NO_INTERFACE_INFO 255/* Valid interface_count always <= 32 */ #define EP2I (ep_address) (((ep_address & 0x80) >> 3) | (ep_address & 0x0f))#define I2EP (i) (((i & 0x10) << 3) | (i & 0x0f))
@@ -968,7 +969,7 @@ static void usbredir_handle_destroy(USBDevice *udev)static int usbredir_check_filter (USBRedirDevice *dev) { -if (dev->interface_info.interface_count ==0 ) { +if (dev->interface_info.interface_count ==NO_INTERFACE_INFO ) {ERROR ("No interface info for device\n" ); goto error; }
@@ -1132,7 +1133,7 @@ static void usbredir_device_disconnect(void *priv)QTAILQ_INIT (&dev->endpoint[i].bufpq); }usb_ep_init (&dev->dev); - dev->interface_info.interface_count =0 ; + dev->interface_info.interface_count =NO_INTERFACE_INFO ; } static void usbredir_interface_info(void *priv,
Signature · 1 line
1.7.9.3
PATCH 2/3 usb-redir: Reset device address and speed on disconnect
Without this disconnected devices look like the last redirected device in the monitor in "info usb".
Signed-off-by Hans de Goede <[email protected]>
--- hw/usb/redirect.c | 2 ++ 1 file changed, 2 insertions(+)
hw/usb/redirect.c +2 -0
@@ -1134,6 +1134,8 @@ static void usbredir_device_disconnect(void *priv) }usb_ep_init (&dev->dev); dev->interface_info.interface_count =NO_INTERFACE_INFO ; + dev->dev.addr =0 ; + dev->dev.speed =0 ; } static void usbredir_interface_info(void *priv,
Signature · 1 line
1.7.9.3
PATCH 3/3 usb-redir: Not finding an async urb id is not an error
In reply to Hans de GoedeWe clear our pending async urb list on device disconnect and we may still receive "packet complete" packets from our peer after this, which will then refer to packet ids no longer in our list.
Signed-off-by Hans de Goede <[email protected]>
--- hw/usb/redirect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/redirect.c +1 -1
@@ -276,7 +276,7 @@ static AsyncURB *async_find(USBRedirDevice *dev, uint32_t packet_id)return aurb; } } -ERROR ("could not find async urb for packet_id %u\n" , packet_id); +DPRINTF ("could not find async urb for packet_id %u\n" , packet_id);return NULL ; }
Signature · 1 line
1.7.9.3