USB kills VMs on 4.3.18
Jung-uk Kim
jkim at FreeBSD.org
Wed Nov 12 22:33:43 UTC 2014
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11/12/2014 16:54, Jung-uk Kim wrote:
> On 11/12/2014 16:38, Jung-uk Kim wrote:
>> On 11/12/2014 16:31, Jung-uk Kim wrote:
>>> On 11/10/2014 02:00, Kevin Oberman wrote:
>>>> Sine the upgrade to VB 4.3.18 plugging in my Logitech Harmony
>>>> control into the USB port of my laptop causes the VM to
>>>> abort instantly. It will not even start ot boot up until I
>>>> unplug the device. The device is reserved for VB and has
>>>> worked fine in the past.
>
>>>> Looks like some sort of regression.Since the VM dies
>>>> instantly and block it from rebooting, I'm not to sure how to
>>>> get any debug information on it.
>
>>>> FreeBSD rogue 10.1-PRERELEASE FreeBSD 10.1-PRERELEASE #0
>>>> r273452: Tue Oct 21 23:00:15 PDT 2014
>>>> root at rogue:/usr/obj/usr/src/sys/GENERIC amd64
>
>>> FYI, incomplete USB support code was committed with r368359.
>
>>> https://svnweb.freebsd.org/changeset/ports/368359
>
>>> The USB patch was originally came from this commit:
>
>>> https://redports.org/changeset/29393
>
>>> i.e., it was just a stub.
>
>>> Please try the attached patch, i.e., just replace
>>> patch-src-VBox-Devices-USB-freebsd-USBProxyDevice-freebsd.cpp
>>> in files directory with it, rebuild, and try again. Note this
>>> patch may still be incomplete.
>
>> Here goes the patch again, sorry.
>
> There was a typo in the patch. :-(
Argh... There was another typo. Now this version is compile-tested.
I am very sorry for the trouble.
Jung-uk Kim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQEcBAEBAgAGBQJUY+BGAAoJEHyflib82/FG/1oH/2EDYuE0HaH+p4kdNzWvUMtt
HyE/tPfu9/Dgmkl9NX7GnJHz5gdvCWwtHeCGG5qJLa8Z71tszUQK07+4Mm5ZUMXp
9CnT8jJ/eOaN5PzeYfK6b/iNhoBxEuOenS3JnhWXi9jwn8tPEeM/MPLeOtR3WkwH
NtrZKC7El6m6rCpsnJ6Ha8JXh//7uGTNP/sACcL9oyCgrNo6dovgj7FxXu0Q0v8y
hfQr+6MqxNRMInH0rXs46Bl0Vn9gYaPxZ5Uvx7LnxiBS6FuAbsCCH5RdD+vypEnV
EmXHrqoSL5+/o+qV7bET7ApOK9tYIpppHYKH26Hb+4k08iSGcOhZZUsBO2LWhKE=
=bxN8
-----END PGP SIGNATURE-----
-------------- next part --------------
--- src/VBox/Devices/USB/freebsd/USBProxyDevice-freebsd.cpp.orig 2014-10-11 08:06:56.000000000 -0400
+++ src/VBox/Devices/USB/freebsd/USBProxyDevice-freebsd.cpp 2014-11-12 16:07:28.000000000 -0500
@@ -52,6 +52,7 @@
#include <iprt/asm.h>
#include <iprt/string.h>
#include <iprt/file.h>
+#include <iprt/pipe.h>
#include "../USBProxyDevice.h"
/** Maximum endpoints supported. */
@@ -95,12 +96,16 @@
{
/** The open file. */
RTFILE hFile;
- /** Software endpoint structures */
- USBENDPOINTFBSD aSwEndpoint[USBFBSD_MAXENDPOINTS];
/** Flag whether an URB is cancelling. */
bool fCancelling;
/** Flag whether initialised or not */
bool fInit;
+ /** Pipe handle for waking up - writing end. */
+ RTPIPE hPipeWakeupW;
+ /** Pipe handle for waking up - reading end. */
+ RTPIPE hPipeWakeupR;
+ /** Software endpoint structures */
+ USBENDPOINTFBSD aSwEndpoint[USBFBSD_MAXENDPOINTS];
/** Kernel endpoint structures */
struct usb_fs_endpoint aHwEndpoint[USBFBSD_MAXENDPOINTS];
} USBPROXYDEVFBSD, *PUSBPROXYDEVFBSD;
@@ -383,10 +388,17 @@
rc = usbProxyFreeBSDFsInit(pProxyDev);
if (RT_SUCCESS(rc))
{
- LogFlow(("usbProxyFreeBSDOpen(%p, %s): returns successfully hFile=%RTfile iActiveCfg=%d\n",
- pProxyDev, pszAddress, pDevFBSD->hFile, pProxyDev->iActiveCfg));
+ /*
+ * Create wakeup pipe.
+ */
+ rc = RTPipeCreate(&pDevFBSD->hPipeWakeupR, &pDevFBSD->hPipeWakeupW, 0);
+ if (RT_SUCCESS(rc))
+ {
+ LogFlow(("usbProxyFreeBSDOpen(%p, %s): returns successfully hFile=%RTfile iActiveCfg=%d\n",
+ pProxyDev, pszAddress, pDevFBSD->hFile, pProxyDev->iActiveCfg));
- return VINF_SUCCESS;
+ return VINF_SUCCESS;
+ }
}
RTFileClose(hFile);
@@ -449,11 +461,13 @@
usbProxyFreeBSDFsUnInit(pProxyDev);
+ RTPipeClose(pDevFBSD->hPipeWakeupR);
+ RTPipeClose(pDevFBSD->hPipeWakeupW);
+
RTFileClose(pDevFBSD->hFile);
pDevFBSD->hFile = NIL_RTFILE;
RTMemFree(pDevFBSD);
- pProxyDev->Backend.pv = NULL;
LogFlow(("usbProxyFreeBSDClose: returns\n"));
}
@@ -822,7 +836,7 @@
PUSBENDPOINTFBSD pEndpointFBSD;
PVUSBURB pUrb;
struct usb_fs_complete UsbFsComplete;
- struct pollfd PollFd;
+ struct pollfd pfd[2];
int rc;
LogFlow(("usbProxyFreeBSDUrbReap: pProxyDev=%p, cMillies=%u\n",
@@ -948,14 +962,32 @@
}
else if (cMillies && rc == VERR_RESOURCE_BUSY)
{
- /* Poll for finished transfers */
- PollFd.fd = RTFileToNative(pDevFBSD->hFile);
- PollFd.events = POLLIN | POLLRDNORM;
- PollFd.revents = 0;
+ pfd[0].fd = RTFileToNative(pDevFBSD->hFile);
+ pfd[0].events = POLLIN | POLLRDNORM;
+ pfd[0].revents = 0;
+
+ pfd[1].fd = RTPipeToNative(pDevFBSD->hPipeWakeupR);
+ pfd[1].events = POLLIN;
+ pfd[1].revents = 0;
- rc = poll(&PollFd, 1, (cMillies == RT_INDEFINITE_WAIT) ? INFTIM : cMillies);
+ rc = poll(pfd, 2, (cMillies == RT_INDEFINITE_WAIT) ? INFTIM : cMillies);
if (rc >= 1)
{
+ if (pfd[1].revents & POLLIN)
+ {
+ /* Got woken up, drain pipe. */
+ uint8_t bRead;
+ size_t cbIgnored = 0;
+ RTPipeRead(pDevFBSD->hPipeWakeupR, &bRead, 1, &cbIgnored);
+
+ /*
+ * It is possible that we got woken up and have an URB pending
+ * for completion. Do it on the way out. Otherwise return
+ * immediately to the caller.
+ */
+ if (!(pfd[0].revents & POLLIN))
+ return NULL;
+ }
goto repeat;
}
else
@@ -984,6 +1016,16 @@
return usbProxyFreeBSDEndpointClose(pProxyDev, index);
}
+static DECLCALLBACK(int) usbProxyFreeBSDWakeup(PUSBPROXYDEV pProxyDev)
+{
+ PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD);
+ size_t cbIgnored;
+
+ LogFlowFunc(("pProxyDev=%p\n", pProxyDev));
+
+ return RTPipeWrite(pDevFBSD->hPipeWakeupW, "", 1, &cbIgnored);
+}
+
/**
* The FreeBSD USB Proxy Backend.
*/
@@ -1005,6 +1047,7 @@
usbProxyFreeBSDUrbQueue,
usbProxyFreeBSDUrbCancel,
usbProxyFreeBSDUrbReap,
+ usbProxyFreeBSDWakeup,
0
};
More information about the freebsd-emulation
mailing list