Index: /trunk/src/VBox/ValidationKit/tests/usb/tdUsb1.py
===================================================================
--- /trunk/src/VBox/ValidationKit/tests/usb/tdUsb1.py	(revision 60521)
+++ /trunk/src/VBox/ValidationKit/tests/usb/tdUsb1.py	(revision 60522)
@@ -64,16 +64,9 @@
     # and the hardware type.
     kdGadgetParams = {
-        # The following is for local testing and not for the test lab.
-        #'adaris': {
-        #    'Low':   ('beaglebone',),
-        #    'Full':  ('beaglebone',),
-        #    'High':  ('beaglebone',),
-        #    'Super': ('odroidxu3',)
-        #},
         'adaris': {
-            'Low':   ('127.0.0.1', 0),
-            'Full':  ('127.0.0.1', 0),
-            'High':  ('127.0.0.1', 0),
-            'Super': ('127.0.0.1', 0)
+            'Low':   ('usbtest.de.oracle.com', None),
+            'Full':  ('usbtest.de.oracle.com', None),
+            'High':  ('usbtest.de.oracle.com', None),
+            'Super': ('usbtest.de.oracle.com', None)
         },
     };
@@ -105,4 +98,6 @@
         self.cUsbReattachCycles    = self.cUsbReattachCyclesDef;
         self.sHostname             = socket.gethostname().lower();
+        self.sGadgetHostnameDef    = 'usbtest.de.oracle.com';
+        self.uGadgetPortDef        = None;
 
     #
@@ -131,4 +126,10 @@
         reporter.log('  --usb-reattach-cycles <cycles>');
         reporter.log('      Default: %s' % (self.cUsbReattachCyclesDef));
+        reporter.log('  --hostname: <hostname>');
+        reporter.log('      Default: %s' % (self.sHostname));
+        reporter.log('  --default-gadget-host <hostname>');
+        reporter.log('      Default: %s' % (self.sGadgetHostnameDef));
+        reporter.log('  --default-gadget-port <port>');
+        reporter.log('      Default: %s' % (6042));
         return rc;
 
@@ -196,4 +197,21 @@
                 raise base.InvalidOption('The "--usb-reattach-cycles" value "%s" is zero or negative.' \
                     % (self.cUsbReattachCycles,));
+        elif asArgs[iArg] == '--hostname':
+            iArg += 1;
+            if iArg >= len(asArgs): raise base.InvalidOption('The "--hostname" takes a hostname');
+            self.sHostname = asArgs[iArg];
+        elif asArgs[iArg] == '--default-gadget-host':
+            iArg += 1;
+            if iArg >= len(asArgs): raise base.InvalidOption('The "--default-gadget-host" takes a hostname');
+            self.sGadgetHostnameDef = asArgs[iArg];
+        elif asArgs[iArg] == '--default-gadget-port':
+            iArg += 1;
+            if iArg >= len(asArgs): raise base.InvalidOption('The "--default-gadget-port" takes port number');
+            try:    self.uGadgetPortDef = int(asArgs[iArg]);
+            except: raise base.InvalidOption('The "--default-gadget-port" value "%s" is not an integer' \
+                    % (asArgs[iArg],));
+            if self.uGadgetPortDef <= 0:
+                raise base.InvalidOption('The "--default-gadget-port" value "%s" is zero or negative.' \
+                    % (self.uGadgetPortDef,));
         else:
             return vbox.TestDriver.parseOption(self, asArgs, iArg);
@@ -271,5 +289,5 @@
     def getGadgetParams(self, sHostname, sSpeed):
         """
-        Returns the gadget hostname and type from the
+        Returns the gadget hostname and port from the
         given hostname the test is running on and device speed we want to test.
         """
@@ -278,5 +296,5 @@
             return kdGadgetsConfigured.get(sSpeed);
 
-        return (None, None);
+        return (self.sGadgetHostnameDef, self.uGadgetPortDef);
 
     #
