Skip to content

Commit 32187f3

Browse files
ybenditokraxel
authored andcommitted
usb-redir: remove 'remote wakeup' flag from configuration descriptor
If the redirected device has this capability, Windows guest may place the device into D2 and expect it to wake when the device becomes active, but this will never happen. For example, when internal Bluetooth adapter is redirected, keyboards and mice connected to it do not work. Current commit removes this capability (starting from machine 5.0) Set 'usb-redir.suppress-remote-wake' property to 'off' to keep 'remote wake' as is or to 'on' to remove 'remote wake' on 4.2 or earlier. Signed-off-by: Yuri Benditovich <[email protected]> Message-id: [email protected] Signed-off-by: Gerd Hoffmann <[email protected]>
1 parent 7bacaf5 commit 32187f3

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

hw/core/machine.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ GlobalProperty hw_compat_4_2[] = {
3333
{ "virtio-scsi-device", "seg_max_adjust", "off"},
3434
{ "vhost-blk-device", "seg_max_adjust", "off"},
3535
{ "usb-host", "suppress-remote-wake", "off" },
36+
{ "usb-redir", "suppress-remote-wake", "off" },
3637
};
3738
const size_t hw_compat_4_2_len = G_N_ELEMENTS(hw_compat_4_2);
3839

hw/usb/redirect.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ struct USBRedirDevice {
113113
/* Properties */
114114
CharBackend cs;
115115
bool enable_streams;
116+
bool suppress_remote_wake;
116117
uint8_t debug;
117118
int32_t bootindex;
118119
char *filter_str;
@@ -1989,6 +1990,23 @@ static void usbredir_control_packet(void *priv, uint64_t id,
19891990
memcpy(dev->dev.data_buf, data, data_len);
19901991
}
19911992
p->actual_length = len;
1993+
/*
1994+
* If this is GET_DESCRIPTOR request for configuration descriptor,
1995+
* remove 'remote wakeup' flag from it to prevent idle power down
1996+
* in Windows guest
1997+
*/
1998+
if (dev->suppress_remote_wake &&
1999+
control_packet->requesttype == USB_DIR_IN &&
2000+
control_packet->request == USB_REQ_GET_DESCRIPTOR &&
2001+
control_packet->value == (USB_DT_CONFIG << 8) &&
2002+
control_packet->index == 0 &&
2003+
/* bmAttributes field of config descriptor */
2004+
len > 7 && (dev->dev.data_buf[7] & USB_CFG_ATT_WAKEUP)) {
2005+
DPRINTF("Removed remote wake %04X:%04X\n",
2006+
dev->device_info.vendor_id,
2007+
dev->device_info.product_id);
2008+
dev->dev.data_buf[7] &= ~USB_CFG_ATT_WAKEUP;
2009+
}
19922010
usb_generic_async_ctrl_complete(&dev->dev, p);
19932011
}
19942012
free(data);
@@ -2530,6 +2548,8 @@ static Property usbredir_properties[] = {
25302548
DEFINE_PROP_UINT8("debug", USBRedirDevice, debug, usbredirparser_warning),
25312549
DEFINE_PROP_STRING("filter", USBRedirDevice, filter_str),
25322550
DEFINE_PROP_BOOL("streams", USBRedirDevice, enable_streams, true),
2551+
DEFINE_PROP_BOOL("suppress-remote-wake", USBRedirDevice,
2552+
suppress_remote_wake, true),
25332553
DEFINE_PROP_END_OF_LIST(),
25342554
};
25352555

0 commit comments

Comments
 (0)