Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 9f0318ce846111224527cfd44c2da266cdec6498)
+++ uspace/Makefile	(revision 95622c4eab4bc4556d44737ddcadf5b86db90997)
@@ -53,4 +53,5 @@
 	app/usbinfo \
 	app/virtusbkbd \
+	app/virtusbhub \
 	app/netecho \
 	app/nettest1 \
Index: uspace/app/virtusbhub/Makefile
===================================================================
--- uspace/app/virtusbhub/Makefile	(revision 95622c4eab4bc4556d44737ddcadf5b86db90997)
+++ uspace/app/virtusbhub/Makefile	(revision 95622c4eab4bc4556d44737ddcadf5b86db90997)
@@ -0,0 +1,73 @@
+#
+# Copyright (c) 2011 Vojtech Horky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+USPACE_PREFIX = ../..
+# acronym for virtual USB hub
+# (it is really annoying to write long names)
+BINARY = vuh
+
+LIBS = $(LIBUSB_PREFIX)/libusb.a $(LIBUSBVIRT_PREFIX)/libusbvirt.a
+EXTRA_CFLAGS = -DSTANDALONE_HUB \
+	-DHUB_PORT_COUNT=10 \
+	-I$(LIBUSB_PREFIX)/include -I$(LIBUSBVIRT_PREFIX)/include -I$(LIBDRV_PREFIX)/include
+
+SOURCES = \
+	main.c \
+	$(STOLEN_VHC_SOURCES)
+
+STOLEN_VHC_SOURCES = \
+	hub.c \
+	virthub.c \
+	virthubops.c 
+STOLEN_VHC_HEADERS = \
+	hub.h \
+	virthub.h
+
+PRE_DEPEND = $(STOLEN_VHC_SOURCES) $(STOLEN_VHC_HEADERS)
+
+EXTRA_CLEAN = $(STOLEN_VHC_SOURCES) $(STOLEN_VHC_HEADERS)
+
+HUB_IN_VHC = $(USPACE_PREFIX)/drv/vhc/hub
+
+include $(USPACE_PREFIX)/Makefile.common
+
+
+hub.h: $(HUB_IN_VHC)/hub.h
+	ln -sfn $(HUB_IN_VHC)/$@ $@
+
+hub.c: $(HUB_IN_VHC)/hub.c
+	ln -sfn $(HUB_IN_VHC)/$@ $@
+
+virthub.h: $(HUB_IN_VHC)/virthub.h
+	ln -sfn $(HUB_IN_VHC)/$@ $@
+
+virthub.c: $(HUB_IN_VHC)/virthub.c
+	ln -sfn $(HUB_IN_VHC)/$@ $@
+
+virthubops.c: $(HUB_IN_VHC)/virthubops.c
+	ln -sfn $(HUB_IN_VHC)/$@ $@
Index: uspace/app/virtusbhub/main.c
===================================================================
--- uspace/app/virtusbhub/main.c	(revision 95622c4eab4bc4556d44737ddcadf5b86db90997)
+++ uspace/app/virtusbhub/main.c	(revision 95622c4eab4bc4556d44737ddcadf5b86db90997)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usbvirthub
+ * @{
+ */
+/**
+ * @file
+ * @brief Virtual USB hub.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <str_error.h>
+#include <bool.h>
+
+#include <usb/usb.h>
+#include <usb/descriptor.h>
+#include <usb/classes/hub.h>
+#include <usbvirt/device.h>
+#include <usbvirt/hub.h>
+
+#include "virthub.h"
+
+#define NAME "vuh"
+
+static usbvirt_device_t hub_device;
+
+#define VERBOSE_SLEEP(sec, msg, ...) \
+	do { \
+		char _status[HUB_PORT_COUNT + 2]; \
+		printf(NAME ": doing nothing for %zu seconds...\n", \
+		    (size_t) (sec)); \
+		fibril_sleep((sec)); \
+		virthub_get_status(&hub_device, _status, HUB_PORT_COUNT + 1); \
+		printf(NAME ": " msg " [%s]\n" #__VA_ARGS__, _status); \
+	} while (0)
+
+static void fibril_sleep(size_t sec)
+{
+	while (sec-- > 0) {
+		async_usleep(1000*1000);
+	}
+}
+
+static int dev1 = 1;
+
+int main(int argc, char * argv[])
+{
+	int rc;
+
+	printf(NAME ": virtual USB hub.\n");
+
+	rc = virthub_init(&hub_device);
+	if (rc != EOK) {
+		printf(NAME ": Unable to start communication with VHCD (%s).\n",
+		    str_error(rc));
+		return rc;
+	}
+	
+	while (true) {
+		VERBOSE_SLEEP(8, "will pretend device plug-in...");
+		virthub_connect_device(&hub_device, &dev1);
+
+		VERBOSE_SLEEP(8, "will pretend device un-plug...");
+		virthub_disconnect_device(&hub_device, &dev1);
+	}
+
+	usbvirt_disconnect(&hub_device);
+	
+	return 0;
+}
+
+
+/** @}
+ */
Index: uspace/doc/doxygroups.h
===================================================================
--- uspace/doc/doxygroups.h	(revision 9f0318ce846111224527cfd44c2da266cdec6498)
+++ uspace/doc/doxygroups.h	(revision 95622c4eab4bc4556d44737ddcadf5b86db90997)
@@ -195,4 +195,13 @@
 		 */
 
+		/**
+		 * @defgroup usbvirthub Virtual USB hub
+		 * @ingroup usbvirt
+		 * @brief Extra virtual USB hub for virtual host controller.
+		 * @details
+		 * Some of the sources are shared with virtual host controller,
+		 * see @ref drvusbvhc for the rest of the files.
+		 */
+
 	 /**
 	  * @defgroup drvusbhub USB hub driver
Index: uspace/drv/vhc/hub/hub.h
===================================================================
--- uspace/drv/vhc/hub/hub.h	(revision 9f0318ce846111224527cfd44c2da266cdec6498)
+++ uspace/drv/vhc/hub/hub.h	(revision 95622c4eab4bc4556d44737ddcadf5b86db90997)
@@ -38,5 +38,7 @@
 #include <fibril_synch.h>
 
+#ifndef HUB_PORT_COUNT
 #define HUB_PORT_COUNT 2
+#endif
 #define BITS2BYTES(bits) (bits ? ((((bits)-1)>>3)+1) : 0)
 
Index: uspace/drv/vhc/hub/virthub.c
===================================================================
--- uspace/drv/vhc/hub/virthub.c	(revision 9f0318ce846111224527cfd44c2da266cdec6498)
+++ uspace/drv/vhc/hub/virthub.c	(revision 95622c4eab4bc4556d44737ddcadf5b86db90997)
@@ -164,7 +164,13 @@
 	dev->device_data = hub;
 
-	usbvirt_connect_local(dev);
-
-	return EOK;
+	int rc;
+#ifdef STANDALONE_HUB
+	dev->name = "hub";
+	rc = usbvirt_connect(dev);
+#else
+	rc = usbvirt_connect_local(dev);
+#endif
+
+	return rc;
 }
 
Index: uspace/drv/vhc/hub/virthub.h
===================================================================
--- uspace/drv/vhc/hub/virthub.h	(revision 9f0318ce846111224527cfd44c2da266cdec6498)
+++ uspace/drv/vhc/hub/virthub.h	(revision 95622c4eab4bc4556d44737ddcadf5b86db90997)
@@ -37,6 +37,11 @@
 
 #include <usbvirt/device.h>
+#include "hub.h"
+
+#ifdef STANDALONE_HUB
+#define virtdev_connection_t int
+#else
 #include "../devices.h"
-#include "hub.h"
+#endif
 
 /** Endpoint number for status change pipe. */
