HRESULT USBDeviceFilters::insertDeviceFilter(ULONG aPosition, const ComPtr<IUSBDeviceFilter> &aFilter) { #ifdef VBOX_WITH_USB /* the machine needs to be mutable */ AutoMutableStateDependency adep(m->pParent); if (FAILED(adep.rc())) return adep.rc(); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); IUSBDeviceFilter *iFilter = aFilter; ComObjPtr<USBDeviceFilter> pFilter = static_cast<USBDeviceFilter*>(iFilter); if (pFilter->mInList) return setError(VBOX_E_INVALID_OBJECT_STATE, tr("The given USB device pFilter is already in the list")); /* backup the list before modification */ m->llDeviceFilters.backup(); /* iterate to the position... */ DeviceFilterList::iterator it; if (aPosition < m->llDeviceFilters->size()) { it = m->llDeviceFilters->begin(); std::advance(it, aPosition); } else it = m->llDeviceFilters->end(); /* ...and insert */ m->llDeviceFilters->insert(it, pFilter); pFilter->mInList = true; /* notify the proxy (only when it makes sense) */ if (pFilter->i_getData().mActive && Global::IsOnline(adep.machineState()) && pFilter->i_getData().mRemote.isMatch(false)) { USBProxyService *pProxySvc = m->pHost->i_usbProxyService(); ComAssertRet(pProxySvc, E_FAIL); ComAssertRet(pFilter->i_getId() == NULL, E_FAIL); pFilter->i_getId() = pProxySvc->insertFilter(&pFilter->i_getData().mUSBFilter); } alock.release(); AutoWriteLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS); m->pParent->i_setModified(Machine::IsModified_USB); mlock.release(); return S_OK; #else /* VBOX_WITH_USB */ NOREF(aPosition); NOREF(aFilter); ReturnComNotImplemented(); #endif /* VBOX_WITH_USB */ }
/** * Called by setter methods of all USB device filters. * * @note Locks nothing. */ HRESULT USBController::onDeviceFilterChange (USBDeviceFilter *aFilter, BOOL aActiveChanged /* = FALSE */) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); /* we need the machine state */ AutoAnyStateDependency adep(m->pParent); AssertComRCReturnRC(adep.rc()); /* nothing to do if the machine isn't running */ if (!Global::IsOnline (adep.machineState())) return S_OK; /* we don't modify our data fields -- no need to lock */ if ( aFilter->mInList && m->pParent->isRegistered()) { USBProxyService *service = m->pHost->usbProxyService(); ComAssertRet(service, E_FAIL); if (aActiveChanged) { if (aFilter->getData().mRemote.isMatch (false)) { /* insert/remove the filter from the proxy */ if (aFilter->getData().mActive) { ComAssertRet(aFilter->getId() == NULL, E_FAIL); aFilter->getId() = service->insertFilter(&aFilter->getData().mUSBFilter); } else { ComAssertRet(aFilter->getId() != NULL, E_FAIL); service->removeFilter(aFilter->getId()); aFilter->getId() = NULL; } } } else { if (aFilter->getData().mActive) { /* update the filter in the proxy */ ComAssertRet(aFilter->getId() != NULL, E_FAIL); service->removeFilter(aFilter->getId()); if (aFilter->getData().mRemote.isMatch (false)) { aFilter->getId() = service->insertFilter(&aFilter->getData().mUSBFilter); } } } } return S_OK; }
/** * Initializes the audio adapter object. * * @param aParent Handle of the parent object. */ HRESULT AudioAdapter::init (Machine *aParent) { LogFlowThisFunc(("aParent=%p\n", aParent)); ComAssertRet(aParent, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); /* Get the default audio driver out of the system properties */ ComPtr<IVirtualBox> VBox; HRESULT rc = aParent->COMGETTER(Parent)(VBox.asOutParam()); if (FAILED(rc)) return rc; ComPtr<ISystemProperties> sysProps; rc = VBox->COMGETTER(SystemProperties)(sysProps.asOutParam()); if (FAILED(rc)) return rc; AudioDriverType_T defaultAudioDriver; rc = sysProps->COMGETTER(DefaultAudioDriver)(&defaultAudioDriver); if (FAILED(rc)) return rc; unconst(mParent) = aParent; /* mPeer is left null */ mData.allocate(); mData->mAudioDriver = defaultAudioDriver; /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
HRESULT USBDeviceFilter::setRemote(const com::Utf8Str &aRemote) { /* the machine needs to be mutable */ AutoMutableOrSavedOrRunningStateDependency adep(mParent->i_getMachine()); if (FAILED(adep.rc())) return adep.rc(); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); Bstr bRemote = Bstr(aRemote).raw(); if (bd->mRemote.string() != bRemote) { BackupableUSBDeviceFilterData::BOOLFilter flt = bRemote; ComAssertRet(!flt.isNull(), E_FAIL); if (!flt.isValid()) return setError(E_INVALIDARG, tr("Remote state filter string '%s' is not valid (error at position %d)"), aRemote.c_str(), flt.errorPosition() + 1); m_fModified = true; ComObjPtr<Machine> pMachine = mParent->i_getMachine(); bd.backup(); bd->mRemote = flt; // leave the lock before informing callbacks alock.release(); AutoWriteLock mlock(pMachine COMMA_LOCKVAL_SRC_POS); pMachine->i_setModified(Machine::IsModified_USB); mlock.release(); return mParent->i_onDeviceFilterChange(this); } return S_OK; }
/** * Initializes the guest object given another guest object * (a kind of copy constructor). This object makes a private copy of data * of the original object passed as an argument. * * @note Locks @a aThat object for reading. */ HRESULT USBDeviceFilter::initCopy(USBDeviceFilters *aParent, USBDeviceFilter *aThat) { LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat)); ComAssertRet(aParent && aThat, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = aParent; /* mPeer is left null */ m_fModified = false; /* sanity */ AutoCaller thatCaller(aThat); AssertComRCReturnRC(thatCaller.rc()); AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS); bd.attachCopy(aThat->bd); /* reset the arbitrary ID field * (this field is something unique that two distinct objects, even if they * are deep copies of each other, should not share) */ bd->mId = NULL; mInList = aThat->mInList; /* Confirm successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the USB device filter object (short version). * * @param aParent Handle of the parent object. */ HRESULT HostUSBDeviceFilter::init(Host *aParent, IN_BSTR aName) { LogFlowThisFunc(("aParent=%p\n", aParent)); ComAssertRet(aParent && aName && *aName, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = aParent; /* register with parent early, since uninit() will unconditionally * unregister on failure */ mParent->i_addChild(this); bd.allocate(); bd->mData.strName = Utf8Str(aName); bd->mData.fActive = FALSE; mInList = false; USBFilterInit(&bd->mUSBFilter, USBFILTERTYPE_IGNORE); bd->mRemote = NULL; bd->mData.ulMaskedInterfaces = 0; /* Confirm successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the USB controller object. * * @returns COM result indicator. * @param aParent Pointer to our parent object. * @param aName The name of the USB controller. * @param enmType The USB controller type. */ HRESULT USBController::init(Machine *aParent, const Utf8Str &aName, USBControllerType_T enmType) { LogFlowThisFunc(("aParent=%p aName=\"%s\"\n", aParent, aName.c_str())); ComAssertRet(aParent && !aName.isEmpty(), E_INVALIDARG); if ( (enmType <= USBControllerType_Null) || (enmType > USBControllerType_XHCI)) return setError(E_INVALIDARG, tr("Invalid USB controller type")); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); m = new Data(aParent); /* mPeer is left null */ m->bd.allocate(); m->bd->strName = aName; m->bd->enmType = enmType; /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the guest object given another guest object * (a kind of copy constructor). This object makes a private copy of data * of the original object passed as an argument. * * @note Locks @a aThat object for reading. */ HRESULT NetworkAdapter::initCopy(Machine *aParent, NetworkAdapter *aThat) { LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat)); ComAssertRet(aParent && aThat, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = aParent; /* mPeer is left null */ unconst(mNATEngine).createObject(); mNATEngine->initCopy(aParent, this, aThat->mNATEngine); AutoCaller thatCaller(aThat); AssertComRCReturnRC(thatCaller.rc()); AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS); mData.attachCopy(aThat->mData); /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the machine debugger object. * * @returns COM result indicator * @param aParent handle of our parent object */ HRESULT MachineDebugger::init(Console *aParent) { LogFlowThisFunc(("aParent=%p\n", aParent)); ComAssertRet(aParent, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = aParent; for (unsigned i = 0; i < RT_ELEMENTS(maiQueuedEmExecPolicyParams); i++) maiQueuedEmExecPolicyParams[i] = UINT8_MAX; mSingleStepQueued = -1; mRecompileUserQueued = -1; mRecompileSupervisorQueued = -1; mPatmEnabledQueued = -1; mCsamEnabledQueued = -1; mLogEnabledQueued = -1; mVirtualTimeRateQueued = UINT32_MAX; mFlushMode = false; /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the medium attachment object given another guest object * (a kind of copy constructor). This object makes a private copy of data * of the original object passed as an argument. */ HRESULT MediumAttachment::initCopy(Machine *aParent, MediumAttachment *aThat) { LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat)); ComAssertRet(aParent && aThat, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); m = new Data(aParent); /* m->pPeer is left null */ AutoCaller thatCaller(aThat); AssertComRCReturnRC(thatCaller.rc()); AutoReadLock thatlock(aThat COMMA_LOCKVAL_SRC_POS); m->bd.attachCopy(aThat->m->bd); /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); /* Construct a short log name for this attachment. */ i_updateLogName(); LogFlowThisFunc(("LEAVE - %s\n", i_getLogName())); return S_OK; }
HRESULT DisplaySourceBitmap::init(ComObjPtr<Display> pDisplay, unsigned uScreenId, DISPLAYFBINFO *pFBInfo) { LogFlowThisFunc(("[%u]\n", uScreenId)); ComAssertRet(!pDisplay.isNull(), E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); m.pDisplay = pDisplay; m.uScreenId = uScreenId; m.pFBInfo = pFBInfo; m.pu8Allocated = NULL; m.pu8Address = NULL; m.ulWidth = 0; m.ulHeight = 0; m.ulBitsPerPixel = 0; m.ulBytesPerLine = 0; m.bitmapFormat = BitmapFormat_Opaque; int rc = initSourceBitmap(uScreenId, pFBInfo); if (RT_FAILURE(rc)) return E_FAIL; /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the USB device filter object (short version). * * @param aParent Handle of the parent object. */ HRESULT USBDeviceFilter::init(USBDeviceFilters *aParent, IN_BSTR aName) { LogFlowThisFunc(("aParent=%p\n", aParent)); ComAssertRet(aParent && aName && *aName, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = aParent; /* mPeer is left null */ m_fModified = false; bd.allocate(); bd->mData.strName = Utf8Str(aName); bd->mData.fActive = FALSE; bd->mData.ulMaskedInterfaces = 0; /* initialize all filters to any match using null string */ USBFilterInit(&bd->mUSBFilter, USBFILTERTYPE_CAPTURE); bd->mRemote = NULL; mInList = false; /* Confirm successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the bandwidth group object. * * @returns COM result indicator. * @param aParent Pointer to our parent object. * @param aName Name of the bandwidth group. * @param aType Type of the bandwidth group (net, disk). * @param aMaxBytesPerSec Maximum bandwidth for the bandwidth group. */ HRESULT BandwidthGroup::init(BandwidthControl *aParent, const Utf8Str &aName, BandwidthGroupType_T aType, LONG64 aMaxBytesPerSec) { LogFlowThisFunc(("aParent=%p aName=\"%s\"\n", aParent, aName.c_str())); ComAssertRet(aParent && !aName.isEmpty(), E_INVALIDARG); if ( (aType <= BandwidthGroupType_Null) || (aType > BandwidthGroupType_Network)) return setError(E_INVALIDARG, tr("Invalid bandwidth group type type")); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); m = new Data(aParent); /* m->pPeer is left null */ m->bd.allocate(); m->bd->strName = aName; m->bd->enmType = aType; m->bd->cReferences = 0; m->bd->aMaxBytesPerSec = aMaxBytesPerSec; /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
HRESULT Guest::facilityUpdate(VBoxGuestFacilityType enmFacility, VBoxGuestFacilityStatus enmStatus) { ComAssertRet(enmFacility < INT32_MAX, E_INVALIDARG); HRESULT rc; RTTIMESPEC tsNow; RTTimeNow(&tsNow); FacilityMapIter it = mData.mFacilityMap.find((AdditionsFacilityType_T)enmFacility); if (it != mData.mFacilityMap.end()) { AdditionsFacility *pFac = it->second; rc = pFac->update((AdditionsFacilityStatus_T)enmStatus, tsNow); } else { ComObjPtr<AdditionsFacility> pFacility; pFacility.createObject(); ComAssert(!pFacility.isNull()); rc = pFacility->init(this, (AdditionsFacilityType_T)enmFacility, (AdditionsFacilityStatus_T)enmStatus); if (SUCCEEDED(rc)) mData.mFacilityMap.insert(std::make_pair((AdditionsFacilityType_T)enmFacility, pFacility)); } LogFlowFunc(("Returned with rc=%Rrc\n")); return rc; }
/** * Initializes the mouse object. * * @returns COM result indicator * @param parent handle of our parent object */ HRESULT Mouse::init (Console *parent) { LogFlowThisFunc(("\n")); ComAssertRet(parent, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = parent; #ifndef VBOXBFE_WITHOUT_COM unconst(mEventSource).createObject(); HRESULT rc = mEventSource->init(static_cast<IMouse*>(this)); AssertComRCReturnRC(rc); mMouseEvent.init(mEventSource, VBoxEventType_OnGuestMouse, 0, 0, 0, 0, 0); #endif /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the USB controller object given another guest object * (a kind of copy constructor). This object makes a private copy of data * of the original object passed as an argument. */ HRESULT USBDeviceFilters::initCopy(Machine *aParent, USBDeviceFilters *aPeer) { LogFlowThisFunc(("aParent=%p, aPeer=%p\n", aParent, aPeer)); ComAssertRet(aParent && aPeer, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); m = new Data(aParent); /* mPeer is left null */ AutoWriteLock thatlock(aPeer COMMA_LOCKVAL_SRC_POS); #ifdef VBOX_WITH_USB /* create private copies of all filters */ m->llDeviceFilters.allocate(); DeviceFilterList::const_iterator it = aPeer->m->llDeviceFilters->begin(); while (it != aPeer->m->llDeviceFilters->end()) { ComObjPtr<USBDeviceFilter> pFilter; pFilter.createObject(); pFilter->initCopy(this, *it); m->llDeviceFilters->push_back(pFilter); ++it; } #endif /* VBOX_WITH_USB */ /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the Serial Port object given another serial port object * (a kind of copy constructor). This object shares data with * the object passed as an argument. * * @note This object must be destroyed before the original object * it shares data with is destroyed. * * @note Locks @a aThat object for reading. */ HRESULT SerialPort::init(Machine *aParent, SerialPort *aThat) { LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat)); ComAssertRet(aParent && aThat, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); m = new Data(); unconst(m->pMachine) = aParent; unconst(m->pPeer) = aThat; AutoCaller thatCaller (aThat); AssertComRCReturnRC(thatCaller.rc()); AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS); m->bd.share (aThat->m->bd); /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the Serial Port object. * * @param aParent Handle of the parent object. */ HRESULT SerialPort::init(Machine *aParent, ULONG aSlot) { LogFlowThisFunc(("aParent=%p, aSlot=%d\n", aParent, aSlot)); ComAssertRet(aParent, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); m = new Data(); unconst(m->pMachine) = aParent; /* m->pPeer is left null */ m->bd.allocate(); /* initialize data */ m->bd->ulSlot = aSlot; /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the guest OS type object. * * @returns COM result indicator * @param aFamilyId os family short name string * @param aFamilyDescription os family name string * @param aId os short name string * @param aDescription os name string * @param aOSType global OS type ID * @param aOSHint os configuration hint * @param aRAMSize recommended RAM size in megabytes * @param aVRAMSize recommended video memory size in megabytes * @param aHDDSize recommended HDD size in bytes */ HRESULT GuestOSType::init(const Global::OSType &ostype)/*const char *aFamilyId, const char *aFamilyDescription, const char *aId, const char *aDescription, VBOXOSTYPE aOSType, uint32_t aOSHint, uint32_t aRAMSize, uint32_t aVRAMSize, uint64_t aHDDSize, NetworkAdapterType_T aNetworkAdapterType, uint32_t aNumSerialEnabled, StorageControllerType_T aDVDStorageControllerType, StorageBus_T aDVDStorageBusType, StorageControllerType_T aHDStorageControllerType, StorageBus_T aHDStorageBusType, ChipsetType_T aChipsetType AudioControllerType_T aAudioControllerType*/ { #if 0 LogFlowThisFunc(("aFamilyId='%s', aFamilyDescription='%s', " "aId='%s', aDescription='%s', " "aType=%d, aOSHint=%x, " "aRAMSize=%d, aVRAMSize=%d, aHDDSize=%lld, " "aNetworkAdapterType=%d, aNumSerialEnabled=%d, " "aStorageControllerType=%d\n", aFamilyId, aFamilyDescription, aId, aDescription, aOSType, aOSHint, aRAMSize, aVRAMSize, aHDDSize, aNetworkAdapterType, aNumSerialEnabled, aStorageControllerType)); #endif ComAssertRet(ostype.familyId && ostype.familyDescription && ostype.id && ostype.description, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mFamilyID) = ostype.familyId; unconst(mFamilyDescription) = ostype.familyDescription; unconst(mID) = ostype.id; unconst(mDescription) = ostype.description; unconst(mOSType) = ostype.osType; unconst(mOSHint) = ostype.osHint; unconst(mRAMSize) = ostype.recommendedRAM; unconst(mVRAMSize) = ostype.recommendedVRAM; unconst(mHDDSize) = ostype.recommendedHDD; unconst(mNetworkAdapterType) = ostype.networkAdapterType; unconst(mNumSerialEnabled) = ostype.numSerialEnabled; unconst(mDVDStorageControllerType) = ostype.dvdStorageControllerType; unconst(mDVDStorageBusType) = ostype.dvdStorageBusType; unconst(mHDStorageControllerType) = ostype.hdStorageControllerType; unconst(mHDStorageBusType) = ostype.hdStorageBusType; unconst(mChipsetType) = ostype.chipsetType; unconst(mAudioControllerType) = ostype.audioControllerType; unconst(mAudioCodecType) = ostype.audioCodecType; /* Confirm a successful initialization when it's the case */ autoInitSpan.setSucceeded(); return S_OK; }
HRESULT PCIDeviceAttachment::initCopy(IMachine *aParent, PCIDeviceAttachment *aThat) { LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat)); ComAssertRet(aParent && aThat, E_INVALIDARG); return init(aParent, aThat->m->DevName, aThat->m->HostAddress, aThat->m->GuestAddress, aThat->m->fPhysical); }
/** * Initializes the guest object. */ HRESULT Guest::init(Console *aParent) { LogFlowThisFunc(("aParent=%p\n", aParent)); ComAssertRet(aParent, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = aParent; /* Confirm a successful initialization when it's the case */ autoInitSpan.setSucceeded(); ULONG aMemoryBalloonSize; HRESULT ret = mParent->machine()->COMGETTER(MemoryBalloonSize)(&aMemoryBalloonSize); if (ret == S_OK) mMemoryBalloonSize = aMemoryBalloonSize; else mMemoryBalloonSize = 0; /* Default is no ballooning */ BOOL fPageFusionEnabled; ret = mParent->machine()->COMGETTER(PageFusionEnabled)(&fPageFusionEnabled); if (ret == S_OK) mfPageFusionEnabled = fPageFusionEnabled; else mfPageFusionEnabled = false; /* Default is no page fusion*/ mStatUpdateInterval = 0; /* Default is not to report guest statistics at all */ mCollectVMMStats = false; /* Clear statistics. */ mNetStatRx = mNetStatTx = 0; mNetStatLastTs = RTTimeNanoTS(); for (unsigned i = 0 ; i < GUESTSTATTYPE_MAX; i++) mCurrentGuestStat[i] = 0; mVmValidStats = pm::VMSTATMASK_NONE; mMagic = GUEST_MAGIC; int vrc = RTTimerLRCreate(&mStatTimer, 1000 /* ms */, &Guest::staticUpdateStats, this); AssertMsgRC(vrc, ("Failed to create guest statistics update timer(%Rra)\n", vrc)); try { #ifdef VBOX_WITH_DRAG_AND_DROP m_pGuestDnD = new GuestDnD(this); AssertPtr(m_pGuestDnD); #endif } catch(std::bad_alloc &) { return E_OUTOFMEMORY; } return S_OK; }
/** * Send an absolute position event to the VMM device. * @note all calls out of this object are made with no locks held! * * @returns COM status code */ HRESULT Mouse::reportAbsEventToVMMDev(int32_t mouseXAbs, int32_t mouseYAbs) { VMMDev *pVMMDev = mParent->getVMMDev(); ComAssertRet(pVMMDev, E_FAIL); PPDMIVMMDEVPORT pVMMDevPort = pVMMDev->getVMMDevPort(); ComAssertRet(pVMMDevPort, E_FAIL); if (mouseXAbs != mcLastAbsX || mouseYAbs != mcLastAbsY) { int vrc = pVMMDevPort->pfnSetAbsoluteMouse(pVMMDevPort, mouseXAbs, mouseYAbs); if (RT_FAILURE(vrc)) return setError(VBOX_E_IPRT_ERROR, tr("Could not send the mouse event to the virtual mouse (%Rrc)"), vrc); } return S_OK; }
/** * Send an absolute position event to the VMM device. * @note all calls out of this object are made with no locks held! * * @returns COM status code */ HRESULT Mouse::reportAbsEventToVMMDev(int32_t x, int32_t y) { VMMDevMouseInterface *pVMMDev = mParent->getVMMDevMouseInterface(); ComAssertRet(pVMMDev, E_FAIL); PPDMIVMMDEVPORT pVMMDevPort = pVMMDev->getVMMDevPort(); ComAssertRet(pVMMDevPort, E_FAIL); if (x != mcLastX || y != mcLastY) { int vrc = pVMMDevPort->pfnSetAbsoluteMouse(pVMMDevPort, x, y); if (RT_FAILURE(vrc)) return setError(VBOX_E_IPRT_ERROR, tr("Could not send the mouse event to the virtual mouse (%Rrc)"), vrc); } return S_OK; }
/** * Send an absolute position event to the display device. * @note all calls out of this object are made with no locks held! * @param x Cursor X position in pixels relative to the first screen, where * (1, 1) is the upper left corner. * @param y Cursor Y position in pixels relative to the first screen, where * (1, 1) is the upper left corner. */ HRESULT Mouse::i_reportAbsEventToDisplayDevice(int32_t x, int32_t y) { DisplayMouseInterface *pDisplay = mParent->getDisplayMouseInterface(); ComAssertRet(pDisplay, E_FAIL); if (x != mcLastX || y != mcLastY) { pDisplay->i_reportHostCursorPosition(x - 1, y - 1); } return S_OK; }
/** * Initializes the host object. * * @returns COM result indicator * @param aInterfaceName name of the network interface * @param aGuid GUID of the host network interface */ HRESULT HostNetworkInterface::init(Bstr aInterfaceName, Guid aGuid, HostNetworkInterfaceType_T ifType) { LogFlowThisFunc(("aInterfaceName={%ls}, aGuid={%s}\n", aInterfaceName.raw(), aGuid.toString().c_str())); ComAssertRet(!aInterfaceName.isEmpty(), E_INVALIDARG); ComAssertRet(!aGuid.isEmpty(), E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mInterfaceName) = aInterfaceName; unconst(mGuid) = aGuid; mIfType = ifType; /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the system information object. * * @returns COM result indicator */ HRESULT SystemProperties::init(VirtualBox *aParent) { LogFlowThisFunc(("aParent=%p\n", aParent)); ComAssertRet(aParent, E_FAIL); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = aParent; setDefaultMachineFolder(Utf8Str::Empty); setDefaultHardDiskFormat(Utf8Str::Empty); setVRDEAuthLibrary(Utf8Str::Empty); setDefaultVRDEExtPack(Utf8Str::Empty); m->ulLogHistoryCount = 3; HRESULT rc = S_OK; /* Fetch info of all available hd backends. */ /// @todo NEWMEDIA VDBackendInfo needs to be improved to let us enumerate /// any number of backends VDBACKENDINFO aVDInfo[100]; unsigned cEntries; int vrc = VDBackendInfo(RT_ELEMENTS(aVDInfo), aVDInfo, &cEntries); AssertRC(vrc); if (RT_SUCCESS(vrc)) { for (unsigned i = 0; i < cEntries; ++ i) { ComObjPtr<MediumFormat> hdf; rc = hdf.createObject(); if (FAILED(rc)) break; rc = hdf->init(&aVDInfo[i]); if (FAILED(rc)) break; m_llMediumFormats.push_back(hdf); } } /* Confirm a successful initialization */ if (SUCCEEDED(rc)) autoInitSpan.setSucceeded(); return rc; }
/** * Initializes the host object. * * @returns COM result indicator * @param aInterfaceName name of the network interface * @param aGuid GUID of the host network interface */ HRESULT HostNetworkInterface::init(Utf8Str aInterfaceName, HostNetworkInterfaceType_T ifType, PNETIFINFO pIf) { // LogFlowThisFunc(("aInterfaceName={%s}, aGuid={%s}\n", // aInterfaceName.c_str(), aGuid.toString().c_str())); // ComAssertRet(aInterfaceName, E_INVALIDARG); // ComAssertRet(aGuid.isValid(), E_INVALIDARG); ComAssertRet(pIf, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mInterfaceName) = aInterfaceName; unconst(mGuid) = pIf->Uuid; if (pIf->szShortName[0]) { unconst(mNetworkName) = i_composeNetworkName(pIf->szShortName); unconst(mShortName) = pIf->szShortName; } else { unconst(mNetworkName) = i_composeNetworkName(aInterfaceName); unconst(mShortName) = aInterfaceName; } mIfType = ifType; int iPrefixIPv6; m.realIPAddress = m.IPAddress = pIf->IPAddress.u; m.realNetworkMask = m.networkMask = pIf->IPNetMask.u; if (pIf->IPv6Address.s.Lo || pIf->IPv6Address.s.Hi) m.realIPV6Address = m.IPV6Address = Utf8StrFmt("%RTnaipv6", &pIf->IPv6Address); else m.realIPV6Address = m.IPV6Address = Utf8Str::Empty; RTNetMaskToPrefixIPv6(&pIf->IPv6NetMask, &iPrefixIPv6); m.realIPV6PrefixLength = m.IPV6NetworkMaskPrefixLength = iPrefixIPv6; m.dhcpEnabled = pIf->fDhcpEnabled; m.hardwareAddress = Utf8StrFmt("%RTmac", &pIf->MACAddress); AssertCompile((unsigned)NETIF_T_UNKNOWN == (unsigned)HostNetworkInterfaceMediumType_Unknown); m.mediumType = (HostNetworkInterfaceMediumType_T)pIf->enmMediumType; AssertCompile((unsigned)NETIF_S_UNKNOWN == (unsigned)HostNetworkInterfaceStatus_Unknown); m.status = (HostNetworkInterfaceStatus_T)pIf->enmStatus; m.speedMbits = pIf->uSpeedMbits; m.wireless = pIf->fWireless; /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the network adapter object. * * @param aParent Handle of the parent object. */ HRESULT NetworkAdapter::init(Machine *aParent, ULONG aSlot) { LogFlowThisFunc(("aParent=%p, aSlot=%d\n", aParent, aSlot)); ComAssertRet(aParent, E_INVALIDARG); uint32_t maxNetworkAdapters = Global::getMaxNetworkAdapters(aParent->getChipsetType()); ComAssertRet(aSlot < maxNetworkAdapters, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = aParent; unconst(mNATEngine).createObject(); mNATEngine->init(aParent, this); /* mPeer is left null */ m_fModified = false; mData.allocate(); /* initialize data */ mData->mSlot = aSlot; /* default to Am79C973 */ mData->mAdapterType = NetworkAdapterType_Am79C973; /* generate the MAC address early to guarantee it is the same both after * changing some other property (i.e. after mData.backup()) and after the * subsequent mData.rollback(). */ generateMACAddress(); /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
STDMETHODIMP NetworkAdapter::COMGETTER(MACAddress)(BSTR *aMACAddress) { CheckComArgOutPointerValid(aMACAddress); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); ComAssertRet(!mData->mMACAddress.isEmpty(), E_FAIL); mData->mMACAddress.cloneTo(aMACAddress); return S_OK; }
/** * Initializes the host object. * * @returns COM result indicator * @param aInterfaceName name of the network interface * @param aGuid GUID of the host network interface */ HRESULT HostNetworkInterface::init(Bstr aInterfaceName, HostNetworkInterfaceType_T ifType, PNETIFINFO pIf) { // LogFlowThisFunc(("aInterfaceName={%ls}, aGuid={%s}\n", // aInterfaceName.raw(), aGuid.toString().raw())); // ComAssertRet(aInterfaceName, E_INVALIDARG); // ComAssertRet(aGuid.isValid(), E_INVALIDARG); ComAssertRet(pIf, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mInterfaceName) = aInterfaceName; unconst(mGuid) = pIf->Uuid; if (pIf->szShortName[0]) { unconst(mNetworkName) = i_composeNetworkName(pIf->szShortName); unconst(mShortName) = pIf->szShortName; } else { unconst(mNetworkName) = i_composeNetworkName(aInterfaceName); unconst(mShortName) = aInterfaceName; } mIfType = ifType; m.realIPAddress = m.IPAddress = pIf->IPAddress.u; m.realNetworkMask = m.networkMask = pIf->IPNetMask.u; m.realIPV6Address = m.IPV6Address = composeIPv6Address(&pIf->IPv6Address); m.realIPV6PrefixLength = m.IPV6NetworkMaskPrefixLength = composeIPv6PrefixLenghFromAddress(&pIf->IPv6NetMask); m.dhcpEnabled = pIf->bDhcpEnabled; m.hardwareAddress = composeHardwareAddress(&pIf->MACAddress); #ifdef RT_OS_WINDOWS m.mediumType = (HostNetworkInterfaceMediumType)pIf->enmMediumType; m.status = (HostNetworkInterfaceStatus)pIf->enmStatus; #else /* !RT_OS_WINDOWS */ m.mediumType = pIf->enmMediumType; m.status = pIf->enmStatus; #endif /* !RT_OS_WINDOWS */ m.speedMbits = pIf->uSpeedMbits; /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }