VirtualBox

Changeset 44340 in vbox for trunk


Ignore:
Timestamp:
Jan 23, 2013 4:20:07 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
83296
Message:

VMM,Main,Debugger,REM: VM API cleanup, prefering PUVM over PVM so we can use real reference counting and not have the memory backing the VM structure disappear on us.

Location:
trunk
Files:
2 deleted
38 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/dbggui.h

    r28800 r44340  
    9898 *
    9999 * @returns VBox status code.
    100  * @param   pVM         The VM handle.
     100 * @param   pUVM        The VM handle.
    101101 * @param   ppGui       Where to store the pointer to the debugger instance.
    102102 * @param   ppGuiVT     Where to store the virtual method table pointer.
    103103 *                      Optional.
    104104 */
    105 DBGDECL(int) DBGGuiCreateForVM(PVM pVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT);
     105DBGDECL(int) DBGGuiCreateForVM(PUVM pUVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT);
    106106/** @copydoc DBGGuiCreateForVM. */
    107 typedef DECLCALLBACK(int) FNDBGGUICREATEFORVM(PVM pVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT);
     107typedef DECLCALLBACK(int) FNDBGGUICREATEFORVM(PUVM pUVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT);
    108108/** Pointer to DBGGuiCreateForVM. */
    109109typedef FNDBGGUICREATEFORVM *PFNDBGGUICREATEFORVM;
  • trunk/include/VBox/vmm/cfgm.h

    r39853 r44340  
    186186 */
    187187VMMR3DECL(PCFGMNODE)    CFGMR3GetRoot(PVM pVM);
     188VMMR3DECL(PCFGMNODE)    CFGMR3GetRootU(PUVM pUVM);
    188189VMMR3DECL(PCFGMNODE)    CFGMR3GetParent(PCFGMNODE pNode);
    189190VMMR3DECL(PCFGMNODE)    CFGMR3GetParentEx(PVM pVM, PCFGMNODE pNode);
  • trunk/include/VBox/vmm/em.h

    r43394 r44340  
    225225 * @{
    226226 */
    227 VMMR3DECL(int)      EMR3Init(PVM pVM);
    228 VMMR3DECL(void)     EMR3Relocate(PVM pVM);
    229 VMMR3DECL(void)     EMR3ResetCpu(PVMCPU pVCpu);
    230 VMMR3DECL(void)     EMR3Reset(PVM pVM);
    231 VMMR3DECL(int)      EMR3Term(PVM pVM);
     227VMMR3DECL(int)          EMR3Init(PVM pVM);
     228VMMR3DECL(void)         EMR3Relocate(PVM pVM);
     229VMMR3DECL(void)         EMR3ResetCpu(PVMCPU pVCpu);
     230VMMR3DECL(void)         EMR3Reset(PVM pVM);
     231VMMR3DECL(int)          EMR3Term(PVM pVM);
    232232VMMR3DECL(DECLNORETURN(void)) EMR3FatalError(PVMCPU pVCpu, int rc);
    233 VMMR3DECL(int)      EMR3ExecuteVM(PVM pVM, PVMCPU pVCpu);
    234 VMMR3DECL(int)      EMR3CheckRawForcedActions(PVM pVM, PVMCPU pVCpu);
    235 VMMR3DECL(int)      EMR3Interpret(PVM pVM);
     233VMMR3DECL(int)          EMR3ExecuteVM(PVM pVM, PVMCPU pVCpu);
     234VMMR3DECL(int)          EMR3CheckRawForcedActions(PVM pVM, PVMCPU pVCpu);
     235VMMR3DECL(int)          EMR3Interpret(PVM pVM);
     236VMMR3_INT_DECL(int)     EMR3NotifyResume(PVM pVM);
     237VMMR3_INT_DECL(int)     EMR3NotifySuspend(PVM pVM);
     238VMMR3_INT_DECL(bool)    EMR3IsExecutionAllowed(PVM pVM, PVMCPU pVCpu);
    236239
    237240/**
  • trunk/include/VBox/vmm/vmapi.h

    r43387 r44340  
    316316} VMINITCOMPLETED;
    317317
    318 
    319 VMMR3DECL(int)  VMR3Create(uint32_t cCpus, PCVMM2USERMETHODS pVm2UserCbs,
    320                            PFNVMATERROR pfnVMAtError, void *pvUserVM,
    321                            PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUserCFGM,
    322                            PVM *ppVM);
    323 VMMR3DECL(int)  VMR3PowerOn(PVM pVM);
    324 VMMR3DECL(int)  VMR3Suspend(PVM pVM);
    325 VMMR3DECL(int)  VMR3Resume(PVM pVM);
    326 VMMR3DECL(int)  VMR3Reset(PVM pVM);
    327 
    328318/**
    329319 * Progress callback.
     
    340330typedef FNVMPROGRESS *PFNVMPROGRESS;
    341331
    342 VMMR3DECL(int)  VMR3Save(PVM pVM, const char *pszFilename, bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended);
    343 VMMR3DECL(int)  VMR3Teleport(PVM pVM, uint32_t cMsDowntime, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, PFNVMPROGRESS pfnProgress, void *pvProgressUser, bool *pfSuspended);
    344 VMMR3DECL(int)  VMR3LoadFromFile(PVM pVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser);
    345 VMMR3DECL(int)  VMR3LoadFromStream(PVM pVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
    346                                    PFNVMPROGRESS pfnProgress, void *pvProgressUser);
    347 VMMR3DECL(int)  VMR3PowerOff(PVM pVM);
    348 VMMR3DECL(int)  VMR3Destroy(PVM pVM);
    349 VMMR3DECL(void) VMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
    350 VMMR3DECL(PVM)  VMR3EnumVMs(PVM pVMPrev);
     332/**
     333 * VM destruction callback.
     334 * @param   pVM     The VM which is about to be destroyed.
     335 * @param   pvUser  The user parameter specified at registration.
     336 */
     337typedef DECLCALLBACK(void) FNVMATDTOR(PVM pVM, void *pvUser);
     338/** Pointer to a VM destruction callback. */
     339typedef FNVMATDTOR *PFNVMATDTOR;
     340
     341
     342VMMR3DECL(int)          VMR3Create(uint32_t cCpus, PCVMM2USERMETHODS pVm2UserCbs,
     343                                   PFNVMATERROR pfnVMAtError, void *pvUserVM,
     344                                   PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUserCFGM,
     345                                   PVM *ppVM, PUVM *ppUVM);
     346VMMR3DECL(int)          VMR3PowerOn(PUVM pUVM);
     347VMMR3DECL(int)          VMR3Suspend(PUVM pUVM);
     348VMMR3DECL(int)          VMR3Resume(PUVM pUVM);
     349VMMR3DECL(int)          VMR3Reset(PUVM pUVM);
     350VMMR3DECL(int)          VMR3Save(PUVM pUVM, const char *pszFilename, bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended);
     351VMMR3_INT_DECL(int)     VMR3SaveFT(PUVM pUVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, bool *pfSuspended, bool fSkipStateChanges);
     352VMMR3DECL(int)          VMR3Teleport(PUVM pUVM, uint32_t cMsDowntime, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, PFNVMPROGRESS pfnProgress, void *pvProgressUser, bool *pfSuspended);
     353VMMR3DECL(int)          VMR3LoadFromFile(PUVM pUVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser);
     354VMMR3DECL(int)          VMR3LoadFromStream(PUVM pUVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
     355                                           PFNVMPROGRESS pfnProgress, void *pvProgressUser);
     356VMMR3_INT_DECL(int)     VMR3LoadFromStreamFT(PUVM pUVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser);
     357
     358VMMR3DECL(int)          VMR3PowerOff(PUVM pUVM);
     359VMMR3DECL(int)          VMR3Destroy(PUVM pUVM);
     360VMMR3_INT_DECL(void)    VMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
    351361
    352362VMMR3DECL(PVM)          VMR3GetVM(PUVM pUVM);
     
    359369VMMR3DECL(VMSTATE)      VMR3GetStateU(PUVM pUVM);
    360370VMMR3DECL(const char *) VMR3GetStateName(VMSTATE enmState);
    361 
    362 /**
    363  * VM destruction callback.
    364  * @param   pVM     The VM which is about to be destroyed.
    365  * @param   pvUser  The user parameter specified at registration.
    366  */
    367 typedef DECLCALLBACK(void) FNVMATDTOR(PVM pVM, void *pvUser);
    368 /** Pointer to a VM destruction callback. */
    369 typedef FNVMATDTOR *PFNVMATDTOR;
    370 
    371 VMMR3DECL(int)      VMR3AtDtorRegister(PFNVMATDTOR pfnAtDtor, void *pvUser);
    372 VMMR3DECL(int)      VMR3AtDtorDeregister(PFNVMATDTOR pfnAtDtor);
    373 VMMR3DECL(int)      VMR3AtStateRegister(PVM pVM, PFNVMATSTATE pfnAtState, void *pvUser);
    374 VMMR3DECL(int)      VMR3AtStateDeregister(PVM pVM, PFNVMATSTATE pfnAtState, void *pvUser);
    375 VMMR3DECL(bool)     VMR3TeleportedAndNotFullyResumedYet(PVM pVM);
    376 VMMR3DECL(int)      VMR3AtErrorRegister(PVM pVM, PFNVMATERROR pfnAtError, void *pvUser);
    377 VMMR3DECL(int)      VMR3AtErrorRegisterU(PUVM pVM, PFNVMATERROR pfnAtError, void *pvUser);
    378 VMMR3DECL(int)      VMR3AtErrorDeregister(PVM pVM, PFNVMATERROR pfnAtError, void *pvUser);
    379 VMMR3DECL(void)     VMR3SetErrorWorker(PVM pVM);
    380 VMMR3DECL(uint32_t) VMR3GetErrorCount(PVM pVM);
    381 VMMR3DECL(uint32_t) VMR3GetErrorCountU(PUVM pUVM);
    382 VMMR3DECL(int)      VMR3AtRuntimeErrorRegister(PVM pVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
    383 VMMR3DECL(int)      VMR3AtRuntimeErrorDeregister(PVM pVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
    384 VMMR3DECL(int)      VMR3SetRuntimeErrorWorker(PVM pVM);
    385 VMMR3DECL(uint32_t) VMR3GetRuntimeErrorCount(PVM pVM);
    386 VMMR3DECL(int)      VMR3ReqCall(PVM pVM, VMCPUID idDstCpu, PVMREQ *ppReq, RTMSINTERVAL cMillies, uint32_t fFlags, PFNRT pfnFunction, unsigned cArgs, ...);
    387 VMMR3DECL(int)      VMR3ReqCallU(PUVM pUVM, VMCPUID idDstCpu, PVMREQ *ppReq, RTMSINTERVAL cMillies, uint32_t fFlags, PFNRT pfnFunction, unsigned cArgs, ...);
    388 VMMR3DECL(int)      VMR3ReqCallVU(PUVM pUVM, VMCPUID idDstCpu, PVMREQ *ppReq, RTMSINTERVAL cMillies, uint32_t fFlags, PFNRT pfnFunction, unsigned cArgs, va_list Args);
    389 VMMR3DECL(int)      VMR3ReqCallWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
    390 VMMR3DECL(int)      VMR3ReqCallNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
    391 VMMR3DECL(int)      VMR3ReqCallVoidWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
    392 VMMR3DECL(int)      VMR3ReqCallVoidNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
    393 VMMR3DECL(int)      VMR3ReqPriorityCallWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
    394 VMMR3DECL(int)      VMR3ReqPriorityCallVoidWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
    395 VMMR3DECL(int)      VMR3ReqAlloc(PVM pVM, PVMREQ *ppReq, VMREQTYPE enmType, VMCPUID idDstCpu);
    396 VMMR3DECL(int)      VMR3ReqAllocU(PUVM pUVM, PVMREQ *ppReq, VMREQTYPE enmType, VMCPUID idDstCpu);
    397 VMMR3DECL(int)      VMR3ReqFree(PVMREQ pReq);
    398 VMMR3DECL(int)      VMR3ReqQueue(PVMREQ pReq, RTMSINTERVAL cMillies);
    399 VMMR3DECL(int)      VMR3ReqWait(PVMREQ pReq, RTMSINTERVAL cMillies);
    400 VMMR3DECL(int)      VMR3ReqProcessU(PUVM pUVM, VMCPUID idDstCpu, bool fPriorityOnly);
    401 VMMR3DECL(void)     VMR3NotifyGlobalFFU(PUVM pUVM, uint32_t fFlags);
    402 VMMR3DECL(void)     VMR3NotifyCpuFFU(PUVMCPU pUVMCpu, uint32_t fFlags);
     371VMMR3DECL(int)          VMR3AtStateRegister(PUVM pUVM, PFNVMATSTATE pfnAtState, void *pvUser);
     372VMMR3DECL(int)          VMR3AtStateDeregister(PUVM pUVM, PFNVMATSTATE pfnAtState, void *pvUser);
     373VMMR3_INT_DECL(bool)    VMR3TeleportedAndNotFullyResumedYet(PVM pVM);
     374VMMR3DECL(int)          VMR3AtErrorRegister(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser);
     375VMMR3DECL(int)          VMR3AtErrorDeregister(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser);
     376VMMR3_INT_DECL(void)    VMR3SetErrorWorker(PVM pVM);
     377VMMR3_INT_DECL(uint32_t) VMR3GetErrorCount(PUVM pUVM);
     378VMMR3DECL(int)          VMR3AtRuntimeErrorRegister(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
     379VMMR3DECL(int)          VMR3AtRuntimeErrorDeregister(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
     380VMMR3_INT_DECL(int)     VMR3SetRuntimeErrorWorker(PVM pVM);
     381VMMR3_INT_DECL(uint32_t) VMR3GetRuntimeErrorCount(PUVM pUVM);
     382
     383VMMR3DECL(int)          VMR3ReqCallU(PUVM pUVM, VMCPUID idDstCpu, PVMREQ *ppReq, RTMSINTERVAL cMillies, uint32_t fFlags, PFNRT pfnFunction, unsigned cArgs, ...);
     384VMMR3DECL(int)          VMR3ReqCallVU(PUVM pUVM, VMCPUID idDstCpu, PVMREQ *ppReq, RTMSINTERVAL cMillies, uint32_t fFlags, PFNRT pfnFunction, unsigned cArgs, va_list Args);
     385VMMR3_INT_DECL(int)     VMR3ReqCallWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     386VMMR3DECL(int)          VMR3ReqCallWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     387VMMR3DECL(int)          VMR3ReqCallNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     388VMMR3DECL(int)          VMR3ReqCallNoWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     389VMMR3_INT_DECL(int)     VMR3ReqCallVoidWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     390VMMR3DECL(int)          VMR3ReqCallVoidWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     391VMMR3DECL(int)          VMR3ReqCallVoidNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     392VMMR3DECL(int)          VMR3ReqPriorityCallWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     393VMMR3DECL(int)          VMR3ReqPriorityCallWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     394VMMR3DECL(int)          VMR3ReqPriorityCallVoidWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     395VMMR3DECL(int)          VMR3ReqAlloc(PUVM pUVM, PVMREQ *ppReq, VMREQTYPE enmType, VMCPUID idDstCpu);
     396VMMR3DECL(int)          VMR3ReqFree(PVMREQ pReq);
     397VMMR3DECL(int)          VMR3ReqQueue(PVMREQ pReq, RTMSINTERVAL cMillies);
     398VMMR3DECL(int)          VMR3ReqWait(PVMREQ pReq, RTMSINTERVAL cMillies);
     399VMMR3_INT_DECL(int)     VMR3ReqProcessU(PUVM pUVM, VMCPUID idDstCpu, bool fPriorityOnly);
     400
    403401/** @name Flags for VMR3NotifyCpuFFU and VMR3NotifyGlobalFFU.
    404402 * @{ */
     
    408406#define VMNOTIFYFF_FLAGS_POKE       RT_BIT_32(1)
    409407/** @} */
    410 
    411 VMMR3DECL(int)              VMR3WaitHalted(PVM pVM, PVMCPU pVCpu, bool fIgnoreInterrupts);
    412 VMMR3DECL(int)              VMR3WaitU(PUVMCPU pUVMCpu);
     408VMMR3_INT_DECL(void)        VMR3NotifyGlobalFFU(PUVM pUVM, uint32_t fFlags);
     409VMMR3_INT_DECL(void)        VMR3NotifyCpuFFU(PUVMCPU pUVMCpu, uint32_t fFlags);
     410VMMR3_INT_DECL(int)         VMR3WaitHalted(PVM pVM, PVMCPU pVCpu, bool fIgnoreInterrupts);
     411VMMR3_INT_DECL(int)         VMR3WaitU(PUVMCPU pUVMCpu);
    413412VMMR3_INT_DECL(int)         VMR3AsyncPdmNotificationWaitU(PUVMCPU pUVCpu);
    414413VMMR3_INT_DECL(void)        VMR3AsyncPdmNotificationWakeupU(PUVM pUVM);
    415 VMMR3DECL(RTCPUID)          VMR3GetVMCPUId(PVM pVM);
    416 VMMR3DECL(RTTHREAD)         VMR3GetVMCPUThread(PVM pVM);
    417 VMMR3DECL(RTTHREAD)         VMR3GetVMCPUThreadU(PUVM pUVM);
     414VMMR3_INT_DECL(RTCPUID)     VMR3GetVMCPUId(PVM pVM);
     415VMMR3DECL(RTTHREAD)         VMR3GetVMCPUThread(PUVM pUVM);
    418416VMMR3DECL(RTNATIVETHREAD)   VMR3GetVMCPUNativeThread(PVM pVM);
    419417VMMR3DECL(RTNATIVETHREAD)   VMR3GetVMCPUNativeThreadU(PUVM pUVM);
    420 VMMR3DECL(int)              VMR3GetCpuCoreAndPackageIdFromCpuId(PVM pVM, VMCPUID idCpu, uint32_t *pidCpuCore, uint32_t *pidCpuPackage);
    421 VMMR3DECL(int)              VMR3HotUnplugCpu(PVM pVM, VMCPUID idCpu);
    422 VMMR3DECL(int)              VMR3HotPlugCpu(PVM pVM, VMCPUID idCpu);
    423 VMMR3DECL(int)              VMR3SetCpuExecutionCap(PVM pVM, uint32_t uCpuExecutionCap);
     418VMMR3DECL(int)              VMR3GetCpuCoreAndPackageIdFromCpuId(PUVM pUVM, VMCPUID idCpu, uint32_t *pidCpuCore, uint32_t *pidCpuPackage);
     419VMMR3DECL(int)              VMR3HotUnplugCpu(PUVM pUVM, VMCPUID idCpu);
     420VMMR3DECL(int)              VMR3HotPlugCpu(PUVM pUVM, VMCPUID idCpu);
     421VMMR3DECL(int)              VMR3SetCpuExecutionCap(PUVM pUVM, uint32_t uCpuExecutionCap);
    424422/** @} */
    425423#endif /* IN_RING3 */
  • trunk/src/VBox/Debugger/VBoxDbg.cpp

    r35346 r44340  
    7272 * @returns VBox status code.
    7373 * @param   pSession    The ISession interface. (DBGGuiCreate)
    74  * @param   pVM         The VM handle. (DBGGuiCreateForVM)
     74 * @param   pUVM        The VM handle. (DBGGuiCreateForVM)
    7575 * @param   ppGui       See DBGGuiCreate.
    7676 * @param   ppGuiVT     See DBGGuiCreate.
    7777 */
    78 static int dbgGuiCreate(ISession *pSession, PVM pVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT)
     78static int dbgGuiCreate(ISession *pSession, PUVM pUVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT)
    7979{
    8080    /*
     
    9191        rc = pGui->pVBoxDbgGui->init(pSession);
    9292    else
    93         rc = pGui->pVBoxDbgGui->init(pVM);
     93        rc = pGui->pVBoxDbgGui->init(pUVM);
    9494    if (RT_SUCCESS(rc))
    9595    {
     
    135135 *
    136136 * @returns VBox status code.
    137  * @param   pVM         The VM handle.
     137 * @param   pUVM        The VM handle.
    138138 * @param   ppGui       Where to store the pointer to the debugger instance.
    139139 * @param   ppGuiVT     Where to store the virtual method table pointer.
    140140 *                      Optional.
    141141 */
    142 DBGDECL(int) DBGGuiCreateForVM(PVM pVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT)
    143 {
    144     AssertPtrReturn(pVM, VERR_INVALID_POINTER);
    145     return dbgGuiCreate(NULL, pVM, ppGui, ppGuiVT);
     142DBGDECL(int) DBGGuiCreateForVM(PUVM pUVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT)
     143{
     144    AssertPtrReturn(pUVM, VERR_INVALID_POINTER);
     145    AssertPtrReturn(VMR3RetainUVM(pUVM) != UINT32_MAX, VERR_INVALID_POINTER);
     146
     147    int rc = dbgGuiCreate(NULL, pUVM, ppGui, ppGuiVT);
     148
     149    VMR3ReleaseUVM(pUVM);
     150    return rc;
    146151}
    147152
  • trunk/src/VBox/Debugger/VBoxDbgBase.cpp

    r38812 r44340  
    3333
    3434VBoxDbgBase::VBoxDbgBase(VBoxDbgGui *a_pDbgGui)
    35     : m_pDbgGui(a_pDbgGui), m_pVM(NULL), m_hGUIThread(RTThreadNativeSelf())
     35    : m_pDbgGui(a_pDbgGui), m_pUVM(NULL), m_hGUIThread(RTThreadNativeSelf())
    3636{
    3737    /*
    3838     * Register
    3939     */
    40     PVM pVM = a_pDbgGui->getVMHandle();
    41     if (pVM)
    42     {
    43         m_pVM = pVM;
    44         int rc = VMR3AtStateRegister(pVM, atStateChange, this);
     40    m_pUVM = a_pDbgGui->getUvmHandle();
     41    if (m_pUVM)
     42    {
     43        VMR3RetainUVM(m_pUVM);
     44
     45        int rc = VMR3AtStateRegister(m_pUVM, atStateChange, this);
    4546        AssertRC(rc);
    4647    }
     
    5455     */
    5556    /** @todo need to do some locking here?  */
    56     PVM pVM = ASMAtomicXchgPtrT(&m_pVM, NULL, PVM);
    57     if (pVM)
    58     {
    59         int rc = VMR3AtStateDeregister(pVM, atStateChange, this);
     57    PUVM pUVM = ASMAtomicXchgPtrT(&m_pUVM, NULL, PUVM);
     58    if (pUVM)
     59    {
     60        int rc = VMR3AtStateDeregister(pUVM, atStateChange, this);
    6061        AssertRC(rc);
     62
     63        VMR3ReleaseUVM(pUVM);
    6164    }
    6265}
     
    6871    QByteArray Utf8Array = rPat.toUtf8();
    6972    const char *pszPat = !rPat.isEmpty() ? Utf8Array.constData() : NULL;
    70     PVM pVM = m_pVM;
    71     if (    pVM
    72         &&  VMR3GetState(pVM) < VMSTATE_DESTROYING)
    73         return STAMR3Reset(pVM, pszPat);
     73    PUVM pUVM = m_pUVM;
     74    if (    pUVM
     75        &&  VMR3GetStateU(pUVM) < VMSTATE_DESTROYING)
     76        return STAMR3Reset(VMR3GetVM(pUVM), pszPat);
    7477    return VERR_INVALID_HANDLE;
    7578}
     
    8184    QByteArray Utf8Array = rPat.toUtf8();
    8285    const char *pszPat = !rPat.isEmpty() ? Utf8Array.constData() : NULL;
    83     PVM pVM = m_pVM;
    84     if (    pVM
    85         &&  VMR3GetState(pVM) < VMSTATE_DESTROYING)
    86         return STAMR3Enum(pVM, pszPat, pfnEnum, pvUser);
     86    PUVM pUVM = m_pUVM;
     87    if (    pUVM
     88        &&  VMR3GetStateU(pUVM) < VMSTATE_DESTROYING)
     89        return STAMR3Enum(VMR3GetVM(pUVM), pszPat, pfnEnum, pvUser);
    8790    return VERR_INVALID_HANDLE;
    8891}
     
    9295VBoxDbgBase::dbgcCreate(PDBGCBACK pBack, unsigned fFlags)
    9396{
    94     PVM pVM = m_pVM;
    95     if (    pVM
    96         &&  VMR3GetState(pVM) < VMSTATE_DESTROYING)
    97         return DBGCCreate(pVM, pBack, fFlags);
     97    PUVM pUVM = m_pUVM;
     98    if (    pUVM
     99        &&  VMR3GetStateU(pUVM) < VMSTATE_DESTROYING)
     100        return DBGCCreate(VMR3GetVM(pUVM), pBack, fFlags);
    98101    return VERR_INVALID_HANDLE;
    99102}
     
    107110    {
    108111        case VMSTATE_TERMINATED:
     112        {
    109113            /** @todo need to do some locking here?  */
    110             if (ASMAtomicCmpXchgPtr(&pThis->m_pVM, NULL, pVM))
     114            PUVM pUVM = ASMAtomicXchgPtrT(&m_pUVM, NULL, PUVM);
     115            if (pUVM)
     116            {
    111117                pThis->sigTerminated();
     118                VMR3ReleaseUVM(pUVM);
     119            }
    112120            break;
     121        }
    113122
    114123        case VMSTATE_DESTROYING:
  • trunk/src/VBox/Debugger/VBoxDbgBase.h

    r35346 r44340  
    6060    bool isVMOk() const
    6161    {
    62         return m_pVM != NULL;
     62        return m_pUVM != NULL;
    6363    }
    6464
     
    120120    /** Pointer to the debugger GUI object. */
    121121    VBoxDbgGui *m_pDbgGui;
    122     /** The VM handle. */
    123     PVM volatile m_pVM;
     122    /** The user mode VM handle. */
     123    PUVM volatile m_pUVM;
    124124    /** The handle of the GUI thread. */
    125125    RTNATIVETHREAD m_hGUIThread;
  • trunk/src/VBox/Debugger/VBoxDbgGui.cpp

    r35346 r44340  
    3333VBoxDbgGui::VBoxDbgGui() :
    3434    m_pDbgStats(NULL), m_pDbgConsole(NULL), m_pSession(NULL), m_pConsole(NULL),
    35     m_pMachineDebugger(NULL), m_pMachine(NULL), m_pVM(NULL),
     35    m_pMachineDebugger(NULL), m_pMachine(NULL), m_pUVM(NULL),
    3636    m_pParent(NULL), m_pMenu(NULL),
    3737    m_x(0), m_y(0), m_cx(0), m_cy(0), m_xDesktop(0), m_yDesktop(0), m_cxDesktop(0), m_cyDesktop(0)
     
    4141
    4242
    43 int VBoxDbgGui::init(PVM pVM)
     43int VBoxDbgGui::init(PUVM pUVM)
    4444{
    4545    /*
    4646     * Set the VM handle and update the desktop size.
    4747     */
    48     m_pVM = pVM;
     48    m_pUVM = pUVM; /* Note! This eats the incoming reference to the handle! */
    4949    updateDesktopSize();
    5050
     
    7979                if (SUCCEEDED(hrc))
    8080                {
    81                     rc = init((PVM)(intptr_t)llVM);
     81                    PUVM pUVM = (PUVM)(intptr_t)llVM;
     82                    rc = init(pUVM);
    8283                    if (RT_SUCCESS(rc))
    8384                        return rc;
     85
     86                    VMR3ReleaseUVM(pUVM);
    8487                }
    8588
     
    137140    }
    138141
    139     m_pVM = NULL;
     142    if (m_pUVM)
     143    {
     144        VMR3ReleaseUVM(m_pUVM);
     145        m_pUVM = NULL;
     146    }
    140147}
    141148
  • trunk/src/VBox/Debugger/VBoxDbgGui.h

    r33540 r44340  
    5858     *
    5959     * @returns VBox status code.
    60      * @param   pVM         The VM handle.
     60     * @param   pUVM        The user mode VM handle. The caller's reference will be
     61     *                      consumed on success.
    6162     */
    62     int init(PVM pVM);
     63    int init(PUVM pUVM);
    6364
    6465    /**
     
    129130
    130131    /**
    131      * Gets the VM handle.
    132      * @returns The VM handle.
     132     * Gets the user mode VM handle.
     133     * @returns The UVM handle.
    133134     */
    134     PVM getVMHandle() const
     135    PUVM getUvmHandle() const
    135136    {
    136         return m_pVM;
     137        return m_pUVM;
    137138    }
    138139
     
    162163    /** The VM instance. */
    163164    PVM m_pVM;
     165    /** The user mode VM handle. */
     166    PUVM m_pUVM;
    164167
    165168    /** The parent widget. */
  • trunk/src/VBox/Debugger/testcase/tstVBoxDbg.cpp

    r38636 r44340  
    4646     */
    4747    PVM pVM;
    48     int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM);
     48    PUVM pUVM;
     49    int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM, &pUVM);
    4950    if (RT_SUCCESS(rc))
    5051    {
     
    5556        PDBGGUI pGui;
    5657        PCDBGGUIVT pGuiVT;
    57         rc = DBGGuiCreateForVM(pVM, &pGui, &pGuiVT);
     58        rc = DBGGuiCreateForVM(pUVM, &pGui, &pGuiVT);
    5859        if (RT_SUCCESS(rc))
    5960        {
     
    9394         * Cleanup.
    9495         */
    95         rc = VMR3Destroy(pVM);
     96        rc = VMR3Destroy(pUVM);
    9697        if (!RT_SUCCESS(rc))
    9798        {
     
    99100            cErrors++;
    100101        }
     102        VMR3ReleaseUVM(pUVM);
    101103    }
    102104    else
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r44322 r44340  
    1542415424    <attribute name="VM" type="long long" readonly="yes" wsmap="suppress">
    1542515425      <desc>
    15426         Gets the VM handle. This is only for internal use while
    15427         we carve the details of this interface.
     15426        Gets the user-mode VM handle, with a reference.  Must be passed to
     15427        VMR3ReleaseUVM when done.  This is only for internal use while we carve
     15428        the details of this interface.
    1542815429      </desc>
    1542915430    </attribute>
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r44191 r44340  
    544544                               bool fForceUnmount,
    545545                               bool fHotplug,
    546                                PVM pVM,
     546                               PUVM pUVM,
    547547                               DeviceType_T *paLedDevType);
    548548    int configMedium(PCFGMNODE pLunL0,
     
    560560                     HRESULT *phrc);
    561561    static DECLCALLBACK(int) reconfigureMediumAttachment(Console *pConsole,
    562                                                          PVM pVM,
     562                                                         PUVM pUVM,
    563563                                                         const char *pcszDevice,
    564564                                                         unsigned uInstance,
     
    573573                                                         HRESULT *phrc);
    574574    static DECLCALLBACK(int) changeRemovableMedium(Console *pThis,
    575                                                    PVM pVM,
     575                                                   PUVM pUVM,
    576576                                                   const char *pcszDevice,
    577577                                                   unsigned uInstance,
     
    592592                      bool fAttachDetach, bool fIgnoreConnectFailure);
    593593
    594     static DECLCALLBACK(int) configGuestProperties(void *pvConsole, PVM pVM);
     594    static DECLCALLBACK(int) configGuestProperties(void *pvConsole, PUVM pUVM);
    595595    static DECLCALLBACK(int) configGuestControl(void *pvConsole);
    596596    static DECLCALLBACK(void) vmstateChangeCallback(PVM aVM, VMSTATE aState,
     
    598598    static DECLCALLBACK(int) unplugCpu(Console *pThis, PVM pVM, unsigned uCpu);
    599599    static DECLCALLBACK(int) plugCpu(Console *pThis, PVM pVM, unsigned uCpu);
    600     HRESULT doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PVM pVM);
     600    HRESULT doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PUVM pUVM);
    601601    HRESULT doCPURemove(ULONG aCpu, PVM pVM);
    602602    HRESULT doCPUAdd(ULONG aCpu, PVM pVM);
    603603
    604     HRESULT doNetworkAdapterChange(PVM pVM, const char *pszDevice, unsigned uInstance,
     604    HRESULT doNetworkAdapterChange(PUVM pUVM, const char *pszDevice, unsigned uInstance,
    605605                                   unsigned uLun, INetworkAdapter *aNetworkAdapter);
    606     static DECLCALLBACK(int) changeNetworkAttachment(Console *pThis, PVM pVM, const char *pszDevice,
     606    static DECLCALLBACK(int) changeNetworkAttachment(Console *pThis, PUVM pUVM, const char *pszDevice,
    607607                                                     unsigned uInstance, unsigned uLun,
    608608                                                     INetworkAdapter *aNetworkAdapter);
     
    615615    HRESULT detachUSBDevice(const ComObjPtr<OUSBDevice> &aHostDevice);
    616616
    617     static DECLCALLBACK(int) usbAttachCallback(Console *that, PVM pVM, IUSBDevice *aHostDevice, PCRTUUID aUuid,
     617    static DECLCALLBACK(int) usbAttachCallback(Console *that, PUVM pUVM, IUSBDevice *aHostDevice, PCRTUUID aUuid,
    618618                       bool aRemote, const char *aAddress, void *pvRemoteBackend, USHORT aPortVersion, ULONG aMaskedIfs);
    619     static DECLCALLBACK(int) usbDetachCallback(Console *that, PVM pVM, PCRTUUID aUuid);
     619    static DECLCALLBACK(int) usbDetachCallback(Console *that, PUVM pUVM, PCRTUUID aUuid);
    620620#endif
    621621
    622622    static DECLCALLBACK(int) attachStorageDevice(Console *pThis,
    623                                                  PVM pVM,
     623                                                 PUVM pUVM,
    624624                                                 const char *pcszDevice,
    625625                                                 unsigned uInstance,
     
    628628                                                 IMediumAttachment *aMediumAtt);
    629629    static DECLCALLBACK(int) detachStorageDevice(Console *pThis,
    630                                                  PVM pVM,
     630                                                 PUVM pUVM,
    631631                                                 const char *pcszDevice,
    632632                                                 unsigned uInstance,
    633633                                                 StorageBus_T enmBus,
    634634                                                 IMediumAttachment *aMediumAtt);
    635     HRESULT doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PVM pVM);
    636     HRESULT doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PVM pVM);
     635    HRESULT doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PUVM pUVM);
     636    HRESULT doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PUVM pUVM);
    637637
    638638    static DECLCALLBACK(int)    fntTakeSnapshotWorker(RTTHREAD Thread, void *pvUser);
     
    648648                                                          const char *pszErrorId, const char *pszFormat, va_list va);
    649649
    650     HRESULT                     captureUSBDevices(PVM pVM);
     650    HRESULT                     captureUSBDevices(PUVM pUVM);
    651651    void                        detachAllUSBDevices(bool aDone);
    652652
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r44288 r44340  
    157157          mServerProgress(aServerProgress),
    158158          mpVM(NULL),
     159          mpUVM(NULL),
    159160          mRC(E_FAIL),
    160161          mpSafeVMPtr(NULL)
     
    168169            mpSafeVMPtr = new Console::SafeVMPtr(aConsole);
    169170            if (mpSafeVMPtr->isOk())
     171            {
    170172                mpVM = mpSafeVMPtr->raw();
     173                mpUVM = mpSafeVMPtr->rawUVM();
     174            }
    171175            else
    172176                mRC = mpSafeVMPtr->rc();
     
    198202    const ComPtr<IProgress>     mServerProgress;
    199203    PVM                         mpVM;
     204    PUVM                        mpUVM;
    200205
    201206private:
     
    22292234    alock.release();
    22302235
    2231     int vrc = VMR3Reset(ptrVM);
     2236    int vrc = VMR3Reset(ptrVM.rawUVM());
    22322237
    22332238    HRESULT rc = RT_SUCCESS(vrc) ? S_OK :
     
    22552260HRESULT Console::doCPURemove(ULONG aCpu, PVM pVM)
    22562261{
     2262    PUVM pUVM = VMR3GetUVM(pVM);
    22572263    HRESULT rc = S_OK;
    22582264
     
    22972303        /* Notify the guest if possible. */
    22982304        uint32_t idCpuCore, idCpuPackage;
    2299         vrc = VMR3GetCpuCoreAndPackageIdFromCpuId(pVM, aCpu, &idCpuCore, &idCpuPackage); AssertRC(vrc);
     2305        vrc = VMR3GetCpuCoreAndPackageIdFromCpuId(pUVM, aCpu, &idCpuCore, &idCpuPackage); AssertRC(vrc);
    23002306        if (RT_SUCCESS(vrc))
    23012307            vrc = pVmmDevPort->pfnCpuHotUnplug(pVmmDevPort, idCpuCore, idCpuPackage);
     
    23292335         */
    23302336        PVMREQ pReq;
    2331         vrc = VMR3ReqCall(pVM, 0, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
    2332                           (PFNRT)Console::unplugCpu, 3,
    2333                           this, pVM, aCpu);
     2337        vrc = VMR3ReqCallU(pUVM, 0, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
     2338                           (PFNRT)Console::unplugCpu, 3,
     2339                           this, pVM, aCpu);
    23342340        if (vrc == VERR_TIMEOUT || RT_SUCCESS(vrc))
    23352341        {
     
    23442350        {
    23452351            /* Detach it from the VM  */
    2346             vrc = VMR3HotUnplugCpu(pVM, aCpu);
     2352            vrc = VMR3HotUnplugCpu(pUVM, aCpu);
    23472353            AssertRC(vrc);
    23482354        }
     
    23622368/*static*/ DECLCALLBACK(int) Console::plugCpu(Console *pThis, PVM pVM, unsigned uCpu)
    23632369{
     2370    PUVM pUVM = VMR3GetUVM(pVM);
    23642371    LogFlowFunc(("pThis=%p uCpu=%u\n", pThis, uCpu));
    23652372
    23662373    AssertReturn(pThis, VERR_INVALID_PARAMETER);
    23672374
    2368     int rc = VMR3HotPlugCpu(pVM, uCpu);
     2375    int rc = VMR3HotPlugCpu(pUVM, uCpu);
    23692376    AssertRC(rc);
    23702377
    2371     PCFGMNODE pInst = CFGMR3GetChild(CFGMR3GetRoot(pVM), "Devices/acpi/0/");
     2378    PCFGMNODE pInst = CFGMR3GetChild(CFGMR3GetRootU(pUVM), "Devices/acpi/0/");
    23722379    AssertRelease(pInst);
    23732380    /* nuke anything which might have been left behind. */
     
    23992406HRESULT Console::doCPUAdd(ULONG aCpu, PVM pVM)
    24002407{
     2408    PUVM pUVM = VMR3GetUVM(pVM);
    24012409    HRESULT rc = S_OK;
    24022410
     
    24352443     */
    24362444    PVMREQ pReq;
    2437     int vrc = VMR3ReqCall(pVM, 0, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
    2438                           (PFNRT)Console::plugCpu, 3,
    2439                           this, pVM, aCpu);
     2445    int vrc = VMR3ReqCallU(pUVM, 0, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
     2446                           (PFNRT)Console::plugCpu, 3,
     2447                           this, pVM, aCpu);
    24402448
    24412449    /* release the lock before a VMR3* call (EMT will call us back)! */
     
    24602468        /* Notify the guest if possible. */
    24612469        uint32_t idCpuCore, idCpuPackage;
    2462         vrc = VMR3GetCpuCoreAndPackageIdFromCpuId(pVM, aCpu, &idCpuCore, &idCpuPackage); AssertRC(vrc);
     2470        vrc = VMR3GetCpuCoreAndPackageIdFromCpuId(pUVM, aCpu, &idCpuCore, &idCpuPackage); AssertRC(vrc);
    24632471        if (RT_SUCCESS(vrc))
    24642472            vrc = pDevPort->pfnCpuHotPlug(pDevPort, idCpuCore, idCpuPackage);
     
    25062514    alock.release();
    25072515
    2508     int vrc = VMR3Suspend(ptrVM);
     2516    int vrc = VMR3Suspend(ptrVM.rawUVM());
    25092517
    25102518    HRESULT hrc = S_OK;
     
    25482556    if (RT_SUCCESS(vrc))
    25492557    {
    2550         if (VMR3GetState(ptrVM) == VMSTATE_CREATED)
    2551             vrc = VMR3PowerOn(ptrVM); /* (PowerUpPaused) */
     2558        if (VMR3GetStateU(ptrVM.rawUVM()) == VMSTATE_CREATED)
     2559            vrc = VMR3PowerOn(ptrVM.rawUVM()); /* (PowerUpPaused) */
    25522560        else
    2553             vrc = VMR3Resume(ptrVM);
     2561            vrc = VMR3Resume(ptrVM.rawUVM());
    25542562    }
    25552563
     
    27852793        /* release the lock before a VMR3* call (EMT will call us back)! */
    27862794        alock.release();
    2787         int vrc = VMR3Suspend(ptrVM);
     2795        int vrc = VMR3Suspend(ptrVM.rawUVM());
    27882796        alock.acquire();
    27892797
     
    28932901            {
    28942902                alock.release();
    2895                 VMR3Resume(ptrVM);
     2903                VMR3Resume(ptrVM.rawUVM());
    28962904                alock.acquire();
    28972905            }
     
    36603668 * @param aMediumAttachment The medium attachment with the new medium state.
    36613669 * @param fForce            Force medium chance, if it is locked or not.
    3662  * @param pVM               Safe VM handle.
     3670 * @param pUVM              Safe VM handle.
    36633671 *
    36643672 * @note Locks this object for writing.
    36653673 */
    3666 HRESULT Console::doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PVM pVM)
     3674HRESULT Console::doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PUVM pUVM)
    36673675{
    36683676    AutoCaller autoCaller(this);
     
    37283736     */
    37293737    PVMREQ pReq;
    3730     int vrc = VMR3ReqCall(pVM,
    3731                           VMCPUID_ANY,
    3732                           &pReq,
    3733                           0 /* no wait! */,
    3734                           VMREQFLAGS_VBOX_STATUS,
    3735                           (PFNRT)Console::changeRemovableMedium,
    3736                           8,
    3737                           this,
    3738                           pVM,
    3739                           pszDevice,
    3740                           uInstance,
    3741                           enmBus,
    3742                           fUseHostIOCache,
    3743                           aMediumAttachment,
    3744                           fForce);
     3738    int vrc = VMR3ReqCallU(pUVM,
     3739                           VMCPUID_ANY,
     3740                           &pReq,
     3741                           0 /* no wait! */,
     3742                           VMREQFLAGS_VBOX_STATUS,
     3743                           (PFNRT)Console::changeRemovableMedium,
     3744                           8,
     3745                           this,
     3746                           pUVM,
     3747                           pszDevice,
     3748                           uInstance,
     3749                           enmBus,
     3750                           fUseHostIOCache,
     3751                           aMediumAttachment,
     3752                           fForce);
    37453753
    37463754    /* release the lock before waiting for a result (EMT will call us back!) */
     
    37783786 *
    37793787 * @param   pThis           Pointer to the Console object.
    3780  * @param   pVM             The VM handle.
     3788 * @param   pUVM            The VM handle.
    37813789 * @param   pcszDevice      The PDM device name.
    37823790 * @param   uInstance       The PDM device instance.
     
    37933801 */
    37943802DECLCALLBACK(int) Console::changeRemovableMedium(Console *pConsole,
    3795                                                  PVM pVM,
     3803                                                 PUVM pUVM,
    37963804                                                 const char *pcszDevice,
    37973805                                                 unsigned uInstance,
     
    38163824     */
    38173825    bool fResume;
    3818     VMSTATE enmVMState = VMR3GetState(pVM);
     3826    VMSTATE enmVMState = VMR3GetStateU(pUVM);
    38193827    switch (enmVMState)
    38203828    {
     
    38253833            /* disable the callback to prevent Console-level state change */
    38263834            pConsole->mVMStateChangeCallbackDisabled = true;
    3827             int rc = VMR3Suspend(pVM);
     3835            int rc = VMR3Suspend(pUVM);
    38283836            pConsole->mVMStateChangeCallbackDisabled = false;
    38293837            AssertRCReturn(rc, rc);
     
    38533861    /* Determine the base path for the device instance. */
    38543862    PCFGMNODE pCtlInst;
    3855     pCtlInst = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/", pcszDevice, uInstance);
     3863    pCtlInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "Devices/%s/%u/", pcszDevice, uInstance);
    38563864    AssertReturn(pCtlInst, VERR_INTERNAL_ERROR);
    38573865
     
    38743882                                             fForce /* fForceUnmount */,
    38753883                                             false  /* fHotplug */,
    3876                                              pVM,
     3884                                             pUVM,
    38773885                                             NULL /* paLedDevType */);
    38783886    /** @todo this dumps everything attached to this device instance, which
     
    38883896        /* disable the callback to prevent Console-level state change */
    38893897        pConsole->mVMStateChangeCallbackDisabled = true;
    3890         rc = VMR3Resume(pVM);
     3898        rc = VMR3Resume(pUVM);
    38913899        pConsole->mVMStateChangeCallbackDisabled = false;
    38923900        AssertRC(rc);
     
    38943902        {
    38953903            /* too bad, we failed. try to sync the console state with the VMM state */
    3896             vmstateChangeCallback(pVM, VMSTATE_SUSPENDED, enmVMState, pConsole);
     3904            vmstateChangeCallback(VMR3GetVM(pUVM), VMSTATE_SUSPENDED, enmVMState, pConsole);
    38973905        }
    38983906        /// @todo (r=dmik) if we failed with drive mount, then the VMR3Resume
     
    39143922 *
    39153923 * @param aMediumAttachment The medium attachment which is added.
    3916  * @param pVM               Safe VM handle.
     3924 * @param pUVM              Safe VM handle.
    39173925 *
    39183926 * @note Locks this object for writing.
    39193927 */
    3920 HRESULT Console::doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PVM pVM)
     3928HRESULT Console::doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PUVM pUVM)
    39213929{
    39223930    AutoCaller autoCaller(this);
     
    39823990     */
    39833991    PVMREQ pReq;
    3984     int vrc = VMR3ReqCall(pVM,
    3985                           VMCPUID_ANY,
    3986                           &pReq,
    3987                           0 /* no wait! */,
    3988                           VMREQFLAGS_VBOX_STATUS,
    3989                           (PFNRT)Console::attachStorageDevice,
    3990                           7,
    3991                           this,
    3992                           pVM,
    3993                           pszDevice,
    3994                           uInstance,
    3995                           enmBus,
    3996                           fUseHostIOCache,
    3997                           aMediumAttachment);
     3992    int vrc = VMR3ReqCallU(pUVM,
     3993                           VMCPUID_ANY,
     3994                           &pReq,
     3995                           0 /* no wait! */,
     3996                           VMREQFLAGS_VBOX_STATUS,
     3997                           (PFNRT)Console::attachStorageDevice,
     3998                           7,
     3999                           this,
     4000                           pUVM,
     4001                           pszDevice,
     4002                           uInstance,
     4003                           enmBus,
     4004                           fUseHostIOCache,
     4005                           aMediumAttachment);
    39984006
    39994007    /* release the lock before waiting for a result (EMT will call us back!) */
     
    40324040 *
    40334041 * @param   pThis           Pointer to the Console object.
    4034  * @param   pVM             The VM handle.
     4042 * @param   pUVM            The VM handle.
    40354043 * @param   pcszDevice      The PDM device name.
    40364044 * @param   uInstance       The PDM device instance.
     
    40394047 */
    40404048DECLCALLBACK(int) Console::attachStorageDevice(Console *pConsole,
    4041                                                PVM pVM,
     4049                                               PUVM pUVM,
    40424050                                               const char *pcszDevice,
    40434051                                               unsigned uInstance,
     
    40614069     */
    40624070    bool fResume;
    4063     VMSTATE enmVMState = VMR3GetState(pVM);
     4071    VMSTATE enmVMState = VMR3GetStateU(pUVM);
    40644072    switch (enmVMState)
    40654073    {
     
    40704078            /* disable the callback to prevent Console-level state change */
    40714079            pConsole->mVMStateChangeCallbackDisabled = true;
    4072             int rc = VMR3Suspend(pVM);
     4080            int rc = VMR3Suspend(pUVM);
    40734081            pConsole->mVMStateChangeCallbackDisabled = false;
    40744082            AssertRCReturn(rc, rc);
     
    40984106    /* Determine the base path for the device instance. */
    40994107    PCFGMNODE pCtlInst;
    4100     pCtlInst = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/", pcszDevice, uInstance);
     4108    pCtlInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "Devices/%s/%u/", pcszDevice, uInstance);
    41014109    AssertReturn(pCtlInst, VERR_INTERNAL_ERROR);
    41024110
     
    41194127                                             false /* fForceUnmount */,
    41204128                                             true   /* fHotplug */,
    4121                                              pVM,
     4129                                             pUVM,
    41224130                                             NULL /* paLedDevType */);
    41234131    /** @todo this dumps everything attached to this device instance, which
     
    41334141        /* disable the callback to prevent Console-level state change */
    41344142        pConsole->mVMStateChangeCallbackDisabled = true;
    4135         rc = VMR3Resume(pVM);
     4143        rc = VMR3Resume(pUVM);
    41364144        pConsole->mVMStateChangeCallbackDisabled = false;
    41374145        AssertRC(rc);
     
    41394147        {
    41404148            /* too bad, we failed. try to sync the console state with the VMM state */
    4141             vmstateChangeCallback(pVM, VMSTATE_SUSPENDED, enmVMState, pConsole);
     4149            vmstateChangeCallback(VMR3GetVM(pUVM), VMSTATE_SUSPENDED, enmVMState, pConsole);
    41424150        }
    41434151        /** @todo: if we failed with drive mount, then the VMR3Resume
     
    41594167 *
    41604168 * @param aMediumAttachment The medium attachment which is added.
    4161  * @param pVM               Safe VM handle.
     4169 * @param pUVM              Safe VM handle.
    41624170 *
    41634171 * @note Locks this object for writing.
    41644172 */
    4165 HRESULT Console::doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PVM pVM)
     4173HRESULT Console::doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PUVM pUVM)
    41664174{
    41674175    AutoCaller autoCaller(this);
     
    42244232     */
    42254233    PVMREQ pReq;
    4226     int vrc = VMR3ReqCall(pVM,
    4227                           VMCPUID_ANY,
    4228                           &pReq,
    4229                           0 /* no wait! */,
    4230                           VMREQFLAGS_VBOX_STATUS,
    4231                           (PFNRT)Console::detachStorageDevice,
    4232                           6,
    4233                           this,
    4234                           pVM,
    4235                           pszDevice,
    4236                           uInstance,
    4237                           enmBus,
    4238                           aMediumAttachment);
     4234    int vrc = VMR3ReqCallU(pUVM,
     4235                           VMCPUID_ANY,
     4236                           &pReq,
     4237                           0 /* no wait! */,
     4238                           VMREQFLAGS_VBOX_STATUS,
     4239                           (PFNRT)Console::detachStorageDevice,
     4240                           6,
     4241                           this,
     4242                           pUVM,
     4243                           pszDevice,
     4244                           uInstance,
     4245                           enmBus,
     4246                           aMediumAttachment);
    42394247
    42404248    /* release the lock before waiting for a result (EMT will call us back!) */
     
    42724280 *
    42734281 * @param   pThis           Pointer to the Console object.
    4274  * @param   pVM             The VM handle.
     4282 * @param   pUVM            The VM handle.
    42754283 * @param   pcszDevice      The PDM device name.
    42764284 * @param   uInstance       The PDM device instance.
     
    42794287 */
    42804288DECLCALLBACK(int) Console::detachStorageDevice(Console *pConsole,
    4281                                                PVM pVM,
     4289                                               PUVM pUVM,
    42824290                                               const char *pcszDevice,
    42834291                                               unsigned uInstance,
     
    43004308     */
    43014309    bool fResume;
    4302     VMSTATE enmVMState = VMR3GetState(pVM);
     4310    VMSTATE enmVMState = VMR3GetStateU(pUVM);
    43034311    switch (enmVMState)
    43044312    {
     
    43094317            /* disable the callback to prevent Console-level state change */
    43104318            pConsole->mVMStateChangeCallbackDisabled = true;
    4311             int rc = VMR3Suspend(pVM);
     4319            int rc = VMR3Suspend(pUVM);
    43124320            pConsole->mVMStateChangeCallbackDisabled = false;
    43134321            AssertRCReturn(rc, rc);
     
    43374345    /* Determine the base path for the device instance. */
    43384346    PCFGMNODE pCtlInst;
    4339     pCtlInst = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/", pcszDevice, uInstance);
     4347    pCtlInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "Devices/%s/%u/", pcszDevice, uInstance);
    43404348    AssertReturn(pCtlInst, VERR_INTERNAL_ERROR);
    43414349
     
    43634371    if (pLunL0)
    43644372    {
    4365         rc = PDMR3DeviceDetach(pVM, pcszDevice, uInstance, uLUN, 0);
     4373        rc = PDMR3DeviceDetach(VMR3GetVM(pUVM), pcszDevice, uInstance, uLUN, 0);
    43664374        if (rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN)
    43674375            rc = VINF_SUCCESS;
     
    43864394        /* disable the callback to prevent Console-level state change */
    43874395        pConsole->mVMStateChangeCallbackDisabled = true;
    4388         rc = VMR3Resume(pVM);
     4396        rc = VMR3Resume(pUVM);
    43894397        pConsole->mVMStateChangeCallbackDisabled = false;
    43904398        AssertRC(rc);
     
    43924400        {
    43934401            /* too bad, we failed. try to sync the console state with the VMM state */
    4394             vmstateChangeCallback(pVM, VMSTATE_SUSPENDED, enmVMState, pConsole);
     4402            vmstateChangeCallback(VMR3GetVM(pUVM), VMSTATE_SUSPENDED, enmVMState, pConsole);
    43954403        }
    43964404        /** @todo: if we failed with drive mount, then the VMR3Resume
     
    44744482                    if (RT_SUCCESS(vrc) && changeAdapter)
    44754483                    {
    4476                         VMSTATE enmVMState = VMR3GetState(ptrVM);
     4484                        VMSTATE enmVMState = VMR3GetStateU(ptrVM.rawUVM());
    44774485                        if (    enmVMState == VMSTATE_RUNNING    /** @todo LiveMigration: Forbid or deal correctly with the _LS variants */
    44784486                            ||  enmVMState == VMSTATE_SUSPENDED)
     
    44844492                            }
    44854493
    4486                             rc = doNetworkAdapterChange(ptrVM, pszAdapterName, ulInstance, 0, aNetworkAdapter);
     4494                            rc = doNetworkAdapterChange(ptrVM.rawUVM(), pszAdapterName, ulInstance, 0, aNetworkAdapter);
    44874495
    44884496                            if (fTraceEnabled && fCableConnected && pINetCfg)
     
    46154623 * @returns COM status code.
    46164624 *
    4617  * @parma   pVM                 The VM handle (caller hold this safely).
     4625 * @parma   pUVM                The VM handle (caller hold this safely).
    46184626 * @param   pszDevice           The PDM device name.
    46194627 * @param   uInstance           The PDM device instance.
     
    46214629 * @param   aNetworkAdapter     The network adapter whose attachment needs to be changed
    46224630 */
    4623 HRESULT Console::doNetworkAdapterChange(PVM pVM,
     4631HRESULT Console::doNetworkAdapterChange(PUVM pUVM,
    46244632                                        const char *pszDevice,
    46254633                                        unsigned uInstance,
     
    46324640    AutoCaller autoCaller(this);
    46334641    AssertComRCReturnRC(autoCaller.rc());
    4634 
    4635     /* Get the VM handle. */
    4636     SafeVMPtr ptrVM(this);
    4637     if (!ptrVM.isOk())
    4638         return ptrVM.rc();
    46394642
    46404643    /*
     
    46444647     */
    46454648    PVMREQ pReq;
    4646     int vrc = VMR3ReqCall(pVM, 0 /*idDstCpu*/, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
    4647                           (PFNRT) Console::changeNetworkAttachment, 6,
    4648                           this, ptrVM.raw(), pszDevice, uInstance, uLun, aNetworkAdapter);
     4649    int vrc = VMR3ReqCallU(pUVM, 0 /*idDstCpu*/, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
     4650                           (PFNRT)Console::changeNetworkAttachment, 6,
     4651                           this, pUVM, pszDevice, uInstance, uLun, aNetworkAdapter);
    46494652
    46504653    if (vrc == VERR_TIMEOUT || RT_SUCCESS(vrc))
     
    46754678 *
    46764679 * @param   pThis               Pointer to the Console object.
    4677  * @param   pVM                 The VM handle.
     4680 * @param   pUVM                The VM handle.
    46784681 * @param   pszDevice           The PDM device name.
    46794682 * @param   uInstance           The PDM device instance.
     
    46854688 */
    46864689DECLCALLBACK(int) Console::changeNetworkAttachment(Console *pThis,
    4687                                                    PVM pVM,
     4690                                                   PUVM pUVM,
    46884691                                                   const char *pszDevice,
    46894692                                                   unsigned uInstance,
     
    47244727     */
    47254728    bool fResume;
    4726     VMSTATE enmVMState = VMR3GetState(pVM);
     4729    VMSTATE enmVMState = VMR3GetStateU(pUVM);
    47274730    switch (enmVMState)
    47284731    {
     
    47334736            /* disable the callback to prevent Console-level state change */
    47344737            pThis->mVMStateChangeCallbackDisabled = true;
    4735             int rc = VMR3Suspend(pVM);
     4738            int rc = VMR3Suspend(pUVM);
    47364739            pThis->mVMStateChangeCallbackDisabled = false;
    47374740            AssertRCReturn(rc, rc);
     
    47554758    PCFGMNODE pCfg = NULL;          /* /Devices/Dev/.../Config/ */
    47564759    PCFGMNODE pLunL0 = NULL;        /* /Devices/Dev/0/LUN#0/ */
    4757     PCFGMNODE pInst = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%d/", pszDevice, uInstance);
     4760    PCFGMNODE pInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "Devices/%s/%d/", pszDevice, uInstance);
    47584761    AssertRelease(pInst);
    47594762
     
    47694772        /* disable the callback to prevent Console-level state change */
    47704773        pThis->mVMStateChangeCallbackDisabled = true;
    4771         rc = VMR3Resume(pVM);
     4774        rc = VMR3Resume(pUVM);
    47724775        pThis->mVMStateChangeCallbackDisabled = false;
    47734776        AssertRC(rc);
     
    47754778        {
    47764779            /* too bad, we failed. try to sync the console state with the VMM state */
    4777             vmstateChangeCallback(pVM, VMSTATE_SUSPENDED, enmVMState, pThis);
     4780            vmstateChangeCallback(VMR3GetVM(pUVM), VMSTATE_SUSPENDED, enmVMState, pThis);
    47784781        }
    47794782        /// @todo (r=dmik) if we failed with drive mount, then the VMR3Resume
     
    48554858    if (ptrVM.isOk())
    48564859    {
    4857         rc = doMediumChange(aMediumAttachment, !!aForce, ptrVM);
     4860        rc = doMediumChange(aMediumAttachment, !!aForce, ptrVM.rawUVM());
    48584861        ptrVM.release();
    48594862    }
     
    49264929        {
    49274930            /* No need to call in the EMT thread. */
    4928             rc = VMR3SetCpuExecutionCap(ptrVM, aExecutionCap);
     4931            rc = VMR3SetCpuExecutionCap(ptrVM.rawUVM(), aExecutionCap);
    49294932        }
    49304933        else
     
    53895392    {
    53905393        if (aRemove)
    5391             rc = doStorageDeviceDetach(aMediumAttachment, ptrVM);
     5394            rc = doStorageDeviceDetach(aMediumAttachment, ptrVM.rawUVM());
    53925395        else
    5393             rc = doStorageDeviceAttach(aMediumAttachment, ptrVM);
     5396            rc = doStorageDeviceAttach(aMediumAttachment, ptrVM.rawUVM());
    53945397        ptrVM.release();
    53955398    }
     
    57125715
    57135716    /* Pause the VM, as it might have pending IO on this drive */
    5714     VMSTATE enmVMState = VMR3GetState(ptrVM);
     5717    VMSTATE enmVMState = VMR3GetStateU(ptrVM.rawUVM());
    57155718    if (mMachineState == MachineState_DeletingSnapshotOnline)
    57165719    {
     
    57185721        /* disable the callback to prevent Console-level state change */
    57195722        mVMStateChangeCallbackDisabled = true;
    5720         int vrc2 = VMR3Suspend(ptrVM);
     5723        int vrc2 = VMR3Suspend(ptrVM.rawUVM());
    57215724        mVMStateChangeCallbackDisabled = false;
    57225725        AssertRCReturn(vrc2, E_FAIL);
    57235726    }
    57245727
    5725     vrc = VMR3ReqCallWait(ptrVM,
    5726                           VMCPUID_ANY,
    5727                           (PFNRT)reconfigureMediumAttachment,
    5728                           13,
    5729                           this,
    5730                           ptrVM.raw(),
    5731                           pcszDevice,
    5732                           uInstance,
    5733                           enmBus,
    5734                           fUseHostIOCache,
    5735                           fBuiltinIOCache,
    5736                           true /* fSetupMerge */,
    5737                           aSourceIdx,
    5738                           aTargetIdx,
    5739                           aMediumAttachment,
    5740                           mMachineState,
    5741                           &rc);
     5728    vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(),
     5729                           VMCPUID_ANY,
     5730                           (PFNRT)reconfigureMediumAttachment,
     5731                           13,
     5732                           this,
     5733                           ptrVM.rawUVM(),
     5734                           pcszDevice,
     5735                           uInstance,
     5736                           enmBus,
     5737                           fUseHostIOCache,
     5738                           fBuiltinIOCache,
     5739                           true /* fSetupMerge */,
     5740                           aSourceIdx,
     5741                           aTargetIdx,
     5742                           aMediumAttachment,
     5743                           mMachineState,
     5744                           &rc);
    57425745    /* error handling is after resuming the VM */
    57435746
     
    57475750        /* disable the callback to prevent Console-level state change */
    57485751        mVMStateChangeCallbackDisabled = true;
    5749         int vrc2 = VMR3Resume(ptrVM);
     5752        int vrc2 = VMR3Resume(ptrVM.rawUVM());
    57505753        mVMStateChangeCallbackDisabled = false;
    57515754        if (RT_FAILURE(vrc2))
     
    57835786
    57845787    /* Pause the VM, as it might have pending IO on this drive */
    5785     enmVMState = VMR3GetState(ptrVM);
     5788    enmVMState = VMR3GetStateU(ptrVM.rawUVM());
    57865789    if (mMachineState == MachineState_DeletingSnapshotOnline)
    57875790    {
     
    57895792        /* disable the callback to prevent Console-level state change */
    57905793        mVMStateChangeCallbackDisabled = true;
    5791         int vrc2 = VMR3Suspend(ptrVM);
     5794        int vrc2 = VMR3Suspend(ptrVM.rawUVM());
    57925795        mVMStateChangeCallbackDisabled = false;
    57935796        AssertRCReturn(vrc2, E_FAIL);
     
    57995802                                           ComSafeArrayInArg(aChildrenToReparent));
    58005803
    5801     vrc = VMR3ReqCallWait(ptrVM,
    5802                           VMCPUID_ANY,
    5803                           (PFNRT)reconfigureMediumAttachment,
    5804                           13,
    5805                           this,
    5806                           ptrVM.raw(),
    5807                           pcszDevice,
    5808                           uInstance,
    5809                           enmBus,
    5810                           fUseHostIOCache,
    5811                           fBuiltinIOCache,
    5812                           false /* fSetupMerge */,
    5813                           0 /* uMergeSource */,
    5814                           0 /* uMergeTarget */,
    5815                           aMediumAttachment,
    5816                           mMachineState,
    5817                           &rc);
     5804    vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(),
     5805                           VMCPUID_ANY,
     5806                           (PFNRT)reconfigureMediumAttachment,
     5807                           13,
     5808                           this,
     5809                           ptrVM.rawUVM(),
     5810                           pcszDevice,
     5811                           uInstance,
     5812                           enmBus,
     5813                           fUseHostIOCache,
     5814                           fBuiltinIOCache,
     5815                           false /* fSetupMerge */,
     5816                           0 /* uMergeSource */,
     5817                           0 /* uMergeTarget */,
     5818                           aMediumAttachment,
     5819                           mMachineState,
     5820                           &rc);
    58185821    /* error handling is after resuming the VM */
    58195822
     
    58235826        /* disable the callback to prevent Console-level state change */
    58245827        mVMStateChangeCallbackDisabled = true;
    5825         int vrc2 = VMR3Resume(ptrVM);
     5828        int vrc2 = VMR3Resume(ptrVM.rawUVM());
    58265829        mVMStateChangeCallbackDisabled = false;
    58275830        AssertRC(vrc2);
     
    61986201        return a_Quiet
    61996202            ? E_ACCESSDENIED
    6200             : setError(E_ACCESSDENIED, tr("The virtual machine is was powered off"));
     6203            : setError(E_ACCESSDENIED, tr("The virtual machine is powered off"));
    62016204
    62026205    /*
     
    62076210        return a_Quiet
    62086211            ? E_ACCESSDENIED
    6209             : setError(E_ACCESSDENIED, tr("The virtual machine is was powered off"));
     6212            : setError(E_ACCESSDENIED, tr("The virtual machine is powered off"));
    62106213
    62116214    PVM pVM = VMR3GetVM(pUVM);
     
    62156218        return a_Quiet
    62166219            ? E_ACCESSDENIED
    6217             : setError(E_ACCESSDENIED, tr("The virtual machine is was powered off"));
     6220            : setError(E_ACCESSDENIED, tr("The virtual machine is powered off"));
    62186221    }
    62196222
     
    69366939        LogFlowThisFunc(("Powering off the VM...\n"));
    69376940        alock.release();
    6938         vrc = VMR3PowerOff(VMR3GetVM(pUVM));
     6941        vrc = VMR3PowerOff(pUVM);
    69396942#ifdef VBOX_WITH_EXTPACK
    69406943        mptrExtPackManager->callAllVmPowerOffHooks(this, VMR3GetVM(pUVM));
     
    70047007        alock.release();
    70057008
    7006         vrc = VMR3Destroy(VMR3GetVM(pUVM));
     7009        vrc = VMR3Destroy(pUVM);
    70077010
    70087011        /* take the lock again */
     
    79587961    Assert(portVersion == 1 || portVersion == 2);
    79597962
    7960     int vrc = VMR3ReqCallWait(ptrVM, 0 /* idDstCpu (saved state, see #6232) */,
    7961                               (PFNRT)usbAttachCallback, 9,
    7962                               this, ptrVM.raw(), aHostDevice, uuid.raw(), fRemote, Address.c_str(), pvRemoteBackend, portVersion, aMaskedIfs);
     7963    int vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(), 0 /* idDstCpu (saved state, see #6232) */,
     7964                               (PFNRT)usbAttachCallback, 9,
     7965                               this, ptrVM.rawUVM(), aHostDevice, uuid.raw(), fRemote,
     7966                               Address.c_str(), pvRemoteBackend, portVersion, aMaskedIfs);
    79637967
    79647968    if (RT_SUCCESS(vrc))
     
    79867990        {
    79877991            case VERR_VUSB_NO_PORTS:
    7988                 hrc = setError(E_FAIL,
    7989                     tr("Failed to attach the USB device. (No available ports on the USB controller)."));
     7992                hrc = setError(E_FAIL, tr("Failed to attach the USB device. (No available ports on the USB controller)."));
    79907993                break;
    79917994            case VERR_VUSB_USBFS_PERMISSION:
    7992                 hrc = setError(E_FAIL,
    7993                     tr("Not permitted to open the USB device, check usbfs options"));
     7995                hrc = setError(E_FAIL, tr("Not permitted to open the USB device, check usbfs options"));
    79947996                break;
    79957997            default:
    7996                 hrc = setError(E_FAIL,
    7997                     tr("Failed to create a proxy device for the USB device. (Error: %Rrc)"),
    7998                     vrc);
     7998                hrc = setError(E_FAIL, tr("Failed to create a proxy device for the USB device. (Error: %Rrc)"), vrc);
    79997999                break;
    80008000        }
     
    80158015//static
    80168016DECLCALLBACK(int)
    8017 Console::usbAttachCallback(Console *that, PVM pVM, IUSBDevice *aHostDevice, PCRTUUID aUuid, bool aRemote, const char *aAddress, void *pvRemoteBackend, USHORT aPortVersion, ULONG aMaskedIfs)
     8017Console::usbAttachCallback(Console *that, PUVM pUVM, IUSBDevice *aHostDevice, PCRTUUID aUuid, bool aRemote,
     8018                           const char *aAddress, void *pvRemoteBackend, USHORT aPortVersion, ULONG aMaskedIfs)
    80188019{
    80198020    LogFlowFuncEnter();
     
    80238024    AssertReturn(!that->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE);
    80248025
    8025     int vrc = PDMR3USBCreateProxyDevice(pVM, aUuid, aRemote, aAddress, pvRemoteBackend,
     8026    int vrc = PDMR3USBCreateProxyDevice(VMR3GetVM(pUVM), aUuid, aRemote, aAddress, pvRemoteBackend,
    80268027                                        aPortVersion == 1 ? VUSB_STDVER_11 : VUSB_STDVER_20, aMaskedIfs);
    80278028    LogFlowFunc(("vrc=%Rrc\n", vrc));
     
    80738074
    80748075    alock.release();
    8075     int vrc = VMR3ReqCallWait(ptrVM, 0 /* idDstCpu (saved state, see #6232) */,
    8076                               (PFNRT)usbDetachCallback, 5,
    8077                               this, ptrVM.raw(), pUuid);
     8076    int vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(), 0 /* idDstCpu (saved state, see #6232) */,
     8077                               (PFNRT)usbDetachCallback, 5,
     8078                               this, ptrVM.rawUVM(), pUuid);
    80788079    if (RT_SUCCESS(vrc))
    80798080    {
     
    80918092/**
    80928093 * USB device detach callback used by DetachUSBDevice().
     8094 *
    80938095 * Note that DetachUSBDevice() doesn't return until this callback is executed,
    80948096 * so we don't use AutoCaller and don't care about reference counters of
     
    80998101//static
    81008102DECLCALLBACK(int)
    8101 Console::usbDetachCallback(Console *that, PVM pVM, PCRTUUID aUuid)
     8103Console::usbDetachCallback(Console *that, PUVM pUVM, PCRTUUID aUuid)
    81028104{
    81038105    LogFlowFuncEnter();
     
    81078109    AssertReturn(!that->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE);
    81088110
    8109     int vrc = PDMR3USBDetachDevice(pVM, aUuid);
     8111    int vrc = PDMR3USBDetachDevice(VMR3GetVM(pUVM), aUuid);
    81108112
    81118113    LogFlowFunc(("vrc=%Rrc\n", vrc));
     
    84938495 * Called at VM startup.
    84948496 *
    8495  * @param   pVM     The VM handle.
     8497 * @param   pUVM    The VM handle.
    84968498 */
    8497 HRESULT Console::captureUSBDevices(PVM pVM)
     8499HRESULT Console::captureUSBDevices(PUVM pUVM)
    84988500{
    84998501    LogFlowThisFunc(("\n"));
     
    85068508     * capture devices */
    85078509    PPDMIBASE pBase;
    8508     int vrc = PDMR3QueryLun(pVM, "usb-ohci", 0, 0, &pBase);
     8510    int vrc = PDMR3QueryLun(VMR3GetVM(pUVM), "usb-ohci", 0, 0, &pBase);
    85098511    if (RT_SUCCESS(vrc))
    85108512    {
     
    88718873        /*
    88728874         * Create the VM
    8873          */
    8874         PVM pVM;
    8875         /*
    8876          * release the lock since EMT will call Console. It's safe because
    8877          * mMachineState is either Starting or Restoring state here.
     8875         *
     8876         * Note! Release the lock since EMT will call Console. It's safe because
     8877         *       mMachineState is either Starting or Restoring state here.
    88788878         */
    88798879        alock.release();
    88808880
     8881        PVM pVM;
    88818882        vrc = VMR3Create(cCpus,
    88828883                         pConsole->mpVmm2UserMethods,
     
    88858886                         task->mConfigConstructor,
    88868887                         static_cast<Console *>(pConsole),
    8887                          &pVM);
     8888                         &pVM, NULL);
    88888889
    88898890        alock.acquire();
     
    89558956                 * Capture USB devices.
    89568957                 */
    8957                 rc = pConsole->captureUSBDevices(pVM);
    8958                 if (FAILED(rc)) break;
     8958                rc = pConsole->captureUSBDevices(pConsole->mpUVM);
     8959                if (FAILED(rc))
     8960                    break;
    89598961
    89608962                /* Load saved state? */
     
    89648966                                 task->mSavedStateFile.c_str()));
    89658967
    8966                     vrc = VMR3LoadFromFile(pVM,
     8968                    vrc = VMR3LoadFromFile(pConsole->mpUVM,
    89678969                                           task->mSavedStateFile.c_str(),
    89688970                                           Console::stateProgressCallback,
     
    89818983#endif
    89828984                            if (RT_SUCCESS(vrc))
    8983                                 vrc = VMR3Resume(pVM);
     8985                                vrc = VMR3Resume(pConsole->mpUVM);
    89848986                            AssertLogRelRC(vrc);
    89858987                        }
     
    89898991                    if (RT_FAILURE(vrc))
    89908992                    {
    8991                         int vrc2 = VMR3PowerOff(pVM); AssertLogRelRC(vrc2);
     8993                        int vrc2 = VMR3PowerOff(pConsole->mpUVM); AssertLogRelRC(vrc2);
    89928994#ifdef VBOX_WITH_EXTPACK
    89938995                        pConsole->mptrExtPackManager->callAllVmPowerOffHooks(pConsole, pVM);
     
    89999001                    /* -> ConsoleImplTeleporter.cpp */
    90009002                    bool fPowerOffOnFailure;
    9001                     rc = pConsole->teleporterTrg(VMR3GetUVM(pVM), pMachine, &task->mErrorMsg, task->mStartPaused,
     9003                    rc = pConsole->teleporterTrg(pConsole->mpUVM, pMachine, &task->mErrorMsg, task->mStartPaused,
    90029004                                                 task->mProgress, &fPowerOffOnFailure);
    90039005                    if (FAILED(rc) && fPowerOffOnFailure)
    90049006                    {
    90059007                        ErrorInfoKeeper eik;
    9006                         int vrc2 = VMR3PowerOff(pVM); AssertLogRelRC(vrc2);
     9008                        int vrc2 = VMR3PowerOff(pConsole->mpUVM); AssertLogRelRC(vrc2);
    90079009#ifdef VBOX_WITH_EXTPACK
    90089010                        pConsole->mptrExtPackManager->callAllVmPowerOffHooks(pConsole, pVM);
     
    90659067#endif
    90669068                    if (RT_SUCCESS(vrc))
    9067                         vrc = VMR3PowerOn(pVM);
     9069                        vrc = VMR3PowerOn(pConsole->mpUVM);
    90689070                    AssertLogRelRC(vrc);
    90699071                }
     
    90959097                 */
    90969098                alock.release();
    9097                 VMR3AtErrorDeregister(pVM, Console::genericVMSetErrorCallback, &task->mErrorMsg);
     9099                VMR3AtErrorDeregister(pConsole->mpUVM, Console::genericVMSetErrorCallback, &task->mErrorMsg);
    90989100                /** @todo register another VMSetError callback? */
    90999101                alock.acquire();
     
    91969198 *
    91979199 * @param   pConsole      Reference to the console object.
    9198  * @param   pVM           The VM handle.
     9200 * @param   pUVM          The VM handle.
    91999201 * @param   lInstance     The instance of the controller.
    92009202 * @param   pcszDevice    The name of the controller type.
     
    92109212/* static */
    92119213DECLCALLBACK(int) Console::reconfigureMediumAttachment(Console *pConsole,
    9212                                                        PVM pVM,
     9214                                                       PUVM pUVM,
    92139215                                                       const char *pcszDevice,
    92149216                                                       unsigned uInstance,
     
    92239225                                                       HRESULT *phrc)
    92249226{
    9225     LogFlowFunc(("pVM=%p aMediumAtt=%p phrc=%p\n", pVM, aMediumAtt, phrc));
     9227    LogFlowFunc(("pUVM=%p aMediumAtt=%p phrc=%p\n", pUVM, aMediumAtt, phrc));
    92269228
    92279229    int             rc;
     
    92419243    /* Determine the base path for the device instance. */
    92429244    PCFGMNODE pCtlInst;
    9243     pCtlInst = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/", pcszDevice, uInstance);
     9245    pCtlInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "Devices/%s/%u/", pcszDevice, uInstance);
    92449246    AssertReturn(pCtlInst, VERR_INTERNAL_ERROR);
    92459247
     
    92609262                                          false /* fForceUnmount */,
    92619263                                          false /* fHotplug */,
    9262                                           pVM,
     9264                                          pUVM,
    92639265                                          NULL /* paLedDevType */);
    92649266    /** @todo this dumps everything attached to this device instance, which
     
    93689370                alock.release();
    93699371                LogFlowFunc(("VMR3Save...\n"));
    9370                 vrc = VMR3Save(ptrVM,
     9372                vrc = VMR3Save(ptrVM.rawUVM(),
    93719373                               strSavedStateFile.c_str(),
    93729374                               true /*fContinueAfterwards*/,
     
    94499451                 * isn't going to need the Console lock.
    94509452                 */
    9451                 vrc = VMR3ReqCallWait(ptrVM,
    9452                                       VMCPUID_ANY,
    9453                                       (PFNRT)reconfigureMediumAttachment,
    9454                                       13,
    9455                                       that,
    9456                                       ptrVM.raw(),
    9457                                       pcszDevice,
    9458                                       lInstance,
    9459                                       enmBus,
    9460                                       fUseHostIOCache,
    9461                                       fBuiltinIOCache,
    9462                                       false /* fSetupMerge */,
    9463                                       0 /* uMergeSource */,
    9464                                       0 /* uMergeTarget */,
    9465                                       atts[i],
    9466                                       that->mMachineState,
    9467                                       &rc);
     9453                vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(),
     9454                                       VMCPUID_ANY,
     9455                                       (PFNRT)reconfigureMediumAttachment,
     9456                                       13,
     9457                                       that,
     9458                                       ptrVM.rawUVM(),
     9459                                       pcszDevice,
     9460                                       lInstance,
     9461                                       enmBus,
     9462                                       fUseHostIOCache,
     9463                                       fBuiltinIOCache,
     9464                                       false /* fSetupMerge */,
     9465                                       0 /* uMergeSource */,
     9466                                       0 /* uMergeTarget */,
     9467                                       atts[i],
     9468                                       that->mMachineState,
     9469                                       &rc);
    94689470                if (RT_FAILURE(vrc))
    94699471                    throw setErrorStatic(E_FAIL, Console::tr("%Rrc"), vrc);
     
    95229524                SafeVMPtr ptrVM(that);
    95239525                alock.release();
    9524                 int vrc = VMR3Resume(ptrVM);
     9526                int vrc = VMR3Resume(ptrVM.rawUVM());
    95259527                alock.acquire();
    95269528                if (RT_FAILURE(vrc))
     
    95809582                        SafeVMPtr ptrVM(that);
    95819583                        alock.release();
    9582                         int vrc = VMR3Resume(ptrVM); AssertLogRelRC(vrc);
     9584                        int vrc = VMR3Resume(ptrVM.rawUVM()); AssertLogRelRC(vrc);
    95839585                        alock.acquire();
    95849586                        if (RT_FAILURE(vrc))
     
    96409642
    96419643    bool fSuspenededBySave;
    9642     int vrc = VMR3Save(task->mpVM,
     9644    int vrc = VMR3Save(task->mpUVM,
    96439645                       task->mSavedStateFile.c_str(),
    96449646                       false, /*fContinueAfterwards*/
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r44191 r44340  
    707707int Console::configConstructorInner(PVM pVM, AutoWriteLock *pAlock)
    708708{
    709     VMMDev *pVMMDev = m_pVMMDev;
    710     Assert(pVMMDev);
    711 
     709    PUVM            pUVM      = VMR3GetUVM(pVM);
     710    VMMDev         *pVMMDev   = m_pVMMDev; Assert(pVMMDev);
    712711    ComPtr<IMachine> pMachine = machine();
    713712
     
    17951794                                            false /* fForceUnmount */,
    17961795                                            false /* fHotplug */,
    1797                                             pVM,
     1796                                            pUVM,
    17981797                                            paLedDevType);
    17991798                if (RT_FAILURE(rc))
     
    26592658         */
    26602659
    2661         rc = configGuestProperties(this, pVM);
     2660        rc = configGuestProperties(this, pUVM);
    26622661#endif /* VBOX_WITH_GUEST_PROPS defined */
    26632662
     
    28352834     * Register VM state change handler.
    28362835     */
    2837     int rc2 = VMR3AtStateRegister(pVM, Console::vmstateChangeCallback, this);
     2836    int rc2 = VMR3AtStateRegister(pUVM, Console::vmstateChangeCallback, this);
    28382837    AssertRC(rc2);
    28392838    if (RT_SUCCESS(rc))
     
    28432842     * Register VM runtime error handler.
    28442843     */
    2845     rc2 = VMR3AtRuntimeErrorRegister(pVM, Console::setVMRuntimeErrorCallback, this);
     2844    rc2 = VMR3AtRuntimeErrorRegister(pUVM, Console::setVMRuntimeErrorCallback, this);
    28462845    AssertRC(rc2);
    28472846    if (RT_SUCCESS(rc))
     
    31203119                                    bool fForceUnmount,
    31213120                                    bool fHotplug,
    3122                                     PVM pVM,
     3121                                    PUVM pUVM,
    31233122                                    DeviceType_T *paLedDevType)
    31243123{
     
    31583157                    /* Unmount existing media only for floppy and DVD drives. */
    31593158                    PPDMIBASE pBase;
    3160                     rc = PDMR3QueryLun(pVM, pcszDevice, uInstance, uLUN, &pBase);
     3159                    rc = PDMR3QueryLun(VMR3GetVM(pUVM), pcszDevice, uInstance, uLUN, &pBase);
    31613160                    if (RT_FAILURE(rc))
    31623161                    {
     
    31803179                }
    31813180
    3182                 rc = PDMR3DeviceDetach(pVM, pcszDevice, uInstance, uLUN, fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG);
     3181                rc = PDMR3DeviceDetach(VMR3GetVM(pUVM), pcszDevice, uInstance, uLUN, fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG);
    31833182                if (rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN)
    31843183                    rc = VINF_SUCCESS;
     
    32843283                    const char *pszUnit;
    32853284                    uint64_t u64Print = formatDiskSize((uint64_t)i64Size, &pszUnit);
    3286                     setVMRuntimeErrorCallbackF(pVM, this, 0,
     3285                    setVMRuntimeErrorCallbackF(VMR3GetVM(pUVM), this, 0,
    32873286                            "FatPartitionDetected",
    32883287                            N_("The medium '%ls' has a logical size of %RU64%s "
     
    33163315                            uint64_t u64PrintSiz = formatDiskSize((LONG64)i64Size, &pszUnitSiz);
    33173316                            uint64_t u64PrintMax = formatDiskSize(maxSize, &pszUnitMax);
    3318                             setVMRuntimeErrorCallbackF(pVM, this, 0,
     3317                            setVMRuntimeErrorCallbackF(VMR3GetVM(pUVM), this, 0,
    33193318                                    "FatPartitionDetected", /* <= not exact but ... */
    33203319                                    N_("The medium '%ls' has a logical size of %RU64%s "
     
    33403339                    const char *pszUnit;
    33413340                    uint64_t u64Print = formatDiskSize(i64Size, &pszUnit);
    3342                     setVMRuntimeErrorCallbackF(pVM, this, 0,
     3341                    setVMRuntimeErrorCallbackF(VMR3GetVM(pUVM), this, 0,
    33433342                            "FatPartitionDetected",
    33443343#ifdef RT_OS_WINDOWS
     
    33823381                        || enmFsTypeFile == RTFSTYPE_XFS)
    33833382                    {
    3384                         setVMRuntimeErrorCallbackF(pVM, this, 0,
     3383                        setVMRuntimeErrorCallbackF(VMR3GetVM(pUVM), this, 0,
    33853384                                "Ext4PartitionDetected",
    33863385                                N_("The host I/O cache for at least one controller is disabled "
     
    34003399                             && !mfSnapshotFolderExt4WarningShown)
    34013400                    {
    3402                         setVMRuntimeErrorCallbackF(pVM, this, 0,
     3401                        setVMRuntimeErrorCallbackF(VMR3GetVM(pUVM), this, 0,
    34033402                                "Ext4PartitionDetected",
    34043403                                N_("The host I/O cache for at least one controller is disabled "
     
    34753474        {
    34763475            /* Attach the new driver. */
    3477             rc = PDMR3DeviceAttach(pVM, pcszDevice, uInstance, uLUN,
    3478                                 fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/);
     3476            rc = PDMR3DeviceAttach(VMR3GetVM(pUVM), pcszDevice, uInstance, uLUN,
     3477                                   fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/);
    34793478            AssertRCReturn(rc, rc);
    34803479
     
    38493848        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    38503849
    3851         PVM pVM = VMR3GetVM(mpUVM);     /* We're on an EMT, so this is safe. */
    3852 
    38533850        ComPtr<IMachine> pMachine = machine();
    38543851
     
    38753872        if (fAttachDetach)
    38763873        {
    3877             rc = PDMR3DeviceDetach(pVM, pszDevice, uInstance, uLun, 0 /*fFlags*/);
     3874            rc = PDMR3DeviceDetach(VMR3GetVM(mpUVM), pszDevice, uInstance, uLun, 0 /*fFlags*/);
    38783875            if (rc == VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN)
    38793876                rc = VINF_SUCCESS;
     
    40814078                    {
    40824079                        case VERR_ACCESS_DENIED:
    4083                             return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,  N_(
     4080                            return VMSetError(VMR3GetVM(mpUVM), VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,  N_(
    40844081                                            "Failed to open '/dev/net/tun' for read/write access. Please check the "
    40854082                                            "permissions of that node. Either run 'chmod 0666 /dev/net/tun' or "
     
    40894086                        default:
    40904087                            AssertMsgFailed(("Could not attach to host interface! Bad!\n"));
    4091                             return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
     4088                            return VMSetError(VMR3GetVM(mpUVM), VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
    40924089                                            "Failed to initialize Host Interface Networking"));
    40934090                    }
     
    41324129//                     * hrc = aNetworkAdapter->Detach();                                   H();
    41334130//                     */
    4134 //                     return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
     4131//                     return VMSetError(VMR3GetVM(mpUVM), VERR_INTERNAL_ERROR, RT_SRC_POS,
    41354132//                                       N_("Malformed host interface networking name '%ls'"),
    41364133//                                       BridgedIfName.raw());
     
    41684165                {
    41694166                    AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: FindByName failed, rc=%Rhrc (0x%x)", hrc, hrc));
    4170                     return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
     4167                    return VMSetError(VMR3GetVM(mpUVM), VERR_INTERNAL_ERROR, RT_SRC_POS,
    41714168                                      N_("Nonexistent host networking interface, name '%ls'"),
    41724169                                      BridgedIfName.raw());
     
    41834180                if (eIfType != HostNetworkInterfaceType_Bridged)
    41844181                {
    4185                     return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
     4182                    return VMSetError(VMR3GetVM(mpUVM), VERR_INTERNAL_ERROR, RT_SRC_POS,
    41864183                                      N_("Interface ('%ls') is not a Bridged Adapter interface"),
    41874184                                      BridgedIfName.raw());
     
    42804277                        {
    42814278                            case VERR_ACCESS_DENIED:
    4282                                 return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,  N_(
     4279                                return VMSetError(VMR3GetVM(mpUVM), VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,  N_(
    42834280                                                "Failed to open '/dev/%s' for read/write access.  Please check the "
    42844281                                                "permissions of that node, and that the net.link.tap.user_open "
     
    42884285                            default:
    42894286                                AssertMsgFailed(("Could not attach to tap interface! Bad!\n"));
    4290                                 return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
     4287                                return VMSetError(VMR3GetVM(mpUVM), VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
    42914288                                                "Failed to initialize Host Interface Networking"));
    42924289                        }
     
    43164313                        if (ioctl(iSock, SIOCGIFFLAGS, &Req) >= 0)
    43174314                            if ((Req.ifr_flags & IFF_UP) == 0)
    4318                                 setVMRuntimeErrorCallbackF(pVM, this, 0, "BridgedInterfaceDown",
     4315                                setVMRuntimeErrorCallbackF(VMR3GetVM(mpUVM), this, 0, "BridgedInterfaceDown",
    43194316                                                           "Bridged interface %s is down. Guest will not be able to use this interface",
    43204317                                                           pszBridgedIfName);
     
    45394536                {
    45404537                    LogRel(("NetworkAttachmentType_HostOnly: FindByName failed, rc (0x%x)\n", rc));
    4541                     return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
     4538                    return VMSetError(VMR3GetVM(mpUVM), VERR_INTERNAL_ERROR, RT_SRC_POS,
    45424539                                      N_("Nonexistent host networking interface, name '%ls'"),
    45434540                                      HostOnlyName.raw());
     
    45644561
    45654562                if (eIfType != HostNetworkInterfaceType_HostOnly)
    4566                     return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
     4563                    return VMSetError(VMR3GetVM(mpUVM), VERR_INTERNAL_ERROR, RT_SRC_POS,
    45674564                                      N_("Interface ('%ls') is not a Host-Only Adapter interface"),
    45684565                                      HostOnlyName.raw());
     
    47634760                    if (fAttachDetach)
    47644761                    {
    4765                         rc = PDMR3DriverAttach(pVM, pszDevice, uInstance, uLun, 0 /*fFlags*/, NULL /* ppBase */);
     4762                        rc = PDMR3DriverAttach(VMR3GetVM(mpUVM), pszDevice, uInstance, uLun, 0 /*fFlags*/, NULL /* ppBase */);
    47664763                        //AssertRC(rc);
    47674764                    }
     
    49154912 * the machine XML and set a couple of initial properties.
    49164913 */
    4917 /* static */ int Console::configGuestProperties(void *pvConsole, PVM pVM)
     4914/* static */ int Console::configGuestProperties(void *pvConsole, PUVM pUVM)
    49184915{
    49194916#ifdef VBOX_WITH_GUEST_PROPS
     
    49474944                PFNDBGFHANDLEREXT pfnHandler = (PFNDBGFHANDLEREXT)(uintptr_t)Params[0].u.pointer.addr;
    49484945                void *pService = (void*)Params[1].u.pointer.addr;
    4949                 DBGFR3InfoRegisterExternal(pVM, "guestprops", "Display the guest properties", pfnHandler, pService);
     4946                DBGFR3InfoRegisterExternal(VMR3GetVM(pUVM), "guestprops", "Display the guest properties", pfnHandler, pService);
    49504947            }
    49514948        }
  • trunk/src/VBox/Main/src-client/ConsoleImplTeleporter.cpp

    r40257 r44340  
    686686    RTSocketRetain(pState->mhSocket);
    687687    void *pvUser = static_cast<void *>(static_cast<TeleporterState *>(pState));
    688     vrc = VMR3Teleport(VMR3GetVM(pState->mpUVM),
     688    vrc = VMR3Teleport(pState->mpUVM,
    689689                       pState->mcMsMaxDowntime,
    690690                       &g_teleporterTcpOps,         pvUser,
     
    887887                        {
    888888                            autoLock.release();
    889                             int rc = VMR3Resume(VMR3GetVM(pState->mpUVM));
     889                            int rc = VMR3Resume(pState->mpUVM);
    890890                            AssertLogRelMsgRC(rc, ("VMR3Resume -> %Rrc\n", rc));
    891891                            autoLock.acquire();
     
    13381338                break;
    13391339
    1340             int vrc2 = VMR3AtErrorRegisterU(pState->mpUVM,
    1341                                             Console::genericVMSetErrorCallback, &pState->mErrorText); AssertRC(vrc2);
     1340            int vrc2 = VMR3AtErrorRegister(pState->mpUVM,
     1341                                           Console::genericVMSetErrorCallback, &pState->mErrorText); AssertRC(vrc2);
    13421342            RTSocketRetain(pState->mhSocket); /* For concurrent access by I/O thread and EMT. */
    13431343            pState->moffStream = 0;
    13441344
    13451345            void *pvUser2 = static_cast<void *>(static_cast<TeleporterState *>(pState));
    1346             vrc = VMR3LoadFromStream(VMR3GetVM(pState->mpUVM),
     1346            vrc = VMR3LoadFromStream(pState->mpUVM,
    13471347                                     &g_teleporterTcpOps, pvUser2,
    13481348                                     teleporterProgressCallback, pvUser2);
    13491349
    13501350            RTSocketRelease(pState->mhSocket);
    1351             vrc2 = VMR3AtErrorDeregister(VMR3GetVM(pState->mpUVM), Console::genericVMSetErrorCallback, &pState->mErrorText); AssertRC(vrc2);
     1351            vrc2 = VMR3AtErrorDeregister(pState->mpUVM, Console::genericVMSetErrorCallback, &pState->mErrorText); AssertRC(vrc2);
    13521352
    13531353            if (RT_FAILURE(vrc))
     
    14121412                {
    14131413                    if (!strcmp(szCmd, "hand-over-resume"))
    1414                         vrc = VMR3Resume(VMR3GetVM(pState->mpUVM));
     1414                        vrc = VMR3Resume(pState->mpUVM);
    14151415                    else
    14161416                        pState->mptrConsole->setMachineState(MachineState_Paused);
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r44130 r44340  
    223223    uint32_t cyPNG = 0;
    224224
    225     Console::SafeVMPtr pVM (that->mParent);
    226     if (SUCCEEDED(pVM.rc()))
     225    Console::SafeVMPtr ptrVM(that->mParent);
     226    if (ptrVM.isOk())
    227227    {
    228228        /* Query RGB bitmap. */
     
    264264    else
    265265    {
    266         LogFunc(("Failed to get VM pointer 0x%x\n", pVM.rc()));
     266        LogFunc(("Failed to get VM pointer 0x%x\n", ptrVM.rc()));
    267267    }
    268268
     
    859859        {
    860860            /* protect mpVM */
    861             Console::SafeVMPtr pVM (mParent);
    862             AssertComRC (pVM.rc());
    863 
    864             STAM_REG(pVM, &StatDisplayRefresh, STAMTYPE_PROFILE, "/PROF/Display/Refresh", STAMUNIT_TICKS_PER_CALL, "Time spent in EMT for display updates.");
     861            Console::SafeVMPtr ptrVM (mParent);
     862            AssertComRC (ptrVM.rc());
     863
     864            STAM_REG(ptrVM.raw(), &StatDisplayRefresh, STAMTYPE_PROFILE, "/PROF/Display/Refresh", STAMUNIT_TICKS_PER_CALL, "Time spent in EMT for display updates.");
    865865            stam = 1;
    866866        }
     
    20692069}
    20702070
    2071 STDMETHODIMP Display::SetFramebuffer (ULONG aScreenId,
    2072     IFramebuffer *aFramebuffer)
     2071STDMETHODIMP Display::SetFramebuffer(ULONG aScreenId, IFramebuffer *aFramebuffer)
    20732072{
    20742073    LogRelFlowFunc (("\n"));
     
    20782077
    20792078    AutoCaller autoCaller(this);
    2080     if (FAILED(autoCaller.rc())) return autoCaller.rc();
     2079    if (FAILED(autoCaller.rc()))
     2080        return autoCaller.rc();
    20812081
    20822082    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    20832083
    2084     Console::SafeVMPtrQuiet pVM (mParent);
    2085     if (pVM.isOk())
     2084    Console::SafeVMPtrQuiet ptrVM(mParent);
     2085    if (ptrVM.isOk())
    20862086    {
    20872087        /* Must release the lock here because the changeFramebuffer will
     
    20902090
    20912091        /* send request to the EMT thread */
    2092         int vrc = VMR3ReqCallWait (pVM, VMCPUID_ANY,
    2093                                    (PFNRT) changeFramebuffer, 3, this, aFramebuffer, aScreenId);
     2092        int vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY,
     2093                                   (PFNRT)changeFramebuffer, 3, this, aFramebuffer, aScreenId);
    20942094
    20952095        alock.acquire();
     
    23232323}
    23242324
    2325 static int displayTakeScreenshot(PVM pVM, Display *pDisplay, struct DRVMAINDISPLAY *pDrv, ULONG aScreenId, BYTE *address, ULONG width, ULONG height)
     2325static int displayTakeScreenshot(PUVM pUVM, Display *pDisplay, struct DRVMAINDISPLAY *pDrv, ULONG aScreenId,
     2326                                 BYTE *address, ULONG width, ULONG height)
    23262327{
    23272328    uint8_t *pu8Data = NULL;
     
    23382339                 it would be nice to have an accurate screenshot for the bug
    23392340                 report if the VM deadlocks. */
    2340         vrc = VMR3ReqPriorityCallWait(pVM, VMCPUID_ANY, (PFNRT)Display::displayTakeScreenshotEMT, 6,
    2341                                       pDisplay, aScreenId, &pu8Data, &cbData, &cx, &cy);
     2341        vrc = VMR3ReqPriorityCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)Display::displayTakeScreenshotEMT, 6,
     2342                                       pDisplay, aScreenId, &pu8Data, &cbData, &cx, &cy);
    23422343        if (vrc != VERR_TRY_AGAIN)
    23432344        {
     
    24172418    CHECK_CONSOLE_DRV(mpDrv);
    24182419
    2419     Console::SafeVMPtr pVM(mParent);
    2420     if (FAILED(pVM.rc())) return pVM.rc();
     2420    Console::SafeVMPtr ptrVM(mParent);
     2421    if (!ptrVM.isOk())
     2422        return ptrVM.rc();
    24212423
    24222424    HRESULT rc = S_OK;
     
    24312433    alock.release();
    24322434
    2433     int vrc = displayTakeScreenshot(pVM, this, mpDrv, aScreenId, address, width, height);
     2435    int vrc = displayTakeScreenshot(ptrVM.rawUVM(), this, mpDrv, aScreenId, address, width, height);
    24342436
    24352437    if (vrc == VERR_NOT_IMPLEMENTED)
     
    24692471    CHECK_CONSOLE_DRV(mpDrv);
    24702472
    2471     Console::SafeVMPtr pVM(mParent);
    2472     if (FAILED(pVM.rc())) return pVM.rc();
     2473    Console::SafeVMPtr ptrVM(mParent);
     2474    if (!ptrVM.isOk())
     2475        return ptrVM.rc();
    24732476
    24742477    HRESULT rc = S_OK;
     
    24892492        return E_OUTOFMEMORY;
    24902493
    2491     int vrc = displayTakeScreenshot(pVM, this, mpDrv, aScreenId, pu8Data, width, height);
     2494    int vrc = displayTakeScreenshot(ptrVM.rawUVM(), this, mpDrv, aScreenId, pu8Data, width, height);
    24922495
    24932496    if (RT_SUCCESS(vrc))
     
    25452548    CHECK_CONSOLE_DRV(mpDrv);
    25462549
    2547     Console::SafeVMPtr pVM(mParent);
    2548     if (FAILED(pVM.rc())) return pVM.rc();
     2550    Console::SafeVMPtr ptrVM(mParent);
     2551    if (!ptrVM.isOk())
     2552        return ptrVM.rc();
    25492553
    25502554    HRESULT rc = S_OK;
     
    25652569        return E_OUTOFMEMORY;
    25662570
    2567     int vrc = displayTakeScreenshot(pVM, this, mpDrv, aScreenId, pu8Data, width, height);
     2571    int vrc = displayTakeScreenshot(ptrVM.rawUVM(), this, mpDrv, aScreenId, pu8Data, width, height);
    25682572
    25692573    if (RT_SUCCESS(vrc))
     
    27322736    CHECK_CONSOLE_DRV (mpDrv);
    27332737
    2734     Console::SafeVMPtr pVM(mParent);
    2735     if (FAILED(pVM.rc())) return pVM.rc();
     2738    Console::SafeVMPtr ptrVM(mParent);
     2739    if (!ptrVM.isOk())
     2740        return ptrVM.rc();
    27362741
    27372742    /* Release lock because the call scheduled on EMT may also try to take it. */
     
    27422747     * dirty conversion work.
    27432748     */
    2744     int rcVBox = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)Display::drawToScreenEMT, 7,
    2745                                  this, aScreenId, address, x, y, width, height);
     2749    int rcVBox = VMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::drawToScreenEMT, 7,
     2750                                  this, aScreenId, address, x, y, width, height);
    27462751
    27472752    /*
     
    28522857    CHECK_CONSOLE_DRV (mpDrv);
    28532858
    2854     Console::SafeVMPtr pVM(mParent);
    2855     if (FAILED(pVM.rc())) return pVM.rc();
     2859    Console::SafeVMPtr ptrVM(mParent);
     2860    if (!ptrVM.isOk())
     2861        return ptrVM.rc();
    28562862
    28572863    HRESULT rc = S_OK;
     
    28632869
    28642870    /* pdm.h says that this has to be called from the EMT thread */
    2865     int rcVBox = VMR3ReqCallVoidWait(pVM, VMCPUID_ANY, (PFNRT)Display::InvalidateAndUpdateEMT,
    2866                                      1, this);
     2871    int rcVBox = VMR3ReqCallVoidWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::InvalidateAndUpdateEMT,
     2872                                      1, this);
    28672873    alock.acquire();
    28682874
     
    29792985     *  time-critical method.
    29802986     */
    2981     Console::SafeVMPtrQuiet pVM (mParent);
    2982     if (pVM.isOk())
    2983         VM_ASSERT_EMT (pVM.raw());
     2987    Console::SafeVMPtrQuiet ptrVM (mParent);
     2988    if (ptrVM.isOk())
     2989        Assert(VM_IS_EMT(ptrVM.raw()));
    29842990#endif
    29852991
  • trunk/src/VBox/Main/src-client/MachineDebuggerImpl.cpp

    r43387 r44340  
    2828#include <VBox/vmm/csam.h>
    2929#include <VBox/vmm/vm.h>
     30#include <VBox/vmm/uvm.h>
    3031#include <VBox/vmm/tm.h>
    3132#include <VBox/vmm/hm.h>
     
    826827
    827828/**
    828  * Hack for getting the VM handle.
     829 * Hack for getting the user mode VM handle (UVM).
    829830 *
    830831 * This is only temporary (promise) while prototyping the debugger.
     
    834835 *                      uintptr_t in COM, we're using the max integer.
    835836 *                      (No, ULONG is not pointer sized!)
    836  */
    837 STDMETHODIMP MachineDebugger::COMGETTER(VM)(LONG64 *a_u64Vm)
    838 {
    839     CheckComArgOutPointerValid(a_u64Vm);
     837 * @remarks The returned handle must be passed to VMR3ReleaseUVM()!
     838 * @remarks Prior to 4.3 this returned PVM.
     839 */
     840STDMETHODIMP MachineDebugger::COMGETTER(VM)(LONG64 *a_i64Vm)
     841{
     842    CheckComArgOutPointerValid(a_i64Vm);
    840843
    841844    AutoCaller autoCaller(this);
     
    848851        hrc = ptrVM.rc();
    849852        if (SUCCEEDED(hrc))
    850             *a_u64Vm = (intptr_t)ptrVM.raw();
     853        {
     854            VMR3RetainUVM(ptrVM.rawUVM());
     855            *a_i64Vm = (intptr_t)ptrVM.rawUVM();
     856        }
    851857
    852858        /*
  • trunk/src/VBox/VMM/VMMR3/CFGM.cpp

    r41975 r44340  
    6161#include "CFGMInternal.h"
    6262#include <VBox/vmm/vm.h>
     63#include <VBox/vmm/uvm.h>
    6364#include <VBox/err.h>
    6465
    6566#include <VBox/log.h>
    6667#include <iprt/assert.h>
     68#include <iprt/param.h>
    6769#include <iprt/string.h>
    6870#include <iprt/uuid.h>
     
    159161VMMR3DECL(PCFGMNODE) CFGMR3GetRoot(PVM pVM)
    160162{
     163    return pVM->cfgm.s.pRoot;
     164}
     165
     166
     167/**
     168 * Gets the root node for the VM.
     169 *
     170 * @returns Pointer to root node.
     171 * @param   pVM             Pointer to the VM.
     172 */
     173VMMR3DECL(PCFGMNODE) CFGMR3GetRootU(PUVM pUVM)
     174{
     175    UVM_ASSERT_VALID_EXT_RETURN(pUVM, NULL);
     176    PVM pVM = pUVM->pVM;
     177    AssertReturn(pVM, NULL);
    161178    return pVM->cfgm.s.pRoot;
    162179}
  • trunk/src/VBox/VMM/VMMR3/DBGFOS.cpp

    r41965 r44340  
    442442     */
    443443    void *pvIf = NULL;
    444     VMR3ReqPriorityCallVoidWait(pVM, VMCPUID_ANY, (PFNRT)dbgfR3OSQueryInterface, 3, pVM, enmIf, &pvIf);
     444    VMR3ReqPriorityCallVoidWaitU(pVM->pUVM, VMCPUID_ANY, (PFNRT)dbgfR3OSQueryInterface, 3, pVM, enmIf, &pvIf);
    445445    return pvIf;
    446446}
  • trunk/src/VBox/VMM/VMMR3/EM.cpp

    r44195 r44340  
    6262#endif
    6363#include "EMInternal.h"
    64 #include "internal/em.h"
    6564#include <VBox/vmm/vm.h>
    6665#include <VBox/vmm/cpumdis.h>
     
    15161515        if (VM_FF_TESTANDCLEAR(pVM, VM_FF_RESET))
    15171516        {
    1518             rc2 = VMR3Reset(pVM);
     1517            rc2 = VMR3Reset(pVM->pUVM);
    15191518            UPDATE_RC();
    15201519        }
     
    18611860 *
    18621861 */
    1863 VMMR3DECL(bool) EMR3IsExecutionAllowed(PVM pVM, PVMCPU pVCpu)
     1862VMMR3_INT_DECL(bool) EMR3IsExecutionAllowed(PVM pVM, PVMCPU pVCpu)
    18641863{
    18651864    uint64_t u64UserTime, u64KernelTime;
     
    23822381 * @param   pVM             Pointer to the VM.
    23832382 */
    2384 VMMR3DECL(int) EMR3NotifySuspend(PVM pVM)
     2383VMMR3_INT_DECL(int) EMR3NotifySuspend(PVM pVM)
    23852384{
    23862385    PVMCPU pVCpu = VMMGetCpu(pVM);
     
    23972396 * @param   pVM             Pointer to the VM.
    23982397 */
    2399 VMMR3DECL(int) EMR3NotifyResume(PVM pVM)
     2398VMMR3_INT_DECL(int) EMR3NotifyResume(PVM pVM)
    24002399{
    24012400    PVMCPU pVCpu = VMMGetCpu(pVM);
  • trunk/src/VBox/VMM/VMMR3/EMHM.cpp

    r43394 r44340  
    4040#include <VBox/vmm/hm.h>
    4141#include "EMInternal.h"
    42 #include "internal/em.h"
    4342#include <VBox/vmm/vm.h>
    4443#include <VBox/vmm/cpumdis.h>
  • trunk/src/VBox/VMM/VMMR3/EMRaw.cpp

    r42772 r44340  
    4242#include <VBox/vmm/patm.h>
    4343#include "EMInternal.h"
    44 #include "internal/em.h"
    4544#include <VBox/vmm/vm.h>
    4645#include <VBox/vmm/cpumdis.h>
  • trunk/src/VBox/VMM/VMMR3/FTM.cpp

    r41801 r44340  
    2121*******************************************************************************/
    2222#define LOG_GROUP LOG_GROUP_FTM
     23#include <VBox/vmm/ftm.h>
     24#include <VBox/vmm/em.h>
     25#include <VBox/vmm/pdm.h>
     26#include <VBox/vmm/pgm.h>
     27#include <VBox/vmm/ssm.h>
     28#include <VBox/vmm/vmm.h>
    2329#include "FTMInternal.h"
    2430#include <VBox/vmm/vm.h>
    25 #include <VBox/vmm/vmm.h>
    2631#include <VBox/err.h>
    2732#include <VBox/param.h>
    28 #include <VBox/vmm/ssm.h>
    2933#include <VBox/log.h>
    30 #include <VBox/vmm/pgm.h>
    31 #include <VBox/vmm/pdm.h>
    3234
    3335#include <iprt/assert.h>
     
    4042#include <iprt/asm.h>
    4143
    42 #include "internal/vm.h"
    43 #include "internal/em.h"
    4444#include "internal/pgm.h"
     45
    4546
    4647/*******************************************************************************
     
    636637    bool fSuspended = false;
    637638
    638     int rc = VMR3Suspend(pVM);
     639    int rc = VMR3Suspend(pVM->pUVM);
    639640    AssertRCReturn(rc, rc);
    640641
     
    654655
    655656    pVM->ftm.s.fDeltaLoadSaveActive = false;
    656     rc = VMR3SaveFT(pVM, &g_ftmR3TcpOps, pVM, &fSuspended, false /* fSkipStateChanges */);
     657    rc = VMR3SaveFT(pVM->pUVM, &g_ftmR3TcpOps, pVM, &fSuspended, false /* fSkipStateChanges */);
    657658    AssertRC(rc);
    658659
     
    666667    AssertRCReturn(rc, rc);
    667668
    668     rc = VMR3Resume(pVM);
     669    rc = VMR3Resume(pVM->pUVM);
    669670    AssertRC(rc);
    670671
     
    10891090
    10901091            pVM->ftm.s.fDeltaLoadSaveActive = (fFullSync == false);
    1091             rc = VMR3LoadFromStreamFT(pVM, &g_ftmR3TcpOps, pVM);
     1092            rc = VMR3LoadFromStreamFT(pVM->pUVM, &g_ftmR3TcpOps, pVM);
    10921093            pVM->ftm.s.fDeltaLoadSaveActive = false;
    10931094            RTSocketRelease(pVM->ftm.s.hSocket);
     
    11751176        /** @todo might need to disable page fusion as well */
    11761177
    1177         return VMR3PowerOn(pVM);
    1178     }
    1179     else
    1180     {
    1181         /* standby */
    1182         rc = RTThreadCreate(NULL, ftmR3StandbyThread, pVM,
    1183                             0, RTTHREADTYPE_DEFAULT, 0, "ftmStandby");
    1184         if (RT_FAILURE(rc))
    1185             return rc;
    1186 
    1187         rc = RTTcpServerCreateEx(pszAddress, uPort, &pVM->ftm.s.standby.hServer);
    1188         if (RT_FAILURE(rc))
    1189             return rc;
    1190         pVM->ftm.s.fIsStandbyNode = true;
    1191 
    1192         rc = RTTcpServerListen(pVM->ftm.s.standby.hServer, ftmR3StandbyServeConnection, pVM);
    1193         /** @todo deal with the exit code to check if we should activate this standby VM. */
    1194         if (pVM->ftm.s.fActivateStandby)
    1195         {
    1196             /** @todo fallover. */
    1197         }
    1198 
    1199         if (pVM->ftm.s.standby.hServer)
    1200         {
    1201             RTTcpServerDestroy(pVM->ftm.s.standby.hServer);
    1202             pVM->ftm.s.standby.hServer = NULL;
    1203         }
    1204         if (rc == VERR_TCP_SERVER_SHUTDOWN)
    1205             rc = VINF_SUCCESS;  /* ignore this error; the standby process was cancelled. */
    1206     }
     1178        return VMR3PowerOn(pVM->pUVM);
     1179    }
     1180
     1181
     1182    /* standby */
     1183    rc = RTThreadCreate(NULL, ftmR3StandbyThread, pVM,
     1184                        0, RTTHREADTYPE_DEFAULT, 0, "ftmStandby");
     1185    if (RT_FAILURE(rc))
     1186        return rc;
     1187
     1188    rc = RTTcpServerCreateEx(pszAddress, uPort, &pVM->ftm.s.standby.hServer);
     1189    if (RT_FAILURE(rc))
     1190        return rc;
     1191    pVM->ftm.s.fIsStandbyNode = true;
     1192
     1193    rc = RTTcpServerListen(pVM->ftm.s.standby.hServer, ftmR3StandbyServeConnection, pVM);
     1194    /** @todo deal with the exit code to check if we should activate this standby VM. */
     1195    if (pVM->ftm.s.fActivateStandby)
     1196    {
     1197        /** @todo fallover. */
     1198    }
     1199
     1200    if (pVM->ftm.s.standby.hServer)
     1201    {
     1202        RTTcpServerDestroy(pVM->ftm.s.standby.hServer);
     1203        pVM->ftm.s.standby.hServer = NULL;
     1204    }
     1205    if (rc == VERR_TCP_SERVER_SHUTDOWN)
     1206        rc = VINF_SUCCESS;  /* ignore this error; the standby process was cancelled. */
    12071207    return rc;
    12081208}
     
    12671267
    12681268    pVM->ftm.s.fDeltaLoadSaveActive = true;
    1269     rc = VMR3SaveFT(pVM, &g_ftmR3TcpOps, pVM, &fSuspended, true /* fSkipStateChanges */);
     1269    rc = VMR3SaveFT(pVM->pUVM, &g_ftmR3TcpOps, pVM, &fSuspended, true /* fSkipStateChanges */);
    12701270    pVM->ftm.s.fDeltaLoadSaveActive = false;
    12711271    AssertRC(rc);
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r43765 r44340  
    31643164    {
    31653165        /* We own the IOM lock here and could cause a deadlock by waiting for a VCPU that is blocking on the IOM lock. */
    3166         rc = VMR3ReqCallNoWait(pVM, VMCPUID_ANY_QUEUE, (PFNRT)VMR3Suspend, 1, pVM);
     3166        rc = VMR3ReqCallNoWait(pVM, VMCPUID_ANY_QUEUE, (PFNRT)VMR3Suspend, 1, pVM->pUVM);
    31673167        AssertRC(rc);
    31683168        rc = VINF_EM_SUSPEND;
    31693169    }
    31703170    else
    3171         rc = VMR3Suspend(pVM);
     3171        rc = VMR3Suspend(pVM->pUVM);
    31723172
    31733173    LogFlow(("pdmR3DevHlp_VMSuspend: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
     
    31893189     * Suspend the VM first then do the saving.
    31903190     */
    3191     int rc = VMR3Suspend(pVM);
     3191    int rc = VMR3Suspend(pVM->pUVM);
    31923192    if (RT_SUCCESS(rc))
    31933193    {
     
    32003200        if (RT_SUCCESS(rc))
    32013201        {
    3202             rc = VMR3PowerOff(pVM);
     3202            rc = VMR3PowerOff(pVM->pUVM);
    32033203            if (RT_FAILURE(rc))
    32043204                LogRel(("%s/SSP: VMR3PowerOff failed: %Rrc\n", pDevIns->pReg->szName, rc));
     
    32553255    {
    32563256        /* We own the IOM lock here and could cause a deadlock by waiting for a VCPU that is blocking on the IOM lock. */
    3257         rc = VMR3ReqCallNoWait(pVM, VMCPUID_ANY_QUEUE, (PFNRT)VMR3PowerOff, 1, pVM);
     3257        rc = VMR3ReqCallNoWait(pVM, VMCPUID_ANY_QUEUE, (PFNRT)VMR3PowerOff, 1, pVM->pUVM);
    32583258        AssertRC(rc);
    32593259        /* Set the VCPU state to stopped here as well to make sure no
     
    32643264    }
    32653265    else
    3266         rc = VMR3PowerOff(pVM);
     3266        rc = VMR3PowerOff(pVM->pUVM);
    32673267
    32683268    LogFlow(("pdmR3DevHlp_VMPowerOff: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
  • trunk/src/VBox/VMM/VMMR3/PGM.cpp

    r43387 r44340  
    13691369     */
    13701370#ifdef VBOX_STRICT
    1371     VMR3AtStateRegister(pVM, pgmR3ResetNoMorePhysWritesFlag, NULL);
     1371    VMR3AtStateRegister(pVM->pUVM, pgmR3ResetNoMorePhysWritesFlag, NULL);
    13721372#endif
    13731373    PGMRegisterStringFormatTypes();
  • trunk/src/VBox/VMM/VMMR3/VM.cpp

    r43657 r44340  
    9191
    9292/*******************************************************************************
    93 *   Structures and Typedefs                                                    *
    94 *******************************************************************************/
    95 /**
    96  * VM destruction callback registration record.
    97  */
    98 typedef struct VMATDTOR
    99 {
    100     /** Pointer to the next record in the list. */
    101     struct VMATDTOR        *pNext;
    102     /** Pointer to the callback function. */
    103     PFNVMATDTOR             pfnAtDtor;
    104     /** The user argument. */
    105     void                   *pvUser;
    106 } VMATDTOR;
    107 /** Pointer to a VM destruction callback registration record. */
    108 typedef VMATDTOR *PVMATDTOR;
    109 
    110 
    111 /*******************************************************************************
    11293*   Global Variables                                                           *
    11394*******************************************************************************/
    11495/** Pointer to the list of VMs. */
    11596static PUVM         g_pUVMsHead = NULL;
    116 
    117 /** Pointer to the list of at VM destruction callbacks. */
    118 static PVMATDTOR    g_pVMAtDtorHead = NULL;
    119 /** Lock the g_pVMAtDtorHead list. */
    120 #define VM_ATDTOR_LOCK() do { } while (0)
    121 /** Unlock the g_pVMAtDtorHead list. */
    122 #define VM_ATDTOR_UNLOCK() do { } while (0)
    12397
    12498
     
    194168 *                              This is called in the context of an EMT0.
    195169 * @param   pvUserCFGM          The user argument passed to pfnCFGMConstructor.
    196  * @param   ppVM                Where to store the 'handle' of the created VM.
     170 * @param   ppVM                Where to optionally store the 'handle' of the
     171 *                              created VM.
     172 * @param   ppUVM               Where to optionally store the user 'handle' of
     173 *                              the created VM, this includes one reference as
     174 *                              if VMR3RetainUVM() was called.  The caller
     175 *                              *MUST* remember to pass the returned value to
     176 *                              VMR3ReleaseUVM() once done with the handle.
    197177 */
    198178VMMR3DECL(int)   VMR3Create(uint32_t cCpus, PCVMM2USERMETHODS pVmm2UserMethods,
    199179                            PFNVMATERROR pfnVMAtError, void *pvUserVM,
    200180                            PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUserCFGM,
    201                             PVM *ppVM)
    202 {
    203     LogFlow(("VMR3Create: cCpus=%RU32 pVmm2UserMethods=%p pfnVMAtError=%p pvUserVM=%p  pfnCFGMConstructor=%p pvUserCFGM=%p ppVM=%p\n",
    204              cCpus, pVmm2UserMethods, pfnVMAtError, pvUserVM, pfnCFGMConstructor, pvUserCFGM, ppVM));
     181                            PVM *ppVM, PUVM *ppUVM)
     182{
     183    LogFlow(("VMR3Create: cCpus=%RU32 pVmm2UserMethods=%p pfnVMAtError=%p pvUserVM=%p  pfnCFGMConstructor=%p pvUserCFGM=%p ppVM=%p ppUVM=%p\n",
     184             cCpus, pVmm2UserMethods, pfnVMAtError, pvUserVM, pfnCFGMConstructor, pvUserCFGM, ppVM, ppUVM));
    205185
    206186    if (pVmm2UserMethods)
     
    218198    AssertPtrNullReturn(pfnVMAtError, VERR_INVALID_POINTER);
    219199    AssertPtrNullReturn(pfnCFGMConstructor, VERR_INVALID_POINTER);
    220     AssertPtrReturn(ppVM, VERR_INVALID_POINTER);
     200    AssertPtrNullReturn(ppVM, VERR_INVALID_POINTER);
     201    AssertPtrNullReturn(ppUVM, VERR_INVALID_POINTER);
     202    AssertReturn(ppVM || ppUVM, VERR_INVALID_PARAMETER);
    221203
    222204    /*
     
    248230        return rc;
    249231    if (pfnVMAtError)
    250         rc = VMR3AtErrorRegisterU(pUVM, pfnVMAtError, pvUserVM);
     232        rc = VMR3AtErrorRegister(pUVM, pfnVMAtError, pvUserVM);
    251233    if (RT_SUCCESS(rc))
    252234    {
     
    277259                     * Success!
    278260                     */
    279                     *ppVM = pUVM->pVM;
    280                     LogFlow(("VMR3Create: returns VINF_SUCCESS *ppVM=%p\n", *ppVM));
     261                    if (ppVM)
     262                        *ppVM = pUVM->pVM;
     263                    if (ppUVM)
     264                    {
     265                        VMR3RetainUVM(pUVM);
     266                        *ppUVM = pUVM;
     267                    }
     268                    LogFlow(("VMR3Create: returns VINF_SUCCESS (pVM=%p, pUVM=%p\n", pUVM->pVM, pUVM));
    281269                    return VINF_SUCCESS;
    282270                }
     
    364352
    365353                default:
    366                     if (VMR3GetErrorCountU(pUVM) == 0)
     354                    if (VMR3GetErrorCount(pUVM) == 0)
    367355                        pszError = RTErrGetFull(rc);
    368356                    else
     
    761749                                    {
    762750                                        /*
    763                                          * Set the state and link into the global list.
     751                                         * Set the state and we're done.
    764752                                         */
    765753                                        vmR3SetState(pVM, VMSTATE_CREATED, VMSTATE_CREATING);
    766                                         pUVM->pNext = g_pUVMsHead;
    767                                         g_pUVMsHead = pUVM;
    768754
    769755#ifdef LOG_ENABLED
     
    11771163 * @param   offDelta    Relocation delta relative to old location.
    11781164 */
    1179 VMMR3DECL(void)  VMR3Relocate(PVM pVM, RTGCINTPTR offDelta)
     1165VMMR3_INT_DECL(void) VMR3Relocate(PVM pVM, RTGCINTPTR offDelta)
    11801166{
    11811167    LogFlow(("VMR3Relocate: offDelta=%RGv\n", offDelta));
     
    12591245 * @returns VBox status code.
    12601246 *
    1261  * @param   pVM         The VM to power on.
     1247 * @param   pUVM        The VM to power on.
    12621248 *
    12631249 * @thread      Any thread.
     
    12651251 * @vmstateto   PoweringOn+Running
    12661252 */
    1267 VMMR3DECL(int) VMR3PowerOn(PVM pVM)
    1268 {
    1269     LogFlow(("VMR3PowerOn: pVM=%p\n", pVM));
     1253VMMR3DECL(int) VMR3PowerOn(PUVM pUVM)
     1254{
     1255    LogFlow(("VMR3PowerOn: pUVM=%p\n", pUVM));
     1256    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     1257    PVM pVM = pUVM->pVM;
    12701258    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    12711259
     
    13531341 *          code that has to be propagated up the call stack.
    13541342 *
    1355  * @param   pVM     The VM to suspend.
     1343 * @param   pUVM    The VM to suspend.
    13561344 *
    13571345 * @thread      Any thread.
     
    13591347 * @vmstateto   Suspending + Suspended or SuspendingExtLS + SuspendedExtLS
    13601348 */
    1361 VMMR3DECL(int) VMR3Suspend(PVM pVM)
    1362 {
    1363     LogFlow(("VMR3Suspend: pVM=%p\n", pVM));
    1364     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     1349VMMR3DECL(int) VMR3Suspend(PUVM pUVM)
     1350{
     1351    LogFlow(("VMR3Suspend: pUVM=%p\n", pUVM));
     1352    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
    13651353
    13661354    /*
     
    13681356     * changing the VM state.
    13691357     */
    1370     int rc = VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_DESCENDING | VMMEMTRENDEZVOUS_FLAGS_STOP_ON_ERROR,
     1358    int rc = VMMR3EmtRendezvous(pUVM->pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_DESCENDING | VMMEMTRENDEZVOUS_FLAGS_STOP_ON_ERROR,
    13711359                                vmR3Suspend, NULL);
    13721360    LogFlow(("VMR3Suspend: returns %Rrc\n", rc));
     
    14401428 * @vmstateto   Running
    14411429 */
    1442 VMMR3DECL(int) VMR3Resume(PVM pVM)
    1443 {
    1444     LogFlow(("VMR3Resume: pVM=%p\n", pVM));
     1430VMMR3DECL(int) VMR3Resume(PUVM pUVM)
     1431{
     1432    LogFlow(("VMR3Resume: pUVM=%p\n", pUVM));
     1433    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     1434    PVM pVM = pUVM->pVM;
    14451435    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    14461436
     
    18181808 * @returns VBox status code.
    18191809 *
    1820  * @param   pVM                 The VM which state should be saved.
     1810 * @param   pUVM                The VM which state should be saved.
    18211811 * @param   pszFilename         The name of the save state file.
    18221812 * @param   pStreamOps          The stream methods.
     
    18331823 *              RunningLS+SuspendingLS+SuspendedLS+Saving+Suspended.
    18341824 */
    1835 VMMR3DECL(int) VMR3Save(PVM pVM, const char *pszFilename, bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended)
    1836 {
    1837     LogFlow(("VMR3Save: pVM=%p pszFilename=%p:{%s} fContinueAfterwards=%RTbool pfnProgress=%p pvUser=%p pfSuspended=%p\n",
    1838              pVM, pszFilename, pszFilename, fContinueAfterwards, pfnProgress, pvUser, pfSuspended));
     1825VMMR3DECL(int) VMR3Save(PUVM pUVM, const char *pszFilename, bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended)
     1826{
     1827    LogFlow(("VMR3Save: pUVM=%p pszFilename=%p:{%s} fContinueAfterwards=%RTbool pfnProgress=%p pvUser=%p pfSuspended=%p\n",
     1828             pUVM, pszFilename, pszFilename, fContinueAfterwards, pfnProgress, pvUser, pfSuspended));
    18391829
    18401830    /*
     
    18431833    AssertPtr(pfSuspended);
    18441834    *pfSuspended = false;
     1835    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     1836    PVM pVM = pUVM->pVM;
    18451837    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    18461838    VM_ASSERT_OTHER_THREAD(pVM);
     
    18641856 * Save current VM state (used by FTM)
    18651857 *
    1866  * Can be used for both saving the state and creating snapshots.
    1867  *
    1868  * When called for a VM in the Running state, the saved state is created live
    1869  * and the VM is only suspended when the final part of the saving is preformed.
    1870  * The VM state will not be restored to Running in this case and it's up to the
    1871  * caller to call VMR3Resume if this is desirable.  (The rational is that the
    1872  * caller probably wish to reconfigure the disks before resuming the VM.)
    18731858 *
    18741859 * @returns VBox status code.
     
    18851870 *              RunningLS+SuspendingLS+SuspendedLS+Saving+Suspended.
    18861871 */
    1887 VMMR3DECL(int) VMR3SaveFT(PVM pVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, bool *pfSuspended,
    1888                           bool fSkipStateChanges)
    1889 {
    1890     LogFlow(("VMR3SaveFT: pVM=%p pStreamOps=%p pvSteamOpsUser=%p pfSuspended=%p\n",
    1891              pVM, pStreamOps, pvStreamOpsUser, pfSuspended));
     1872VMMR3_INT_DECL(int) VMR3SaveFT(PUVM pUVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, bool *pfSuspended, bool fSkipStateChanges)
     1873{
     1874    LogFlow(("VMR3SaveFT: pUVM=%p pStreamOps=%p pvSteamOpsUser=%p pfSuspended=%p\n",
     1875             pUVM, pStreamOps, pvStreamOpsUser, pfSuspended));
    18921876
    18931877    /*
     
    18961880    AssertPtr(pfSuspended);
    18971881    *pfSuspended = false;
     1882    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     1883    PVM pVM = pUVM->pVM;
    18981884    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    18991885    AssertReturn(pStreamOps, VERR_INVALID_PARAMETER);
     
    19161902 * @returns VBox status code.
    19171903 *
    1918  * @param   pVM                 The VM which state should be saved.
     1904 * @param   pUVM                The VM which state should be saved.
    19191905 * @param   cMsMaxDowntime      The maximum downtime given as milliseconds.
    19201906 * @param   pStreamOps          The stream methods.
     
    19291915 *              RunningLS+SuspendingLS+SuspendedLS+Saving+Suspended.
    19301916 */
    1931 VMMR3DECL(int) VMR3Teleport(PVM pVM, uint32_t cMsMaxDowntime, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
     1917VMMR3DECL(int) VMR3Teleport(PUVM pUVM, uint32_t cMsMaxDowntime, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
    19321918                            PFNVMPROGRESS pfnProgress, void *pvProgressUser, bool *pfSuspended)
    19331919{
    1934     LogFlow(("VMR3Teleport: pVM=%p cMsMaxDowntime=%u pStreamOps=%p pvStreamOps=%p pfnProgress=%p pvProgressUser=%p\n",
    1935              pVM, cMsMaxDowntime, pStreamOps, pvStreamOpsUser, pfnProgress, pvProgressUser));
     1920    LogFlow(("VMR3Teleport: pUVM=%p cMsMaxDowntime=%u pStreamOps=%p pvStreamOps=%p pfnProgress=%p pvProgressUser=%p\n",
     1921             pUVM, cMsMaxDowntime, pStreamOps, pvStreamOpsUser, pfnProgress, pvProgressUser));
    19361922
    19371923    /*
     
    19401926    AssertPtr(pfSuspended);
    19411927    *pfSuspended = false;
     1928    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     1929    PVM pVM = pUVM->pVM;
    19421930    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    19431931    VM_ASSERT_OTHER_THREAD(pVM);
     
    19631951 * @returns VBox status code.
    19641952 *
    1965  * @param   pVM                 Pointer to the VM.
     1953 * @param   pUVM                Pointer to the VM.
    19661954 * @param   pszFilename         The name of the file.  NULL if pStreamOps is used.
    19671955 * @param   pStreamOps          The stream methods.  NULL if pszFilename is used.
     
    19741962 * @thread  EMT.
    19751963 */
    1976 static DECLCALLBACK(int) vmR3Load(PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
     1964static DECLCALLBACK(int) vmR3Load(PUVM pUVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
    19771965                                  PFNVMPROGRESS pfnProgress, void *pvProgressUser, bool fTeleporting,
    19781966                                  bool fSkipStateChanges)
     
    19801968    int rc = VINF_SUCCESS;
    19811969
    1982     LogFlow(("vmR3Load: pVM=%p pszFilename=%p:{%s} pStreamOps=%p pvStreamOpsUser=%p pfnProgress=%p pvProgressUser=%p fTeleporting=%RTbool\n",
    1983              pVM, pszFilename, pszFilename, pStreamOps, pvStreamOpsUser, pfnProgress, pvProgressUser, fTeleporting));
     1970    LogFlow(("vmR3Load: pUVM=%p pszFilename=%p:{%s} pStreamOps=%p pvStreamOpsUser=%p pfnProgress=%p pvProgressUser=%p fTeleporting=%RTbool\n",
     1971             pUVM, pszFilename, pszFilename, pStreamOps, pvStreamOpsUser, pfnProgress, pvProgressUser, fTeleporting));
    19841972
    19851973    /*
    19861974     * Validate input (paranoia).
    19871975     */
    1988     AssertPtr(pVM);
     1976    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     1977    PVM pVM = pUVM->pVM;
     1978    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    19891979    AssertPtrNull(pszFilename);
    19901980    AssertPtrNull(pStreamOps);
     
    20001990         */
    20011991        rc = vmR3TrySetState(pVM, "VMR3Load", 2,
    2002                                  VMSTATE_LOADING, VMSTATE_CREATED,
    2003                                  VMSTATE_LOADING, VMSTATE_SUSPENDED);
     1992                             VMSTATE_LOADING, VMSTATE_CREATED,
     1993                             VMSTATE_LOADING, VMSTATE_SUSPENDED);
    20041994        if (RT_FAILURE(rc))
    20051995            return rc;
     
    20071997    pVM->vm.s.fTeleportedAndNotFullyResumedYet = fTeleporting;
    20081998
    2009     uint32_t cErrorsPriorToSave = VMR3GetErrorCount(pVM);
     1999    uint32_t cErrorsPriorToSave = VMR3GetErrorCount(pUVM);
    20102000    rc = SSMR3Load(pVM, pszFilename, pStreamOps, pvStreamOpsUser, SSMAFTER_RESUME, pfnProgress, pvProgressUser);
    20112001    if (RT_SUCCESS(rc))
     
    20212011            vmR3SetState(pVM, VMSTATE_LOAD_FAILURE, VMSTATE_LOADING);
    20222012
    2023         if (cErrorsPriorToSave == VMR3GetErrorCount(pVM))
     2013        if (cErrorsPriorToSave == VMR3GetErrorCount(pUVM))
    20242014            rc = VMSetError(pVM, rc, RT_SRC_POS,
    20252015                            N_("Unable to restore the virtual machine's saved state from '%s'. "
     
    20502040 * @vmstateto   Loading+Suspended
    20512041 */
    2052 VMMR3DECL(int) VMR3LoadFromFile(PVM pVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser)
    2053 {
    2054     LogFlow(("VMR3LoadFromFile: pVM=%p pszFilename=%p:{%s} pfnProgress=%p pvUser=%p\n",
    2055              pVM, pszFilename, pszFilename, pfnProgress, pvUser));
     2042VMMR3DECL(int) VMR3LoadFromFile(PUVM pUVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser)
     2043{
     2044    LogFlow(("VMR3LoadFromFile: pUVM=%p pszFilename=%p:{%s} pfnProgress=%p pvUser=%p\n",
     2045             pUVM, pszFilename, pszFilename, pfnProgress, pvUser));
    20562046
    20572047    /*
    20582048     * Validate input.
    20592049     */
    2060     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     2050    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
    20612051    AssertPtrReturn(pszFilename, VERR_INVALID_POINTER);
    20622052
     
    20652055     * since there is no execution taking place when this call is allowed.
    20662056     */
    2067     int rc = VMR3ReqCallWait(pVM, 0 /*idDstCpu*/, (PFNRT)vmR3Load, 8,
    2068                              pVM, pszFilename, (uintptr_t)NULL /*pStreamOps*/, (uintptr_t)NULL /*pvStreamOpsUser*/, pfnProgress, pvUser,
    2069                              false /*fTeleporting*/, false /* fSkipStateChanges */);
     2057    int rc = VMR3ReqCallWaitU(pUVM, 0 /*idDstCpu*/, (PFNRT)vmR3Load, 8,
     2058                              pUVM, pszFilename, (uintptr_t)NULL /*pStreamOps*/, (uintptr_t)NULL /*pvStreamOpsUser*/, pfnProgress, pvUser,
     2059                              false /*fTeleporting*/, false /* fSkipStateChanges */);
    20702060    LogFlow(("VMR3LoadFromFile: returns %Rrc\n", rc));
    20712061    return rc;
     
    20782068 * @returns VBox status code.
    20792069 *
    2080  * @param   pVM             Pointer to the VM.
     2070 * @param   pUVM            Pointer to the VM.
    20812071 * @param   pStreamOps      The stream methods.
    20822072 * @param   pvStreamOpsUser The user argument to the stream methods.
     
    20882078 * @vmstateto   Loading+Suspended
    20892079 */
    2090 VMMR3DECL(int) VMR3LoadFromStream(PVM pVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
     2080VMMR3DECL(int) VMR3LoadFromStream(PUVM pUVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
    20912081                                  PFNVMPROGRESS pfnProgress, void *pvProgressUser)
    20922082{
    2093     LogFlow(("VMR3LoadFromStream: pVM=%p pStreamOps=%p pvStreamOpsUser=%p pfnProgress=%p pvProgressUser=%p\n",
    2094              pVM, pStreamOps, pvStreamOpsUser, pfnProgress, pvProgressUser));
     2083    LogFlow(("VMR3LoadFromStream: pUVM=%p pStreamOps=%p pvStreamOpsUser=%p pfnProgress=%p pvProgressUser=%p\n",
     2084             pUVM, pStreamOps, pvStreamOpsUser, pfnProgress, pvProgressUser));
    20952085
    20962086    /*
    20972087     * Validate input.
    20982088     */
    2099     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     2089    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
    21002090    AssertPtrReturn(pStreamOps, VERR_INVALID_POINTER);
    21012091
     
    21042094     * since there is no execution taking place when this call is allowed.
    21052095     */
    2106     int rc = VMR3ReqCallWait(pVM, 0 /*idDstCpu*/, (PFNRT)vmR3Load, 8,
    2107                              pVM, (uintptr_t)NULL /*pszFilename*/, pStreamOps, pvStreamOpsUser, pfnProgress, pvProgressUser,
    2108                              true /*fTeleporting*/, false /* fSkipStateChanges */);
     2096    int rc = VMR3ReqCallWaitU(pUVM, 0 /*idDstCpu*/, (PFNRT)vmR3Load, 8,
     2097                              pUVM, (uintptr_t)NULL /*pszFilename*/, pStreamOps, pvStreamOpsUser, pfnProgress, pvProgressUser,
     2098                              true /*fTeleporting*/, false /* fSkipStateChanges */);
    21092099    LogFlow(("VMR3LoadFromStream: returns %Rrc\n", rc));
    21102100    return rc;
     
    21132103
    21142104/**
    2115  * VMR3LoadFromFileFT for arbitrary file streams.
     2105 * Special version for the FT component, it skips state changes.
    21162106 *
    21172107 * @returns VBox status code.
    21182108 *
    2119  * @param   pVM             Pointer to the VM.
     2109 * @param   pUVM            The VM handle.
    21202110 * @param   pStreamOps      The stream methods.
    21212111 * @param   pvStreamOpsUser The user argument to the stream methods.
     
    21272117 * @vmstateto   Loading+Suspended
    21282118 */
    2129 VMMR3DECL(int) VMR3LoadFromStreamFT(PVM pVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser)
    2130 {
    2131     LogFlow(("VMR3LoadFromStreamFT: pVM=%p pStreamOps=%p pvStreamOpsUser=%p\n",
    2132              pVM, pStreamOps, pvStreamOpsUser));
     2119VMMR3_INT_DECL(int) VMR3LoadFromStreamFT(PUVM pUVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser)
     2120{
     2121    LogFlow(("VMR3LoadFromStreamFT: pUVM=%p pStreamOps=%p pvStreamOpsUser=%p\n", pUVM, pStreamOps, pvStreamOpsUser));
    21332122
    21342123    /*
    21352124     * Validate input.
    21362125     */
    2137     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     2126    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
    21382127    AssertPtrReturn(pStreamOps, VERR_INVALID_POINTER);
    21392128
     
    21422131     * since there is no execution taking place when this call is allowed.
    21432132     */
    2144     int rc = VMR3ReqCallWait(pVM, 0 /*idDstCpu*/, (PFNRT)vmR3Load, 8,
    2145                              pVM, (uintptr_t)NULL /*pszFilename*/, pStreamOps, pvStreamOpsUser, NULL, NULL,
    2146                              true /*fTeleporting*/, true /* fSkipStateChanges */);
     2133    int rc = VMR3ReqCallWaitU(pUVM, 0 /*idDstCpu*/, (PFNRT)vmR3Load, 8,
     2134                              pUVM, (uintptr_t)NULL /*pszFilename*/, pStreamOps, pvStreamOpsUser, NULL, NULL,
     2135                              true /*fTeleporting*/, true /* fSkipStateChanges */);
    21472136    LogFlow(("VMR3LoadFromStream: returns %Rrc\n", rc));
    21482137    return rc;
     
    22882277 *          code that has to be propagated up the call stack.
    22892278 *
    2290  * @param   pVM     The handle of the VM to be powered off.
     2279 * @param   pUVM    The handle of the VM to be powered off.
    22912280 *
    22922281 * @thread      Any thread.
     
    22942283 * @vmstateto   Off or OffLS
    22952284 */
    2296 VMMR3DECL(int)   VMR3PowerOff(PVM pVM)
    2297 {
    2298     LogFlow(("VMR3PowerOff: pVM=%p\n", pVM));
     2285VMMR3DECL(int)   VMR3PowerOff(PUVM pUVM)
     2286{
     2287    LogFlow(("VMR3PowerOff: pUVM=%p\n", pUVM));
     2288    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     2289    PVM pVM = pUVM->pVM;
    22992290    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    23002291
     
    23252316 * @vmstateto   N/A
    23262317 */
    2327 VMMR3DECL(int) VMR3Destroy(PVM pVM)
    2328 {
    2329     LogFlow(("VMR3Destroy: pVM=%p\n", pVM));
     2318VMMR3DECL(int) VMR3Destroy(PUVM pUVM)
     2319{
     2320    LogFlow(("VMR3Destroy: pUVM=%p\n", pUVM));
    23302321
    23312322    /*
    23322323     * Validate input.
    23332324     */
    2334     if (!pVM)
     2325    if (!pUVM)
    23352326        return VERR_INVALID_VM_HANDLE;
     2327    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     2328    PVM pVM = pUVM->pVM;
    23362329    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    23372330    AssertLogRelReturn(!VM_IS_EMT(pVM), VERR_VM_THREAD_IS_EMT);
    23382331
    23392332    /*
    2340      * Change VM state to destroying and unlink the VM.
     2333     * Change VM state to destroying and aall vmR3Destroy on each of the EMTs
     2334     * ending with EMT(0) doing the bulk of the cleanup.
    23412335     */
    23422336    int rc = vmR3TrySetState(pVM, "VMR3Destroy", 1, VMSTATE_DESTROYING, VMSTATE_OFF);
     
    23442338        return rc;
    23452339
    2346     /** @todo lock this when we start having multiple machines in a process... */
    2347     PUVM pUVM = pVM->pUVM; AssertPtr(pUVM);
    2348     if (g_pUVMsHead == pUVM)
    2349         g_pUVMsHead = pUVM->pNext;
    2350     else
    2351     {
    2352         PUVM pPrev = g_pUVMsHead;
    2353         while (pPrev && pPrev->pNext != pUVM)
    2354             pPrev = pPrev->pNext;
    2355         AssertMsgReturn(pPrev, ("pUVM=%p / pVM=%p  is INVALID!\n", pUVM, pVM), VERR_INVALID_PARAMETER);
    2356 
    2357         pPrev->pNext = pUVM->pNext;
    2358     }
    2359     pUVM->pNext = NULL;
    2360 
    2361     /*
    2362      * Notify registered at destruction listeners.
    2363      */
    2364     vmR3AtDtor(pVM);
    2365 
    2366     /*
    2367      * Call vmR3Destroy on each of the EMTs ending with EMT(0) doing the bulk
    2368      * of the cleanup.
    2369      */
    2370     /* vmR3Destroy on all EMTs, ending with EMT(0). */
    23712340    rc = VMR3ReqCallWait(pVM, VMCPUID_ALL_REVERSE, (PFNRT)vmR3Destroy, 1, pVM);
    23722341    AssertLogRelRC(rc);
    23732342
    2374     /* Wait for EMTs and destroy the UVM. */
     2343    /*
     2344     * Wait for EMTs to quit and destroy the UVM.
     2345     */
    23752346    vmR3DestroyUVM(pUVM, 30000);
    23762347
     
    26402611
    26412612/**
    2642  * Enumerates the VMs in this process.
    2643  *
    2644  * @returns Pointer to the next VM.
    2645  * @returns NULL when no more VMs.
    2646  * @param   pVMPrev     The previous VM
    2647  *                      Use NULL to start the enumeration.
    2648  */
    2649 VMMR3DECL(PVM) VMR3EnumVMs(PVM pVMPrev)
    2650 {
    2651     /*
    2652      * This is quick and dirty. It has issues with VM being
    2653      * destroyed during the enumeration.
    2654      */
    2655     PUVM pNext;
    2656     if (pVMPrev)
    2657         pNext = pVMPrev->pUVM->pNext;
    2658     else
    2659         pNext = g_pUVMsHead;
    2660     return pNext ? pNext->pVM : NULL;
    2661 }
    2662 
    2663 
    2664 /**
    2665  * Registers an at VM destruction callback.
    2666  *
    2667  * @returns VBox status code.
    2668  * @param   pfnAtDtor       Pointer to callback.
    2669  * @param   pvUser          User argument.
    2670  */
    2671 VMMR3DECL(int) VMR3AtDtorRegister(PFNVMATDTOR pfnAtDtor, void *pvUser)
    2672 {
    2673     /*
    2674      * Check if already registered.
    2675      */
    2676     VM_ATDTOR_LOCK();
    2677     PVMATDTOR   pCur = g_pVMAtDtorHead;
    2678     while (pCur)
    2679     {
    2680         if (pfnAtDtor == pCur->pfnAtDtor)
    2681         {
    2682             VM_ATDTOR_UNLOCK();
    2683             AssertMsgFailed(("Already registered at destruction callback %p!\n", pfnAtDtor));
    2684             return VERR_INVALID_PARAMETER;
    2685         }
    2686 
    2687         /* next */
    2688         pCur = pCur->pNext;
    2689     }
    2690     VM_ATDTOR_UNLOCK();
    2691 
    2692     /*
    2693      * Allocate new entry.
    2694      */
    2695     PVMATDTOR   pVMAtDtor = (PVMATDTOR)RTMemAlloc(sizeof(*pVMAtDtor));
    2696     if (!pVMAtDtor)
    2697         return VERR_NO_MEMORY;
    2698 
    2699     VM_ATDTOR_LOCK();
    2700     pVMAtDtor->pfnAtDtor = pfnAtDtor;
    2701     pVMAtDtor->pvUser    = pvUser;
    2702     pVMAtDtor->pNext     = g_pVMAtDtorHead;
    2703     g_pVMAtDtorHead      = pVMAtDtor;
    2704     VM_ATDTOR_UNLOCK();
    2705 
    2706     return VINF_SUCCESS;
    2707 }
    2708 
    2709 
    2710 /**
    2711  * Deregisters an at VM destruction callback.
    2712  *
    2713  * @returns VBox status code.
    2714  * @param   pfnAtDtor       Pointer to callback.
    2715  */
    2716 VMMR3DECL(int) VMR3AtDtorDeregister(PFNVMATDTOR pfnAtDtor)
    2717 {
    2718     /*
    2719      * Find it, unlink it and free it.
    2720      */
    2721     VM_ATDTOR_LOCK();
    2722     PVMATDTOR   pPrev = NULL;
    2723     PVMATDTOR   pCur = g_pVMAtDtorHead;
    2724     while (pCur)
    2725     {
    2726         if (pfnAtDtor == pCur->pfnAtDtor)
    2727         {
    2728             if (pPrev)
    2729                 pPrev->pNext = pCur->pNext;
    2730             else
    2731                 g_pVMAtDtorHead = pCur->pNext;
    2732             pCur->pNext = NULL;
    2733             VM_ATDTOR_UNLOCK();
    2734 
    2735             RTMemFree(pCur);
    2736             return VINF_SUCCESS;
    2737         }
    2738 
    2739         /* next */
    2740         pPrev = pCur;
    2741         pCur = pCur->pNext;
    2742     }
    2743     VM_ATDTOR_UNLOCK();
    2744 
    2745     return VERR_INVALID_PARAMETER;
    2746 }
    2747 
    2748 
    2749 /**
    2750  * Walks the list of at VM destructor callbacks.
    2751  * @param   pVM     The VM which is about to be destroyed.
    2752  */
    2753 static void vmR3AtDtor(PVM pVM)
    2754 {
    2755     /*
    2756      * Find it, unlink it and free it.
    2757      */
    2758     VM_ATDTOR_LOCK();
    2759     for (PVMATDTOR pCur = g_pVMAtDtorHead; pCur; pCur = pCur->pNext)
    2760         pCur->pfnAtDtor(pVM, pCur->pvUser);
    2761     VM_ATDTOR_UNLOCK();
    2762 }
    2763 
    2764 
    2765 /**
    27662613 * Worker which checks integrity of some internal structures.
    27672614 * This is yet another attempt to track down that AVL tree crash.
     
    29142761 *
    29152762 * @returns VBox status code.
    2916  * @param   pVM    VM to reset.
    2917  */
    2918 VMMR3DECL(int) VMR3Reset(PVM pVM)
     2763 * @param   pUVM    The VM to reset.
     2764 */
     2765VMMR3DECL(int) VMR3Reset(PUVM pUVM)
    29192766{
    29202767    LogFlow(("VMR3Reset:\n"));
     2768    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     2769    PVM pVM = pUVM->pVM;
    29212770    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    29222771
     
    35503399 * @thread  Any thread.
    35513400 */
    3552 VMMR3DECL(bool) VMR3TeleportedAndNotFullyResumedYet(PVM pVM)
     3401VMMR3_INT_DECL(bool) VMR3TeleportedAndNotFullyResumedYet(PVM pVM)
    35533402{
    35543403    VM_ASSERT_VALID_EXT_RETURN(pVM, false);
     
    35643413 *
    35653414 * @returns VBox status code.
    3566  * @param   pVM             Pointer to the VM.
     3415 * @param   pUVM            The VM handle.
    35673416 * @param   pfnAtState      Pointer to callback.
    35683417 * @param   pvUser          User argument.
    35693418 * @thread  Any.
    35703419 */
    3571 VMMR3DECL(int) VMR3AtStateRegister(PVM pVM, PFNVMATSTATE pfnAtState, void *pvUser)
     3420VMMR3DECL(int) VMR3AtStateRegister(PUVM pUVM, PFNVMATSTATE pfnAtState, void *pvUser)
    35723421{
    35733422    LogFlow(("VMR3AtStateRegister: pfnAtState=%p pvUser=%p\n", pfnAtState, pvUser));
     
    35773426     */
    35783427    AssertPtrReturn(pfnAtState, VERR_INVALID_PARAMETER);
    3579     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     3428    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
    35803429
    35813430    /*
    35823431     * Allocate a new record.
    35833432     */
    3584     PUVM pUVM = pVM->pUVM;
    35853433    PVMATSTATE pNew = (PVMATSTATE)MMR3HeapAllocU(pUVM, MM_TAG_VM, sizeof(*pNew));
    35863434    if (!pNew)
     
    36063454 *
    36073455 * @returns VBox status code.
    3608  * @param   pVM             Pointer to the VM.
     3456 * @param   pUVM            The VM handle.
    36093457 * @param   pfnAtState      Pointer to callback.
    36103458 * @param   pvUser          User argument.
    36113459 * @thread  Any.
    36123460 */
    3613 VMMR3DECL(int) VMR3AtStateDeregister(PVM pVM, PFNVMATSTATE pfnAtState, void *pvUser)
     3461VMMR3DECL(int) VMR3AtStateDeregister(PUVM pUVM, PFNVMATSTATE pfnAtState, void *pvUser)
    36143462{
    36153463    LogFlow(("VMR3AtStateDeregister: pfnAtState=%p pvUser=%p\n", pfnAtState, pvUser));
     
    36193467     */
    36203468    AssertPtrReturn(pfnAtState, VERR_INVALID_PARAMETER);
    3621     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    3622 
    3623     PUVM pUVM = pVM->pUVM;
     3469    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     3470
    36243471    RTCritSectEnter(&pUVM->vm.s.AtStateCritSect);
    36253472
     
    36763523 *
    36773524 * @returns VBox status code.
    3678  * @param   pVM             Pointer to the VM.
     3525 * @param   pUVM            The VM handle.
    36793526 * @param   pfnAtError      Pointer to callback.
    36803527 * @param   pvUser          User argument.
    36813528 * @thread  Any.
    36823529 */
    3683 VMMR3DECL(int)   VMR3AtErrorRegister(PVM pVM, PFNVMATERROR pfnAtError, void *pvUser)
    3684 {
    3685     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    3686     return VMR3AtErrorRegisterU(pVM->pUVM, pfnAtError, pvUser);
    3687 }
    3688 
    3689 
    3690 /**
    3691  * Registers a VM error callback.
    3692  *
    3693  * @returns VBox status code.
    3694  * @param   pUVM            Pointer to the VM.
    3695  * @param   pfnAtError      Pointer to callback.
    3696  * @param   pvUser          User argument.
    3697  * @thread  Any.
    3698  */
    3699 VMMR3DECL(int)   VMR3AtErrorRegisterU(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser)
     3530VMMR3DECL(int)  VMR3AtErrorRegister(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser)
    37003531{
    37013532    LogFlow(("VMR3AtErrorRegister: pfnAtError=%p pvUser=%p\n", pfnAtError, pvUser));
     
    37333564 *
    37343565 * @returns VBox status code.
    3735  * @param   pVM             Pointer to the VM.
     3566 * @param   pUVM            The VM handle.
    37363567 * @param   pfnAtError      Pointer to callback.
    37373568 * @param   pvUser          User argument.
    37383569 * @thread  Any.
    37393570 */
    3740 VMMR3DECL(int) VMR3AtErrorDeregister(PVM pVM, PFNVMATERROR pfnAtError, void *pvUser)
     3571VMMR3DECL(int) VMR3AtErrorDeregister(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser)
    37413572{
    37423573    LogFlow(("VMR3AtErrorDeregister: pfnAtError=%p pvUser=%p\n", pfnAtError, pvUser));
     
    37463577     */
    37473578    AssertPtrReturn(pfnAtError, VERR_INVALID_PARAMETER);
    3748     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    3749 
    3750     PUVM pUVM = pVM->pUVM;
     3579    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     3580
    37513581    RTCritSectEnter(&pUVM->vm.s.AtErrorCritSect);
    37523582
     
    38183648 * @thread  EMT.
    38193649 */
    3820 VMMR3DECL(void) VMR3SetErrorWorker(PVM pVM)
     3650VMMR3_INT_DECL(void) VMR3SetErrorWorker(PVM pVM)
    38213651{
    38223652    VM_ASSERT_EMT(pVM);
     
    38663696 *
    38673697 * @returns The error count.
    3868  * @param   pVM             Pointer to the VM.
    3869  */
    3870 VMMR3DECL(uint32_t) VMR3GetErrorCount(PVM pVM)
    3871 {
    3872     AssertPtrReturn(pVM, 0);
    3873     return VMR3GetErrorCountU(pVM->pUVM);
    3874 }
    3875 
    3876 
    3877 /**
    3878  * Gets the number of errors raised via VMSetError.
    3879  *
    3880  * This can be used avoid double error messages.
    3881  *
    3882  * @returns The error count.
    3883  * @param   pVM             Pointer to the VM.
    3884  */
    3885 VMMR3DECL(uint32_t) VMR3GetErrorCountU(PUVM pUVM)
     3698 * @param   pUVM            The VM handle.
     3699 */
     3700VMMR3_INT_DECL(uint32_t) VMR3GetErrorCount(PUVM pUVM)
    38863701{
    38873702    AssertPtrReturn(pUVM, 0);
     
    39773792 * @thread  Any.
    39783793 */
    3979 VMMR3DECL(int)   VMR3AtRuntimeErrorRegister(PVM pVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser)
     3794VMMR3DECL(int)   VMR3AtRuntimeErrorRegister(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser)
    39803795{
    39813796    LogFlow(("VMR3AtRuntimeErrorRegister: pfnAtRuntimeError=%p pvUser=%p\n", pfnAtRuntimeError, pvUser));
     
    39853800     */
    39863801    AssertPtrReturn(pfnAtRuntimeError, VERR_INVALID_PARAMETER);
    3987     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     3802    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
    39883803
    39893804    /*
    39903805     * Allocate a new record.
    39913806     */
    3992     PUVM pUVM = pVM->pUVM;
    39933807    PVMATRUNTIMEERROR pNew = (PVMATRUNTIMEERROR)MMR3HeapAllocU(pUVM, MM_TAG_VM, sizeof(*pNew));
    39943808    if (!pNew)
     
    40143828 *
    40153829 * @returns VBox status code.
    4016  * @param   pVM                 Pointer to the VM.
     3830 * @param   pUVM                The user mode VM handle.
    40173831 * @param   pfnAtRuntimeError   Pointer to callback.
    40183832 * @param   pvUser              User argument.
    40193833 * @thread  Any.
    40203834 */
    4021 VMMR3DECL(int)   VMR3AtRuntimeErrorDeregister(PVM pVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser)
     3835VMMR3DECL(int) VMR3AtRuntimeErrorDeregister(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser)
    40223836{
    40233837    LogFlow(("VMR3AtRuntimeErrorDeregister: pfnAtRuntimeError=%p pvUser=%p\n", pfnAtRuntimeError, pvUser));
     
    40273841     */
    40283842    AssertPtrReturn(pfnAtRuntimeError, VERR_INVALID_PARAMETER);
    4029     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    4030 
    4031     PUVM pUVM = pVM->pUVM;
     3843    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     3844
    40323845    RTCritSectEnter(&pUVM->vm.s.AtErrorCritSect);
    40333846
     
    41423955                                vmR3SetRuntimeErrorChangeState, NULL);
    41433956    else if (fFlags & VMSETRTERR_FLAGS_SUSPEND)
    4144         rc = VMR3Suspend(pVM);
     3957        rc = VMR3Suspend(pVM->pUVM);
    41453958    else
    41463959        rc = VINF_SUCCESS;
     
    41884001 * @thread  EMT.
    41894002 */
    4190 VMMR3DECL(int) VMR3SetRuntimeErrorWorker(PVM pVM)
     4003VMMR3_INT_DECL(int) VMR3SetRuntimeErrorWorker(PVM pVM)
    41914004{
    41924005    VM_ASSERT_EMT(pVM);
     
    42864099 *
    42874100 * @returns The runtime error count.
     4101 * @param   pUVM            The user mode VM handle.
     4102 */
     4103VMMR3_INT_DECL(uint32_t) VMR3GetRuntimeErrorCount(PUVM pUVM)
     4104{
     4105    return pUVM->vm.s.cRuntimeErrors;
     4106}
     4107
     4108
     4109/**
     4110 * Gets the ID virtual of the virtual CPU associated with the calling thread.
     4111 *
     4112 * @returns The CPU ID. NIL_VMCPUID if the thread isn't an EMT.
     4113 *
    42884114 * @param   pVM             Pointer to the VM.
    42894115 */
    4290 VMMR3DECL(uint32_t) VMR3GetRuntimeErrorCount(PVM pVM)
    4291 {
    4292     return pVM->pUVM->vm.s.cRuntimeErrors;
    4293 }
    4294 
    4295 
    4296 /**
    4297  * Gets the ID virtual of the virtual CPU associated with the calling thread.
    4298  *
    4299  * @returns The CPU ID. NIL_VMCPUID if the thread isn't an EMT.
    4300  *
    4301  * @param   pVM             Pointer to the VM.
    4302  */
    4303 VMMR3DECL(RTCPUID) VMR3GetVMCPUId(PVM pVM)
     4116VMMR3_INT_DECL(RTCPUID) VMR3GetVMCPUId(PVM pVM)
    43044117{
    43054118    PUVMCPU pUVCpu = (PUVMCPU)RTTlsGet(pVM->pUVM->vm.s.idxTLS);
     
    43504163 *
    43514164 * @returns Handle if this is an EMT thread; NIL_RTNATIVETHREAD otherwise
    4352  * @param   pVM             Pointer to the VM.
     4165 * @param   pUVM            The user mode VM handle.
    43534166 * @thread  EMT
    43544167 */
    4355 VMMR3DECL(RTTHREAD) VMR3GetVMCPUThread(PVM pVM)
    4356 {
    4357     PUVMCPU pUVCpu = (PUVMCPU)RTTlsGet(pVM->pUVM->vm.s.idxTLS);
     4168VMMR3DECL(RTTHREAD) VMR3GetVMCPUThread(PUVM pUVM)
     4169{
     4170    PUVMCPU pUVCpu = (PUVMCPU)RTTlsGet(pUVM->vm.s.idxTLS);
    43584171
    43594172    if (!pUVCpu)
     
    43654178
    43664179/**
    4367  * Returns the handle of the current EMT VMCPU thread.
    4368  *
    4369  * @returns Handle if this is an EMT thread; NIL_RTNATIVETHREAD otherwise
    4370  * @param   pVM             Pointer to the VM.
    4371  * @thread  EMT
    4372  */
    4373 VMMR3DECL(RTTHREAD) VMR3GetVMCPUThreadU(PUVM pUVM)
    4374 {
    4375     PUVMCPU pUVCpu = (PUVMCPU)RTTlsGet(pUVM->vm.s.idxTLS);
    4376 
    4377     if (!pUVCpu)
    4378         return NIL_RTTHREAD;
    4379 
    4380     return pUVCpu->vm.s.ThreadEMT;
    4381 }
    4382 
    4383 
    4384 /**
    4385  * Return the package and core id of a CPU.
     4180 * Return the package and core ID of a CPU.
    43864181 *
    43874182 * @returns VBOX status code.
    4388  * @param   pVM              Pointer to the VM.
     4183 * @param   pUVM             The user mode VM handle.
    43894184 * @param   idCpu            Virtual CPU to get the ID from.
    43904185 * @param   pidCpuCore       Where to store the core ID of the virtual CPU.
     
    43924187 *
    43934188 */
    4394 VMMR3DECL(int) VMR3GetCpuCoreAndPackageIdFromCpuId(PVM pVM, VMCPUID idCpu, uint32_t *pidCpuCore, uint32_t *pidCpuPackage)
     4189VMMR3DECL(int) VMR3GetCpuCoreAndPackageIdFromCpuId(PUVM pUVM, VMCPUID idCpu, uint32_t *pidCpuCore, uint32_t *pidCpuPackage)
    43954190{
    43964191    /*
    43974192     * Validate input.
    43984193     */
     4194    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     4195    PVM pVM = pUVM->pVM;
    43994196    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    44004197    AssertPtrReturn(pidCpuCore, VERR_INVALID_POINTER);
     
    44524249 *
    44534250 * @returns VBox status code.
    4454  * @param   pVM     Pointer to the VM.
     4251 * @param   pUVM    The user mode VM handle.
    44554252 * @param   idCpu   Virtual CPU to perform the hot unplugging operation on.
    44564253 */
    4457 VMMR3DECL(int) VMR3HotUnplugCpu(PVM pVM, VMCPUID idCpu)
    4458 {
     4254VMMR3DECL(int) VMR3HotUnplugCpu(PUVM pUVM, VMCPUID idCpu)
     4255{
     4256    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     4257    PVM pVM = pUVM->pVM;
    44594258    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    44604259    AssertReturn(idCpu < pVM->cCpus, VERR_INVALID_CPU_ID);
     
    44644263     *        offline and send it to SPIP wait.  Maybe modify VMCPUSTATE and push
    44654264     *        it out of the EM loops when offline. */
    4466     return VMR3ReqCallNoWait(pVM, idCpu, (PFNRT)vmR3HotUnplugCpu, 2, pVM, idCpu);
     4265    return VMR3ReqCallNoWaitU(pUVM, idCpu, (PFNRT)vmR3HotUnplugCpu, 2, pVM, idCpu);
    44674266}
    44684267
     
    44724271 *
    44734272 * @returns VBox status code.
    4474  * @param   pVM     Pointer to the VM.
     4273 * @param   pUVM    The user mode VM handle.
    44754274 * @param   idCpu   Virtual CPU to perform the hot plugging operation on.
    44764275 */
    4477 VMMR3DECL(int) VMR3HotPlugCpu(PVM pVM, VMCPUID idCpu)
    4478 {
     4276VMMR3DECL(int) VMR3HotPlugCpu(PUVM pUVM, VMCPUID idCpu)
     4277{
     4278    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     4279    PVM pVM = pUVM->pVM;
    44794280    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    44804281    AssertReturn(idCpu < pVM->cCpus, VERR_INVALID_CPU_ID);
     
    44934294 *                              100 is max performance (default).
    44944295 */
    4495 VMMR3DECL(int) VMR3SetCpuExecutionCap(PVM pVM, uint32_t uCpuExecutionCap)
    4496 {
     4296VMMR3DECL(int) VMR3SetCpuExecutionCap(PUVM pUVM, uint32_t uCpuExecutionCap)
     4297{
     4298    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     4299    PVM pVM = pUVM->pVM;
    44974300    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    44984301    AssertReturn(uCpuExecutionCap > 0 && uCpuExecutionCap <= 100, VERR_INVALID_PARAMETER);
  • trunk/src/VBox/VMM/VMMR3/VMEmt.cpp

    r41965 r44340  
    195195                 * Service a delayed reset request.
    196196                 */
    197                 rc = VMR3Reset(pVM);
     197                rc = VMR3Reset(pVM->pUVM);
    198198                VM_FF_CLEAR(pVM, VM_FF_RESET);
    199199                Log(("vmR3EmulationThread: Reset rc=%Rrc, VM state %s -> %s\n", rc, VMR3GetStateName(enmBefore), VMR3GetStateName(pVM->enmVMState)));
     
    10021002 * @param   pUVM            Pointer to the user mode VM structure.
    10031003 * @param   fFlags          Notification flags, VMNOTIFYFF_FLAGS_*.
    1004  */
    1005 VMMR3DECL(void) VMR3NotifyGlobalFFU(PUVM pUVM, uint32_t fFlags)
     1004 * @internal
     1005 */
     1006VMMR3_INT_DECL(void) VMR3NotifyGlobalFFU(PUVM pUVM, uint32_t fFlags)
    10061007{
    10071008    LogFlow(("VMR3NotifyGlobalFFU:\n"));
     
    10241025 * @param   pUVM            Pointer to the user mode VM structure.
    10251026 * @param   fFlags          Notification flags, VMNOTIFYFF_FLAGS_*.
    1026  */
    1027 VMMR3DECL(void) VMR3NotifyCpuFFU(PUVMCPU pUVCpu, uint32_t fFlags)
     1027 * @internal
     1028 */
     1029VMMR3_INT_DECL(void) VMR3NotifyCpuFFU(PUVMCPU pUVCpu, uint32_t fFlags)
    10281030{
    10291031    PUVM pUVM = pUVCpu->pUVM;
     
    10441046 * @param   fIgnoreInterrupts   If set the VM_FF_INTERRUPT flags is ignored.
    10451047 * @thread  The emulation thread.
    1046  */
    1047 VMMR3DECL(int) VMR3WaitHalted(PVM pVM, PVMCPU pVCpu, bool fIgnoreInterrupts)
     1048 * @internal
     1049 */
     1050VMMR3_INT_DECL(int) VMR3WaitHalted(PVM pVM, PVMCPU pVCpu, bool fIgnoreInterrupts)
    10481051{
    10491052    LogFlow(("VMR3WaitHalted: fIgnoreInterrupts=%d\n", fIgnoreInterrupts));
     
    11231126 * @param   pUVCpu          Pointer to the user mode VMCPU structure.
    11241127 * @thread  The emulation thread.
    1125  */
    1126 VMMR3DECL(int) VMR3WaitU(PUVMCPU pUVCpu)
     1128 * @internal
     1129 */
     1130VMMR3_INT_DECL(int) VMR3WaitU(PUVMCPU pUVCpu)
    11271131{
    11281132    LogFlow(("VMR3WaitU:\n"));
  • trunk/src/VBox/VMM/VMMR3/VMM.cpp

    r44078 r44340  
    16801680     * Validate input.
    16811681     */
     1682    AssertReturn(pVM, VERR_INVALID_VM_HANDLE);
    16821683    AssertMsg(   (fFlags & VMMEMTRENDEZVOUS_FLAGS_TYPE_MASK) != VMMEMTRENDEZVOUS_FLAGS_TYPE_INVALID
    16831684              && (fFlags & VMMEMTRENDEZVOUS_FLAGS_TYPE_MASK) <= VMMEMTRENDEZVOUS_FLAGS_TYPE_DESCENDING
  • trunk/src/VBox/VMM/VMMR3/VMReq.cpp

    r41965 r44340  
    4545
    4646/**
    47  * Allocate and queue a call request.
    48  *
    49  * If it's desired to poll on the completion of the request set cMillies
    50  * to 0 and use VMR3ReqWait() to check for completion. In the other case
    51  * use RT_INDEFINITE_WAIT.
    52  * The returned request packet must be freed using VMR3ReqFree().
    53  *
    54  * @returns VBox status code.
    55  *          Will not return VERR_INTERRUPTED.
    56  * @returns VERR_TIMEOUT if cMillies was reached without the packet being completed.
    57  *
    58  * @param   pVM             Pointer to the VM.
    59  * @param   idDstCpu        The destination CPU(s). Either a specific CPU ID or
    60  *                          one of the following special values:
    61  *                              VMCPUID_ANY, VMCPUID_ANY_QUEUE, VMCPUID_ALL or VMCPUID_ALL_REVERSE.
    62  * @param   ppReq           Where to store the pointer to the request.
    63  *                          This will be NULL or a valid request pointer not matter what happens.
    64  * @param   cMillies        Number of milliseconds to wait for the request to
    65  *                          be completed. Use RT_INDEFINITE_WAIT to only
    66  *                          wait till it's completed.
    67  * @param   fFlags          A combination of the VMREQFLAGS values.
    68  * @param   pfnFunction     Pointer to the function to call.
    69  * @param   cArgs           Number of arguments following in the ellipsis.
    70  * @param   ...             Function arguments.
    71  *
    72  * @remarks See remarks on VMR3ReqCallVU.
    73  */
    74 VMMR3DECL(int) VMR3ReqCall(PVM pVM, VMCPUID idDstCpu, PVMREQ *ppReq, RTMSINTERVAL cMillies, uint32_t fFlags,
    75                            PFNRT pfnFunction, unsigned cArgs, ...)
    76 {
    77     va_list va;
    78     va_start(va, cArgs);
    79     int rc = VMR3ReqCallVU(pVM->pUVM, idDstCpu, ppReq, cMillies, fFlags, pfnFunction, cArgs, va);
    80     va_end(va);
    81     return rc;
    82 }
    83 
    84 
    85 /**
    8647 * Convenience wrapper for VMR3ReqCallU.
    8748 *
     
    10364 *
    10465 * @remarks See remarks on VMR3ReqCallVU.
    105  */
    106 VMMR3DECL(int) VMR3ReqCallWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...)
     66 * @internal
     67 */
     68VMMR3_INT_DECL(int) VMR3ReqCallWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...)
    10769{
    10870    PVMREQ pReq;
     
    12284 * Convenience wrapper for VMR3ReqCallU.
    12385 *
    124  * This assumes (1) you're calling a function that returns an VBox status code
    125  * and that you do not wish to wait for it to complete.
    126  *
    127  * @returns VBox status code returned by VMR3ReqCallVU.
     86 * This assumes (1) you're calling a function that returns an VBox status code,
     87 * (2) that you want it's return code on success, and (3) that you wish to wait
     88 * for ever for it to return.
     89 *
     90 * @returns VBox status code.  In the unlikely event that VMR3ReqCallVU fails,
     91 *          its status code is return.  Otherwise, the status of pfnFunction is
     92 *          returned.
    12893 *
    12994 * @param   pVM             Pointer to the VM.
     
    136101 *
    137102 * @remarks See remarks on VMR3ReqCallVU.
    138  */
    139 VMMR3DECL(int) VMR3ReqCallNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...)
    140 {
     103 * @internal
     104 */
     105VMMR3DECL(int) VMR3ReqCallWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...)
     106{
     107    PVMREQ pReq;
    141108    va_list va;
    142109    va_start(va, cArgs);
    143     int rc = VMR3ReqCallVU(pVM->pUVM, idDstCpu, NULL, 0, VMREQFLAGS_VBOX_STATUS | VMREQFLAGS_NO_WAIT,
     110    int rc = VMR3ReqCallVU(pUVM, idDstCpu, &pReq, RT_INDEFINITE_WAIT, VMREQFLAGS_VBOX_STATUS,
    144111                           pfnFunction, cArgs, va);
    145112    va_end(va);
     113    if (RT_SUCCESS(rc))
     114        rc = pReq->iStatus;
     115    VMR3ReqFree(pReq);
    146116    return rc;
    147117}
     
    151121 * Convenience wrapper for VMR3ReqCallU.
    152122 *
    153  * This assumes (1) you're calling a function that returns void, and (2) that
    154  * you wish to wait for ever for it to return.
    155  *
    156  * @returns VBox status code of VMR3ReqCallVU.
     123 * This assumes (1) you're calling a function that returns an VBox status code
     124 * and that you do not wish to wait for it to complete.
     125 *
     126 * @returns VBox status code returned by VMR3ReqCallVU.
    157127 *
    158128 * @param   pVM             Pointer to the VM.
     
    165135 *
    166136 * @remarks See remarks on VMR3ReqCallVU.
    167  */
    168 VMMR3DECL(int) VMR3ReqCallVoidWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...)
     137 * @internal
     138 */
     139VMMR3DECL(int) VMR3ReqCallNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...)
     140{
     141    va_list va;
     142    va_start(va, cArgs);
     143    int rc = VMR3ReqCallVU(pVM->pUVM, idDstCpu, NULL, 0, VMREQFLAGS_VBOX_STATUS | VMREQFLAGS_NO_WAIT,
     144                           pfnFunction, cArgs, va);
     145    va_end(va);
     146    return rc;
     147}
     148
     149
     150/**
     151 * Convenience wrapper for VMR3ReqCallU.
     152 *
     153 * This assumes (1) you're calling a function that returns an VBox status code
     154 * and that you do not wish to wait for it to complete.
     155 *
     156 * @returns VBox status code returned by VMR3ReqCallVU.
     157 *
     158 * @param   pUVM            Pointer to the VM.
     159 * @param   idDstCpu        The destination CPU(s). Either a specific CPU ID or
     160 *                          one of the following special values:
     161 *                              VMCPUID_ANY, VMCPUID_ANY_QUEUE, VMCPUID_ALL or VMCPUID_ALL_REVERSE.
     162 * @param   pfnFunction     Pointer to the function to call.
     163 * @param   cArgs           Number of arguments following in the ellipsis.
     164 * @param   ...             Function arguments.
     165 *
     166 * @remarks See remarks on VMR3ReqCallVU.
     167 */
     168VMMR3DECL(int) VMR3ReqCallNoWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...)
     169{
     170    va_list va;
     171    va_start(va, cArgs);
     172    int rc = VMR3ReqCallVU(pUVM, idDstCpu, NULL, 0, VMREQFLAGS_VBOX_STATUS | VMREQFLAGS_NO_WAIT,
     173                           pfnFunction, cArgs, va);
     174    va_end(va);
     175    return rc;
     176}
     177
     178
     179/**
     180 * Convenience wrapper for VMR3ReqCallU.
     181 *
     182 * This assumes (1) you're calling a function that returns void, and (2) that
     183 * you wish to wait for ever for it to return.
     184 *
     185 * @returns VBox status code of VMR3ReqCallVU.
     186 *
     187 * @param   pVM             Pointer to the VM.
     188 * @param   idDstCpu        The destination CPU(s). Either a specific CPU ID or
     189 *                          one of the following special values:
     190 *                              VMCPUID_ANY, VMCPUID_ANY_QUEUE, VMCPUID_ALL or VMCPUID_ALL_REVERSE.
     191 * @param   pfnFunction     Pointer to the function to call.
     192 * @param   cArgs           Number of arguments following in the ellipsis.
     193 * @param   ...             Function arguments.
     194 *
     195 * @remarks See remarks on VMR3ReqCallVU.
     196 * @internal
     197 */
     198VMMR3_INT_DECL(int) VMR3ReqCallVoidWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...)
    169199{
    170200    PVMREQ pReq;
     
    183213 *
    184214 * This assumes (1) you're calling a function that returns void, and (2) that
     215 * you wish to wait for ever for it to return.
     216 *
     217 * @returns VBox status code of VMR3ReqCallVU.
     218 *
     219 * @param   pUVM            Pointer to the VM.
     220 * @param   idDstCpu        The destination CPU(s). Either a specific CPU ID or
     221 *                          one of the following special values:
     222 *                              VMCPUID_ANY, VMCPUID_ANY_QUEUE, VMCPUID_ALL or VMCPUID_ALL_REVERSE.
     223 * @param   pfnFunction     Pointer to the function to call.
     224 * @param   cArgs           Number of arguments following in the ellipsis.
     225 * @param   ...             Function arguments.
     226 *
     227 * @remarks See remarks on VMR3ReqCallVU.
     228 */
     229VMMR3DECL(int) VMR3ReqCallVoidWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...)
     230{
     231    PVMREQ pReq;
     232    va_list va;
     233    va_start(va, cArgs);
     234    int rc = VMR3ReqCallVU(pUVM, idDstCpu, &pReq, RT_INDEFINITE_WAIT, VMREQFLAGS_VOID,
     235                           pfnFunction, cArgs, va);
     236    va_end(va);
     237    VMR3ReqFree(pReq);
     238    return rc;
     239}
     240
     241
     242/**
     243 * Convenience wrapper for VMR3ReqCallU.
     244 *
     245 * This assumes (1) you're calling a function that returns void, and (2) that
    185246 * you do not wish to wait for it to complete.
    186247 *
     
    196257 *
    197258 * @remarks See remarks on VMR3ReqCallVU.
     259 * @internal
    198260 */
    199261VMMR3DECL(int) VMR3ReqCallVoidNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...)
     
    231293 *
    232294 * @remarks See remarks on VMR3ReqCallVU.
     295 * @internal
    233296 */
    234297VMMR3DECL(int) VMR3ReqPriorityCallWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...)
     
    250313 * Convenience wrapper for VMR3ReqCallU.
    251314 *
    252  * This assumes (1) you're calling a function that returns void, (2) that you
    253  * wish to wait for ever for it to return, and (3) that it's priority request
    254  * that can be safely be handled during async suspend and power off.
    255  *
    256  * @returns VBox status code of VMR3ReqCallVU.
    257  *
    258  * @param   pVM             Pointer to the VM.
     315 * This assumes (1) you're calling a function that returns an VBox status code,
     316 * (2) that you want it's return code on success, (3) that you wish to wait for
     317 * ever for it to return, and (4) that it's priority request that can be safely
     318 * be handled during async suspend and power off.
     319 *
     320 * @returns VBox status code.  In the unlikely event that VMR3ReqCallVU fails,
     321 *          its status code is return.  Otherwise, the status of pfnFunction is
     322 *          returned.
     323 *
     324 * @param   pUVM            The user mode VM handle.
    259325 * @param   idDstCpu        The destination CPU(s). Either a specific CPU ID or
    260326 *                          one of the following special values:
     
    266332 * @remarks See remarks on VMR3ReqCallVU.
    267333 */
    268 VMMR3DECL(int) VMR3ReqPriorityCallVoidWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...)
     334VMMR3DECL(int) VMR3ReqPriorityCallWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...)
    269335{
    270336    PVMREQ pReq;
    271337    va_list va;
    272338    va_start(va, cArgs);
    273     int rc = VMR3ReqCallVU(pVM->pUVM, idDstCpu, &pReq, RT_INDEFINITE_WAIT, VMREQFLAGS_VOID | VMREQFLAGS_PRIORITY,
     339    int rc = VMR3ReqCallVU(pUVM, idDstCpu, &pReq, RT_INDEFINITE_WAIT, VMREQFLAGS_VBOX_STATUS | VMREQFLAGS_PRIORITY,
     340                           pfnFunction, cArgs, va);
     341    va_end(va);
     342    if (RT_SUCCESS(rc))
     343        rc = pReq->iStatus;
     344    VMR3ReqFree(pReq);
     345    return rc;
     346}
     347
     348
     349/**
     350 * Convenience wrapper for VMR3ReqCallU.
     351 *
     352 * This assumes (1) you're calling a function that returns void, (2) that you
     353 * wish to wait for ever for it to return, and (3) that it's priority request
     354 * that can be safely be handled during async suspend and power off.
     355 *
     356 * @returns VBox status code of VMR3ReqCallVU.
     357 *
     358 * @param   pUVM            The user mode VM handle.
     359 * @param   idDstCpu        The destination CPU(s). Either a specific CPU ID or
     360 *                          one of the following special values:
     361 *                              VMCPUID_ANY, VMCPUID_ANY_QUEUE, VMCPUID_ALL or VMCPUID_ALL_REVERSE.
     362 * @param   pfnFunction     Pointer to the function to call.
     363 * @param   cArgs           Number of arguments following in the ellipsis.
     364 * @param   ...             Function arguments.
     365 *
     366 * @remarks See remarks on VMR3ReqCallVU.
     367 */
     368VMMR3DECL(int) VMR3ReqPriorityCallVoidWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...)
     369{
     370    PVMREQ pReq;
     371    va_list va;
     372    va_start(va, cArgs);
     373    int rc = VMR3ReqCallVU(pUVM, idDstCpu, &pReq, RT_INDEFINITE_WAIT, VMREQFLAGS_VOID | VMREQFLAGS_PRIORITY,
    274374                           pfnFunction, cArgs, va);
    275375    va_end(va);
     
    380480     * Allocate request
    381481     */
    382     int rc = VMR3ReqAllocU(pUVM, &pReq, VMREQTYPE_INTERNAL, idDstCpu);
     482    int rc = VMR3ReqAlloc(pUVM, &pReq, VMREQTYPE_INTERNAL, idDstCpu);
    383483    if (RT_FAILURE(rc))
    384484        return rc;
     
    478578 * @returns VBox status code.
    479579 *
    480  * @param   pVM             Pointer to the VM.
    481  * @param   ppReq           Where to store the pointer to the allocated packet.
    482  * @param   enmType         Package type.
    483  * @param   idDstCpu        The destination CPU(s). Either a specific CPU ID or
    484  *                          one of the following special values:
    485  *                              VMCPUID_ANY, VMCPUID_ANY_QUEUE, VMCPUID_ALL or VMCPUID_ALL_REVERSE.
    486  */
    487 VMMR3DECL(int) VMR3ReqAlloc(PVM pVM, PVMREQ *ppReq, VMREQTYPE enmType, VMCPUID idDstCpu)
    488 {
    489     return VMR3ReqAllocU(pVM->pUVM, ppReq, enmType, idDstCpu);
    490 }
    491 
    492 
    493 /**
    494  * Allocates a request packet.
    495  *
    496  * The caller allocates a request packet, fills in the request data
    497  * union and queues the request.
    498  *
    499  * @returns VBox status code.
    500  *
    501580 * @param   pUVM            Pointer to the user mode VM structure.
    502581 * @param   ppReq           Where to store the pointer to the allocated packet.
     
    506585 *                              VMCPUID_ANY, VMCPUID_ANY_QUEUE, VMCPUID_ALL or VMCPUID_ALL_REVERSE.
    507586 */
    508 VMMR3DECL(int) VMR3ReqAllocU(PUVM pUVM, PVMREQ *ppReq, VMREQTYPE enmType, VMCPUID idDstCpu)
     587VMMR3DECL(int) VMR3ReqAlloc(PUVM pUVM, PVMREQ *ppReq, VMREQTYPE enmType, VMCPUID idDstCpu)
    509588{
    510589    /*
     
    10211100 * @remarks This was made reentrant for async PDM handling, the debugger and
    10221101 *          others.
    1023  */
    1024 VMMR3DECL(int) VMR3ReqProcessU(PUVM pUVM, VMCPUID idDstCpu, bool fPriorityOnly)
     1102 * @internal
     1103 */
     1104VMMR3_INT_DECL(int) VMR3ReqProcessU(PUVM pUVM, VMCPUID idDstCpu, bool fPriorityOnly)
    10251105{
    10261106    LogFlow(("VMR3ReqProcessU: (enmVMState=%d) idDstCpu=%d\n", pUVM->pVM ? pUVM->pVM->enmVMState : VMSTATE_CREATING, idDstCpu));
  • trunk/src/VBox/VMM/testcase/tstAnimate.cpp

    r41965 r44340  
    832832     */
    833833    PVM pVM;
    834     rc = VMR3Create(1, NULL, NULL, NULL, cfgmR3CreateDefault, &cbMem, &pVM);
     834    PUVM pUVM;
     835    rc = VMR3Create(1, NULL, NULL, NULL, cfgmR3CreateDefault, &cbMem, &pVM, &pUVM);
    835836    if (RT_SUCCESS(rc))
    836837    {
     
    839840         */
    840841        if (FileRawMem != NIL_RTFILE)
    841             rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)loadMem, 3, pVM, FileRawMem, &offRawMem);
     842            rc = VMR3ReqCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)loadMem, 3, pVM, FileRawMem, &offRawMem);
    842843        else
    843             rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)SSMR3Load,
    844                                  7, pVM, pszSavedState, (uintptr_t)NULL /*pStreamOps*/, (uintptr_t)NULL /*pvUser*/,
    845                                  SSMAFTER_DEBUG_IT, (uintptr_t)NULL /*pfnProgress*/, (uintptr_t)NULL /*pvProgressUser*/);
     844            rc = VMR3ReqCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)SSMR3Load,
     845                                  7, pVM, pszSavedState, (uintptr_t)NULL /*pStreamOps*/, (uintptr_t)NULL /*pvUser*/,
     846                                  SSMAFTER_DEBUG_IT, (uintptr_t)NULL /*pfnProgress*/, (uintptr_t)NULL /*pvProgressUser*/);
    846847        if (RT_SUCCESS(rc))
    847848        {
     
    850851             */
    851852            if (FileScript != NIL_RTFILE)
    852                 rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)scriptRun, 2, pVM, FileScript);
     853                rc = VMR3ReqCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)scriptRun, 2, pVM, FileScript);
    853854            if (RT_SUCCESS(rc))
    854855            {
     
    882883                        DBGFR3Info(pVM, "cpumguest", "verbose", NULL);
    883884                        if (fPowerOn)
    884                             rc = VMR3PowerOn(pVM);
     885                            rc = VMR3PowerOn(pUVM);
    885886                        if (RT_SUCCESS(rc))
    886887                        {
     
    918919         * Cleanup.
    919920         */
    920         rc = VMR3Destroy(pVM);
     921        rc = VMR3Destroy(pUVM);
    921922        if (!RT_SUCCESS(rc))
    922923        {
     
    924925            rcRet++;
    925926        }
     927
     928        VMR3ReleaseUVM(pUVM);
    926929    }
    927930    else
  • trunk/src/VBox/VMM/testcase/tstMicro.cpp

    r41965 r44340  
    347347     */
    348348    PVM pVM;
    349     int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM);
     349    PUVM pUVM;
     350    int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM, &pUVM);
    350351    if (RT_SUCCESS(rc))
    351352    {
     
    353354         * Do testing.
    354355         */
    355         rc = VMR3ReqCallVoidWait(pVM, VMCPUID_ANY, (PFNRT)doit, 1, pVM);
     356        rc = VMR3ReqCallVoidWaitU(pUVM, VMCPUID_ANY, (PFNRT)doit, 1, pVM);
    356357        AssertRC(rc);
    357358        STAMR3Dump(pVM, "*");
     
    360361         * Cleanup.
    361362         */
    362         rc = VMR3PowerOff(pVM);
     363        rc = VMR3PowerOff(pUVM);
    363364        if (!RT_SUCCESS(rc))
    364365        {
     
    366367            rcRet++;
    367368        }
    368         rc = VMR3Destroy(pVM);
     369        rc = VMR3Destroy(pUVM);
    369370        if (!RT_SUCCESS(rc))
    370371        {
     
    372373            rcRet++;
    373374        }
     375        VMR3ReleaseUVM(pUVM);
    374376    }
    375377    else
  • trunk/src/VBox/VMM/testcase/tstPDMAsyncCompletion.cpp

    r39084 r44340  
    8787
    8888    PVM pVM;
    89     int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM);
     89    PUVM pUVM;
     90    int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM, &pUVM);
    9091    if (RT_SUCCESS(rc))
    9192    {
    92         PPDMASYNCCOMPLETIONTEMPLATE pTemplate;
    93 
    9493        /*
    9594         * Little hack to avoid the VM_ASSERT_EMT assertion.
     
    102101         * Create the template.
    103102         */
     103        PPDMASYNCCOMPLETIONTEMPLATE pTemplate;
    104104        rc = PDMR3AsyncCompletionTemplateCreateInternal(pVM, &pTemplate, pfnAsyncTaskCompleted, NULL, "Test");
    105105        if (RT_FAILURE(rc))
     
    236236        }
    237237
    238         rc = VMR3Destroy(pVM);
     238        rc = VMR3Destroy(pUVM);
    239239        AssertMsg(rc == VINF_SUCCESS, ("%s: Destroying VM failed rc=%Rrc!!\n", __FUNCTION__, rc));
     240        VMR3ReleaseUVM(pUVM);
    240241
    241242        /*
  • trunk/src/VBox/VMM/testcase/tstPDMAsyncCompletionStress.cpp

    r39084 r44340  
    575575
    576576    PVM pVM;
    577     int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM);
     577    PUVM pUVM;
     578    int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM, &pUVM);
    578579    if (RT_SUCCESS(rc))
    579580    {
     
    617618        }
    618619
    619         rc = VMR3Destroy(pVM);
     620        rc = VMR3Destroy(pUVM);
    620621        AssertMsg(rc == VINF_SUCCESS, ("%s: Destroying VM failed rc=%Rrc!!\n", __FUNCTION__, rc));
    621622    }
  • trunk/src/VBox/VMM/testcase/tstVMM-HM.cpp

    r43391 r44340  
    8484    RTPrintf(TESTCASE ": Initializing...\n");
    8585    PVM pVM;
    86     int rc = VMR3Create(1, NULL, NULL, NULL, CFGMConstructor, NULL, &pVM);
     86    PUVM pUVM;
     87    int rc = VMR3Create(1, NULL, NULL, NULL, CFGMConstructor, NULL, &pVM, &pUVM);
    8788    if (RT_SUCCESS(rc))
    8889    {
     
    9192         */
    9293        RTPrintf(TESTCASE ": Testing...\n");
    93         rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)VMMDoHmTest, 1, pVM);
     94        rc = VMR3ReqCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)VMMDoHmTest, 1, pVM);
    9495        AssertRC(rc);
    9596
     
    99100         * Cleanup.
    100101         */
    101         rc = VMR3Destroy(pVM);
     102        rc = VMR3Destroy(pUVM);
    102103        if (RT_FAILURE(rc))
    103104        {
     
    105106            rcRet++;
    106107        }
     108        VMR3ReleaseUVM(pUVM);
    107109    }
    108110    else
  • trunk/src/VBox/VMM/testcase/tstVMM.cpp

    r41965 r44340  
    248248    RTPrintf(TESTCASE ": Initializing...\n");
    249249    PVM pVM;
    250     rc = VMR3Create(g_cCpus, NULL, NULL, NULL, tstVMMConfigConstructor, NULL, &pVM);
     250    PUVM pUVM;
     251    rc = VMR3Create(g_cCpus, NULL, NULL, NULL, tstVMMConfigConstructor, NULL, &pVM, &pUVM);
    251252    if (RT_SUCCESS(rc))
    252253    {
     
    263264            {
    264265                RTTestSub(hTest, "VMM");
    265                 rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)VMMDoTest, 1, pVM);
     266                rc = VMR3ReqCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)VMMDoTest, 1, pVM);
    266267                if (RT_FAILURE(rc))
    267268                    RTTestFailed(hTest, "VMMDoTest failed: rc=%Rrc\n", rc);
     
    274275                for (VMCPUID idCpu = 1; idCpu < g_cCpus; idCpu++)
    275276                {
    276                     rc = VMR3ReqCallNoWait(pVM, idCpu, (PFNRT)tstTMWorker, 2, pVM, hTest);
     277                    rc = VMR3ReqCallNoWaitU(pUVM, idCpu, (PFNRT)tstTMWorker, 2, pVM, hTest);
    277278                    if (RT_FAILURE(rc))
    278279                        RTTestFailed(hTest, "VMR3ReqCall failed: rc=%Rrc\n", rc);
    279280                }
    280281
    281                 rc = VMR3ReqCallWait(pVM, 0 /*idDstCpu*/, (PFNRT)tstTMWorker, 2, pVM, hTest);
     282                rc = VMR3ReqCallWaitU(pUVM, 0 /*idDstCpu*/, (PFNRT)tstTMWorker, 2, pVM, hTest);
    282283                if (RT_FAILURE(rc))
    283284                    RTTestFailed(hTest, "VMMDoTest failed: rc=%Rrc\n", rc);
     
    291292         * Cleanup.
    292293         */
    293         rc = VMR3PowerOff(pVM);
     294        rc = VMR3PowerOff(pUVM);
    294295        if (RT_FAILURE(rc))
    295296            RTTestFailed(hTest, "VMR3PowerOff failed: rc=%Rrc\n", rc);
    296         rc = VMR3Destroy(pVM);
     297        rc = VMR3Destroy(pUVM);
    297298        if (RT_FAILURE(rc))
    298299            RTTestFailed(hTest, "VMR3Destroy failed: rc=%Rrc\n", rc);
     300        VMR3ReleaseUVM(pUVM);
    299301    }
    300302    else
  • trunk/src/VBox/VMM/testcase/tstVMMFork.cpp

    r41965 r44340  
    6767    RTPrintf(TESTCASE ": Initializing...\n");
    6868    PVM pVM;
    69     int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM);
     69    PUVM pUVM;
     70    int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM, &pUVM);
    7071    if (RT_SUCCESS(rc))
    7172    {
     
    132133                RTPrintf(TESTCASE ": fork() returned fine.\n");
    133134                RTPrintf(TESTCASE ": testing VM after fork.\n");
    134                 VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)VMMDoTest, 1, pVM);
     135                VMR3ReqCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)VMMDoTest, 1, pVM);
    135136
    136137                STAMR3Dump(pVM, "*");
     
    146147         * Cleanup.
    147148         */
    148         rc = VMR3PowerOff(pVM);
     149        rc = VMR3PowerOff(pUVM);
    149150        if (!RT_SUCCESS(rc))
    150151        {
     
    152153            rcErrors++;
    153154        }
    154         rc = VMR3Destroy(pVM);
     155        rc = VMR3Destroy(pUVM);
    155156        if (!RT_SUCCESS(rc))
    156157        {
     
    158159            rcErrors++;
    159160        }
     161        VMR3ReleaseUVM(pUVM);
    160162    }
    161163    else
  • trunk/src/VBox/VMM/testcase/tstVMREQ.cpp

    r44230 r44340  
    8686 * The function PassVA and PassVA2 calls.
    8787 */
    88 static DECLCALLBACK(int) PassVACallback(PVM pVM, unsigned u4K, unsigned u1G, const char *pszFormat, va_list *pva)
    89 {
    90     NOREF(pVM);
     88static DECLCALLBACK(int) PassVACallback(PUVM pUVM, unsigned u4K, unsigned u1G, const char *pszFormat, va_list *pva)
     89{
     90    NOREF(pUVM);
    9191    if (u4K != _4K)
    9292    {
     
    122122 * similar to VMSetRuntimeError.
    123123 */
    124 static void PassVA2(PVM pVM, const char *pszFormat, va_list va)
     124static void PassVA2(PUVM pUVM, const char *pszFormat, va_list va)
    125125{
    126126#if 0 /** @todo test if this is a GCC problem only or also happens with AMD64+VCC80... */
     
    132132#endif
    133133
    134     int rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)PassVACallback, 5, pVM, _4K, _1G, pszFormat, pvVA);
     134    int rc = VMR3ReqCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)PassVACallback, 5, pUVM, _4K, _1G, pszFormat, pvVA);
    135135    NOREF(rc);
    136136
     
    145145 * similar to VMSetRuntimeError.
    146146 */
    147 static void PassVA(PVM pVM, const char *pszFormat, ...)
     147static void PassVA(PUVM pUVM, const char *pszFormat, ...)
    148148{
    149149    /* 1st test */
    150150    va_list va1;
    151151    va_start(va1, pszFormat);
    152     int rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)PassVACallback, 5, pVM, _4K, _1G, pszFormat, &va1);
     152    int rc = VMR3ReqCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)PassVACallback, 5, pUVM, _4K, _1G, pszFormat, &va1);
    153153    va_end(va1);
    154154    NOREF(rc);
     
    157157    va_list va2;
    158158    va_start(va2, pszFormat);
    159     PassVA2(pVM, pszFormat, va2);
     159    PassVA2(pUVM, pszFormat, va2);
    160160    va_end(va2);
    161161}
     
    168168{
    169169    int rc = VINF_SUCCESS;
    170     PVM pVM = (PVM)pvUser;
     170    PUVM pUVM = (PUVM)pvUser;
    171171    NOREF(hThreadSelf);
    172172
     
    178178        for (iReq = 0; iReq < cReqs; iReq++)
    179179        {
    180             rc = VMR3ReqAlloc(pVM, &apReq[iReq], VMREQTYPE_INTERNAL, VMCPUID_ANY);
     180            rc = VMR3ReqAlloc(pUVM, &apReq[iReq], VMREQTYPE_INTERNAL, VMCPUID_ANY);
    181181            if (RT_FAILURE(rc))
    182182            {
     
    219219     * Create empty VM.
    220220     */
    221     PVM pVM;
    222     int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM);
     221    PUVM pUVM;
     222    int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, NULL, &pUVM);
    223223    if (RT_SUCCESS(rc))
    224224    {
     
    228228        uint64_t u64StartTS = RTTimeNanoTS();
    229229        RTTHREAD Thread0;
    230         rc = RTThreadCreate(&Thread0, Thread, pVM, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "REQ1");
     230        rc = RTThreadCreate(&Thread0, Thread, pUVM, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "REQ1");
    231231        if (RT_SUCCESS(rc))
    232232        {
    233233            RTTHREAD Thread1;
    234             rc = RTThreadCreate(&Thread1, Thread, pVM, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "REQ1");
     234            rc = RTThreadCreate(&Thread1, Thread, pUVM, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "REQ1");
    235235            if (RT_SUCCESS(rc))
    236236            {
     
    273273         * Print stats.
    274274         */
    275         STAMR3Print(pVM, "/VM/Req/*");
     275        STAMR3Print(VMR3GetVM(pUVM), "/VM/Req/*");
    276276
    277277        /*
     
    279279         */
    280280        RTPrintf(TESTCASE ": va_list argument test...\n"); RTStrmFlush(g_pStdOut);
    281         PassVA(pVM, "hello %s", "world");
    282         VMR3AtRuntimeErrorRegister(pVM, MyAtRuntimeError, (void *)"user argument");
    283         VMSetRuntimeError(pVM, 0 /*fFlags*/, "enum", "some %s string", "error");
     281        PassVA(pUVM, "hello %s", "world");
     282        VMR3AtRuntimeErrorRegister(pUVM, MyAtRuntimeError, (void *)"user argument");
     283        VMSetRuntimeError(VMR3GetVM(pUVM), 0 /*fFlags*/, "enum", "some %s string", "error");
    284284
    285285        /*
    286286         * Cleanup.
    287287         */
    288         rc = VMR3PowerOff(pVM);
     288        rc = VMR3PowerOff(pUVM);
    289289        if (!RT_SUCCESS(rc))
    290290        {
     
    292292            g_cErrors++;
    293293        }
    294         rc = VMR3Destroy(pVM);
     294        rc = VMR3Destroy(pUVM);
    295295        if (!RT_SUCCESS(rc))
    296296        {
     
    298298            g_cErrors++;
    299299        }
     300        VMR3ReleaseUVM(pUVM);
    300301    }
    301302    else
  • trunk/src/recompiler/VBoxREMWrapper.cpp

    r43387 r44340  
    13101310    { "TRPMSetFaultAddress",                    VMM_FN(TRPMSetFaultAddress),            &g_aArgsTRPMSetFaultAddress[0],             RT_ELEMENTS(g_aArgsTRPMSetFaultAddress),               REMFNDESC_FLAGS_RET_VOID,   0,                  NULL },
    13111311    { "VMMGetCpu",                              VMM_FN(VMMGetCpu),                      &g_aArgsVM[0],                              RT_ELEMENTS(g_aArgsVM),                                REMFNDESC_FLAGS_RET_INT,    sizeof(PVMCPU),     NULL },
    1312     { "VMR3ReqCallWait",                        VMM_FN(VMR3ReqCallWait),                &g_aArgsVMR3ReqCallWait[0],                 RT_ELEMENTS(g_aArgsVMR3ReqCallWait),                   REMFNDESC_FLAGS_RET_INT | REMFNDESC_FLAGS_ELLIPSIS, sizeof(int), NULL },
    13131312    { "VMR3ReqPriorityCallWait",                VMM_FN(VMR3ReqPriorityCallWait),        &g_aArgsVMR3ReqCallWait[0],                 RT_ELEMENTS(g_aArgsVMR3ReqCallWait),                   REMFNDESC_FLAGS_RET_INT | REMFNDESC_FLAGS_ELLIPSIS, sizeof(int), NULL },
    13141313    { "VMR3ReqFree",                            VMM_FN(VMR3ReqFree),                    &g_aArgsVMR3ReqFree[0],                     RT_ELEMENTS(g_aArgsVMR3ReqFree),                       REMFNDESC_FLAGS_RET_INT,    sizeof(int),        NULL },
    1315     { "VMR3GetVMCPUId",                         VMM_FN(VMR3GetVMCPUId),                 &g_aArgsVM[0],                              RT_ELEMENTS(g_aArgsVM),                                REMFNDESC_FLAGS_RET_INT,    sizeof(int),        NULL },
    1316     { "VMR3GetVMCPUNativeThread",               VMM_FN(VMR3GetVMCPUNativeThread),       &g_aArgsVM[0],                              RT_ELEMENTS(g_aArgsVM),                                REMFNDESC_FLAGS_RET_INT,    sizeof(void *),     NULL },
    13171314//    { "",                        VMM_FN(),                &g_aArgsVM[0],                              RT_ELEMENTS(g_aArgsVM),                                REMFNDESC_FLAGS_RET_INT,    sizeof(int),   NULL },
    13181315};
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette