STDMETHODIMP SystemProperties::COMSETTER(AutostartDatabasePath)(IN_BSTR aAutostartDbPath) { AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); HRESULT rc = setAutostartDatabasePath(aAutostartDbPath); alock.release(); if (SUCCEEDED(rc)) { // VirtualBox::saveSettings() needs vbox write lock AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS); rc = mParent->saveSettings(); } return rc; }
STDMETHODIMP SystemProperties::COMSETTER(WebServiceAuthLibrary)(IN_BSTR aWebServiceAuthLibrary) { AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); HRESULT rc = setWebServiceAuthLibrary(aWebServiceAuthLibrary); alock.release(); if (SUCCEEDED(rc)) { // VirtualBox::saveSettings() needs vbox write lock AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS); rc = mParent->saveSettings(); } return rc; }
STDMETHODIMP Session::OnSharedFolderChange(BOOL aGlobal) { LogFlowThisFunc(("\n")); AutoCaller autoCaller(this); AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); #ifndef VBOX_COM_INPROC_API_CLIENT AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); return mConsole->onSharedFolderChange(aGlobal); #else return S_OK; #endif }
STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFormat)(IN_BSTR aDefaultHardDiskFormat) { AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); HRESULT rc = setDefaultHardDiskFormat(aDefaultHardDiskFormat); alock.release(); if (SUCCEEDED(rc)) { // VirtualBox::saveSettings() needs vbox write lock AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS); rc = mParent->saveSettings(); } return rc; }
STDMETHODIMP HostUSBDeviceFilter::COMGETTER(Action) (USBDeviceFilterAction_T *aAction) { CheckComArgOutPointerValid(aAction); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); switch (USBFilterGetFilterType (&mData->mUSBFilter)) { case USBFILTERTYPE_IGNORE: *aAction = USBDeviceFilterAction_Ignore; break; case USBFILTERTYPE_CAPTURE: *aAction = USBDeviceFilterAction_Hold; break; default: *aAction = USBDeviceFilterAction_Null; break; } return S_OK; }
/** * Marks the operation as complete and attaches full error info. * * See VirtualBoxBase::setError(HRESULT, const GUID &, const wchar_t * *, const char *, ...) for more info. * * @param aResultCode Operation result (error) code, must not be S_OK. * @param aIID IID of the interface that defines the error. * @param aComponent Name of the component that generates the error. * @param aText Error message (must not be null), an RTStrPrintf-like * format string in UTF-8 encoding. * @param va List of arguments for the format string. */ HRESULT Progress::i_notifyCompleteV(HRESULT aResultCode, const GUID &aIID, const char *pcszComponent, const char *aText, va_list va) { Utf8Str text(aText, va); AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); AssertReturn(mCompleted == FALSE, E_FAIL); if (mCanceled && SUCCEEDED(aResultCode)) aResultCode = E_FAIL; mCompleted = TRUE; mResultCode = aResultCode; AssertReturn(FAILED(aResultCode), E_FAIL); ComObjPtr<VirtualBoxErrorInfo> errorInfo; HRESULT rc = errorInfo.createObject(); AssertComRC(rc); if (SUCCEEDED(rc)) { errorInfo->init(aResultCode, aIID, pcszComponent, text); errorInfo.queryInterfaceTo(mErrorInfo.asOutParam()); } #if !defined VBOX_COM_INPROC /* remove from the global collection of pending progress operations */ if (mParent) mParent->i_removeProgress(mId.ref()); #endif /* wake up all waiting threads */ if (mWaitersCount > 0) RTSemEventMultiSignal(mCompletedSem); return rc; }
bool SerialPort::i_hasDefaults() { /* sanity */ AutoCaller autoCaller(this); AssertComRCReturn(autoCaller.rc(), true); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); if ( !m->bd->fEnabled && m->bd->portMode == PortMode_Disconnected && !m->bd->fServer) { /* Could be default, check the IO base and IRQ. */ switch (m->bd->ulSlot) { case 0: if (m->bd->ulIOBase == 0x3f8 && m->bd->ulIRQ == 4) return true; break; case 1: if (m->bd->ulIOBase == 0x2f8 && m->bd->ulIRQ == 3) return true; break; case 2: if (m->bd->ulIOBase == 0x3e8 && m->bd->ulIRQ == 4) return true; break; case 3: if (m->bd->ulIOBase == 0x2e8 && m->bd->ulIRQ == 3) return true; break; default: AssertMsgFailed(("Serial port slot %u exceeds limit\n", m->bd->ulSlot)); break; } /* Detect old-style defaults (0x3f8, irq 4) in any slot, they are still * in place for many VMs created by old VirtualBox versions. */ if (m->bd->ulIOBase == 0x3f8 && m->bd->ulIRQ == 4) return true; } return false; }
/** * Notifies the proxy service about all filters as requested by the * @a aInsertFilters argument. * * @param aInsertFilters @c true to insert filters, @c false to remove. * * @note Locks this object for reading. */ HRESULT USBController::notifyProxy (bool aInsertFilters) { LogFlowThisFunc(("aInsertFilters=%RTbool\n", aInsertFilters)); AutoCaller autoCaller(this); AssertComRCReturn (autoCaller.rc(), false); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); USBProxyService *service = m->pHost->usbProxyService(); AssertReturn(service, E_FAIL); DeviceFilterList::const_iterator it = m->llDeviceFilters->begin(); while (it != m->llDeviceFilters->end()) { USBDeviceFilter *flt = *it; /* resolve ambiguity (for ComPtr below) */ /* notify the proxy (only if the filter is active) */ if (flt->getData().mActive && flt->getData().mRemote.isMatch (false) /* and if the filter is NOT remote */ ) { if (aInsertFilters) { AssertReturn(flt->getId() == NULL, E_FAIL); flt->getId() = service->insertFilter(&flt->getData().mUSBFilter); } else { /* It's possible that the given filter was not inserted the proxy * when this method gets called (as a result of an early VM * process crash for example. So, don't assert that ID != NULL. */ if (flt->getId() != NULL) { service->removeFilter(flt->getId()); flt->getId() = NULL; } } } ++ it; } return S_OK; }
HRESULT HostNetworkInterface::setVirtualBox(VirtualBox *pVBox) { AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); unconst(mVBox) = pVBox; #if !defined(RT_OS_WINDOWS) /* If IPv4 address hasn't been initialized */ if (m.IPAddress == 0 && mIfType == HostNetworkInterfaceType_HostOnly) { Bstr tmpAddr, tmpMask; HRESULT hrc = mVBox->GetExtraData(BstrFmt("HostOnly/%ls/IPAddress", mInterfaceName.raw()).raw(), tmpAddr.asOutParam()); if (FAILED(hrc) || tmpAddr.isEmpty()) tmpAddr = getDefaultIPv4Address(mInterfaceName); hrc = mVBox->GetExtraData(BstrFmt("HostOnly/%ls/IPNetMask", mInterfaceName.raw()).raw(), tmpMask.asOutParam()); if (FAILED(hrc) || tmpMask.isEmpty()) tmpMask = Bstr(VBOXNET_IPV4MASK_DEFAULT); m.IPAddress = inet_addr(Utf8Str(tmpAddr).c_str()); m.networkMask = inet_addr(Utf8Str(tmpMask).c_str()); } if (m.IPV6Address.isEmpty()) { Bstr tmpPrefixLen; HRESULT hrc = mVBox->GetExtraData(BstrFmt("HostOnly/%ls/IPV6Address", mInterfaceName.raw()).raw(), m.IPV6Address.asOutParam()); if (SUCCEEDED(hrc) && !m.IPV6Address.isEmpty()) { hrc = mVBox->GetExtraData(BstrFmt("HostOnly/%ls/IPV6PrefixLen", mInterfaceName.raw()).raw(), tmpPrefixLen.asOutParam()); if (SUCCEEDED(hrc) && !tmpPrefixLen.isEmpty()) m.IPV6NetworkMaskPrefixLength = Utf8Str(tmpPrefixLen).toUInt32(); else m.IPV6NetworkMaskPrefixLength = 64; } } #endif return S_OK; }
STDMETHODIMP GuestSessionWrap::ProcessCreateEx(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment), ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS, ProcessPriority_T aPriority, ComSafeArrayIn(LONG, aAffinity), IGuestProcess **aGuestProcess) { LogRelFlow(("{%p} %s:enter aCommand=%ls aArguments=%zu aEnvironment=%zu aFlags=%zu aTimeoutMS=%RU32 aPriority=%RU32 aAffinity=%zu aGuestProcess=%p\n", this, "GuestSession::processCreateEx", aCommand, aArguments, aEnvironment, aFlags, aTimeoutMS, aPriority, aAffinity, aGuestProcess)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aGuestProcess); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = processCreateEx(BSTRInConverter(aCommand).str(), ArrayBSTRInConverter(ComSafeArrayInArg(aArguments)).array(), ArrayBSTRInConverter(ComSafeArrayInArg(aEnvironment)).array(), ArrayInConverter<ProcessCreateFlag_T>(ComSafeArrayInArg(aFlags)).array(), aTimeoutMS, aPriority, ArrayInConverter<LONG>(ComSafeArrayInArg(aAffinity)).array(), ComTypeOutConverter<IGuestProcess>(aGuestProcess).ptr()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave aGuestProcess=%p hrc=%Rhrc\n", this, "GuestSession::processCreateEx", *aGuestProcess, hrc)); return hrc; }
void SerialPort::i_applyDefaults (GuestOSType *aOsType) { AssertReturnVoid (aOsType != NULL); /* sanity */ AutoCaller autoCaller(this); AssertComRCReturnVoid (autoCaller.rc()); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); /* Set some more defaults. * Note that the default value for COM1 (slot 0) is set in the constructor * of bd. So slot 0 is correct already. */ switch (m->bd->ulSlot) { case 1: { m->bd->ulIOBase = 0x2F8; m->bd->ulIRQ = 3; break; } case 2: { m->bd->ulIOBase = 0x3e8; m->bd->ulIRQ = 4; break; } case 3: { m->bd->ulIOBase = 0x2e8; m->bd->ulIRQ = 3; break; } default: break; } uint32_t numSerialEnabled = aOsType->i_numSerialEnabled(); /* Enable port if requested */ if (m->bd->ulSlot < numSerialEnabled) { m->bd->fEnabled = true; } }
/** * Returns the current singlestepping flag. * * @returns COM status code * @param a_fEnabled Where to store the result. */ STDMETHODIMP MachineDebugger::COMGETTER(SingleStep)(BOOL *a_fEnabled) { CheckComArgOutPointerValid(a_fEnabled); AutoCaller autoCaller(this); HRESULT hrc = autoCaller.rc(); if (SUCCEEDED(hrc)) { AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); Console::SafeVMPtr ptrVM(mParent); hrc = ptrVM.rc(); if (SUCCEEDED(hrc)) { /** @todo */ ReturnComNotImplemented(); } } return hrc; }
HRESULT SystemProperties::i_loadSettings(const settings::SystemProperties &data) { AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); HRESULT rc = S_OK; rc = i_setDefaultMachineFolder(data.strDefaultMachineFolder); if (FAILED(rc)) return rc; rc = i_setLoggingLevel(data.strLoggingLevel); if (FAILED(rc)) return rc; rc = i_setDefaultHardDiskFormat(data.strDefaultHardDiskFormat); if (FAILED(rc)) return rc; rc = i_setVRDEAuthLibrary(data.strVRDEAuthLibrary); if (FAILED(rc)) return rc; rc = i_setWebServiceAuthLibrary(data.strWebServiceAuthLibrary); if (FAILED(rc)) return rc; rc = i_setDefaultVRDEExtPack(data.strDefaultVRDEExtPack); if (FAILED(rc)) return rc; m->ulLogHistoryCount = data.ulLogHistoryCount; m->fExclusiveHwVirt = data.fExclusiveHwVirt; rc = i_setAutostartDatabasePath(data.strAutostartDatabasePath); if (FAILED(rc)) return rc; { /* must ignore errors signalled here, because the guest additions * file may not exist, and in this case keep the empty string */ ErrorInfoKeeper eik; (void)i_setDefaultAdditionsISO(data.strDefaultAdditionsISO); } rc = i_setDefaultFrontend(data.strDefaultFrontend); if (FAILED(rc)) return rc; return S_OK; }
/** * Saves settings to the given adapter node. * * Note that the given Adapter node is completely empty on input. * * @param aAdapterNode <Adapter> node. * * @note Locks this object for reading. */ HRESULT NetworkAdapter::saveSettings(settings::NetworkAdapter &data) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); data.fEnabled = !!mData->mEnabled; data.strMACAddress = mData->mMACAddress; data.fCableConnected = !!mData->mCableConnected; data.enmPromiscModePolicy = mData->mPromiscModePolicy; data.ulLineSpeed = mData->mLineSpeed; data.fTraceEnabled = !!mData->mTraceEnabled; data.strTraceFile = mData->mTraceFile; data.ulBootPriority = mData->mBootPriority; data.strBandwidthGroup = mData->mBandwidthGroup; data.type = mData->mAdapterType; data.mode = mData->mAttachmentType; mNATEngine->commit(); mNATEngine->saveSettings(data.nat); data.strBridgedName = mData->mBridgedInterface; data.strHostOnlyName = mData->mHostOnlyInterface; data.strInternalNetworkName = mData->mInternalNetwork; data.strGenericDriver = mData->mGenericDriver; data.genericProperties = mData->mGenericProperties; // after saving settings, we are no longer different from the XML on disk m_fModified = false; return S_OK; }
STDMETHODIMP Session::OnUSBDeviceDetach(IN_BSTR aId, IVirtualBoxErrorInfo *aError) { LogFlowThisFunc(("\n")); AutoCaller autoCaller(this); AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); #ifndef VBOX_COM_INPROC_API_CLIENT AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); return mConsole->onUSBDeviceDetach(aId, aError); #else return S_OK; #endif }
STDMETHODIMP Session::EnableVMMStatistics(BOOL aEnable) { AutoCaller autoCaller(this); AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); #ifndef VBOX_COM_INPROC_API_CLIENT AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); mConsole->enableVMMStatistics(aEnable); return S_OK; #else AssertFailed(); return E_NOTIMPL; #endif }
/** * @note Locks this object for writing, together with the peer object * represented by @a aThat (locked for reading). */ void USBDeviceFilters::i_copyFrom(USBDeviceFilters *aThat) { AssertReturnVoid(aThat != NULL); /* sanity */ AutoCaller autoCaller(this); AssertComRCReturnVoid(autoCaller.rc()); /* sanity too */ AutoCaller thatCaller(aThat); AssertComRCReturnVoid(thatCaller.rc()); /* even more sanity */ AutoAnyStateDependency adep(m->pParent); AssertComRCReturnVoid(adep.rc()); /* Machine::copyFrom() may not be called when the VM is running */ AssertReturnVoid(!Global::IsOnline(adep.machineState())); /* peer is not modified, lock it for reading (aThat is "master" so locked * first) */ AutoReadLock rl(aThat COMMA_LOCKVAL_SRC_POS); AutoWriteLock wl(this COMMA_LOCKVAL_SRC_POS); #ifdef VBOX_WITH_USB /* Note that we won't inform the USB proxy about new filters since the VM is * not running when we are here and therefore no need to do so */ /* create private copies of all filters */ m->llDeviceFilters.backup(); m->llDeviceFilters->clear(); for (DeviceFilterList::const_iterator it = aThat->m->llDeviceFilters->begin(); it != aThat->m->llDeviceFilters->end(); ++it) { ComObjPtr<USBDeviceFilter> pFilter; pFilter.createObject(); pFilter->initCopy(this, *it); m->llDeviceFilters->push_back(pFilter); } #endif /* VBOX_WITH_USB */ }
STDMETHODIMP SystemProperties::COMSETTER(LoggingLevel)(IN_BSTR aLoggingLevel) { AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); HRESULT rc = setLoggingLevel(aLoggingLevel); alock.release(); if (SUCCEEDED(rc)) { AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS); rc = mParent->saveSettings(); } else LogRel(("Cannot set passed logging level=%ls, or the default one - Error=%Rhrc \n", aLoggingLevel, rc)); return rc; }
STDMETHODIMP Guest::COMGETTER(EventSource)(IEventSource ** aEventSource) { #ifndef VBOX_WITH_GUEST_CONTROL ReturnComNotImplemented(); #else LogFlowThisFuncEnter(); CheckComArgOutPointerValid(aEventSource); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); // no need to lock - lifetime constant mEventSource.queryInterfaceTo(aEventSource); LogFlowFuncLeaveRC(S_OK); return S_OK; #endif /* VBOX_WITH_GUEST_CONTROL */ }
STDMETHODIMP NetworkAdapter::COMSETTER(BandwidthGroup)(IBandwidthGroup *aBwGroup) { LogFlowThisFuncEnter(); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); /* the machine needs to be mutable */ AutoMutableStateDependency adep(mParent); if (FAILED(adep.rc())) return adep.rc(); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); Utf8Str strBwGroup; if (aBwGroup) strBwGroup = static_cast<BandwidthGroup*>(aBwGroup)->getName(); if (mData->mBandwidthGroup != strBwGroup) { ComObjPtr<BandwidthGroup> pBwGroup; if (!strBwGroup.isEmpty()) { HRESULT hrc = mParent->getBandwidthGroup(strBwGroup, pBwGroup, false /* fSetError */); NOREF(hrc); Assert(SUCCEEDED(hrc)); /* This is not allowed to fail because the existence of the group was checked when it was attached. */ } updateBandwidthGroup(pBwGroup); m_fModified = true; // leave the lock before informing callbacks alock.release(); AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); mParent->setModified(Machine::IsModified_NetworkAdapters); mlock.release(); /* TODO: changeAdapter=???. */ mParent->onNetworkAdapterChange(this, FALSE); } LogFlowThisFuncLeave(); return S_OK; }
STDMETHODIMP HostUSBDeviceFilter::COMSETTER(Active) (BOOL aActive) { AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); if (mData->mActive != aActive) { mData->mActive = aActive; /* leave the lock before informing callbacks */ alock.release(); return mParent->onUSBDeviceFilterChange (this, TRUE /* aActiveChanged */); } return S_OK; }
STDMETHODIMP GuestSessionWrap::FileOpenEx(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, IN_BSTR aSharingMode, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile) { LogRelFlow(("{%p} %s:enter aPath=%ls aOpenMode=%ls aDisposition=%ls aSharingMode=%ls aCreationMode=%RU32 aOffset=%RI64 aFile=%p\n", this, "GuestSession::fileOpenEx", aPath, aOpenMode, aDisposition, aSharingMode, aCreationMode, aOffset, aFile)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aFile); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = fileOpenEx(BSTRInConverter(aPath).str(), BSTRInConverter(aOpenMode).str(), BSTRInConverter(aDisposition).str(), BSTRInConverter(aSharingMode).str(), aCreationMode, aOffset, ComTypeOutConverter<IGuestFile>(aFile).ptr()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave aFile=%p hrc=%Rhrc\n", this, "GuestSession::fileOpenEx", *aFile, hrc)); return hrc; }
STDMETHODIMP GuestFile::ReadAt(LONG64 aOffset, ULONG aToRead, ULONG aTimeoutMS, ComSafeArrayOut(BYTE, aData)) { #ifndef VBOX_WITH_GUEST_CONTROL ReturnComNotImplemented(); #else if (aToRead == 0) return setError(E_INVALIDARG, tr("The size to read is zero")); CheckComArgOutSafeArrayPointerValid(aData); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); com::SafeArray<BYTE> data((size_t)aToRead); Assert(data.size() >= aToRead); HRESULT hr = S_OK; size_t cbRead; int vrc = readDataAt(aOffset, aToRead, aTimeoutMS, data.raw(), aToRead, &cbRead); if (RT_SUCCESS(vrc)) { if (data.size() != cbRead) data.resize(cbRead); data.detachTo(ComSafeArrayOutArg(aData)); } else { switch (vrc) { default: hr = setError(VBOX_E_IPRT_ERROR, tr("Reading from file \"%s\" (at offset %RU64) failed: %Rrc"), mData.mOpenInfo.mFileName.c_str(), aOffset, vrc); break; } } LogFlowFuncLeaveRC(vrc); return hr; #endif /* VBOX_WITH_GUEST_CONTROL */ }
STDMETHODIMP SystemProperties::GetMaxPortCountForStorageBus(StorageBus_T aBus, ULONG *aMaxPortCount) { CheckComArgOutPointerValid(aMaxPortCount); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); /* no need to lock, this is const */ switch (aBus) { case StorageBus_SATA: { *aMaxPortCount = 30; break; } case StorageBus_SCSI: { *aMaxPortCount = 16; break; } case StorageBus_IDE: { *aMaxPortCount = 2; break; } case StorageBus_Floppy: { *aMaxPortCount = 1; break; } case StorageBus_SAS: { *aMaxPortCount = 8; break; } default: AssertMsgFailed(("Invalid bus type %d\n", aBus)); } return S_OK; }
STDMETHODIMP AudioAdapter::COMSETTER(AudioController)(AudioControllerType_T aAudioController) { AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); /* the machine needs to be mutable */ AutoMutableStateDependency adep(mParent); if (FAILED(adep.rc())) return adep.rc(); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); HRESULT rc = S_OK; if (mData->mAudioController != aAudioController) { /* * which audio hardware type are we supposed to use? */ switch (aAudioController) { case AudioControllerType_AC97: case AudioControllerType_SB16: case AudioControllerType_HDA: { mData.backup(); mData->mAudioController = aAudioController; alock.release(); AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking mParent->setModified(Machine::IsModified_AudioAdapter); break; } default: AssertMsgFailed (("Wrong audio controller type %d\n", aAudioController)); rc = E_FAIL; } } return rc; }
/** * @note Locks this object for writing, together with the peer object * represented by @a aThat (locked for reading). */ void NetworkAdapter::copyFrom(NetworkAdapter *aThat) { AssertReturnVoid(aThat != NULL); /* sanity */ AutoCaller autoCaller(this); AssertComRCReturnVoid(autoCaller.rc()); /* sanity too */ AutoCaller thatCaller(aThat); AssertComRCReturnVoid(thatCaller.rc()); /* peer is not modified, lock it for reading (aThat is "master" so locked * first) */ AutoReadLock rl(aThat COMMA_LOCKVAL_SRC_POS); AutoWriteLock wl(this COMMA_LOCKVAL_SRC_POS); /* this will back up current data */ mData.assignCopy(aThat->mData); }
void HostUSBDeviceFilter::saveSettings(settings::USBDeviceFilter &data) { AutoCaller autoCaller(this); AssertComRCReturnVoid(autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); data.strName = mData->mName; data.fActive = !!mData->mActive; usbFilterFieldToString(&mData->mUSBFilter, USBFILTERIDX_VENDOR_ID, data.strVendorId); usbFilterFieldToString(&mData->mUSBFilter, USBFILTERIDX_PRODUCT_ID, data.strProductId); usbFilterFieldToString(&mData->mUSBFilter, USBFILTERIDX_DEVICE, data.strRevision); usbFilterFieldToString(&mData->mUSBFilter, USBFILTERIDX_MANUFACTURER_STR, data.strManufacturer); usbFilterFieldToString(&mData->mUSBFilter, USBFILTERIDX_PRODUCT_STR, data.strProduct); usbFilterFieldToString(&mData->mUSBFilter, USBFILTERIDX_SERIAL_NUMBER_STR, data.strSerialNumber); usbFilterFieldToString(&mData->mUSBFilter, USBFILTERIDX_PORT, data.strPort); COMGETTER(Action)(&data.action); }
/** * Send a relative mouse event to the guest. * @note the VMMDev capability change is so that the guest knows we are sending * real events over the PS/2 device and not dummy events to signal the * arrival of new absolute pointer data * * @returns COM status code * @param dx X movement * @param dy Y movement * @param dz Z movement * @param buttonState The mouse button state */ STDMETHODIMP Mouse::PutMouseEvent(LONG dx, LONG dy, LONG dz, LONG dw, LONG buttonState) { HRESULT rc; uint32_t fButtons; AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); LogRel3(("%s: dx=%d, dy=%d, dz=%d, dw=%d\n", __PRETTY_FUNCTION__, dx, dy, dz, dw)); fButtons = mouseButtonsToPDM(buttonState); /* Make sure that the guest knows that we are sending real movement * events to the PS/2 device and not just dummy wake-up ones. */ updateVMMDevMouseCaps(0, VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE); rc = reportRelEventToMouseDev(dx, dy, dz, dw, fButtons); fireMouseEvent(false, dx, dy, dz, dw, buttonState); return rc; }
STDMETHODIMP NATEngine::GetNetworkSettings(ULONG *aMtu, ULONG *aSockSnd, ULONG *aSockRcv, ULONG *aTcpWndSnd, ULONG *aTcpWndRcv) { AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); if (aMtu) *aMtu = mData->mMtu; if (aSockSnd) *aSockSnd = mData->mSockSnd; if (aSockRcv) *aSockRcv = mData->mSockRcv; if (aTcpWndSnd) *aTcpWndSnd = mData->mTcpSnd; if (aTcpWndRcv) *aTcpWndRcv = mData->mTcpRcv; return S_OK; }
STDMETHODIMP SystemProperties::GetDeviceTypesForStorageBus(StorageBus_T aBus, ComSafeArrayOut(DeviceType_T, aDeviceTypes)) { CheckComArgOutSafeArrayPointerValid(aDeviceTypes); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); /* no need to lock, this is const */ switch (aBus) { case StorageBus_IDE: case StorageBus_SATA: { com::SafeArray<DeviceType_T> saDeviceTypes(2); saDeviceTypes[0] = DeviceType_DVD; saDeviceTypes[1] = DeviceType_HardDisk; saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes)); break; } case StorageBus_SCSI: case StorageBus_SAS: { com::SafeArray<DeviceType_T> saDeviceTypes(1); saDeviceTypes[0] = DeviceType_HardDisk; saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes)); break; } case StorageBus_Floppy: { com::SafeArray<DeviceType_T> saDeviceTypes(1); saDeviceTypes[0] = DeviceType_Floppy; saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes)); break; } default: AssertMsgFailed(("Invalid bus type %d\n", aBus)); } return S_OK; }