vbox: enable usb support for guests

Fixes #1438
This commit is contained in:
Alexander Boettcher
2015-02-22 19:04:55 +01:00
committed by Christian Helmuth
parent d76220d6a9
commit c8a9b1802e
27 changed files with 293 additions and 56 deletions

View File

@ -117,6 +117,10 @@ extern "C" int VBoxDevicesRegister(PPDMDEVREGCB pCallbacks, uint32_t u32Version)
if (RT_FAILURE(rc))
return rc;
rc = pCallbacks->pfnRegister(pCallbacks, &g_DeviceOHCI);
if (RT_FAILURE(rc))
return rc;
return VINF_SUCCESS;
}

View File

@ -32,6 +32,7 @@ extern "C" int VBoxDriversRegister(PCPDMDRVREGCB pCallbacks, uint32_t u32Version
&g_DrvHostSerial,
&g_DrvVD,
&g_DrvHostInterface,
&g_DrvVUSBRootHub,
0
};

View File

@ -85,6 +85,7 @@ class Mouse;
class NATEngine;
class NATNetwork;
class NetworkAdapter;
class OUSBDevice;
class ParallelPort;
class PCIDeviceAttachment;
class SerialPort;
@ -162,7 +163,7 @@ typedef StorageController IStorageController;
typedef SystemProperties ISystemProperties;
typedef Token IToken;
typedef USBController IUSBController;
class IUSBDevice;
typedef OUSBDevice IUSBDevice;
typedef USBDeviceFilter IUSBDeviceFilter;
typedef USBDeviceFilters IUSBDeviceFilters;
typedef VirtualBox IVirtualBox;
@ -269,6 +270,7 @@ typedef struct IFsObjInfo { } IFsObjInfo;
#include "MediumImpl.h"
#include "SessionImpl.h"
#include "HostImpl.h"
#include "USBDeviceImpl.h"
class VRDEServerInfo { };
class EmulatedUSB { };

View File

@ -118,6 +118,8 @@ class VirtualBoxBase : public util::Lockable {
RWLockHandle * lockHandle() const;
};
class VirtualBoxTranslatable : public util::Lockable { };
template <typename T>
class Shareable {

View File

@ -2,6 +2,8 @@
#include "VirtualBoxBase.h"
#include <VBox/usbfilter.h>
static bool debug = false;
#define TRACE(X) \
@ -119,25 +121,20 @@ HRESULT Host::buildDVDDrivesList(MediaList &list) DUMMY(E_FAIL)
HRESULT Host::buildFloppyDrivesList(MediaList &list) DUMMY(E_FAIL)
#ifdef VBOX_WITH_USB
USBProxyService* Host::usbProxyService() DUMMY(nullptr)
HRESULT Host::addChild(HostUSBDeviceFilter *pChild) DUMMY(E_FAIL)
HRESULT Host::removeChild(HostUSBDeviceFilter *pChild) DUMMY(E_FAIL)
VirtualBox* Host::parent() DUMMY(nullptr)
USBProxyService* Host::usbProxyService()
{
TRACE(nullptr)
}
HRESULT Host::onUSBDeviceFilterChange(HostUSBDeviceFilter *aFilter) DUMMY(E_FAIL)
HRESULT Host::addChild(HostUSBDeviceFilter *pChild) DUMMY(E_FAIL)
HRESULT Host::removeChild(HostUSBDeviceFilter *pChild) DUMMY(E_FAIL)
VirtualBox* Host::parent() DUMMY(nullptr)
void Host::getUSBFilters(Host::USBDeviceFilterList *aGlobalFilters) DUMMY()
HRESULT Host::onUSBDeviceFilterChange(HostUSBDeviceFilter *, BOOL) DUMMY(E_FAIL)
void Host::getUSBFilters(Host::USBDeviceFilterList *aGlobalFilters) DUMMY()
HRESULT Host::checkUSBProxyService() TRACE(S_OK)
int USBFilterMatchRated(PCUSBFILTER pFilter, PCUSBFILTER pDevice) DUMMY(-1)
#endif
/*
void Host::getDVDInfoFromDevTree(std::list<ComObjPtr<Medium> > &list) DUMMY()
bool Host::getDVDInfoFromHal(std::list<ComObjPtr<Medium> > &list) DUMMY(false)
bool Host::getFloppyInfoFromHal(std::list< ComObjPtr<Medium> > &list) DUMMY(false)
void Host::parseMountTable(char *mountTable, std::list< ComObjPtr<Medium> > &list) DUMMY()
bool Host::validateDevice(const char *deviceNode, bool isCDROM) DUMMY(false)
HRESULT Host::checkUSBProxyService() DUMMY(E_FAIL)
HRESULT Host::updateNetIfList() DUMMY(E_FAIL)
void Host::registerDiskMetrics(PerformanceCollector *aCollector) DUMMY()
void Host::registerMetrics(PerformanceCollector *aCollector) DUMMY()
void Host::unregisterMetrics (PerformanceCollector *aCollector) DUMMY()
*/

View File

@ -6,6 +6,9 @@
#include "ProgressProxyImpl.h"
#include "SharedFolderImpl.h"
#include <VBox/usbfilter.h>
#include "USBProxyService.h"
static bool debug = false;
#define TRACE(X) \
@ -205,3 +208,29 @@ void Machine::ClientToken::getId(Utf8Str &strId)
HRESULT com::Initialize(bool fGui) TRACE(S_OK)
HRESULT USBProxyService::captureDeviceForVM(SessionMachine *, IN_GUID) DUMMY(E_FAIL)
HRESULT USBProxyService::detachAllDevicesFromVM(SessionMachine*, bool, bool) DUMMY(E_FAIL)
HRESULT USBProxyService::autoCaptureDevicesForVM(SessionMachine *) DUMMY(E_FAIL)
HRESULT USBProxyService::detachDeviceFromVM(SessionMachine*, GUID, bool) DUMMY(E_FAIL)
void matching::ParsedBoolFilter::parse(com::Bstr const&) DUMMY()
USBFILTERMATCH USBFilterGetMatchingMethod(PCUSBFILTER, USBFILTERIDX) DUMMY(USBFILTERMATCH_INVALID)
const char * USBFilterGetString(PCUSBFILTER pFilter, USBFILTERIDX enmFieldIdx) DUMMY(nullptr)
bool USBFilterIsMethodNumeric(USBFILTERMATCH enmMatchingMethod) DUMMY(false)
bool USBFilterMatch(PCUSBFILTER pFilter, PCUSBFILTER pDevice) DUMMY(false)
void USBFilterInit(PUSBFILTER pFilter, USBFILTERTYPE enmType) DUMMY()
int USBFilterSetStringExact(PUSBFILTER, USBFILTERIDX, const char *, bool) DUMMY(-1)
int USBFilterSetNumExact(PUSBFILTER, USBFILTERIDX, uint16_t, bool) DUMMY(-1)
int USBFilterGetNum(PCUSBFILTER pFilter, USBFILTERIDX enmFieldIdx) DUMMY(-1)
bool USBFilterIsNumericField(USBFILTERIDX enmFieldIdx) DUMMY(false)
bool USBFilterIsMethodString(USBFILTERMATCH enmMatchingMethod) DUMMY(false)
bool USBFilterIsStringField(USBFILTERIDX enmFieldIdx) DUMMY(false)
int USBFilterSetStringPattern(PUSBFILTER, USBFILTERIDX, const char *, bool) DUMMY(-1)
int USBFilterSetNumExpression(PUSBFILTER, USBFILTERIDX, const char *, bool) DUMMY(-1)
int USBFilterSetIgnore(PUSBFILTER pFilter, USBFILTERIDX enmFieldIdx) DUMMY(-1)

View File

@ -628,4 +628,8 @@ enum HWVirtExPropertyType_T
HWVirtExPropertyType_UnrestrictedExecution,
};
enum USBDeviceState_T
{
};
#endif /* !___VBox_com_defs_h */

View File

@ -0,0 +1,131 @@
+++ src/app/virtualbox/src/VBox/Devices/USB/VUSBDevice.cpp
@@ -230,7 +230,14 @@
if (i != VUSB_PIPE_DEFAULT)
{
vusbMsgFreeExtraData(pDev->aPipes[i].pCtrl);
+
+ int rc = RTCritSectDelete(&pDev->aPipes[i].CritSectCtrl);
+ AssertRC(rc);
+
memset(&pDev->aPipes[i], 0, sizeof(pDev->aPipes[i]));
+
+ rc = RTCritSectInit(&pDev->aPipes[i].CritSectCtrl);
+ AssertRC(rc);
}
}
memset(pDev->paIfStates, 0, pCfgDesc->Core.bNumInterfaces * sizeof(pDev->paIfStates[0]));
@@ -1134,7 +1134,7 @@
vusbUrbDoReapAsyncDev(pDev, RT_INDEFINITE_WAIT);
/* Process any URBs waiting to be cancelled first. */
- int rc = RTReqQueueProcess(pDev->hReqQueueSync, 0); /* Don't wait if there is nothing to do. */
+ int rc = RTReqQueueProcess(pDev->hReqQueueSync, pDev->enmState == VUSB_DEVICE_STATE_RESET ? 5 : 0); /* if in reset state (takes 10ms) sleep a bit - otherwise this thread consumes in this loop a lot of cpu time */
Assert(RT_SUCCESS(rc) || rc == VERR_TIMEOUT);
}
+++ src/app/virtualbox/src/VBox/Main/src-server/MachineImpl.cpp
@@ -13571,6 +13582,7 @@
AutoCaller autoCaller(this);
AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
+#if 0
#ifdef VBOX_WITH_USB
HRESULT rc = mUSBDeviceFilters->notifyProxy(true /* aInsertFilters */);
AssertComRC(rc);
@@ -13579,6 +13591,7 @@
USBProxyService *service = mParent->host()->usbProxyService();
AssertReturn(service, E_FAIL);
return service->autoCaptureDevicesForVM(this);
+#endif /* if 0 */
#else
return S_OK;
#endif
@@ -13601,6 +13614,7 @@
AutoCaller autoCaller(this);
AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
+#if 0
#ifdef VBOX_WITH_USB
HRESULT rc = mUSBDeviceFilters->notifyProxy(false /* aInsertFilters */);
AssertComRC(rc);
@@ -13609,6 +13623,7 @@
USBProxyService *service = mParent->host()->usbProxyService();
AssertReturn(service, E_FAIL);
return service->detachAllDevicesFromVM(this, !!aDone, false /* aAbnormal */);
+#endif /* if 0 */
#else
NOREF(aDone);
return S_OK;
+++ src/app/virtualbox/src/VBox/Main/include/Matching.h
@@ -291,10 +291,12 @@
return mValueAny || mValue == aValue;
}
+#if 0
bool isMatch (const BOOL aValue) const
{
return isMatch (bool (aValue == TRUE));
}
+#endif /* if 0 */
private:
+++ src/app/virtualbox/src/VBox/Main/src-server/USBDeviceFiltersImpl.cpp
@@ -1037,13 +1037,10 @@
LogFlowThisFunc(("aInsertFilters=%RTbool\n", aInsertFilters));
AutoCaller autoCaller(this);
- AssertComRCReturn(autoCaller.rc(), false);
+ AssertComRCReturnRC(autoCaller.rc());
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
- USBProxyService *pProxySvc = m->pHost->usbProxyService();
- AssertReturn(pProxySvc, E_FAIL);
-
DeviceFilterList::const_iterator it = m->llDeviceFilters->begin();
while (it != m->llDeviceFilters->end())
{
@@ -1054,6 +1051,9 @@
&& pFilter->getData().mRemote.isMatch(false) /* and if the filter is NOT remote */
)
{
+ USBProxyService *pProxySvc = m->pHost->usbProxyService();
+ AssertReturn(pProxySvc, E_FAIL);
+
if (aInsertFilters)
{
AssertReturn(pFilter->getId() == NULL, E_FAIL);
+++ src/app/virtualbox/src/VBox/Devices/USB/USBProxyDevice.cpp
@@ -843,10 +843,14 @@
/*
* Select backend and open the device.
*/
+
+ return PDMUSB_SET_ERROR(pUsbIns, VERR_NOT_SUPPORTED, N_("USBProxy: not supported on Genode"));
+#if 0
if (!fRemote)
pThis->pOps = &g_USBProxyDeviceHost;
else
pThis->pOps = &g_USBProxyDeviceVRDP;
+#endif /* if 0 */
pThis->pvInstanceDataR3 = RTMemAllocZ(pThis->pOps->cbBackend);
if (!pThis->pvInstanceDataR3)
+++ src/app/virtualbox/src/VBox/Devices/build/VBoxDD.cpp
@@ -39,6 +39,7 @@
NULL,
};
+#if 0
/**
* Register builtin devices.
@@ -329,6 +330,7 @@
return VINF_SUCCESS;
}
+#endif /* if 0 */
/**
* Register builtin USB device.

View File

@ -428,16 +428,6 @@
}
hrc = pMachine->COMGETTER(Name)(bstr.asOutParam()); H();
InsertConfigString(pCfg, "StreamName", bstr);
@@ -2430,7 +2446,9 @@
* The USB Controllers.
*/
com::SafeIfaceArray<IUSBController> usbCtrls;
+#if 0
hrc = pMachine->COMGETTER(USBControllers)(ComSafeArrayAsOutParam(usbCtrls)); H();
+#endif
bool fOhciPresent = false; /**< Flag whether at least one OHCI controller is presnet. */
for (size_t i = 0; i < usbCtrls.size(); ++i)
@@ -3533,6 +3551,8 @@
ComPtr<IMedium> pMedium;
hrc = pMediumAtt->COMGETTER(Medium)(pMedium.asOutParam()); H();

View File

@ -19,6 +19,7 @@
#include <VBox/vmm/pdmapi.h>
#include <VBox/vmm/pdmdrv.h>
#include <VBox/vmm/pdmdev.h>
#include <VBox/vmm/pdmusb.h>
#include "util.h"
@ -73,6 +74,7 @@ int PDMR3LdrGetSymbolR0Lazy(PVM pVM, const char *pszModule,
extern "C" int VBoxDriversRegister(PCPDMDRVREGCB, uint32_t);
extern "C" int VBoxDevicesRegister(PPDMDEVREGCB, uint32_t);
extern "C" int VBoxDriversRegister_Main(PCPDMDRVREGCB, uint32_t);
extern "C" int VBoxUsbRegister(PCPDMUSBREGCB, uint32_t);
static int dummy_VBoxDriversRegister(PCPDMDRVREGCB, uint32_t) { return VINF_SUCCESS; }
@ -102,6 +104,10 @@ int PDMR3LdrGetSymbolR3(PVM pVM, const char *pszModule, const char *pszSymbol,
*ppvValue = (void *)VBoxDevicesRegister;
return VINF_SUCCESS;
}
if (Genode::strcmp(pszSymbol, "VBoxUsbRegister") == 0) {
*ppvValue = (void *)VBoxUsbRegister;
return VINF_SUCCESS;
}
}
if (Genode::strcmp(pszModule, "VBoxDD2") == 0) {

View File

@ -57,7 +57,7 @@ static Genode::Cpu_session * get_cpu_session(RTTHREADTYPE type) {
/* upgrade memory of cpu session for frequent used thread type */
if (type == RTTHREADTYPE_IO)
Genode::env()->parent()->upgrade(con[type - 1]->cap(), "ram_quota=4096");
Genode::env()->parent()->upgrade(con[type - 1]->cap(), "ram_quota=8192");
return con[type - 1];
}