@@ -288,9 +306,9 @@
         """
         # Get configured USB test devices from hostname we are running on
-        sGadgetHost, _ = self.getGadgetParams(self.sHostname, sSpeed);
+        sGadgetHost, uGadgetPort = self.getGadgetParams(self.sHostname, sSpeed);
 
         oUsbGadget = usbgadget2.UsbGadget();
         reporter.log('Connecting to UTS: ' + sGadgetHost);
-        fRc = oUsbGadget.connectTo(30 * 1000, sGadgetHost);
+        fRc = oUsbGadget.connectTo(30 * 1000, sGadgetHost, uPort = uGadgetPort);
         if fRc is True:
             reporter.log('Connect succeeded');
Index: /trunk/src/VBox/ValidationKit/tests/usb/tst-utsgadget.py
===================================================================
--- /trunk/src/VBox/ValidationKit/tests/usb/tst-utsgadget.py	(revision 60521)
+++ /trunk/src/VBox/ValidationKit/tests/usb/tst-utsgadget.py	(revision 60522)
@@ -37,4 +37,5 @@
 sys.path.insert(0, '.');
 sys.path.insert(0, '..');
+sys.path.insert(0, '../..');
 import usbgadget2 as usbgadget;
 import testdriver.reporter as reporter
@@ -98,9 +99,25 @@
 
     if fStdTests:
+        if oGadget.getUsbIpPort() is not None:
+            rc = True;
+        else:
+            rc = False;
+        print '%s: getUsbIpPort() -> %s' % (boolRes(rc), oGadget.getUsbIpPort());
 
+        rc = oGadget.impersonate(usbgadget.g_ksGadgetImpersonationTest);
+        print '%s: impersonate()' % (boolRes(rc));
+
+        rc = oGadget.disconnectUsb();
+        print '%s: disconnectUsb()' % (boolRes(rc));
+
+        rc = oGadget.connectUsb();
+        print '%s: connectUsb()' % (boolRes(rc));
+
+        rc = oGadget.clearImpersonation();
+        print '%s: clearImpersonation()' % (boolRes(rc));
 
         # Done
         rc = oGadget.disconnectFrom();
-        print '%s: disconnect() -> %s' % (boolRes(rc), rc);
+        print '%s: disconnectFrom() -> %s' % (boolRes(rc), rc);
 
     if g_cFailures != 0:
Index: /trunk/src/VBox/ValidationKit/tests/usb/usbgadget2.py
===================================================================
--- /trunk/src/VBox/ValidationKit/tests/usb/usbgadget2.py	(revision 60521)
+++ /trunk/src/VBox/ValidationKit/tests/usb/usbgadget2.py	(revision 60522)
@@ -758,5 +758,5 @@
     def taskGadgetDestroy(self, iGadgetId):
         """Destroys the given gadget handle on UTS"""
-        fRc = self.sendMsg("GDGTDTOR", (iGadgetId, ));
+        fRc = self.sendMsg("GDGTDTOR", (iGadgetId, zeroByteArray(12)));
         if fRc is True:
             fRc = self.recvAckLogged("GDGTDTOR");
@@ -765,5 +765,5 @@
     def taskGadgetConnect(self, iGadgetId):
         """Connects the given gadget handle on UTS"""
-        fRc = self.sendMsg("GDGTCNCT", (iGadgetId, ));
+        fRc = self.sendMsg("GDGTCNCT", (iGadgetId, zeroByteArray(12)));
         if fRc is True:
             fRc = self.recvAckLogged("GDGTCNCT");
@@ -772,5 +772,5 @@
     def taskGadgetDisconnect(self, iGadgetId):
         """Disconnects the given gadget handle from UTS"""
-        fRc = self.sendMsg("GDGTDCNT", (iGadgetId, ));
+        fRc = self.sendMsg("GDGTDCNT", (iGadgetId, zeroByteArray(12)));
         if fRc is True:
             fRc = self.recvAckLogged("GDGTDCNT");
@@ -877,5 +877,5 @@
         """
         return self.startTask(cMsTimeout, fIgnoreErrors, "GadgetConnect", self.taskGadgetConnect, \
-                              (long(iGadgetId), ));
+                              (iGadgetId, ));
 
     def syncGadgetConnect(self, iGadgetId, cMsTimeout = 30000, fIgnoreErrors = False):
@@ -892,5 +892,5 @@
         """
         return self.startTask(cMsTimeout, fIgnoreErrors, "GadgetDisconnect", self.taskGadgetDisconnect, \
-                              (long(iGadgetId), ));
+                              (iGadgetId, ));
 
     def syncGadgetDisconnect(self, iGadgetId, cMsTimeout = 30000, fIgnoreErrors = False):
@@ -1297,5 +1297,5 @@
         self.iUsbIpPort     = None;
 
-    def _clearImpersonation(self):
+    def clearImpersonation(self):
         """
         Removes the current impersonation of the gadget.
@@ -1305,4 +1305,5 @@
         if self.idGadget is not None:
             fRc = self.oUtsSession.syncGadgetDestroy(self.idGadget);
+            self.idGadget = None;
 
         return fRc;
@@ -1327,10 +1328,16 @@
 
         # Clear any previous impersonation
-        self._clearImpersonation();
+        self.clearImpersonation();
         self.sImpersonation = sImpersonation;
 
         fRc = False;
         if sImpersonation == g_ksGadgetImpersonationTest:
-            fRc = self.oUtsSession.syncGadgetCreate(g_kiGadgetTypeTest, g_kiGadgetAccessUsbIp);
+            fDone = self.oUtsSession.syncGadgetCreate(g_kiGadgetTypeTest, g_kiGadgetAccessUsbIp);
+            if fDone is True and self.oUtsSession.isSuccess():
+                # Get the gadget ID.
+                _, _, abPayload = self.oUtsSession.getLastReply();
+
+                fRc = True;
+                self.idGadget = getU32(abPayload, 16);
         else:
             reporter.log('Invalid or unsupported impersonation');
@@ -1388,5 +1395,5 @@
         fRc = True;
 
-        self._clearImpersonation();
+        self.clearImpersonation();
         if self.oUtsSession is not None:
             fRc = self.oUtsSession.syncDisconnect();
Index: /trunk/src/VBox/ValidationKit/utils/usb/UsbTest.cpp
===================================================================
--- /trunk/src/VBox/ValidationKit/utils/usb/UsbTest.cpp	(revision 60521)
+++ /trunk/src/VBox/ValidationKit/utils/usb/UsbTest.cpp	(revision 60522)
@@ -30,5 +30,7 @@
 *   Header Files                                                                                                                 *
 *********************************************************************************************************************************/
+#include <iprt/dir.h>
 #include <iprt/err.h>
+#include <iprt/file.h>
 #include <iprt/getopt.h>
 #include <iprt/path.h>
@@ -38,5 +40,4 @@
 #include <iprt/string.h>
 #include <iprt/test.h>
-#include <iprt/file.h>
 
 #include <unistd.h>
@@ -273,54 +274,69 @@
      * Assumption is that the path looks like /dev/bus/usb/%3d/%3d.
      */
-    uint8_t uBus = 1;
-    bool fBusExists = false;
-    char aszDevPath[64];
-
-    RT_ZERO(aszDevPath);
-
-    do
+    char *pszDevPath = NULL;
+
+    PRTDIR pDirUsb = NULL;
+    int rc = RTDirOpen(&pDirUsb, "/dev/bus/usb");
+    if (RT_SUCCESS(rc))
     {
-        RTStrPrintf(aszDevPath, sizeof(aszDevPath), "/dev/bus/usb/%03d", uBus);
-
-        fBusExists = RTPathExists(aszDevPath);
-
-        if (fBusExists)
+        do
         {
-            /* Check every device. */
-            bool fDevExists = false;
-            uint8_t uDev = 1;
-
-            do
+            RTDIRENTRY DirUsbBus;
+            rc = RTDirRead(pDirUsb, &DirUsbBus, NULL);
+            if (RT_SUCCESS(rc))
             {
-                RTStrPrintf(aszDevPath, sizeof(aszDevPath), "/dev/bus/usb/%03d/%03d", uBus, uDev);
-
-                fDevExists = RTPathExists(aszDevPath);
-
-                if (fDevExists)
+                char aszPath[RTPATH_MAX + 1];
+                RTStrPrintf(&aszPath[0], RT_ELEMENTS(aszPath), "/dev/bus/usb/%s", DirUsbBus.szName);
+
+                PRTDIR pDirUsbBus = NULL;
+                rc = RTDirOpen(&pDirUsbBus, &aszPath[0]);
+                if (RT_SUCCESS(rc))
                 {
-                    RTFILE hFileDev;
-                    int rc = RTFileOpen(&hFileDev, aszDevPath, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE);
-                    if (RT_SUCCESS(rc))
+                    do
                     {
-                        USBDEVDESC DevDesc;
-
-                        rc = RTFileRead(hFileDev, &DevDesc, sizeof(DevDesc), NULL);
-                        RTFileClose(hFileDev);
-
-                        if (   RT_SUCCESS(rc)
-                            && DevDesc.idVendor == 0x0525
-                            && DevDesc.idProduct == 0xa4a0)
-                            return RTStrDup(aszDevPath);
-                    }
+                        RTDIRENTRY DirUsbDev;
+                        rc = RTDirRead(pDirUsbBus, &DirUsbDev, NULL);
+                        if (RT_SUCCESS(rc))
+                        {
+                            char aszPathDev[RTPATH_MAX + 1];
+                            RTStrPrintf(&aszPathDev[0], RT_ELEMENTS(aszPathDev), "/dev/bus/usb/%s/%s",
+                                        DirUsbBus.szName, DirUsbDev.szName);
+
+                            RTFILE hFileDev;
+                            rc = RTFileOpen(&hFileDev, aszPathDev, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE);
+                            if (RT_SUCCESS(rc))
+                            {
+                                USBDEVDESC DevDesc;
+
+                                rc = RTFileRead(hFileDev, &DevDesc, sizeof(DevDesc), NULL);
+                                RTFileClose(hFileDev);
+
+                                if (   RT_SUCCESS(rc)
+                                    && DevDesc.idVendor == 0x0525
+                                    && DevDesc.idProduct == 0xa4a0)
+                                    pszDevPath = RTStrDup(aszPathDev);
+                            }
+
+                            rc = VINF_SUCCESS;
+                        }
+                        else if (rc != VERR_NO_MORE_FILES)
+                            rc = VINF_SUCCESS;
+
+                    } while (   RT_SUCCESS(rc)
+                             && !pszDevPath);
+
+                    rc = VINF_SUCCESS;
+                    RTDirClose(pDirUsbBus);
                 }
-
-                uDev++;
-            } while (fDevExists);
-        }
-
-        uBus++;
-    } while (fBusExists);
-
-    return NULL;
+            }
+            else if (rc != VERR_NO_MORE_FILES)
+                rc = VINF_SUCCESS;
+        } while (   RT_SUCCESS(rc)
+                 && !pszDevPath);
+
+        RTDirClose(pDirUsb);
+    }
+
+    return pszDevPath;
 }
 
