void GuestFsObjInfo::FinalRelease(void) { LogFlowThisFuncEnter(); uninit(); BaseFinalRelease(); LogFlowThisFuncLeave(); }
/** * Uninitializes the Session object. * * @note Locks this object for writing. */ void Session::uninit() { LogFlowThisFuncEnter(); /* Enclose the state transition Ready->InUninit->NotReady */ AutoUninitSpan autoUninitSpan(this); if (autoUninitSpan.uninitDone()) { LogFlowThisFunc(("Already uninitialized.\n")); LogFlowThisFuncLeave(); return; } /* close() needs write lock */ AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); if (mState != SessionState_Unlocked) { Assert(mState == SessionState_Locked || mState == SessionState_Spawning); HRESULT rc = unlockMachine(true /* aFinalRelease */, false /* aFromServer */); AssertComRC(rc); } LogFlowThisFuncLeave(); }
int GuestObject::sendCommand(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms) { LogFlowThisFuncEnter(); #ifndef VBOX_GUESTCTRL_TEST_CASE ComObjPtr<Console> pConsole = mConsole; Assert(!pConsole.isNull()); /* Forward the information to the VMM device. */ VMMDev *pVMMDev = pConsole->getVMMDev(); AssertPtr(pVMMDev); LogFlowThisFunc(("uFunction=%RU32, uParms=%RU32\n", uFunction, uParms)); int vrc = pVMMDev->hgcmHostCall(HGCMSERVICE_NAME, uFunction, uParms, paParms); if (RT_FAILURE(vrc)) { /** @todo What to do here? */ } #else /* Not needed within testcases. */ int vrc = VINF_SUCCESS; #endif LogFlowFuncLeaveRC(vrc); return vrc; }
STDMETHODIMP Session::GetRemoteConsole(IConsole **aConsole) { LogFlowThisFuncEnter(); AssertReturn(aConsole, E_POINTER); AutoCaller autoCaller(this); AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); AssertReturn(mState != SessionState_Unlocked, VBOX_E_INVALID_VM_STATE); AssertMsgReturn(mType == SessionType_WriteLock && !!mConsole, ("This is not a direct session!\n"), VBOX_E_INVALID_OBJECT_STATE); /* return a failure if the session already transitioned to Closing * but the server hasn't processed Machine::OnSessionEnd() yet. */ if (mState != SessionState_Locked) return VBOX_E_INVALID_VM_STATE; mConsole.queryInterfaceTo(aConsole); LogFlowThisFuncLeave(); return S_OK; }
void NetworkAdapter::updateBandwidthGroup(BandwidthGroup *aBwGroup) { LogFlowThisFuncEnter(); Assert(isWriteLockOnCurrentThread()); ComObjPtr<BandwidthGroup> pOldBwGroup; if (!mData->mBandwidthGroup.isEmpty()) { HRESULT hrc = mParent->getBandwidthGroup(mData->mBandwidthGroup, pOldBwGroup, 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. */ } mData.backup(); if (!pOldBwGroup.isNull()) { pOldBwGroup->release(); mData->mBandwidthGroup = Utf8Str::Empty; } if (aBwGroup) { mData->mBandwidthGroup = aBwGroup->getName(); aBwGroup->reference(); } LogFlowThisFuncLeave(); }
// Wrapped IGuestFile methods ///////////////////////////////////////////////////////////////////////////// HRESULT GuestFile::close() { LogFlowThisFuncEnter(); /* Close file on guest. */ int guestRc; int rc = i_closeFile(&guestRc); /* On failure don't return here, instead do all the cleanup * work first and then return an error. */ AssertPtr(mSession); int rc2 = mSession->i_fileRemoveFromList(this); if (RT_SUCCESS(rc)) rc = rc2; if (RT_FAILURE(rc)) { if (rc == VERR_GSTCTL_GUEST_ERROR) return GuestFile::i_setErrorExternal(this, guestRc); return setError(VBOX_E_IPRT_ERROR, tr("Closing guest file failed with %Rrc\n"), rc); } LogFlowThisFunc(("Returning rc=%Rrc\n", rc)); return S_OK; }
HRESULT GuestFile::writeAt(LONG64 aOffset, const std::vector<BYTE> &aData, ULONG aTimeoutMS, ULONG *aWritten) { LogFlowThisFuncEnter(); HRESULT hr = S_OK; uint32_t cbData = (uint32_t)aData.size(); void *pvData = cbData > 0? (void *)&aData.front(): NULL; int vrc = i_writeData(aTimeoutMS, pvData, cbData, (uint32_t*)aWritten); if (RT_FAILURE(vrc)) { switch (vrc) { default: hr = setError(VBOX_E_IPRT_ERROR, tr("Writing %zubytes to file \"%s\" (at offset %RU64) failed: %Rrc"), aData.size(), mData.mOpenInfo.mFileName.c_str(), aOffset, vrc); break; } } LogFlowFuncLeaveRC(vrc); return hr; }
/** * Initializes the Session object. */ HRESULT Session::init() { /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); LogFlowThisFuncEnter(); mState = SessionState_Unlocked; mType = SessionType_Null; #if defined(RT_OS_WINDOWS) mIPCSem = NULL; mIPCThreadSem = NULL; #elif defined(RT_OS_OS2) mIPCThread = NIL_RTTHREAD; mIPCThreadSem = NIL_RTSEMEVENT; #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) mIPCSem = -1; #else # error "Port me!" #endif /* Confirm a successful initialization when it's the case */ autoInitSpan.setSucceeded(); LogFlowThisFuncLeave(); return S_OK; }
void MediumAttachment::FinalRelease() { LogFlowThisFuncEnter(); uninit(); BaseFinalRelease(); LogFlowThisFuncLeave(); }
STDMETHODIMP NetworkAdapter::COMGETTER(BandwidthGroup)(IBandwidthGroup **aBwGroup) { LogFlowThisFuncEnter(); CheckComArgOutPointerValid(aBwGroup); HRESULT hrc = S_OK; AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); if (mData->mBandwidthGroup.isNotEmpty()) { ComObjPtr<BandwidthGroup> pBwGroup; hrc = mParent->getBandwidthGroup(mData->mBandwidthGroup, pBwGroup, true /* fSetError */); Assert(SUCCEEDED(hrc)); /* This is not allowed to fail because the existence of the group was checked when it was attached. */ if (SUCCEEDED(hrc)) pBwGroup.queryInterfaceTo(aBwGroup); } LogFlowThisFuncLeave(); return hrc; }
STDMETHODIMP GuestDirectory::Close(void) { #ifndef VBOX_WITH_GUEST_CONTROL ReturnComNotImplemented(); #else LogFlowThisFuncEnter(); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AssertPtr(mData.mSession); int rc = mData.mSession->directoryRemoveFromList(this); mData.mProcessTool.Terminate(); /* * Release autocaller before calling uninit. */ autoCaller.release(); uninit(); LogFlowFuncLeaveRC(rc); return S_OK; #endif /* VBOX_WITH_GUEST_CONTROL */ }
/** * Closes the object's internal handles (to files / ...). * */ void DnDURIObject::closeInternal(void) { LogFlowThisFuncEnter(); switch (m_enmType) { case Type_File: { RTFileClose(u.File.hFile); u.File.hFile = NIL_RTFILE; RT_ZERO(u.File.objInfo); break; } case Type_Directory: { RTDirClose(u.Dir.hDir); u.Dir.hDir = NIL_RTDIR; RT_ZERO(u.Dir.objInfo); break; } default: break; } }
UIDnDMIMEData::UIDnDMIMEData(UIDnDHandler *pDnDHandler, QStringList lstFormats, Qt::DropAction defAction, Qt::DropActions actions) : m_pDnDHandler(pDnDHandler) , m_lstFormats(lstFormats) , m_defAction(defAction) , m_curAction(Qt::IgnoreAction) , m_actions(actions) , m_enmState(Dragging) , m_vaData(QVariant::Invalid) #ifdef RT_OS_DARWIN , m_fCanDrop(false) #endif { LogFlowThisFuncEnter(); #ifdef DEBUG LogFlowFunc(("Number of formats: %d\n", m_lstFormats.size())); for (int i = 0; i < m_lstFormats.size(); i++) LogFlowFunc(("\tFormat %d: %s\n", i, m_lstFormats.at(i).toAscii().constData())); #endif #ifdef RT_OS_DARWIN connect(this, SIGNAL(notifyDropped()), this, SLOT(sltDropped())); #endif }
void GuestDirectory::FinalRelease(void) { LogFlowThisFuncEnter(); uninit(); BaseFinalRelease(); LogFlowThisFuncLeave(); }
STDMETHODIMP GuestFile::WriteAt(LONG64 aOffset, ComSafeArrayIn(BYTE, aData), ULONG aTimeoutMS, ULONG *aWritten) { #ifndef VBOX_WITH_GUEST_CONTROL ReturnComNotImplemented(); #else LogFlowThisFuncEnter(); CheckComArgSafeArrayNotNull(aData); CheckComArgOutPointerValid(aWritten); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); HRESULT hr = S_OK; com::SafeArray<BYTE> data(ComSafeArrayInArg(aData)); int vrc = writeData(aTimeoutMS, data.raw(), (uint32_t)data.size(), (uint32_t*)aWritten); if (RT_FAILURE(vrc)) { switch (vrc) { default: hr = setError(VBOX_E_IPRT_ERROR, tr("Writing %zubytes to file \"%s\" (at offset %RU64) failed: %Rrc"), data.size(), mData.mOpenInfo.mFileName.c_str(), aOffset, vrc); break; } } LogFlowFuncLeaveRC(vrc); return hr; #endif /* VBOX_WITH_GUEST_CONTROL */ }
STDMETHODIMP GuestFile::Close(void) { #ifndef VBOX_WITH_GUEST_CONTROL ReturnComNotImplemented(); #else LogFlowThisFuncEnter(); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); /* Close file on guest. */ int guestRc; int rc = closeFile(&guestRc); /* On failure don't return here, instead do all the cleanup * work first and then return an error. */ AssertPtr(mSession); int rc2 = mSession->fileRemoveFromList(this); if (RT_SUCCESS(rc)) rc = rc2; if (RT_FAILURE(rc)) { if (rc == VERR_GSTCTL_GUEST_ERROR) return GuestFile::setErrorExternal(this, guestRc); return setError(VBOX_E_IPRT_ERROR, tr("Closing guest file failed with %Rrc\n"), rc); } LogFlowThisFunc(("Returning rc=%Rrc\n", rc)); return S_OK; #endif /* VBOX_WITH_GUEST_CONTROL */ }
void GuestDnDSource::FinalRelease(void) { LogFlowThisFuncEnter(); uninit(); BaseFinalRelease(); LogFlowThisFuncLeave(); }
void GuestDnDResponse::reset(void) { LogFlowThisFuncEnter(); m_defAction = 0; m_allActions = 0; m_lstFormats.clear(); }
/** * @note XPCOM: when this method is not called on the main XPCOM thread, it * simply blocks the thread until mCompletedSem is signalled. If the * thread has its own event queue (hmm, what for?) that it must run, then * calling this method will definitely freeze event processing. */ STDMETHODIMP Progress::WaitForOperationCompletion(ULONG aOperation, LONG aTimeout) { LogFlowThisFuncEnter(); LogFlowThisFunc(("aOperation=%d, aTimeout=%d\n", aOperation, aTimeout)); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); CheckComArgExpr(aOperation, aOperation < m_cOperations); /* if we're already completed or if the given operation is already done, * then take a shortcut */ if ( !mCompleted && aOperation >= m_ulCurrentOperation) { int vrc = VINF_SUCCESS; bool fForever = aTimeout < 0; int64_t timeLeft = aTimeout; int64_t lastTime = RTTimeMilliTS(); while ( !mCompleted && aOperation >= m_ulCurrentOperation && (fForever || timeLeft > 0)) { mWaitersCount ++; alock.release(); vrc = RTSemEventMultiWait(mCompletedSem, fForever ? RT_INDEFINITE_WAIT : (unsigned) timeLeft); alock.acquire(); mWaitersCount--; /* the last waiter resets the semaphore */ if (mWaitersCount == 0) RTSemEventMultiReset(mCompletedSem); if (RT_FAILURE(vrc) && vrc != VERR_TIMEOUT) break; if (!fForever) { int64_t now = RTTimeMilliTS(); timeLeft -= now - lastTime; lastTime = now; } } if (RT_FAILURE(vrc) && vrc != VERR_TIMEOUT) return setError(E_FAIL, tr("Failed to wait for the operation completion (%Rrc)"), vrc); } LogFlowThisFuncLeave(); return S_OK; }
void GuestBase::baseUninit(void) { LogFlowThisFuncEnter(); int rc = RTCritSectDelete(&mWaitEventCritSect); LogFlowFuncLeaveRC(rc); /* No return value. */ }
HRESULT MediumAttachment::getPort(LONG *aPort) { LogFlowThisFuncEnter(); /* m->bd->port is constant during life time, no need to lock */ *aPort = m->bd->mData.lPort; LogFlowThisFuncLeave(); return S_OK; }
HRESULT GuestFile::getStatus(FileStatus_T *aStatus) { LogFlowThisFuncEnter(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); *aStatus = mData.mStatus; return S_OK; }
HRESULT MediumAttachment::getType(DeviceType_T *aType) { LogFlowThisFuncEnter(); /* m->bd->type is constant during life time, no need to lock */ *aType = m->bd->mData.deviceType; LogFlowThisFuncLeave(); return S_OK; }
HRESULT Guest::getEventSource(ComPtr<IEventSource> &aEventSource) { LogFlowThisFuncEnter(); /* No need to lock - lifetime constant. */ mEventSource.queryInterfaceTo(aEventSource.asOutParam()); LogFlowFuncLeaveRC(S_OK); return S_OK; }
HRESULT MediumAttachment::getController(com::Utf8Str &aController) { LogFlowThisFuncEnter(); /* m->controller is constant during life time, no need to lock */ aController = Utf8Str(m->bd->strControllerName); LogFlowThisFuncLeave(); return S_OK; }
HRESULT MediumAttachment::getDevice(LONG *aDevice) { LogFlowThisFuncEnter(); /* m->bd->device is constant during life time, no need to lock */ *aDevice = m->bd->mData.lDevice; LogFlowThisFuncLeave(); return S_OK; }
HRESULT MediumAttachment::getDiscard(BOOL *aDiscard) { LogFlowThisFuncEnter(); AutoReadLock lock(this COMMA_LOCKVAL_SRC_POS); *aDiscard = m->bd->mData.fDiscard; LogFlowThisFuncLeave(); return S_OK; }
void MediumAttachment::i_updateBandwidthGroup(const Utf8Str &aBandwidthGroup) { LogFlowThisFuncEnter(); Assert(isWriteLockOnCurrentThread()); Assert(!m->pMachine->i_isSnapshotMachine()); m->bd.backup(); m->bd->mData.strBwGroup = aBandwidthGroup; LogFlowThisFuncLeave(); }
HRESULT MediumAttachment::getHotPluggable(BOOL *aHotPluggable) { LogFlowThisFuncEnter(); AutoReadLock lock(this COMMA_LOCKVAL_SRC_POS); *aHotPluggable = m->bd->mData.fHotPluggable; LogFlowThisFuncLeave(); return S_OK; }
int GuestFile::openFile(uint32_t uTimeoutMS, int *pGuestRc) { LogFlowThisFuncEnter(); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); LogFlowThisFunc(("strFile=%s, strOpenMode=%s, strDisposition=%s, uCreationMode=%RU32, uOffset=%RU64\n", mData.mOpenInfo.mFileName.c_str(), mData.mOpenInfo.mOpenMode.c_str(), mData.mOpenInfo.mDisposition.c_str(), mData.mOpenInfo.mCreationMode, mData.mOpenInfo.mInitialOffset)); int vrc; GuestWaitEvent *pEvent = NULL; GuestEventTypes eventTypes; try { eventTypes.push_back(VBoxEventType_OnGuestFileStateChanged); vrc = registerWaitEvent(eventTypes, &pEvent); } catch (std::bad_alloc) { vrc = VERR_NO_MEMORY; } if (RT_FAILURE(vrc)) return vrc; /* Prepare HGCM call. */ VBOXHGCMSVCPARM paParms[8]; int i = 0; paParms[i++].setUInt32(pEvent->ContextID()); paParms[i++].setPointer((void*)mData.mOpenInfo.mFileName.c_str(), (ULONG)mData.mOpenInfo.mFileName.length() + 1); paParms[i++].setPointer((void*)mData.mOpenInfo.mOpenMode.c_str(), (ULONG)mData.mOpenInfo.mOpenMode.length() + 1); paParms[i++].setPointer((void*)mData.mOpenInfo.mDisposition.c_str(), (ULONG)mData.mOpenInfo.mDisposition.length() + 1); paParms[i++].setPointer((void*)mData.mOpenInfo.mSharingMode.c_str(), (ULONG)mData.mOpenInfo.mSharingMode.length() + 1); paParms[i++].setUInt32(mData.mOpenInfo.mCreationMode); paParms[i++].setUInt64(mData.mOpenInfo.mInitialOffset); alock.release(); /* Drop write lock before sending. */ vrc = sendCommand(HOST_FILE_OPEN, i, paParms); if (RT_SUCCESS(vrc)) vrc = waitForStatusChange(pEvent, uTimeoutMS, NULL /* FileStatus */, pGuestRc); unregisterWaitEvent(pEvent); LogFlowFuncLeaveRC(vrc); return vrc; }