From 1dd69eeb6c62278fc4c1703850c1ada764fc11d9 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Mon, 8 Aug 2022 14:20:07 +0200 Subject: [PATCH] lx_emul: skip USB config setting if already set Skip SET_CONFIGURATION requests if the device already has the selected config as active config. This workaround prevents issues with Linux guests in VirtualBox and SDC-reader passthrough. Thanks to Peter for the patch. --- repos/dde_linux/src/lib/lx_emul/usb.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/repos/dde_linux/src/lib/lx_emul/usb.c b/repos/dde_linux/src/lib/lx_emul/usb.c index ed328119cd..17b6728bf6 100644 --- a/repos/dde_linux/src/lib/lx_emul/usb.c +++ b/repos/dde_linux/src/lib/lx_emul/usb.c @@ -366,6 +366,17 @@ static genode_usb_request_ret_t handle_config_request(unsigned cfg_idx, void * data) { struct usb_device * udev = (struct usb_device *) data; + + if (udev && udev->actconfig + && udev->actconfig->desc.bConfigurationValue == cfg_idx) { + /* + * Skip SET_CONFIGURATION requests if the device already has the + * selected config as active config. This workaround prevents issues + * with Linux guests in vbox and SDC-reader passthrough. + */ + return NO_ERROR; + } + return (usb_set_configuration(udev, cfg_idx)) ? UNKNOWN_ERROR : NO_ERROR; }