Index: /trunk/src/VBox/ValidationKit/utils/usb/UsbTestService.cpp
===================================================================
--- /trunk/src/VBox/ValidationKit/utils/usb/UsbTestService.cpp	(revision 60521)
+++ /trunk/src/VBox/ValidationKit/utils/usb/UsbTestService.cpp	(revision 60522)
@@ -832,5 +832,5 @@
         rc = utsDoGadgetCreate(pClient, pPktHdr);
     else if (utsIsSameOpcode(pPktHdr, UTSPKT_OPCODE_GADGET_DESTROY))
-        rc = utsDoGadgetCreate(pClient, pPktHdr);
+        rc = utsDoGadgetDestroy(pClient, pPktHdr);
     else if (utsIsSameOpcode(pPktHdr, UTSPKT_OPCODE_GADGET_CONNECT))
         rc = utsDoGadgetConnect(pClient, pPktHdr);
Index: /trunk/src/VBox/ValidationKit/utils/usb/UsbTestServiceGadgetClassTest.cpp
===================================================================
--- /trunk/src/VBox/ValidationKit/utils/usb/UsbTestServiceGadgetClassTest.cpp	(revision 60521)
+++ /trunk/src/VBox/ValidationKit/utils/usb/UsbTestServiceGadgetClassTest.cpp	(revision 60522)
@@ -32,4 +32,5 @@
 #include <iprt/string.h>
 #include <iprt/symlink.h>
+#include <iprt/thread.h>
 #include <iprt/types.h>
 
@@ -359,4 +360,6 @@
                     if (RT_SUCCESS(rc))
                         rc = RTLinuxSysFsWriteStrFile(pClass->pszUdc, 0, NULL, "%s/UDC", pClass->pszGadgetPath);
+                    if (RT_SUCCESS(rc))
+                        RTThreadSleep(500); /* Fudge: Sleep a bit to give the device a chance to appear on the host so binding succeeds. */
                 }
             }
@@ -406,5 +409,9 @@
 static DECLCALLBACK(int) utsGadgetClassTestConnect(PUTSGADGETCLASSINT pClass)
 {
-    return RTLinuxSysFsWriteStrFile("connect", 0, NULL, "/sys/class/udc/%s/soft_connect", pClass->pszUdc);
+    int rc = RTLinuxSysFsWriteStrFile("connect", 0, NULL, "/sys/class/udc/%s/soft_connect", pClass->pszUdc);
+    if (RT_SUCCESS(rc))
+        RTThreadSleep(500); /* Fudge: Sleep a bit to give the device a chance to appear on the host so binding succeeds. */
+
+    return rc;
 }
 
Index: /trunk/src/VBox/ValidationKit/utils/usb/UsbTestServicePlatform-linux.cpp
===================================================================
--- /trunk/src/VBox/ValidationKit/utils/usb/UsbTestServicePlatform-linux.cpp	(revision 60521)
+++ /trunk/src/VBox/ValidationKit/utils/usb/UsbTestServicePlatform-linux.cpp	(revision 60522)
@@ -178,4 +178,5 @@
                                         g_paDummyHcd[idxHcdCur].uBusId      = uBusId;
                                         g_paDummyHcd[idxHcdCur].fAvailable  = true;
+                                        idxHcdCur++;
                                     }
                                 }
@@ -300,5 +301,5 @@
         pszIdx++;
         uint32_t idxHcd = 0;
-        rc = RTStrToUInt32Ex(pszUdc, NULL, 10, &idxHcd);
+        rc = RTStrToUInt32Ex(pszIdx, NULL, 10, &idxHcd);
         if (RT_SUCCESS(rc))
         {
