VirtualBox

Changeset 93444 in vbox


Ignore:
Timestamp:
Jan 26, 2022 6:01:15 PM (3 years ago)
Author:
vboxsync
Message:

VMM,Main,HostServices: Use a function table for accessing the VBoxVMM.dll/so/dylib functionality, and load it dynamically when the Console object is initialized. Also converted a few drivers in Main to use device helpers to get config values and such. bugref:10074

Location:
trunk
Files:
3 added
58 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/Makefile.kmk

    r93115 r93444  
    4747        VBox/settings.h \
    4848        VBox/com/Guid.h \
     49        VBox/vmm/vmmapi.h \
    4950        iprt/cpp/% \
    5051        VBox/com/% \
  • trunk/include/VBox/hgcmsvc.h

    r93115 r93444  
    8484 *          acMaxClients and acMaxCallsPerClient added (VBox 6.1.26).
    8585 * 9.1->10.1 Because pfnDisconnectClient was added back (VBox 6.1.28).
     86 * 10.1->11.1 Because pVMM added to pfnSaveState & pfnLoadState (VBox 7.0).
    8687 */
    87 #define VBOX_HGCM_SVC_VERSION_MAJOR (0x000a)
     88#define VBOX_HGCM_SVC_VERSION_MAJOR (0x000b)
    8889#define VBOX_HGCM_SVC_VERSION_MINOR (0x0001)
    8990#define VBOX_HGCM_SVC_VERSION ((VBOX_HGCM_SVC_VERSION_MAJOR << 16) + VBOX_HGCM_SVC_VERSION_MINOR)
     
    478479#endif
    479480
    480 #ifdef IN_RING3
     481#if defined(IN_RING3) && defined(VBOX_INCLUDED_vmm_vmmr3vtable_h)
     482
    481483/**
    482484 * Puts (serializes) a VBOXHGCMSVCPARM struct into SSM.
    483485 *
    484486 * @returns VBox status code.
    485  * @param   pParm               VBOXHGCMSVCPARM to serialize.
    486  * @param   pSSM                SSM handle to serialize to.
     487 * @param   pParm   VBOXHGCMSVCPARM to serialize.
     488 * @param   pSSM    SSM handle to serialize to.
     489 * @param   pVMM    The VMM vtable.
    487490 */
    488 DECLINLINE(int) HGCMSvcSSMR3Put(VBOXHGCMSVCPARM *pParm, PSSMHANDLE pSSM)
     491DECLINLINE(int) HGCMSvcSSMR3Put(VBOXHGCMSVCPARM *pParm, PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM)
    489492{
    490493    int rc;
     
    493496    AssertPtrReturn(pSSM,  VERR_INVALID_POINTER);
    494497
    495     rc = SSMR3PutU32(pSSM, sizeof(VBOXHGCMSVCPARM));
     498    rc = pVMM->pfnSSMR3PutU32(pSSM, sizeof(VBOXHGCMSVCPARM));
    496499    AssertRCReturn(rc, rc);
    497     rc = SSMR3PutU32(pSSM, pParm->type);
     500    rc = pVMM->pfnSSMR3PutU32(pSSM, pParm->type);
    498501    AssertRCReturn(rc, rc);
    499502
     
    501504    {
    502505        case VBOX_HGCM_SVC_PARM_32BIT:
    503             rc = SSMR3PutU32(pSSM, pParm->u.uint32);
     506            rc = pVMM->pfnSSMR3PutU32(pSSM, pParm->u.uint32);
    504507            break;
    505508        case VBOX_HGCM_SVC_PARM_64BIT:
    506             rc = SSMR3PutU64(pSSM, pParm->u.uint64);
     509            rc = pVMM->pfnSSMR3PutU64(pSSM, pParm->u.uint64);
    507510            break;
    508511        case VBOX_HGCM_SVC_PARM_PTR:
    509             rc = SSMR3PutU32(pSSM, pParm->u.pointer.size);
     512            rc = pVMM->pfnSSMR3PutU32(pSSM, pParm->u.pointer.size);
    510513            if (RT_SUCCESS(rc))
    511                 rc = SSMR3PutMem(pSSM, pParm->u.pointer.addr, pParm->u.pointer.size);
     514                rc = pVMM->pfnSSMR3PutMem(pSSM, pParm->u.pointer.addr, pParm->u.pointer.size);
    512515            break;
    513516        default:
     
    524527 *
    525528 * @returns VBox status code.
    526  * @param   pParm               VBOXHGCMSVCPARM to load into. Must be initialied (zero-ed) properly.
    527  * @param   pSSM                SSM handle to load from.
     529 * @param   pParm   VBOXHGCMSVCPARM to load into. Must be zero'ed.
     530 * @param   pSSM    SSM handle to load from.
     531 * @param   pVMM    The VMM vtable.
    528532 */
    529 DECLINLINE(int) HGCMSvcSSMR3Get(VBOXHGCMSVCPARM *pParm, PSSMHANDLE pSSM)
     533DECLINLINE(int) HGCMSvcSSMR3Get(VBOXHGCMSVCPARM *pParm, PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM)
    530534{
    531535    uint32_t cbParm;
     
    535539    AssertPtrReturn(pSSM,  VERR_INVALID_POINTER);
    536540
    537     rc = SSMR3GetU32(pSSM, &cbParm);
     541    rc = pVMM->pfnSSMR3GetU32(pSSM, &cbParm);
    538542    AssertRCReturn(rc, rc);
    539543    AssertReturn(cbParm == sizeof(VBOXHGCMSVCPARM), VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
    540544
    541     rc = SSMR3GetU32(pSSM, &pParm->type);
     545    rc = pVMM->pfnSSMR3GetU32(pSSM, &pParm->type);
    542546    AssertRCReturn(rc, rc);
    543547
     
    546550        case VBOX_HGCM_SVC_PARM_32BIT:
    547551        {
    548             rc = SSMR3GetU32(pSSM, &pParm->u.uint32);
     552            rc = pVMM->pfnSSMR3GetU32(pSSM, &pParm->u.uint32);
    549553            AssertRCReturn(rc, rc);
    550554            break;
     
    553557        case VBOX_HGCM_SVC_PARM_64BIT:
    554558        {
    555             rc = SSMR3GetU64(pSSM, &pParm->u.uint64);
     559            rc = pVMM->pfnSSMR3GetU64(pSSM, &pParm->u.uint64);
    556560            AssertRCReturn(rc, rc);
    557561            break;
     
    563567                            ("Pointer size parameter already in use (or not initialized)\n"), VERR_INVALID_PARAMETER);
    564568
    565             rc = SSMR3GetU32(pSSM, &pParm->u.pointer.size);
     569            rc = pVMM->pfnSSMR3GetU32(pSSM, &pParm->u.pointer.size);
    566570            AssertRCReturn(rc, rc);
    567571
     
    571575            pParm->u.pointer.addr = RTMemAlloc(pParm->u.pointer.size);
    572576            AssertPtrReturn(pParm->u.pointer.addr, VERR_NO_MEMORY);
    573             rc = SSMR3GetMem(pSSM, pParm->u.pointer.addr, pParm->u.pointer.size);
     577            rc = pVMM->pfnSSMR3GetMem(pSSM, pParm->u.pointer.addr, pParm->u.pointer.size);
    574578
    575579            AssertRCReturn(rc, rc);
     
    585589    return VINF_SUCCESS;
    586590}
     591
    587592#endif /* IN_RING3 */
    588593
     
    693698
    694699    /** Inform the service about a VM save operation. */
    695     DECLR3CALLBACKMEMBER(int, pfnSaveState, (void *pvService, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM));
     700    DECLR3CALLBACKMEMBER(int, pfnSaveState, (void *pvService, uint32_t u32ClientID, void *pvClient,
     701                                             PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM));
    696702
    697703    /** Inform the service about a VM load operation. */
    698     DECLR3CALLBACKMEMBER(int, pfnLoadState, (void *pvService, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM,
    699                                              uint32_t uVersion));
     704    DECLR3CALLBACKMEMBER(int, pfnLoadState, (void *pvService, uint32_t u32ClientID, void *pvClient,
     705                                             PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion));
    700706
    701707    /** Register a service extension callback. */
  • trunk/include/VBox/types.h

    r93115 r93444  
    7777#define NIL_SUPSEMEVENTMULTI                        ((SUPSEMEVENTMULTI)0)
    7878
     79
     80/** Pointer to a ring-3 VMM API vtable. */
     81typedef R3PTRTYPE(const struct VMMR3VTABLE *) PCVMMR3VTABLE;
    7982
    8083/** Pointer to a VM. */
  • trunk/include/VBox/vmm/cfgm.h

    r93115 r93444  
    8282 * @param   pUVM        The user mode VM handle.
    8383 * @param   pVM         The cross context VM structure.
     84 * @param   pVMM        The VMM R3 vtable.
    8485 * @param   pvUser      The argument supplied to VMR3Create().
    8586 */
    86 typedef DECLCALLBACKTYPE(int, FNCFGMCONSTRUCTOR,(PUVM pUVM, PVM pVM, void *pvUser));
     87typedef DECLCALLBACKTYPE(int, FNCFGMCONSTRUCTOR,(PUVM pUVM, PVM pVM, PCVMMR3VTABLE pVMM, void *pvUser));
    8788/** Pointer to a FNCFGMCONSTRUCTOR(). */
    8889typedef FNCFGMCONSTRUCTOR *PFNCFGMCONSTRUCTOR;
  • trunk/include/VBox/vmm/dbgf.h

    r93115 r93444  
    22782278VMMR3DECL(int) DBGFR3RegCpuQueryU64( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t    *pu64);
    22792279VMMR3DECL(int) DBGFR3RegCpuQueryU128(PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint128_t   *pu128);
    2280 VMMR3DECL(int) DBGFR3RegCpuQueryLrd( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, long double *plrd);
     2280/*VMMR3DECL(int) DBGFR3RegCpuQueryLrd( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, long double *plrd);*/
    22812281VMMR3DECL(int) DBGFR3RegCpuQueryXdtr(PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t *pu64Base, uint16_t *pu16Limit);
    22822282#if 0
  • trunk/include/VBox/vmm/ssm.h

    r93115 r93444  
    945945 * @returns VBox status code.
    946946 * @param   pSSM            SSM operation handle.
     947 * @param   pVMM            The VMM ring-3 vtable.
    947948 * @param   pvUser          User argument.
    948949 * @thread  Any.
    949950 */
    950 typedef DECLCALLBACKTYPE(int, FNSSMEXTLIVEPREP,(PSSMHANDLE pSSM, void *pvUser));
     951typedef DECLCALLBACKTYPE(int, FNSSMEXTLIVEPREP,(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser));
    951952/** Pointer to a FNSSMEXTLIVEPREP() function. */
    952953typedef FNSSMEXTLIVEPREP *PFNSSMEXTLIVEPREP;
     
    960961 * @returns VBox status code.
    961962 * @param   pSSM            SSM operation handle.
     963 * @param   pVMM            The VMM ring-3 vtable.
    962964 * @param   pvUser          User argument.
    963965 * @param   uPass           The data pass.
    964966 * @thread  Any.
    965967 */
    966 typedef DECLCALLBACKTYPE(int, FNSSMEXTLIVEEXEC,(PSSMHANDLE pSSM, void *pvUser, uint32_t uPass));
     968typedef DECLCALLBACKTYPE(int, FNSSMEXTLIVEEXEC,(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser, uint32_t uPass));
    967969/** Pointer to a FNSSMEXTLIVEEXEC() function. */
    968970typedef FNSSMEXTLIVEEXEC *PFNSSMEXTLIVEEXEC;
     
    982984 *
    983985 * @param   pSSM            SSM operation handle.
     986 * @param   pVMM            The VMM ring-3 vtable.
    984987 * @param   pvUser          User argument.
    985988 * @param   uPass           The data pass.
    986989 * @thread  Any.
    987990 */
    988 typedef DECLCALLBACKTYPE(int, FNSSMEXTLIVEVOTE,(PSSMHANDLE pSSM, void *pvUser, uint32_t uPass));
     991typedef DECLCALLBACKTYPE(int, FNSSMEXTLIVEVOTE,(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser, uint32_t uPass));
    989992/** Pointer to a FNSSMEXTLIVEVOTE() function. */
    990993typedef FNSSMEXTLIVEVOTE *PFNSSMEXTLIVEVOTE;
     
    995998 * @returns VBox status code.
    996999 * @param   pSSM            SSM operation handle.
     1000 * @param   pVMM            The VMM ring-3 vtable.
    9971001 * @param   pvUser          User argument.
    9981002 */
    999 typedef DECLCALLBACKTYPE(int, FNSSMEXTSAVEPREP,(PSSMHANDLE pSSM, void *pvUser));
     1003typedef DECLCALLBACKTYPE(int, FNSSMEXTSAVEPREP,(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser));
    10001004/** Pointer to a FNSSMEXTSAVEPREP() function. */
    10011005typedef FNSSMEXTSAVEPREP *PFNSSMEXTSAVEPREP;
     
    10041008 * Execute state save operation.
    10051009 *
    1006  * @param   pSSM            SSM operation handle.
     1010 * @returns VBox status code.
     1011 * @param   pSSM            SSM operation handle.
     1012 * @param   pVMM            The VMM ring-3 vtable.
    10071013 * @param   pvUser          User argument.
    1008  * @author  The lack of return code is for legacy reasons.
    1009  */
    1010 typedef DECLCALLBACKTYPE(void, FNSSMEXTSAVEEXEC,(PSSMHANDLE pSSM, void *pvUser));
     1014 */
     1015typedef DECLCALLBACKTYPE(int, FNSSMEXTSAVEEXEC,(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser));
    10111016/** Pointer to a FNSSMEXTSAVEEXEC() function. */
    10121017typedef FNSSMEXTSAVEEXEC *PFNSSMEXTSAVEEXEC;
     
    10171022 * @returns VBox status code.
    10181023 * @param   pSSM            SSM operation handle.
     1024 * @param   pVMM            The VMM ring-3 vtable.
    10191025 * @param   pvUser          User argument.
    10201026 */
    1021 typedef DECLCALLBACKTYPE(int, FNSSMEXTSAVEDONE,(PSSMHANDLE pSSM, void *pvUser));
     1027typedef DECLCALLBACKTYPE(int, FNSSMEXTSAVEDONE,(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser));
    10221028/** Pointer to a FNSSMEXTSAVEDONE() function. */
    10231029typedef FNSSMEXTSAVEDONE *PFNSSMEXTSAVEDONE;
     
    10281034 * @returns VBox status code.
    10291035 * @param   pSSM            SSM operation handle.
     1036 * @param   pVMM            The VMM ring-3 vtable.
    10301037 * @param   pvUser          User argument.
    10311038 */
    1032 typedef DECLCALLBACKTYPE(int, FNSSMEXTLOADPREP,(PSSMHANDLE pSSM, void *pvUser));
     1039typedef DECLCALLBACKTYPE(int, FNSSMEXTLOADPREP,(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser));
    10331040/** Pointer to a FNSSMEXTLOADPREP() function. */
    10341041typedef FNSSMEXTLOADPREP *PFNSSMEXTLOADPREP;
     
    10391046 * @returns VBox status code.
    10401047 * @param   pSSM            SSM operation handle.
     1048 * @param   pVMM            The VMM ring-3 vtable.
    10411049 * @param   pvUser          User argument.
    10421050 * @param   uVersion        Data layout version.
     
    10451053 * @remark  The odd return value is for legacy reasons.
    10461054 */
    1047 typedef DECLCALLBACKTYPE(int, FNSSMEXTLOADEXEC,(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass));
     1055typedef DECLCALLBACKTYPE(int, FNSSMEXTLOADEXEC,(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser,
     1056                                                uint32_t uVersion, uint32_t uPass));
    10481057/** Pointer to a FNSSMEXTLOADEXEC() function. */
    10491058typedef FNSSMEXTLOADEXEC *PFNSSMEXTLOADEXEC;
     
    10541063 * @returns VBox load code.
    10551064 * @param   pSSM            SSM operation handle.
     1065 * @param   pVMM            The VMM ring-3 vtable.
    10561066 * @param   pvUser          User argument.
    10571067 */
    1058 typedef DECLCALLBACKTYPE(int, FNSSMEXTLOADDONE,(PSSMHANDLE pSSM, void *pvUser));
     1068typedef DECLCALLBACKTYPE(int, FNSSMEXTLOADDONE,(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser));
    10591069/** Pointer to a FNSSMEXTLOADDONE() function. */
    10601070typedef FNSSMEXTLOADDONE *PFNSSMEXTLOADDONE;
     
    11911201VMMR3_INT_DECL(int)     SSMR3DeregisterUsb(PVM pVM, PPDMUSBINS pUsbIns, const char *pszName, uint32_t uInstance);
    11921202VMMR3DECL(int)          SSMR3DeregisterInternal(PVM pVM, const char *pszName);
    1193 VMMR3DECL(int)          SSMR3DeregisterExternal(PVM pVM, const char *pszName);
     1203VMMR3DECL(int)          SSMR3DeregisterExternal(PUVM pUVM, const char *pszName);
    11941204VMMR3DECL(int)          SSMR3Save(PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser);
    11951205VMMR3_INT_DECL(int)     SSMR3LiveSave(PVM pVM, uint32_t cMsMaxDowntime,
     
    13021312VMMR3DECL(int) SSMR3GetStrZ(PSSMHANDLE pSSM, char *psz, size_t cbMax);
    13031313VMMR3DECL(int) SSMR3GetStrZEx(PSSMHANDLE pSSM, char *psz, size_t cbMax, size_t *pcbStr);
    1304 VMMR3DECL(int) SSMR3GetTimer(PSSMHANDLE pSSM, PTMTIMER pTimer);
    13051314VMMR3DECL(int) SSMR3Skip(PSSMHANDLE pSSM, size_t cb);
    13061315VMMR3DECL(int) SSMR3SkipToEndOfUnit(PSSMHANDLE pSSM);
  • trunk/include/VBox/vmm/vmapi.h

    r93115 r93444  
    159159 *
    160160 * @param   pUVM        The user mode VM handle.
     161 * @param   pVMM        The VMM ring-3 vtable.
    161162 * @param   enmState    The new state.
    162163 * @param   enmOldState The old state.
    163164 * @param   pvUser      The user argument.
    164165 */
    165 typedef DECLCALLBACKTYPE(void, FNVMATSTATE,(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser));
     166typedef DECLCALLBACKTYPE(void, FNVMATSTATE,(PUVM pUVM, PCVMMR3VTABLE pVMM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser));
    166167/** Pointer to a VM state callback. */
    167168typedef FNVMATSTATE *PFNVMATSTATE;
  • trunk/src/VBox/Debugger/VBoxDbgBase.cpp

    r93115 r93444  
    107107
    108108/*static*/ DECLCALLBACK(void)
    109 VBoxDbgBase::atStateChange(PUVM pUVM, VMSTATE enmState, VMSTATE /*enmOldState*/, void *pvUser)
     109VBoxDbgBase::atStateChange(PUVM pUVM, PCVMMR3VTABLE /*pVMM*/, VMSTATE enmState, VMSTATE /*enmOldState*/, void *pvUser)
    110110{
    111111    VBoxDbgBase *pThis = (VBoxDbgBase *)pvUser; NOREF(pUVM);
  • trunk/src/VBox/Debugger/VBoxDbgBase.h

    r93115 r93444  
    107107private:
    108108    /** @callback_method_impl{FNVMATSTATE}  */
    109     static DECLCALLBACK(void) atStateChange(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
     109    static DECLCALLBACK(void) atStateChange(PUVM pUVM, PCVMMR3VTABLE pVMM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
    110110
    111111private:
  • trunk/src/VBox/HostServices/DragAndDrop/Makefile.kmk

    r93115 r93444  
    4747
    4848VBoxDragAndDropSvc_LIBS = \
    49         $(LIB_VMM) \
    5049        $(LIB_RUNTIME) \
    51         $(LIB_REM) \
    5250        $(PATH_STAGE_LIB)/VBoxDnDHostR3Lib$(VBOX_SUFF_LIB)
    5351
  • trunk/src/VBox/HostServices/GuestControl/Makefile.kmk

    r93115 r93444  
    4040
    4141VBoxGuestControlSvc_LIBS = \
    42         $(LIB_VMM) \
    43         $(LIB_RUNTIME) \
    44         $(LIB_REM)
     42        $(LIB_RUNTIME)
    4543
    4644VBoxGuestControlSvc_LDFLAGS.darwin = \
  • trunk/src/VBox/HostServices/GuestControl/VBoxGuestControlSvc.cpp

    r93115 r93444  
    6969#include <VBox/VMMDev.h>
    7070#include <VBox/vmm/ssm.h>
     71#include <VBox/vmm/vmmr3vtable.h>
    7172#include <iprt/assert.h>
    7273#include <iprt/cpp/autores.h>
     
    905906                                      uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[], uint64_t tsArrival);
    906907    static DECLCALLBACK(int)  svcHostCall(void *pvService, uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[]);
    907     static DECLCALLBACK(int)  svcSaveState(void *pvService, uint32_t idClient, void *pvClient, PSSMHANDLE pSSM);
    908     static DECLCALLBACK(int)  svcLoadState(void *pvService, uint32_t idClient, void *pvClient, PSSMHANDLE pSSM, uint32_t uVersion);
     908    static DECLCALLBACK(int)  svcSaveState(void *pvService, uint32_t idClient, void *pvClient,
     909                                           PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM);
     910    static DECLCALLBACK(int)  svcLoadState(void *pvService, uint32_t idClient, void *pvClient,
     911                                           PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion);
    909912    static DECLCALLBACK(int)  svcRegisterExtension(void *pvService, PFNHGCMSVCEXT pfnExtension, void *pvExtension);
    910913
     
    24232426 */
    24242427/*static*/ DECLCALLBACK(int)
    2425 GstCtrlService::svcSaveState(void *pvService, uint32_t idClient, void *pvClient, PSSMHANDLE pSSM)
     2428GstCtrlService::svcSaveState(void *pvService, uint32_t idClient, void *pvClient, PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM)
    24262429{
    24272430    RT_NOREF(pvClient);
     
    24342437             Only the root service survives, so remember who that is and its mode. */
    24352438
    2436     SSMR3PutU32(pSSM, 1);
    2437     SSMR3PutBool(pSSM, pThis->m_fLegacyMode);
    2438     return SSMR3PutBool(pSSM, idClient == pThis->m_idMasterClient);
     2439    pVMM->pfnSSMR3PutU32(pSSM, 1);
     2440    pVMM->pfnSSMR3PutBool(pSSM, pThis->m_fLegacyMode);
     2441    return pVMM->pfnSSMR3PutBool(pSSM, idClient == pThis->m_idMasterClient);
    24392442}
    24402443
     
    24442447 */
    24452448/*static*/ DECLCALLBACK(int)
    2446 GstCtrlService::svcLoadState(void *pvService, uint32_t idClient, void *pvClient, PSSMHANDLE pSSM, uint32_t uVersion)
     2449GstCtrlService::svcLoadState(void *pvService, uint32_t idClient, void *pvClient,
     2450                             PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion)
    24472451{
    24482452    SELF *pThis = reinterpret_cast<SELF *>(pvService);
     
    24552459    {
    24562460        uint32_t uSubVersion;
    2457         int rc = SSMR3GetU32(pSSM, &uSubVersion);
     2461        int rc = pVMM->pfnSSMR3GetU32(pSSM, &uSubVersion);
    24582462        AssertRCReturn(rc, rc);
    24592463        if (uSubVersion != 1)
    2460             return SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     2464            return pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    24612465                                     "sub version %u, expected 1\n", uSubVersion);
    24622466        bool fLegacyMode;
    2463         rc = SSMR3GetBool(pSSM, &fLegacyMode);
     2467        rc = pVMM->pfnSSMR3GetBool(pSSM, &fLegacyMode);
    24642468        AssertRCReturn(rc, rc);
    24652469        pThis->m_fLegacyMode = fLegacyMode;
    24662470
    24672471        bool fIsMaster;
    2468         rc = SSMR3GetBool(pSSM, &fIsMaster);
     2472        rc = pVMM->pfnSSMR3GetBool(pSSM, &fIsMaster);
    24692473        AssertRCReturn(rc, rc);
    24702474
  • trunk/src/VBox/HostServices/GuestControl/testcase/Makefile.kmk

    r93115 r93444  
    3535        ../VBoxGuestControlSvc.cpp \
    3636        tstGuestControlSvc.cpp
    37  tstGuestControlSvc_LIBS     = $(LIB_RUNTIME) $(LIB_VMM)
     37 tstGuestControlSvc_LIBS     = $(LIB_RUNTIME)
    3838
    3939$$(tstGuestControlSvc_0_OUTDIR)/tstGuestControlSvc.run: $$(tstGuestControlSvc_1_STAGE_TARGET)
  • trunk/src/VBox/HostServices/GuestProperties/Makefile.kmk

    r93115 r93444  
    4040
    4141VBoxGuestPropSvc_LIBS = \
    42         $(LIB_VMM) \
    43         $(LIB_RUNTIME) \
    44         $(LIB_REM)
     42        $(LIB_RUNTIME)
    4543
    4644VBoxGuestPropSvc_LDFLAGS.darwin = \
  • trunk/src/VBox/HostServices/HostChannel/Makefile.kmk

    r93115 r93444  
    3636
    3737VBoxHostChannel_LIBS = \
    38         $(LIB_VMM) \
    3938        $(LIB_RUNTIME)
    4039
  • trunk/src/VBox/HostServices/SharedClipboard/Makefile.kmk

    r93115 r93444  
    7373
    7474VBoxSharedClipboard_LIBS = \
    75         $(LIB_VMM) \
    76         $(LIB_RUNTIME) \
    77         $(LIB_REM)
     75        $(LIB_RUNTIME)
    7876if1of ($(KBUILD_TARGET), linux solaris freebsd)
    7977 ifndef VBOX_HEADLESS
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r93316 r93444  
    184184#define LOG_GROUP LOG_GROUP_SHARED_CLIPBOARD
    185185#include <VBox/log.h>
     186#include <VBox/vmm/vmmr3vtable.h> /* must be included before hgcmsvc.h */
    186187
    187188#include <VBox/GuestHost/clipboard-helper.h>
     
    24572458#endif /* !UNIT_TEST */
    24582459
    2459 static DECLCALLBACK(int) svcSaveState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM)
     2460static DECLCALLBACK(int) svcSaveState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM)
    24602461{
    24612462    LogFlowFuncEnter();
     
    24752476
    24762477    /* Write Shared Clipboard saved state version. */
    2477     SSMR3PutU32(pSSM, VBOX_SHCL_SAVED_STATE_VER_CURRENT);
    2478 
    2479     int rc = SSMR3PutStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /*fFlags*/, &s_aShClSSMClientState[0], NULL);
     2478    pVMM->pfnSSMR3PutU32(pSSM, VBOX_SHCL_SAVED_STATE_VER_CURRENT);
     2479
     2480    int rc = pVMM->pfnSSMR3PutStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /*fFlags*/, &s_aShClSSMClientState[0], NULL);
    24802481    AssertRCReturn(rc, rc);
    24812482
    2482     rc = SSMR3PutStructEx(pSSM, &pClient->State.POD, sizeof(pClient->State.POD), 0 /*fFlags*/, &s_aShClSSMClientPODState[0], NULL);
     2483    rc = pVMM->pfnSSMR3PutStructEx(pSSM, &pClient->State.POD, sizeof(pClient->State.POD), 0 /*fFlags*/, &s_aShClSSMClientPODState[0], NULL);
    24832484    AssertRCReturn(rc, rc);
    24842485
    2485     rc = SSMR3PutStructEx(pSSM, &pClient->State.Transfers, sizeof(pClient->State.Transfers), 0 /*fFlags*/, &s_aShClSSMClientTransferState[0], NULL);
     2486    rc = pVMM->pfnSSMR3PutStructEx(pSSM, &pClient->State.Transfers, sizeof(pClient->State.Transfers), 0 /*fFlags*/, &s_aShClSSMClientTransferState[0], NULL);
    24862487    AssertRCReturn(rc, rc);
    24872488
    24882489    /* Serialize the client's internal message queue. */
    2489     rc = SSMR3PutU64(pSSM, pClient->cMsgAllocated);
     2490    rc = pVMM->pfnSSMR3PutU64(pSSM, pClient->cMsgAllocated);
    24902491    AssertRCReturn(rc, rc);
    24912492
     
    24932494    RTListForEach(&pClient->MsgQueue, pMsg, SHCLCLIENTMSG, ListEntry)
    24942495    {
    2495         SSMR3PutStructEx(pSSM, pMsg, sizeof(SHCLCLIENTMSG), 0 /*fFlags*/, &s_aShClSSMClientMsgHdr[0], NULL);
    2496         SSMR3PutStructEx(pSSM, pMsg, sizeof(SHCLCLIENTMSG), 0 /*fFlags*/, &s_aShClSSMClientMsgCtx[0], NULL);
     2496        pVMM->pfnSSMR3PutStructEx(pSSM, pMsg, sizeof(SHCLCLIENTMSG), 0 /*fFlags*/, &s_aShClSSMClientMsgHdr[0], NULL);
     2497        pVMM->pfnSSMR3PutStructEx(pSSM, pMsg, sizeof(SHCLCLIENTMSG), 0 /*fFlags*/, &s_aShClSSMClientMsgCtx[0], NULL);
    24972498
    24982499        for (uint32_t iParm = 0; iParm < pMsg->cParms; iParm++)
    2499             HGCMSvcSSMR3Put(&pMsg->aParms[iParm], pSSM);
    2500     }
    2501 
    2502     rc = SSMR3PutU64(pSSM, pClient->Legacy.cCID);
     2500            HGCMSvcSSMR3Put(&pMsg->aParms[iParm], pSSM, pVMM);
     2501    }
     2502
     2503    rc = pVMM->pfnSSMR3PutU64(pSSM, pClient->Legacy.cCID);
    25032504    AssertRCReturn(rc, rc);
    25042505
     
    25062507    RTListForEach(&pClient->Legacy.lstCID, pCID, SHCLCLIENTLEGACYCID, Node)
    25072508    {
    2508         rc = SSMR3PutStructEx(pSSM, pCID, sizeof(SHCLCLIENTLEGACYCID), 0 /*fFlags*/, &s_aShClSSMClientLegacyCID[0], NULL);
     2509        rc = pVMM->pfnSSMR3PutStructEx(pSSM, pCID, sizeof(SHCLCLIENTLEGACYCID), 0 /*fFlags*/, &s_aShClSSMClientLegacyCID[0], NULL);
    25092510        AssertRCReturn(rc, rc);
    25102511    }
    25112512#else  /* UNIT_TEST */
    2512     RT_NOREF3(u32ClientID, pvClient, pSSM);
     2513    RT_NOREF(u32ClientID, pvClient, pSSM, pVMM);
    25132514#endif /* UNIT_TEST */
    25142515    return VINF_SUCCESS;
     
    25162517
    25172518#ifndef UNIT_TEST
    2518 static int svcLoadStateV0(uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, uint32_t uVersion)
     2519static int svcLoadStateV0(uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion)
    25192520{
    25202521    RT_NOREF(u32ClientID, pvClient, pSSM, uVersion);
    25212522
    25222523    uint32_t uMarker;
    2523     int rc = SSMR3GetU32(pSSM, &uMarker);   /* Begin marker. */
     2524    int rc = pVMM->pfnSSMR3GetU32(pSSM, &uMarker);   /* Begin marker. */
    25242525    AssertRC(rc);
    25252526    Assert(uMarker == UINT32_C(0x19200102)  /* SSMR3STRUCT_BEGIN */);
    25262527
    2527     rc = SSMR3Skip(pSSM, sizeof(uint32_t)); /* Client ID */
     2528    rc = pVMM->pfnSSMR3Skip(pSSM, sizeof(uint32_t)); /* Client ID */
    25282529    AssertRCReturn(rc, rc);
    25292530
    25302531    bool fValue;
    2531     rc = SSMR3GetBool(pSSM, &fValue);       /* fHostMsgQuit */
     2532    rc = pVMM->pfnSSMR3GetBool(pSSM, &fValue);       /* fHostMsgQuit */
    25322533    AssertRCReturn(rc, rc);
    25332534
    2534     rc = SSMR3GetBool(pSSM, &fValue);       /* fHostMsgReadData */
     2535    rc = pVMM->pfnSSMR3GetBool(pSSM, &fValue);       /* fHostMsgReadData */
    25352536    AssertRCReturn(rc, rc);
    25362537
    2537     rc = SSMR3GetBool(pSSM, &fValue);       /* fHostMsgFormats */
     2538    rc = pVMM->pfnSSMR3GetBool(pSSM, &fValue);       /* fHostMsgFormats */
    25382539    AssertRCReturn(rc, rc);
    25392540
    25402541    uint32_t fFormats;
    2541     rc = SSMR3GetU32(pSSM, &fFormats);      /* u32RequestedFormat */
     2542    rc = pVMM->pfnSSMR3GetU32(pSSM, &fFormats);      /* u32RequestedFormat */
    25422543    AssertRCReturn(rc, rc);
    25432544
    2544     rc = SSMR3GetU32(pSSM, &uMarker);       /* End marker. */
     2545    rc = pVMM->pfnSSMR3GetU32(pSSM, &uMarker);       /* End marker. */
    25452546    AssertRCReturn(rc, rc);
    25462547    Assert(uMarker == UINT32_C(0x19920406) /* SSMR3STRUCT_END */);
     
    25502551#endif /* UNIT_TEST */
    25512552
    2552 static DECLCALLBACK(int) svcLoadState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, uint32_t uVersion)
     2553static DECLCALLBACK(int) svcLoadState(void *, uint32_t u32ClientID, void *pvClient,
     2554                                      PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion)
    25532555{
    25542556    LogFlowFuncEnter();
     
    25632565    /* Restore the client data. */
    25642566    uint32_t lenOrVer;
    2565     int rc = SSMR3GetU32(pSSM, &lenOrVer);
     2567    int rc = pVMM->pfnSSMR3GetU32(pSSM, &lenOrVer);
    25662568    AssertRCReturn(rc, rc);
    25672569
     
    25692571
    25702572    if (lenOrVer == VBOX_SHCL_SAVED_STATE_VER_3_1)
    2571         return svcLoadStateV0(u32ClientID, pvClient, pSSM, uVersion);
     2573        return svcLoadStateV0(u32ClientID, pvClient, pSSM, pVMM, uVersion);
    25722574
    25732575    if (   lenOrVer >= VBOX_SHCL_SAVED_STATE_VER_6_1B2
     
    25762578        if (lenOrVer >= VBOX_SHCL_SAVED_STATE_VER_6_1RC1)
    25772579        {
    2578             SSMR3GetStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /* fFlags */, &s_aShClSSMClientState[0], NULL);
    2579             SSMR3GetStructEx(pSSM, &pClient->State.POD, sizeof(pClient->State.POD), 0 /* fFlags */,
    2580                              &s_aShClSSMClientPODState[0], NULL);
     2580            pVMM->pfnSSMR3GetStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /* fFlags */,
     2581                                      &s_aShClSSMClientState[0], NULL);
     2582            pVMM->pfnSSMR3GetStructEx(pSSM, &pClient->State.POD, sizeof(pClient->State.POD), 0 /* fFlags */,
     2583                                      &s_aShClSSMClientPODState[0], NULL);
    25812584        }
    25822585        else
    2583             SSMR3GetStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /* fFlags */, &s_aShClSSMClientState61B1[0], NULL);
    2584         rc = SSMR3GetStructEx(pSSM, &pClient->State.Transfers, sizeof(pClient->State.Transfers), 0 /* fFlags */,
    2585                               &s_aShClSSMClientTransferState[0], NULL);
     2586            pVMM->pfnSSMR3GetStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /* fFlags */,
     2587                                      &s_aShClSSMClientState61B1[0], NULL);
     2588        rc = pVMM->pfnSSMR3GetStructEx(pSSM, &pClient->State.Transfers, sizeof(pClient->State.Transfers), 0 /* fFlags */,
     2589                                       &s_aShClSSMClientTransferState[0], NULL);
    25862590        AssertRCReturn(rc, rc);
    25872591
    25882592        /* Load the client's internal message queue. */
    25892593        uint64_t cMsgs;
    2590         rc = SSMR3GetU64(pSSM, &cMsgs);
     2594        rc = pVMM->pfnSSMR3GetU64(pSSM, &cMsgs);
    25912595        AssertRCReturn(rc, rc);
    25922596        AssertLogRelMsgReturn(cMsgs < _16K, ("Too many messages: %u (%x)\n", cMsgs, cMsgs), VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
     
    26002604            } u;
    26012605
    2602             SSMR3GetStructEx(pSSM, &u.Msg, RT_UOFFSETOF(SHCLCLIENTMSG, aParms), 0 /*fFlags*/, &s_aShClSSMClientMsgHdr[0], NULL);
    2603             rc = SSMR3GetStructEx(pSSM, &u.Msg, RT_UOFFSETOF(SHCLCLIENTMSG, aParms), 0 /*fFlags*/, &s_aShClSSMClientMsgCtx[0], NULL);
     2606            pVMM->pfnSSMR3GetStructEx(pSSM, &u.Msg, RT_UOFFSETOF(SHCLCLIENTMSG, aParms), 0 /*fFlags*/,
     2607                                      &s_aShClSSMClientMsgHdr[0], NULL);
     2608            rc = pVMM->pfnSSMR3GetStructEx(pSSM, &u.Msg, RT_UOFFSETOF(SHCLCLIENTMSG, aParms), 0 /*fFlags*/,
     2609                                           &s_aShClSSMClientMsgCtx[0], NULL);
    26042610            AssertRCReturn(rc, rc);
    26052611
     
    26142620            for (uint32_t p = 0; p < pMsg->cParms; p++)
    26152621            {
    2616                 rc = HGCMSvcSSMR3Get(&pMsg->aParms[p], pSSM);
     2622                rc = HGCMSvcSSMR3Get(&pMsg->aParms[p], pSSM, pVMM);
    26172623                AssertRCReturnStmt(rc, shClSvcMsgFree(pClient, pMsg), rc);
    26182624            }
     
    26262632        {
    26272633            uint64_t cCID;
    2628             rc = SSMR3GetU64(pSSM, &cCID);
     2634            rc = pVMM->pfnSSMR3GetU64(pSSM, &cCID);
    26292635            AssertRCReturn(rc, rc);
    26302636            AssertLogRelMsgReturn(cCID < _16K, ("Too many context IDs: %u (%x)\n", cCID, cCID), VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
     
    26352641                AssertPtrReturn(pCID, VERR_NO_MEMORY);
    26362642
    2637                 SSMR3GetStructEx(pSSM, pCID, sizeof(SHCLCLIENTLEGACYCID), 0 /* fFlags */, &s_aShClSSMClientLegacyCID[0], NULL);
     2643                pVMM->pfnSSMR3GetStructEx(pSSM, pCID, sizeof(SHCLCLIENTLEGACYCID), 0 /* fFlags */,
     2644                                          &s_aShClSSMClientLegacyCID[0], NULL);
    26382645                RTListAppend(&pClient->Legacy.lstCID, &pCID->Node);
    26392646            }
     
    26502657
    26512658#else  /* UNIT_TEST */
    2652     RT_NOREF(u32ClientID, pvClient, pSSM, uVersion);
     2659    RT_NOREF(u32ClientID, pvClient, pSSM, pVMM, uVersion);
    26532660#endif /* UNIT_TEST */
    26542661    return VINF_SUCCESS;
  • trunk/src/VBox/HostServices/SharedFolders/Makefile.kmk

    r93115 r93444  
    4747
    4848VBoxSharedFolders_LIBS = \
    49         $(LIB_VMM) \
    50         $(LIB_RUNTIME) \
    51         $(LIB_REM)
     49        $(LIB_RUNTIME)
    5250
    5351include $(FILE_KBUILD_SUB_FOOTER)
  • trunk/src/VBox/HostServices/SharedFolders/VBoxSharedFoldersSvc.cpp

    r93115 r93444  
    3333#include <VBox/vmm/ssm.h>
    3434#include <VBox/vmm/pdmifs.h>
     35#include <VBox/vmm/vmmr3vtable.h>
    3536
    3637
     
    194195 *        as the contents of a shared folder might change in between save and restore.
    195196 */
    196 static DECLCALLBACK(int) svcSaveState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM)
     197static DECLCALLBACK(int) svcSaveState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM)
    197198{
    198199#ifndef UNITTEST  /* Read this as not yet tested */
     
    202203    Log(("SharedFolders host service: saving state, u32ClientID = %u\n", u32ClientID));
    203204
    204     int rc = SSMR3PutU32(pSSM, SHFL_SAVED_STATE_VERSION);
     205    int rc = pVMM->pfnSSMR3PutU32(pSSM, SHFL_SAVED_STATE_VERSION);
    205206    AssertRCReturn(rc, rc);
    206207
    207     rc = SSMR3PutU32(pSSM, SHFL_MAX_MAPPINGS);
     208    rc = pVMM->pfnSSMR3PutU32(pSSM, SHFL_MAX_MAPPINGS);
    208209    AssertRCReturn(rc, rc);
    209210
    210211    /* Save client structure length & contents */
    211     rc = SSMR3PutU32(pSSM, sizeof(*pClient));
     212    rc = pVMM->pfnSSMR3PutU32(pSSM, sizeof(*pClient));
    212213    AssertRCReturn(rc, rc);
    213214
    214     rc = SSMR3PutMem(pSSM, pClient, sizeof(*pClient));
     215    rc = pVMM->pfnSSMR3PutMem(pSSM, pClient, sizeof(*pClient));
    215216    AssertRCReturn(rc, rc);
    216217
     
    221222        MAPPING *pFolderMapping = vbsfMappingGetByRoot(i);
    222223
    223         rc = SSMR3PutU32(pSSM, pFolderMapping? pFolderMapping->cMappings: 0);
     224        rc = pVMM->pfnSSMR3PutU32(pSSM, pFolderMapping? pFolderMapping->cMappings: 0);
    224225        AssertRCReturn(rc, rc);
    225226
    226         rc = SSMR3PutBool(pSSM, pFolderMapping? pFolderMapping->fValid: false);
     227        rc = pVMM->pfnSSMR3PutBool(pSSM, pFolderMapping? pFolderMapping->fValid: false);
    227228        AssertRCReturn(rc, rc);
    228229
     
    230231        {
    231232            uint32_t len = (uint32_t)strlen(pFolderMapping->pszFolderName);
    232             SSMR3PutU32(pSSM, len);
    233             SSMR3PutStrZ(pSSM, pFolderMapping->pszFolderName);
     233            pVMM->pfnSSMR3PutU32(pSSM, len);
     234            pVMM->pfnSSMR3PutStrZ(pSSM, pFolderMapping->pszFolderName);
    234235
    235236            len = ShflStringSizeOfBuffer(pFolderMapping->pMapName);
    236             SSMR3PutU32(pSSM, len);
    237             SSMR3PutMem(pSSM, pFolderMapping->pMapName, len);
    238 
    239             SSMR3PutBool(pSSM, pFolderMapping->fHostCaseSensitive);
    240 
    241             SSMR3PutBool(pSSM, pFolderMapping->fGuestCaseSensitive);
     237            pVMM->pfnSSMR3PutU32(pSSM, len);
     238            pVMM->pfnSSMR3PutMem(pSSM, pFolderMapping->pMapName, len);
     239
     240            pVMM->pfnSSMR3PutBool(pSSM, pFolderMapping->fHostCaseSensitive);
     241
     242            pVMM->pfnSSMR3PutBool(pSSM, pFolderMapping->fGuestCaseSensitive);
    242243
    243244            len = ShflStringSizeOfBuffer(pFolderMapping->pAutoMountPoint);
    244             SSMR3PutU32(pSSM, len);
    245             rc = SSMR3PutMem(pSSM, pFolderMapping->pAutoMountPoint, len);
     245            pVMM->pfnSSMR3PutU32(pSSM, len);
     246            rc = pVMM->pfnSSMR3PutMem(pSSM, pFolderMapping->pAutoMountPoint, len);
    246247            AssertRCReturn(rc, rc);
    247248        }
     
    249250
    250251#else
    251     RT_NOREF3(u32ClientID, pvClient, pSSM);
     252    RT_NOREF(u32ClientID, pvClient, pSSM, pVMM);
    252253#endif
    253254    return VINF_SUCCESS;
    254255}
    255256
    256 static DECLCALLBACK(int) svcLoadState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, uint32_t uVersion)
     257static DECLCALLBACK(int) svcLoadState(void *, uint32_t u32ClientID, void *pvClient,
     258                                      PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion)
    257259{
    258260#ifndef UNITTEST  /* Read this as not yet tested */
     
    265267
    266268    uint32_t uShfVersion = 0;
    267     int rc = SSMR3GetU32(pSSM, &uShfVersion);
     269    int rc = pVMM->pfnSSMR3GetU32(pSSM, &uShfVersion);
    268270    AssertRCReturn(rc, rc);
    269271
    270272    if (   uShfVersion > SHFL_SAVED_STATE_VERSION
    271273        || uShfVersion < SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16)
    272         return SSMR3SetLoadError(pSSM, VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION, RT_SRC_POS,
    273                                  "Unknown shared folders state version %u!", uShfVersion);
    274 
    275     rc = SSMR3GetU32(pSSM, &nrMappings);
     274        return pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION, RT_SRC_POS,
     275                                          "Unknown shared folders state version %u!", uShfVersion);
     276
     277    rc = pVMM->pfnSSMR3GetU32(pSSM, &nrMappings);
    276278    AssertRCReturn(rc, rc);
    277279    if (nrMappings != SHFL_MAX_MAPPINGS)
     
    279281
    280282    /* Restore the client data (flags + path delimiter + mapping counts (new) at the moment) */
    281     rc = SSMR3GetU32(pSSM, &len);
     283    rc = pVMM->pfnSSMR3GetU32(pSSM, &len);
    282284    AssertRCReturn(rc, rc);
    283285
     
    285287        pClient->fHasMappingCounts = false;
    286288    else if (len != sizeof(*pClient))
    287         return SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    288                                  "Saved SHFLCLIENTDATA size %u differs from current %u!", len, sizeof(*pClient));
    289 
    290     rc = SSMR3GetMem(pSSM, pClient, len);
     289        return pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     290                                          "Saved SHFLCLIENTDATA size %u differs from current %u!", len, sizeof(*pClient));
     291
     292    rc = pVMM->pfnSSMR3GetMem(pSSM, pClient, len);
    291293    AssertRCReturn(rc, rc);
    292294
     
    297299    else if (   pClient->enmErrorStyle <= kShflErrorStyle_Invalid
    298300             || pClient->enmErrorStyle >= kShflErrorStyle_End)
    299         return SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    300                                  "Saved SHFLCLIENTDATA enmErrorStyle value %d is not known/valid!", pClient->enmErrorStyle);
     301        return pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     302                                          "Saved SHFLCLIENTDATA enmErrorStyle value %d is not known/valid!", pClient->enmErrorStyle);
    301303
    302304    /* Drop the root IDs of all configured mappings before restoring: */
     
    311313
    312314        /* restore the folder mapping counter. */
    313         rc = SSMR3GetU32(pSSM, &mapping.cMappings);
     315        rc = pVMM->pfnSSMR3GetU32(pSSM, &mapping.cMappings);
    314316        AssertRCReturn(rc, rc);
    315317
    316         rc = SSMR3GetBool(pSSM, &mapping.fValid);
     318        rc = pVMM->pfnSSMR3GetBool(pSSM, &mapping.fValid);
    317319        AssertRCReturn(rc, rc);
    318320
     
    321323            /* Load the host path name. */
    322324            uint32_t cb;
    323             rc = SSMR3GetU32(pSSM, &cb);
     325            rc = pVMM->pfnSSMR3GetU32(pSSM, &cb);
    324326            AssertRCReturn(rc, rc);
    325327
     
    328330            {
    329331                AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
    330                              SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad folder name size: %#x", cb));
     332                             pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     333                                                        "Bad folder name size: %#x", cb));
    331334                PSHFLSTRING pFolderName = (PSHFLSTRING)RTMemAlloc(cb);
    332335                AssertReturn(pFolderName != NULL, VERR_NO_MEMORY);
    333336
    334                 rc = SSMR3GetMem(pSSM, pFolderName, cb);
     337                rc = pVMM->pfnSSMR3GetMem(pSSM, pFolderName, cb);
    335338                AssertRCReturn(rc, rc);
    336339                AssertReturn(pFolderName->u16Size < cb && pFolderName->u16Length < pFolderName->u16Size,
    337                              SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    338                                                "Bad folder name string: %#x/%#x cb=%#x",
    339                                                pFolderName->u16Size, pFolderName->u16Length, cb));
     340                             pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     341                                                        "Bad folder name string: %#x/%#x cb=%#x",
     342                                                        pFolderName->u16Size, pFolderName->u16Length, cb));
    340343
    341344                rc = RTUtf16ToUtf8(pFolderName->String.ucs2, &pszFolderName);
     
    348351                AssertReturn(pszFolderName, VERR_NO_MEMORY);
    349352
    350                 rc = SSMR3GetStrZ(pSSM, pszFolderName, cb + 1);
     353                rc = pVMM->pfnSSMR3GetStrZ(pSSM, pszFolderName, cb + 1);
    351354                AssertRCReturn(rc, rc);
    352355                mapping.pszFolderName = pszFolderName;
     
    354357
    355358            /* Load the map name. */
    356             rc = SSMR3GetU32(pSSM, &cb);
     359            rc = pVMM->pfnSSMR3GetU32(pSSM, &cb);
    357360            AssertRCReturn(rc, rc);
    358361            AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
    359                          SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad map name size: %#x", cb));
     362                         pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     363                                                    "Bad map name size: %#x", cb));
    360364
    361365            PSHFLSTRING pMapName = (PSHFLSTRING)RTMemAlloc(cb);
    362366            AssertReturn(pMapName != NULL, VERR_NO_MEMORY);
    363367
    364             rc = SSMR3GetMem(pSSM, pMapName, cb);
     368            rc = pVMM->pfnSSMR3GetMem(pSSM, pMapName, cb);
    365369            AssertRCReturn(rc, rc);
    366370            AssertReturn(pMapName->u16Size < cb && pMapName->u16Length < pMapName->u16Size,
    367                          SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    368                                            "Bad map name string: %#x/%#x cb=%#x",
    369                                            pMapName->u16Size, pMapName->u16Length, cb));
     371                         pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     372                                                    "Bad map name string: %#x/%#x cb=%#x",
     373                                                    pMapName->u16Size, pMapName->u16Length, cb));
    370374
    371375            /* Load case sensitivity config. */
    372             rc = SSMR3GetBool(pSSM, &mapping.fHostCaseSensitive);
     376            rc = pVMM->pfnSSMR3GetBool(pSSM, &mapping.fHostCaseSensitive);
    373377            AssertRCReturn(rc, rc);
    374378
    375             rc = SSMR3GetBool(pSSM, &mapping.fGuestCaseSensitive);
     379            rc = pVMM->pfnSSMR3GetBool(pSSM, &mapping.fGuestCaseSensitive);
    376380            AssertRCReturn(rc, rc);
    377381
     
    380384            if (uShfVersion > SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT)
    381385            {
    382                 rc = SSMR3GetU32(pSSM, &cb);
     386                rc = pVMM->pfnSSMR3GetU32(pSSM, &cb);
    383387                AssertRCReturn(rc, rc);
    384388                AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
    385                              SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad auto mount point size: %#x", cb));
     389                             pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     390                                                        "Bad auto mount point size: %#x", cb));
    386391
    387392                pAutoMountPoint = (PSHFLSTRING)RTMemAlloc(cb);
    388393                AssertReturn(pAutoMountPoint != NULL, VERR_NO_MEMORY);
    389394
    390                 rc = SSMR3GetMem(pSSM, pAutoMountPoint, cb);
     395                rc = pVMM->pfnSSMR3GetMem(pSSM, pAutoMountPoint, cb);
    391396                AssertRCReturn(rc, rc);
    392397                AssertReturn(pAutoMountPoint->u16Size < cb && pAutoMountPoint->u16Length < pAutoMountPoint->u16Size,
    393                              SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    394                                                "Bad auto mount point string: %#x/%#x cb=%#x",
    395                                                pAutoMountPoint->u16Size, pAutoMountPoint->u16Length, cb));
     398                             pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     399                                                        "Bad auto mount point string: %#x/%#x cb=%#x",
     400                                                        pAutoMountPoint->u16Size, pAutoMountPoint->u16Length, cb));
    396401
    397402            }
     
    428433    Log(("SharedFolders host service: successfully loaded state\n"));
    429434#else
    430     RT_NOREF(u32ClientID, pvClient, pSSM, uVersion);
     435    RT_NOREF(u32ClientID, pvClient, pSSM, pVMM, uVersion);
    431436#endif
    432437    return VINF_SUCCESS;
  • trunk/src/VBox/Main/Makefile.kmk

    r93424 r93444  
    10291029
    10301030VBoxC_LIBS += \
    1031         $(PATH_STAGE_LIB)/VBoxAPIWrap$(VBOX_SUFF_LIB) \
    1032         $(if-expr "$(LIB_VMM)" == "$(VBOX_LIB_VMM_LAZY)",$(LIB_REM),) \
    1033         $(VBOX_LIB_VMM_LAZY)
     1031        $(PATH_STAGE_LIB)/VBoxAPIWrap$(VBOX_SUFF_LIB)
    10341032VBoxC_LIBS.win += \
    10351033        $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/psapi.lib \
     
    10681066        src-all/DisplayPNGUtil.cpp \
    10691067        src-all/DisplayResampleImage.cpp \
    1070         src-all/DisplayUtils.cpp \
    10711068        src-all/EventImpl.cpp \
    10721069        src-all/Global.cpp \
  • trunk/src/VBox/Main/include/AudioDriver.h

    r93115 r93444  
    9797    bool IsAttached(void) { return mfAttached; }
    9898
    99     int doAttachDriverViaEmt(PUVM pUVM, util::AutoWriteLock *pAutoLock);
    100     int doDetachDriverViaEmt(PUVM pUVM, util::AutoWriteLock *pAutoLock);
     99    int doAttachDriverViaEmt(PUVM pUVM, PCVMMR3VTABLE pVMM, util::AutoWriteLock *pAutoLock);
     100    int doDetachDriverViaEmt(PUVM pUVM, PCVMMR3VTABLE pVMM, util::AutoWriteLock *pAutoLock);
    101101
    102102protected:
     
    107107
    108108    /**
    109      * Optional (virtual) function to give the derived audio driver
    110      * class the ability to add (or change) the driver configuration
    111      * entries when setting up.
     109     * Virtual function for child specific driver configuration.
    112110     *
    113      * @return VBox status code.
    114      * @param  pLunCfg          CFGM configuration node of the driver.
     111     * This is called at the end of AudioDriver::configure().
     112     *
     113     * @returns VBox status code.
     114     * @param   pLunCfg          CFGM configuration node of the driver.
     115     * @param   pVMM            The VMM ring-3 vtable.
    115116     */
    116     virtual int configureDriver(PCFGMNODE pLunCfg) { RT_NOREF(pLunCfg); return VINF_SUCCESS; }
     117    virtual int configureDriver(PCFGMNODE pLunCfg, PCVMMR3VTABLE pVMM)
     118    {
     119        RT_NOREF(pLunCfg, pVMM);
     120        return VINF_SUCCESS;
     121    }
    117122
    118123protected:
  • trunk/src/VBox/Main/include/BusAssignmentManager.h

    r93115 r93444  
    4747    };
    4848
    49     static BusAssignmentManager *createInstance(ChipsetType_T chipsetType, IommuType_T iommuType);
     49    static BusAssignmentManager *createInstance(PCVMMR3VTABLE pVMM, ChipsetType_T chipsetType, IommuType_T iommuType);
    5050    virtual void AddRef();
    5151    virtual void Release();
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r93312 r93444  
    135135
    136136    // public initializers/uninitializers for internal purposes only
    137     HRESULT init(IMachine *aMachine, IInternalMachineControl *aControl, LockType_T aLockType);
     137    HRESULT initWithMachine(IMachine *aMachine, IInternalMachineControl *aControl, LockType_T aLockType);
    138138    void uninit();
    139139
     
    146146     */
    147147
     148    PCVMMR3VTABLE i_getVMMVTable() const RT_NOEXCEPT { return mpVMM; }
    148149    Guest *i_getGuest() const { return mGuest; }
    149150    Keyboard *i_getKeyboard() const { return mKeyboard; }
     
    162163    int i_recordingStop(util::AutoWriteLock *pAutoLock = NULL);
    163164# ifdef VBOX_WITH_AUDIO_RECORDING
    164     AudioVideoRec *i_recordingGetAudioDrv(void) const { return Recording.mAudioRec; }
     165    AudioVideoRec *i_recordingGetAudioDrv(void) const { return mRecording.mAudioRec; }
    165166# endif
    166     RecordingContext *i_recordingGetContext(void) const { return Recording.mpCtx; }
     167    RecordingContext *i_recordingGetContext(void) const { return mRecording.mpCtx; }
    167168# ifdef VBOX_WITH_AUDIO_RECORDING
    168169    HRESULT i_recordingSendAudio(const void *pvData, size_t cbData, uint64_t uDurationMs);
     
    328329private:
    329330
    330     // wraped IConsole properties
     331    // wrapped IConsole properties
    331332    HRESULT getMachine(ComPtr<IMachine> &aMachine);
    332333    HRESULT getState(MachineState_T *aState);
     
    346347    HRESULT getEmulatedUSB(ComPtr<IEmulatedUSB> &aEmulatedUSB);
    347348
    348     // wraped IConsole methods
     349    // wrapped IConsole methods
    349350    HRESULT powerUp(ComPtr<IProgress> &aProgress);
    350351    HRESULT powerUpPaused(ComPtr<IProgress> &aProgress);
     
    384385    HRESULT clearAllDiskEncryptionPasswords();
    385386
    386     void notifyNatDnsChange(PUVM pUVM, const char *pszDevice, ULONG ulInstanceMax);
     387    void notifyNatDnsChange(PUVM pUVM, PCVMMR3VTABLE pVMM, const char *pszDevice, ULONG ulInstanceMax);
    387388    Utf8Str VRDPServerErrorToMsg(int vrc);
    388389
     
    492493        typedef AutoVMCallerBase<taQuiet, true> Base;
    493494    public:
    494         SafeVMPtrBase(Console *aThat) : Base(aThat), mRC(E_FAIL), mpUVM(NULL)
     495        SafeVMPtrBase(Console *aThat) : Base(aThat), mRC(E_FAIL), mpUVM(NULL), mpVMM(NULL)
    495496        {
    496497            if (Base::isOk())
    497                 mRC = aThat->i_safeVMPtrRetainer(&mpUVM, taQuiet);
     498                mRC = aThat->i_safeVMPtrRetainer(&mpUVM, &mpVMM, taQuiet);
    498499        }
    499500        ~SafeVMPtrBase()
     
    503504        /** Direct PUVM access. */
    504505        PUVM rawUVM() const { return mpUVM; }
     506        /** Direct PCVMMR3VTABLE access. */
     507        PCVMMR3VTABLE vtable() const { return mpVMM; }
    505508        /** Release the handles. */
    506509        void release()
     
    525528            Base::doRelease();
    526529        }
    527         HRESULT mRC; /* Whether the VM ptr was retained. */
    528         PUVM    mpUVM;
     530        HRESULT         mRC; /* Whether the VM ptr was retained. */
     531        PUVM            mpUVM;
     532        PCVMMR3VTABLE   mpVMM;
    529533        DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(SafeVMPtrBase);
    530534    };
     
    637641    typedef std::list <ComObjPtr<RemoteUSBDevice> > RemoteUSBDeviceList;
    638642
     643    HRESULT i_loadVMM(void) RT_NOEXCEPT;
    639644    HRESULT i_addVMCaller(bool aQuiet = false, bool aAllowNullVM = false);
    640645    void    i_releaseVMCaller();
    641     HRESULT i_safeVMPtrRetainer(PUVM *a_ppUVM, bool aQuiet);
     646    HRESULT i_safeVMPtrRetainer(PUVM *a_ppUVM, PCVMMR3VTABLE *a_ppVMM, bool aQuiet) RT_NOEXCEPT;
    642647    void    i_safeVMPtrReleaser(PUVM *a_ppUVM);
    643648
     
    671676    HRESULT i_removeSharedFolder(const Utf8Str &strName);
    672677
    673     HRESULT i_suspendBeforeConfigChange(PUVM pUVM, AutoWriteLock *pAlock, bool *pfResume);
    674     void    i_resumeAfterConfigChange(PUVM pUVM);
    675 
    676     static DECLCALLBACK(int) i_configConstructor(PUVM pUVM, PVM pVM, void *pvConsole);
     678    HRESULT i_suspendBeforeConfigChange(PUVM pUVM, PCVMMR3VTABLE pVMM, AutoWriteLock *pAlock, bool *pfResume);
     679    void    i_resumeAfterConfigChange(PUVM pUVM, PCVMMR3VTABLE pVMM);
     680
     681    static DECLCALLBACK(int) i_configConstructor(PUVM pUVM, PVM pVM, PCVMMR3VTABLE pVMM, void *pvConsole);
     682    void InsertConfigString(PCFGMNODE pNode, const char *pcszName, const char *pcszValue);
     683    void InsertConfigString(PCFGMNODE pNode, const char *pcszName, const Utf8Str &rStrValue);
     684    void InsertConfigString(PCFGMNODE pNode, const char *pcszName, const Bstr &rBstrValue);
     685    void InsertConfigPassword(PCFGMNODE pNode, const char *pcszName, const Utf8Str &rStrValue);
     686    void InsertConfigBytes(PCFGMNODE pNode, const char *pcszName, const void *pvBytes, size_t cbBytes);
     687    void InsertConfigInteger(PCFGMNODE pNode, const char *pcszName, uint64_t u64Integer);
     688    void InsertConfigNode(PCFGMNODE pNode, const char *pcszName, PCFGMNODE *ppChild);
     689    void InsertConfigNodeF(PCFGMNODE pNode, PCFGMNODE *ppChild, const char *pszNameFormat, ...);
     690    void RemoveConfigValue(PCFGMNODE pNode, const char *pcszName);
     691    int  SetBiosDiskInfo(ComPtr<IMachine> pMachine, PCFGMNODE pCfg, PCFGMNODE pBiosCfg,
     692                         Bstr controllerName, const char * const s_apszBiosConfig[4]);
    677693    void i_configAudioDriver(IVirtualBox *pVirtualBox, IMachine *pMachine, PCFGMNODE pLUN, const char *pszDriverName,
    678694                             bool fAudioEnabledIn, bool fAudioEnabledOut);
    679     int i_configConstructorInner(PUVM pUVM, PVM pVM, AutoWriteLock *pAlock);
     695    int i_configConstructorInner(PUVM pUVM, PVM pVM, PCVMMR3VTABLE pVMM, AutoWriteLock *pAlock);
    680696    int i_configCfgmOverlay(PCFGMNODE pRoot, IVirtualBox *pVirtualBox, IMachine *pMachine);
    681697    int i_configDumpAPISettingsTweaks(IVirtualBox *pVirtualBox, IMachine *pMachine);
     
    689705                                   bool fHMEnabled);
    690706    int i_checkMediumLocation(IMedium *pMedium, bool *pfUseHostIOCache);
    691     int i_unmountMediumFromGuest(PUVM pUVM, StorageBus_T enmBus, DeviceType_T enmDevType,
     707    int i_unmountMediumFromGuest(PUVM pUVM, PCVMMR3VTABLE pVMM, StorageBus_T enmBus, DeviceType_T enmDevType,
    692708                                 const char *pcszDevice, unsigned uInstance, unsigned uLUN,
    693                                  bool fForceUnmount);
     709                                 bool fForceUnmount) RT_NOEXCEPT;
    694710    int i_removeMediumDriverFromVm(PCFGMNODE pCtlInst,
    695711                                   const char *pcszDevice,
     
    701717                                   bool fForceUnmount,
    702718                                   PUVM pUVM,
     719                                   PCVMMR3VTABLE pVMM,
    703720                                   DeviceType_T enmDevType,
    704721                                   PCFGMNODE *ppLunL0);
     
    719736                                 bool fHotplug,
    720737                                 PUVM pUVM,
     738                                 PCVMMR3VTABLE pVMM,
    721739                                 DeviceType_T *paLedDevType,
    722740                                 PCFGMNODE *ppLunL0);
     
    739757    static DECLCALLBACK(int) i_reconfigureMediumAttachment(Console *pThis,
    740758                                                           PUVM pUVM,
     759                                                           PCVMMR3VTABLE pVMM,
    741760                                                           const char *pcszDevice,
    742761                                                           unsigned uInstance,
     
    753772    static DECLCALLBACK(int) i_changeRemovableMedium(Console *pThis,
    754773                                                     PUVM pUVM,
     774                                                     PCVMMR3VTABLE pVMM,
    755775                                                     const char *pcszDevice,
    756776                                                     unsigned uInstance,
     
    770790                              const char *pcszDevice, unsigned uInstance);
    771791
    772     int i_configNetwork(const char *pszDevice, unsigned uInstance, unsigned uLun,
    773                         INetworkAdapter *aNetworkAdapter, PCFGMNODE pCfg,
    774                         PCFGMNODE pLunL0, PCFGMNODE pInst,
    775                         bool fAttachDetach, bool fIgnoreConnectFailure);
     792    int i_configNetwork(const char *pszDevice, unsigned uInstance, unsigned uLun, INetworkAdapter *aNetworkAdapter,
     793                        PCFGMNODE pCfg,  PCFGMNODE pLunL0, PCFGMNODE pInst, bool fAttachDetach, bool fIgnoreConnectFailure,
     794                        PUVM pUVM, PCVMMR3VTABLE pVMM);
    776795    int i_configSerialPort(PCFGMNODE pInst, PortMode_T ePortMode, const char *pszPath, bool fServer);
    777     static DECLCALLBACK(void) i_vmstateChangeCallback(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
    778     static DECLCALLBACK(int) i_unplugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu);
    779     static DECLCALLBACK(int) i_plugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu);
    780     HRESULT i_doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PUVM pUVM);
    781     HRESULT i_doCPURemove(ULONG aCpu, PUVM pUVM);
    782     HRESULT i_doCPUAdd(ULONG aCpu, PUVM pUVM);
    783 
    784     HRESULT i_doNetworkAdapterChange(PUVM pUVM, const char *pszDevice, unsigned uInstance,
     796    static DECLCALLBACK(void) i_vmstateChangeCallback(PUVM pUVM, PCVMMR3VTABLE pVMM, VMSTATE enmState,
     797                                                      VMSTATE enmOldState, void *pvUser);
     798    static DECLCALLBACK(int) i_unplugCpu(Console *pThis, PUVM pUVM, PCVMMR3VTABLE pVMM, VMCPUID idCpu);
     799    static DECLCALLBACK(int) i_plugCpu(Console *pThis, PUVM pUVM, PCVMMR3VTABLE pVMM, VMCPUID idCpu);
     800    HRESULT i_doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PUVM pUVM, PCVMMR3VTABLE pVMM);
     801    HRESULT i_doCPURemove(ULONG aCpu, PUVM pUVM, PCVMMR3VTABLE pVMM);
     802    HRESULT i_doCPUAdd(ULONG aCpu, PUVM pUVM, PCVMMR3VTABLE pVMM);
     803
     804    HRESULT i_doNetworkAdapterChange(PUVM pUVM, PCVMMR3VTABLE pVMM, const char *pszDevice, unsigned uInstance,
    785805                                     unsigned uLun, INetworkAdapter *aNetworkAdapter);
    786     static DECLCALLBACK(int) i_changeNetworkAttachment(Console *pThis, PUVM pUVM, const char *pszDevice,
    787                                                        unsigned uInstance, unsigned uLun,
    788                                                        INetworkAdapter *aNetworkAdapter);
    789     static DECLCALLBACK(int) i_changeSerialPortAttachment(Console *pThis, PUVM pUVM,
    790                                                           ISerialPort *pSerialPort);
     806    static DECLCALLBACK(int) i_changeNetworkAttachment(Console *pThis, PUVM pUVM, PCVMMR3VTABLE pVMM, const char *pszDevice,
     807                                                       unsigned uInstance, unsigned uLun, INetworkAdapter *aNetworkAdapter);
     808    static DECLCALLBACK(int) i_changeSerialPortAttachment(Console *pThis, PUVM pUVM, PCVMMR3VTABLE pVMM, ISerialPort *pSerialPort);
    791809
    792810    int i_changeClipboardMode(ClipboardMode_T aClipboardMode);
     
    798816    HRESULT i_detachUSBDevice(const ComObjPtr<OUSBDevice> &aHostDevice);
    799817
    800     static DECLCALLBACK(int) i_usbAttachCallback(Console *that, PUVM pUVM, IUSBDevice *aHostDevice, PCRTUUID aUuid,
    801                                                  const char *aBackend, const char *aAddress, void *pvRemoteBackend,
    802                                                  USBConnectionSpeed_T enmSpeed, ULONG aMaskedIfs,
     818    static DECLCALLBACK(int) i_usbAttachCallback(Console *that, PUVM pUVM, PCVMMR3VTABLE pVMM, IUSBDevice *aHostDevice,
     819                                                 PCRTUUID aUuid, const char *aBackend, const char *aAddress,
     820                                                 void *pvRemoteBackend, USBConnectionSpeed_T enmSpeed, ULONG aMaskedIfs,
    803821                                                 const char *pszCaptureFilename);
    804     static DECLCALLBACK(int) i_usbDetachCallback(Console *that, PUVM pUVM, PCRTUUID aUuid);
     822    static DECLCALLBACK(int) i_usbDetachCallback(Console *that, PUVM pUVM, PCVMMR3VTABLE pVMM, PCRTUUID aUuid);
    805823#endif
    806824
    807825    static DECLCALLBACK(int) i_attachStorageDevice(Console *pThis,
    808826                                                   PUVM pUVM,
     827                                                   PCVMMR3VTABLE pVMM,
    809828                                                   const char *pcszDevice,
    810829                                                   unsigned uInstance,
     
    815834    static DECLCALLBACK(int) i_detachStorageDevice(Console *pThis,
    816835                                                   PUVM pUVM,
     836                                                   PCVMMR3VTABLE pVMM,
    817837                                                   const char *pcszDevice,
    818838                                                   unsigned uInstance,
     
    820840                                                   IMediumAttachment *aMediumAtt,
    821841                                                   bool fSilent);
    822     HRESULT i_doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent);
    823     HRESULT i_doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent);
     842    HRESULT i_doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PUVM pUVM, PCVMMR3VTABLE pVMM, bool fSilent);
     843    HRESULT i_doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PUVM pUVM, PCVMMR3VTABLE pVMM, bool fSilent);
    824844
    825845    static DECLCALLBACK(int)    i_stateProgressCallback(PUVM pUVM, unsigned uPercent, void *pvUser);
     
    866886
    867887    HRESULT i_loadDataFromSavedState();
    868     int i_loadStateFileExecInternal(PSSMHANDLE pSSM, uint32_t u32Version);
    869 
    870     static DECLCALLBACK(void)   i_saveStateFileExec(PSSMHANDLE pSSM, void *pvUser);
    871     static DECLCALLBACK(int)    i_loadStateFileExec(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
     888    int i_loadStateFileExecInternal(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t u32Version);
     889
     890    static DECLCALLBACK(int)    i_saveStateFileExec(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser);
     891    static DECLCALLBACK(int)    i_loadStateFileExec(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser,
     892                                                    uint32_t uVersion, uint32_t uPass);
    872893
    873894#ifdef VBOX_WITH_GUEST_PROPS
     
    907928    HRESULT                     i_teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich, const char *pszNAckMsg = NULL);
    908929    HRESULT                     i_teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand, bool fWaitForAck = true);
    909     HRESULT                     i_teleporterTrg(PUVM pUVM, IMachine *pMachine, Utf8Str *pErrorMsg, bool fStartPaused,
    910                                               Progress *pProgress, bool *pfPowerOffOnFailure);
     930    HRESULT                     i_teleporterTrg(PUVM pUVM, PCVMMR3VTABLE pVMM, IMachine *pMachine, Utf8Str *pErrorMsg,
     931                                                bool fStartPaused, Progress *pProgress, bool *pfPowerOffOnFailure);
    911932    static DECLCALLBACK(int)    i_teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser);
    912933    /** @} */
     
    945966    SharedFolderMap m_mapSharedFolders;             // the console instances
    946967
     968    /** VMM loader handle. */
     969    RTLDRMOD mhModVMM;
     970    /** The VMM vtable. */
     971    PCVMMR3VTABLE mpVMM;
    947972    /** The user mode VM handle. */
    948973    PUVM mpUVM;
     
    10821107        AudioVideoRec * const mAudioRec;
    10831108# endif
    1084     } Recording;
     1109    } mRecording;
    10851110#endif /* VBOX_WITH_RECORDING */
    10861111
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r93115 r93444  
    343343#endif
    344344
    345     static DECLCALLBACK(void) i_displaySSMSaveScreenshot(PSSMHANDLE pSSM, void *pvUser);
    346     static DECLCALLBACK(int)  i_displaySSMLoadScreenshot(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
    347     static DECLCALLBACK(void) i_displaySSMSave(PSSMHANDLE pSSM, void *pvUser);
    348     static DECLCALLBACK(int)  i_displaySSMLoad(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
     345    static DECLCALLBACK(int)  i_displaySSMSaveScreenshot(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser);
     346    static DECLCALLBACK(int)  i_displaySSMLoadScreenshot(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser,
     347                                                         uint32_t uVersion, uint32_t uPass);
     348    static DECLCALLBACK(int)  i_displaySSMSave(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser);
     349    static DECLCALLBACK(int)  i_displaySSMLoad(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser,
     350                                               uint32_t uVersion, uint32_t uPass);
    349351
    350352    Console * const         mParent;
  • trunk/src/VBox/Main/include/DisplayUtils.h

    r93115 r93444  
    3737                             uint32_t *pu32Width, uint32_t *pu32Height, uint16_t *pu16Flags);
    3838
    39 int readSavedDisplayScreenshot(const Utf8Str &strStateFilePath, uint32_t u32Type, uint8_t **ppu8Data, uint32_t *pcbData, uint32_t *pu32Width, uint32_t *pu32Height);
     39int readSavedDisplayScreenshot(const Utf8Str &strStateFilePath, uint32_t u32Type, uint8_t **ppu8Data,
     40                               uint32_t *pcbData, uint32_t *pu32Width, uint32_t *pu32Height);
    4041void freeSavedDisplayScreenshot(uint8_t *pu8Data);
    4142
  • trunk/src/VBox/Main/include/DrvAudioRec.h

    r93115 r93444  
    5858private:
    5959
    60     int configureDriver(PCFGMNODE pLunCfg);
     60    virtual int configureDriver(PCFGMNODE pLunCfg, PCVMMR3VTABLE pVMM) RT_OVERRIDE;
    6161
    6262    /** Pointer to the associated video recording audio driver. */
  • trunk/src/VBox/Main/include/DrvAudioVRDE.h

    r93115 r93444  
    6666private:
    6767
    68     int configureDriver(PCFGMNODE pLunCfg);
     68    virtual int configureDriver(PCFGMNODE pLunCfg, PCVMMR3VTABLE pVMM) RT_OVERRIDE;
    6969
    7070    /** Pointer to the associated VRDE audio driver. */
  • trunk/src/VBox/Main/include/HGCM.h

    r93115 r93444  
    3636int HGCMHostReset(bool fForShutdown);
    3737
    38 int HGCMHostLoad(const char *pszServiceLibrary, const char *pszServiceName, PUVM pUVM, PPDMIHGCMPORT pHgcmPort);
     38int HGCMHostLoad(const char *pszServiceLibrary, const char *pszServiceName,
     39                 PUVM pUVM, PCVMMR3VTABLE pVMM, PPDMIHGCMPORT pHgcmPort);
    3940
    4041int HGCMHostRegisterServiceExtension(HGCMSVCEXTHANDLE *pHandle, const char *pszServiceName, PFNHGCMSVCEXT pfnExtension, void *pvExtension);
     
    5051int HGCMBroadcastEvent(HGCMNOTIFYEVENT enmEvent);
    5152
    52 int HGCMHostSaveState(PSSMHANDLE pSSM);
    53 int HGCMHostLoadState(PSSMHANDLE pSSM, uint32_t uVersion);
     53int HGCMHostSaveState(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM);
     54int HGCMHostLoadState(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion);
    5455
    5556RT_C_DECLS_END
  • trunk/src/VBox/Main/include/HGCMThread.h

    r93115 r93444  
    143143 * @param pUVM              The user mode VM handle to register statistics with.
    144144 *                          NULL if no stats.
     145 * @param pVMM              The VMM vtable for statistics registration. NULL if
     146 *                          no stats.
    145147 *
    146148 * @return VBox status code.
    147149 */
    148150int hgcmThreadCreate(HGCMThread **ppThread, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser,
    149                      const char *pszStatsSubDir, PUVM pUVM);
     151                     const char *pszStatsSubDir, PUVM pUVM, PCVMMR3VTABLE pVMM);
    150152
    151153/** Wait for termination of a HGCM worker thread.
  • trunk/src/VBox/Main/include/VMMDev.h

    r93115 r93444  
    8686    static DECLCALLBACK(void)   drvSuspend(PPDMDRVINS pDrvIns);
    8787    static DECLCALLBACK(void)   drvResume(PPDMDRVINS pDrvIns);
     88    static DECLCALLBACK(int)    hgcmSave(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
     89    static DECLCALLBACK(int)    hgcmLoad(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
    8890
    8991    Console * const         mParent;
  • trunk/src/VBox/Main/src-all/DisplayUtils.cpp

    r93115 r93444  
    11/* $Id$ */
    22/** @file
    3  * Implementation of IDisplay helpers.
     3 * Implementation of IDisplay helpers, currently only used in VBoxSVC.
    44 */
    55
  • trunk/src/VBox/Main/src-all/NvramStoreImpl.cpp

    r93115 r93444  
    10371037DECLCALLBACK(int) NvramStore::i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
    10381038{
    1039     RT_NOREF(fFlags);
    10401039    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
     1040    RT_NOREF(fFlags, pCfg);
    10411041    PDRVMAINNVRAMSTORE pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINNVRAMSTORE);
    10421042    LogFlow(("NvramStore::drvConstruct: iInstance=%d\n", pDrvIns->iInstance));
     
    10451045     * Validate configuration.
    10461046     */
    1047     if (!CFGMR3AreValuesValid(pCfg, ""))
    1048         return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
     1047    PDMDRV_VALIDATE_CONFIG_RETURN(pDrvIns, "", "");
    10491048    AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
    10501049                    ("Configuration error: Not possible to attach anything to this driver!\n"),
  • trunk/src/VBox/Main/src-client/AudioDriver.cpp

    r93115 r93444  
    2828#include <VBox/vmm/pdmapi.h>
    2929#include <VBox/vmm/pdmdrv.h>
     30#include <VBox/vmm/vmmr3vtable.h>
    3031
    3132#include "AudioDriver.h"
     
    8081 *
    8182 * @returns VBox status code.
    82  * @param   pUVM                The user mode VM handle for talking to EMT.
    83  * @param   pAutoLock           The callers auto lock instance.  Can be NULL if
    84  *                              not locked.
    85  */
    86 int AudioDriver::doAttachDriverViaEmt(PUVM pUVM, util::AutoWriteLock *pAutoLock)
     83 * @param   pUVM        The user mode VM handle for talking to EMT.
     84 * @param   pVMM        The VMM ring-3 vtable.
     85 * @param   pAutoLock   The callers auto lock instance.  Can be NULL if not
     86 *                      locked.
     87 */
     88int AudioDriver::doAttachDriverViaEmt(PUVM pUVM, PCVMMR3VTABLE pVMM, util::AutoWriteLock *pAutoLock)
    8789{
    8890    if (!isConfigured())
     
    9092
    9193    PVMREQ pReq;
    92     int vrc = VMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
    93                            (PFNRT)attachDriverOnEmt, 1, this);
     94    int vrc = pVMM->pfnVMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
     95                                    (PFNRT)attachDriverOnEmt, 1, this);
    9496    if (vrc == VERR_TIMEOUT)
    9597    {
     
    98100            pAutoLock->release();
    99101
    100         vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
     102        vrc = pVMM->pfnVMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    101103
    102104        if (pAutoLock)
     
    105107
    106108    AssertRC(vrc);
    107     VMR3ReqFree(pReq);
     109    pVMM->pfnVMR3ReqFree(pReq);
    108110
    109111    return vrc;
     
    138140
    139141    /* Detach the driver chain from the audio device first. */
    140     int rc = PDMR3DeviceDetach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN, 0 /* fFlags */);
     142    int rc = ptrVM.vtable()->pfnPDMR3DeviceDetach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN, 0 /* fFlags */);
    141143    if (RT_SUCCESS(rc))
    142144    {
    143145        rc = pThis->configure(pCfg->uLUN, true /* Attach */);
    144146        if (RT_SUCCESS(rc))
    145             rc = PDMR3DriverAttach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN, 0 /* fFlags */,
    146                                    NULL /* ppBase */);
     147            rc = ptrVM.vtable()->pfnPDMR3DriverAttach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN,
     148                                                      0 /* fFlags */, NULL /* ppBase */);
    147149    }
    148150
     
    164166 *
    165167 * @returns VBox status code.
    166  * @param   pUVM                The user mode VM handle for talking to EMT.
    167  * @param   pAutoLock           The callers auto lock instance.  Can be NULL if
    168  *                              not locked.
    169  */
    170 int AudioDriver::doDetachDriverViaEmt(PUVM pUVM, util::AutoWriteLock *pAutoLock)
     168 * @param   pUVM        The user mode VM handle for talking to EMT.
     169 * @param   pVMM        The VMM ring-3 vtable.
     170 * @param   pAutoLock   The callers auto lock instance.  Can be NULL if not
     171 *                      locked.
     172 */
     173int AudioDriver::doDetachDriverViaEmt(PUVM pUVM, PCVMMR3VTABLE pVMM, util::AutoWriteLock *pAutoLock)
    171174{
    172175    if (!isConfigured())
     
    174177
    175178    PVMREQ pReq;
    176     int vrc = VMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
    177                            (PFNRT)detachDriverOnEmt, 1, this);
     179    int vrc = pVMM->pfnVMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
     180                                    (PFNRT)detachDriverOnEmt, 1, this);
    178181    if (vrc == VERR_TIMEOUT)
    179182    {
     
    182185            pAutoLock->release();
    183186
    184         vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
     187        vrc = pVMM->pfnVMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    185188
    186189        if (pAutoLock)
     
    189192
    190193    AssertRC(vrc);
    191     VMR3ReqFree(pReq);
     194    pVMM->pfnVMR3ReqFree(pReq);
    192195
    193196    return vrc;
     
    227230     * Start with the "AUDIO" driver, as this driver serves as the audio connector between
    228231     * the device emulation and the select backend(s). */
    229     int rc = PDMR3DriverDetach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN,
    230                                "AUDIO", 0 /* iOccurrence */,  0 /* fFlags */);
     232    int rc = ptrVM.vtable()->pfnPDMR3DriverDetach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN,
     233                                                  "AUDIO", 0 /* iOccurrence */,  0 /* fFlags */);
    231234    if (RT_SUCCESS(rc))
    232235        rc = pThis->configure(pCfg->uLUN, false /* Detach */);/** @todo r=bird: Illogical and from what I can tell pointless! */
     
    256259{
    257260    Console::SafeVMPtrQuiet ptrVM(mpConsole);
    258     Assert(ptrVM.isOk());
    259 
    260     PUVM pUVM = ptrVM.rawUVM();
    261     AssertPtr(pUVM);
    262 
    263     PCFGMNODE pRoot = CFGMR3GetRootU(pUVM);
     261    AssertReturn(ptrVM.isOk(), VERR_INVALID_STATE);
     262
     263    PCFGMNODE pRoot = ptrVM.vtable()->pfnCFGMR3GetRootU(ptrVM.rawUVM());
    264264    AssertPtr(pRoot);
    265     PCFGMNODE pDev0 = CFGMR3GetChildF(pRoot, "Devices/%s/%u/", mCfg.strDev.c_str(), mCfg.uInst);
     265    PCFGMNODE pDev0 = ptrVM.vtable()->pfnCFGMR3GetChildF(pRoot, "Devices/%s/%u/", mCfg.strDev.c_str(), mCfg.uInst);
    266266
    267267    if (!pDev0) /* No audio device configured? Bail out. */
     
    273273    int rc = VINF_SUCCESS;
    274274
    275     PCFGMNODE pDevLun = CFGMR3GetChildF(pDev0, "LUN#%u/", uLUN);
     275    PCFGMNODE pDevLun = ptrVM.vtable()->pfnCFGMR3GetChildF(pDev0, "LUN#%u/", uLUN);
    276276
    277277    if (fAttach)
    278278    {
    279         do
     279        do  /* break "loop" */
    280280        {
    281281            AssertMsgBreakStmt(pDevLun, ("%s: Device LUN #%u not found\n", mCfg.strName.c_str(), uLUN), rc = VERR_NOT_FOUND);
     
    283283            LogRel2(("%s: Configuring audio driver (to LUN #%u)\n", mCfg.strName.c_str(), uLUN));
    284284
    285             CFGMR3RemoveNode(pDevLun); /* Remove LUN completely first. */
     285            ptrVM.vtable()->pfnCFGMR3RemoveNode(pDevLun); /* Remove LUN completely first. */
    286286
    287287            /* Insert new LUN configuration and build up the new driver chain. */
    288             rc = CFGMR3InsertNodeF(pDev0, &pDevLun, "LUN#%u/", uLUN);                               AssertRCBreak(rc);
    289             rc = CFGMR3InsertString(pDevLun, "Driver", "AUDIO");                                    AssertRCBreak(rc);
     288            rc = ptrVM.vtable()->pfnCFGMR3InsertNodeF(pDev0, &pDevLun, "LUN#%u/", uLUN);                        AssertRCBreak(rc);
     289            rc = ptrVM.vtable()->pfnCFGMR3InsertString(pDevLun, "Driver", "AUDIO");                             AssertRCBreak(rc);
    290290
    291291            PCFGMNODE pLunCfg;
    292             rc = CFGMR3InsertNode(pDevLun, "Config", &pLunCfg);                                     AssertRCBreak(rc);
    293 
    294             rc = CFGMR3InsertStringF(pLunCfg, "DriverName",    "%s", mCfg.strName.c_str());         AssertRCBreak(rc);
    295             rc = CFGMR3InsertInteger(pLunCfg, "InputEnabled",  mCfg.fEnabledIn);                    AssertRCBreak(rc);
    296             rc = CFGMR3InsertInteger(pLunCfg, "OutputEnabled", mCfg.fEnabledOut);                   AssertRCBreak(rc);
     292            rc = ptrVM.vtable()->pfnCFGMR3InsertNode(pDevLun, "Config", &pLunCfg);                              AssertRCBreak(rc);
     293
     294            rc = ptrVM.vtable()->pfnCFGMR3InsertStringF(pLunCfg, "DriverName",    "%s", mCfg.strName.c_str());  AssertRCBreak(rc);
     295            rc = ptrVM.vtable()->pfnCFGMR3InsertInteger(pLunCfg, "InputEnabled",  mCfg.fEnabledIn);             AssertRCBreak(rc);
     296            rc = ptrVM.vtable()->pfnCFGMR3InsertInteger(pLunCfg, "OutputEnabled", mCfg.fEnabledOut);            AssertRCBreak(rc);
    297297
    298298            PCFGMNODE pAttachedDriver;
    299             rc = CFGMR3InsertNode(pDevLun, "AttachedDriver", &pAttachedDriver);                     AssertRCBreak(rc);
    300             rc = CFGMR3InsertStringF(pAttachedDriver, "Driver", "%s", mCfg.strName.c_str());        AssertRCBreak(rc);
     299            rc = ptrVM.vtable()->pfnCFGMR3InsertNode(pDevLun, "AttachedDriver", &pAttachedDriver);              AssertRCBreak(rc);
     300            rc = ptrVM.vtable()->pfnCFGMR3InsertStringF(pAttachedDriver, "Driver", "%s", mCfg.strName.c_str()); AssertRCBreak(rc);
    301301            PCFGMNODE pAttachedDriverCfg;
    302             rc = CFGMR3InsertNode(pAttachedDriver, "Config", &pAttachedDriverCfg);                  AssertRCBreak(rc);
     302            rc = ptrVM.vtable()->pfnCFGMR3InsertNode(pAttachedDriver, "Config", &pAttachedDriverCfg);           AssertRCBreak(rc);
    303303
    304304            /* Call the (virtual) method for driver-specific configuration. */
    305             rc = configureDriver(pAttachedDriverCfg);                                               AssertRCBreak(rc);
     305            rc = configureDriver(pAttachedDriverCfg, ptrVM.vtable());                                           AssertRCBreak(rc);
    306306
    307307        } while (0);
     
    316316#ifdef LOG_ENABLED
    317317        LogFunc(("%s: fAttach=%RTbool\n", mCfg.strName.c_str(), fAttach));
    318         CFGMR3Dump(pDevLun);
     318        ptrVM.vtable()->pfnCFGMR3Dump(pDevLun);
    319319#endif
    320320    }
  • trunk/src/VBox/Main/src-client/BusAssignmentManager.cpp

    r93115 r93444  
    1616 */
    1717
     18
     19/*********************************************************************************************************************************
     20*   Header Files                                                                                                                 *
     21*********************************************************************************************************************************/
    1822#define LOG_GROUP LOG_GROUP_MAIN
    1923#include "LoggingNew.h"
     
    2529
    2630#include <VBox/vmm/cfgm.h>
     31#include <VBox/vmm/vmmr3vtable.h>
    2732#include <VBox/com/array.h>
    2833
     
    3136#include <algorithm>
    3237
     38
     39/*********************************************************************************************************************************
     40*   Structures and Typedefs                                                                                                      *
     41*********************************************************************************************************************************/
    3342struct DeviceAssignmentRule
    3443{
     
    4655};
    4756
     57
     58/*********************************************************************************************************************************
     59*   Global Variables                                                                                                             *
     60*********************************************************************************************************************************/
    4861/* Those rules define PCI slots assignment */
    4962/** @note
     
    297310};
    298311
     312
     313
     314/**
     315 * Bus assignment manage state data.
     316 * @internal
     317 */
    299318struct BusAssignmentManager::State
    300319{
     
    337356    PCIMap           mPCIMap;
    338357    ReversePCIMap    mReversePCIMap;
     358    PCVMMR3VTABLE    mpVMM;
    339359
    340360    State()
    341         : cRefCnt(1), mChipsetType(ChipsetType_Null), mpszBridgeName("unknownbridge")
     361        : cRefCnt(1), mChipsetType(ChipsetType_Null), mpszBridgeName("unknownbridge"), mpVMM(NULL)
    342362    {}
    343363    ~State()
    344364    {}
    345365
    346     HRESULT init(ChipsetType_T chipsetType, IommuType_T iommuType);
     366    HRESULT init(PCVMMR3VTABLE pVMM, ChipsetType_T chipsetType, IommuType_T iommuType);
    347367
    348368    HRESULT record(const char *pszName, PCIBusAddress& GuestAddress, PCIBusAddress HostAddress);
     
    356376};
    357377
    358 HRESULT BusAssignmentManager::State::init(ChipsetType_T chipsetType, IommuType_T iommuType)
    359 {
     378
     379HRESULT BusAssignmentManager::State::init(PCVMMR3VTABLE pVMM, ChipsetType_T chipsetType, IommuType_T iommuType)
     380{
     381    mpVMM = pVMM;
     382
    360383    if (iommuType != IommuType_None)
    361384    {
     
    550573}
    551574
    552 BusAssignmentManager *BusAssignmentManager::createInstance(ChipsetType_T chipsetType, IommuType_T iommuType)
     575BusAssignmentManager *BusAssignmentManager::createInstance(PCVMMR3VTABLE pVMM, ChipsetType_T chipsetType, IommuType_T iommuType)
    553576{
    554577    BusAssignmentManager *pInstance = new BusAssignmentManager();
    555     pInstance->pState->init(chipsetType, iommuType);
     578    pInstance->pState->init(pVMM, chipsetType, iommuType);
    556579    Assert(pInstance);
    557580    return pInstance;
     
    562585    ASMAtomicIncS32(&pState->cRefCnt);
    563586}
     587
    564588void BusAssignmentManager::Release()
    565589{
     
    568592}
    569593
    570 DECLINLINE(HRESULT) InsertConfigInteger(PCFGMNODE pCfg, const char *pszName, uint64_t u64)
    571 {
    572     int vrc = CFGMR3InsertInteger(pCfg, pszName, u64);
     594DECLINLINE(HRESULT) InsertConfigInteger(PCVMMR3VTABLE pVMM, PCFGMNODE pCfg, const char *pszName, uint64_t u64)
     595{
     596    int vrc = pVMM->pfnCFGMR3InsertInteger(pCfg, pszName, u64);
    573597    if (RT_FAILURE(vrc))
    574598        return E_INVALIDARG;
     
    577601}
    578602
    579 DECLINLINE(HRESULT) InsertConfigNode(PCFGMNODE pNode, const char *pcszName, PCFGMNODE *ppChild)
    580 {
    581     int vrc = CFGMR3InsertNode(pNode, pcszName, ppChild);
     603DECLINLINE(HRESULT) InsertConfigNode(PCVMMR3VTABLE pVMM, PCFGMNODE pNode, const char *pcszName, PCFGMNODE *ppChild)
     604{
     605    int vrc = pVMM->pfnCFGMR3InsertNode(pNode, pcszName, ppChild);
    582606    if (RT_FAILURE(vrc))
    583607        return E_INVALIDARG;
     
    619643        return rc;
    620644
     645    PCVMMR3VTABLE const pVMM = pState->mpVMM;
    621646    if (pCfg)
    622647    {
    623         rc = InsertConfigInteger(pCfg, "PCIBusNo",      GuestAddress.miBus);
     648        rc = InsertConfigInteger(pVMM, pCfg, "PCIBusNo",      GuestAddress.miBus);
    624649        if (FAILED(rc))
    625650            return rc;
    626         rc = InsertConfigInteger(pCfg, "PCIDeviceNo",   GuestAddress.miDevice);
     651        rc = InsertConfigInteger(pVMM, pCfg, "PCIDeviceNo",   GuestAddress.miDevice);
    627652        if (FAILED(rc))
    628653            return rc;
    629         rc = InsertConfigInteger(pCfg, "PCIFunctionNo", GuestAddress.miFn);
     654        rc = InsertConfigInteger(pVMM, pCfg, "PCIFunctionNo", GuestAddress.miFn);
    630655        if (FAILED(rc))
    631656            return rc;
     
    636661        && !hasPCIDevice(pState->mpszBridgeName, GuestAddress.miBus - 1))
    637662    {
    638         PCFGMNODE pDevices = CFGMR3GetParent(CFGMR3GetParent(pCfg));
     663        PCFGMNODE pDevices = pVMM->pfnCFGMR3GetParent(pVMM->pfnCFGMR3GetParent(pCfg));
    639664        AssertLogRelMsgReturn(pDevices, ("BusAssignmentManager: cannot find base device configuration\n"), E_UNEXPECTED);
    640         PCFGMNODE pBridges = CFGMR3GetChild(pDevices, "ich9pcibridge");
     665        PCFGMNODE pBridges = pVMM->pfnCFGMR3GetChild(pDevices, "ich9pcibridge");
    641666        AssertLogRelMsgReturn(pBridges, ("BusAssignmentManager: cannot find bridge configuration base\n"), E_UNEXPECTED);
    642667
     
    654679
    655680                PCFGMNODE pInst;
    656                 InsertConfigNode(pBridges, Utf8StrFmt("%d", iBridge).c_str(), &pInst);
    657                 InsertConfigInteger(pInst, "Trusted", 1);
     681                InsertConfigNode(pVMM, pBridges, Utf8StrFmt("%d", iBridge).c_str(), &pInst);
     682                InsertConfigInteger(pVMM, pInst, "Trusted", 1);
    658683                rc = assignPCIDevice(pState->mpszBridgeName, pInst);
    659684                if (FAILED(rc))
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r93440 r93444  
    105105#include <iprt/memsafer.h>
    106106
     107#include <VBox/vmm/vmmr3vtable.h>
    107108#include <VBox/vmm/vmapi.h>
    108109#include <VBox/vmm/vmm.h>
     
    229230                  Progress *aProgress)
    230231        : VMTask(aConsole, aProgress, NULL /* aServerProgress */, false /* aUsesVMPtr */)
    231         , mConfigConstructor(NULL)
     232        , mpfnConfigConstructor(NULL)
    232233        , mStartPaused(false)
    233234        , mTeleporterEnabled(FALSE)
     
    236237    }
    237238
    238     PFNCFGMCONSTRUCTOR mConfigConstructor;
     239    PFNCFGMCONSTRUCTOR mpfnConfigConstructor;
    239240    Utf8Str mSavedStateFile;
    240241    Console::SharedFolderDataMap mSharedFolders;
     
    389390    , mfVRDEChangeInProcess(false)
    390391    , mfVRDEChangePending(false)
     392    , mhModVMM(NIL_RTLDRMOD)
     393    , mpVMM(NULL)
    391394    , mpUVM(NULL)
    392395    , mVMCallers(0)
     
    475478/////////////////////////////////////////////////////////////////////////////
    476479
    477 HRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl, LockType_T aLockType)
     480/** @todo r=bird: aLockType is always LockType_VM.   */
     481HRESULT Console::initWithMachine(IMachine *aMachine, IInternalMachineControl *aControl, LockType_T aLockType)
    478482{
    479483    AssertReturn(aMachine && aControl, E_INVALIDARG);
     
    516520
    517521    /* Now the VM specific parts */
     522    /** @todo r=bird: aLockType is always LockType_VM.   */
    518523    if (aLockType == LockType_VM)
    519524    {
     525        /* Load the VMM. We won't continue without it being successfully loaded here. */
     526        rc = i_loadVMM();
     527        AssertComRCReturnRC(rc);
     528
    520529        rc = mMachine->COMGETTER(VRDEServer)(unconst(mVRDEServer).asOutParam());
    521530        AssertComRCReturnRC(rc);
     
    594603#endif
    595604#ifdef VBOX_WITH_AUDIO_RECORDING
    596         unconst(Recording.mAudioRec) = new AudioVideoRec(this);
    597         AssertReturn(Recording.mAudioRec, E_FAIL);
     605        unconst(mRecording.mAudioRec) = new AudioVideoRec(this);
     606        AssertReturn(mRecording.mAudioRec, E_FAIL);
    598607#endif
    599608
     
    728737    i_recordingDestroy();
    729738# ifdef VBOX_WITH_AUDIO_RECORDING
    730     if (Recording.mAudioRec)
    731     {
    732         delete Recording.mAudioRec;
    733         unconst(Recording.mAudioRec) = NULL;
     739    if (mRecording.mAudioRec)
     740    {
     741        delete mRecording.mAudioRec;
     742        unconst(mRecording.mAudioRec) = NULL;
    734743    }
    735744# endif
     
    827836    unconst(mptrExtPackManager).setNull();
    828837#endif
     838
     839    /* Unload the VMM. */
     840    mpVMM = NULL;
     841    if (mhModVMM != NIL_RTLDRMOD)
     842    {
     843        RTLdrClose(mhModVMM);
     844        mhModVMM = NIL_RTLDRMOD;
     845    }
    829846
    830847    /* Release memory held by the LED sets. */
     
    15591576/**
    15601577 * Loads various console data stored in the saved state file.
     1578 *
    15611579 * This method does validation of the state file and returns an error info
    15621580 * when appropriate.
     
    15691587HRESULT Console::i_loadDataFromSavedState()
    15701588{
    1571     if ((mMachineState != MachineState_Saved && mMachineState != MachineState_AbortedSaved) || mSavedStateDataLoaded)
     1589    if (   (   mMachineState != MachineState_Saved
     1590            && mMachineState != MachineState_AbortedSaved)
     1591        || mSavedStateDataLoaded)
    15721592        return S_OK;
    15731593
    1574     Bstr savedStateFile;
    1575     HRESULT rc = mMachine->COMGETTER(StateFilePath)(savedStateFile.asOutParam());
    1576     if (FAILED(rc))
    1577         return rc;
    1578 
    1579     PSSMHANDLE ssm;
    1580     int vrc = SSMR3Open(Utf8Str(savedStateFile).c_str(), 0, &ssm);
    1581     if (RT_SUCCESS(vrc))
    1582     {
    1583         uint32_t version = 0;
    1584         vrc = SSMR3Seek(ssm, sSSMConsoleUnit, 0 /* iInstance */, &version);
    1585         if (SSM_VERSION_MAJOR(version) == SSM_VERSION_MAJOR(CONSOLE_SAVED_STATE_VERSION))
    1586         {
    1587             if (RT_SUCCESS(vrc))
    1588                 vrc = i_loadStateFileExecInternal(ssm, version);
    1589             else if (vrc == VERR_SSM_UNIT_NOT_FOUND)
    1590                 vrc = VINF_SUCCESS;
    1591         }
    1592         else
    1593             vrc = VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    1594 
    1595         SSMR3Close(ssm);
    1596     }
    1597 
    1598     if (RT_FAILURE(vrc))
    1599         rc = setErrorBoth(VBOX_E_FILE_ERROR, vrc,
    1600                           tr("The saved state file '%ls' is invalid (%Rrc). Delete the saved state and try again"),
    1601                           savedStateFile.raw(), vrc);
    1602 
    1603     mSavedStateDataLoaded = true;
    1604 
    1605     return rc;
     1594    Bstr bstrSavedStateFile;
     1595    HRESULT hrc = mMachine->COMGETTER(StateFilePath)(bstrSavedStateFile.asOutParam());
     1596    if (SUCCEEDED(hrc))
     1597    {
     1598        Utf8Str const strSavedStateFile(bstrSavedStateFile);
     1599
     1600        PCVMMR3VTABLE pVMM = mpVMM;
     1601        AssertPtrReturn(pVMM, E_UNEXPECTED);
     1602
     1603        PSSMHANDLE pSSM;
     1604        int vrc = pVMM->pfnSSMR3Open(strSavedStateFile.c_str(), 0, &pSSM);
     1605        if (RT_SUCCESS(vrc))
     1606        {
     1607            uint32_t uVersion = 0;
     1608            vrc = pVMM->pfnSSMR3Seek(pSSM, sSSMConsoleUnit, 0 /* iInstance */, &uVersion);
     1609            /** @todo r=bird: This version check is premature, so the logic here is
     1610             * buggered as we won't ignore VERR_SSM_UNIT_NOT_FOUND as seems to be
     1611             * intended. Sigh. */
     1612            if (SSM_VERSION_MAJOR(uVersion) == SSM_VERSION_MAJOR(CONSOLE_SAVED_STATE_VERSION))
     1613            {
     1614                if (RT_SUCCESS(vrc))
     1615                    try
     1616                    {
     1617                        vrc = i_loadStateFileExecInternal(pSSM, pVMM, uVersion);
     1618                    }
     1619                    catch (std::bad_alloc &)
     1620                    {
     1621                        vrc = VERR_NO_MEMORY;
     1622                    }
     1623                else if (vrc == VERR_SSM_UNIT_NOT_FOUND)
     1624                    vrc = VINF_SUCCESS;
     1625            }
     1626            else
     1627                vrc = VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
     1628
     1629            pVMM->pfnSSMR3Close(pSSM);
     1630        }
     1631
     1632        if (RT_FAILURE(vrc))
     1633            hrc = setErrorBoth(VBOX_E_FILE_ERROR, vrc,
     1634                               tr("The saved state file '%s' is invalid (%Rrc). Delete the saved state and try again"),
     1635                               strSavedStateFile.c_str(), vrc);
     1636
     1637        mSavedStateDataLoaded = true;
     1638    }
     1639
     1640    return hrc;
    16061641}
    16071642
     
    16101645 * called when the user saves the VM state.
    16111646 *
    1612  * @param pSSM      SSM handle.
    1613  * @param pvUser    pointer to Console
    1614  *
    1615  * @note Locks the Console object for reading.
    1616  */
    1617 //static
    1618 DECLCALLBACK(void) Console::i_saveStateFileExec(PSSMHANDLE pSSM, void *pvUser)
     1647 * @returns VBox status code.
     1648 * @param   pSSM      SSM handle.
     1649 * @param   pVMM      The VMM ring-3 vtable.
     1650 * @param   pvUser    Pointer to Console
     1651 *
     1652 * @note    Locks the Console object for reading.
     1653 */
     1654/*static*/ DECLCALLBACK(int)
     1655Console::i_saveStateFileExec(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser)
    16191656{
    16201657    LogFlowFunc(("\n"));
    16211658
    1622     Console *that = static_cast<Console *>(pvUser);
    1623     AssertReturnVoid(that);
    1624 
    1625     AutoCaller autoCaller(that);
    1626     AssertComRCReturnVoid(autoCaller.rc());
    1627 
    1628     AutoReadLock alock(that COMMA_LOCKVAL_SRC_POS);
    1629 
    1630     SSMR3PutU32(pSSM, (uint32_t)that->m_mapSharedFolders.size());
    1631 
    1632     for (SharedFolderMap::const_iterator it = that->m_mapSharedFolders.begin();
    1633          it != that->m_mapSharedFolders.end();
     1659    Console *pThat = static_cast<Console *>(pvUser);
     1660    AssertReturn(pThat, VERR_INVALID_POINTER);
     1661
     1662    AutoCaller autoCaller(pThat);
     1663    AssertComRCReturn(autoCaller.rc(), VERR_INVALID_STATE);
     1664
     1665    AutoReadLock alock(pThat COMMA_LOCKVAL_SRC_POS);
     1666
     1667    pVMM->pfnSSMR3PutU32(pSSM, (uint32_t)pThat->m_mapSharedFolders.size());
     1668
     1669    for (SharedFolderMap::const_iterator it = pThat->m_mapSharedFolders.begin();
     1670         it != pThat->m_mapSharedFolders.end();
    16341671         ++it)
    16351672    {
     
    16391676
    16401677        const Utf8Str &name = pSF->i_getName();
    1641         SSMR3PutU32(pSSM, (uint32_t)name.length() + 1 /* term. 0 */);
    1642         SSMR3PutStrZ(pSSM, name.c_str());
     1678        pVMM->pfnSSMR3PutU32(pSSM, (uint32_t)name.length() + 1 /* term. 0 */);
     1679        pVMM->pfnSSMR3PutStrZ(pSSM, name.c_str());
    16431680
    16441681        const Utf8Str &hostPath = pSF->i_getHostPath();
    1645         SSMR3PutU32(pSSM, (uint32_t)hostPath.length() + 1 /* term. 0 */);
    1646         SSMR3PutStrZ(pSSM, hostPath.c_str());
    1647 
    1648         SSMR3PutBool(pSSM, !!pSF->i_isWritable());
    1649         SSMR3PutBool(pSSM, !!pSF->i_isAutoMounted());
     1682        pVMM->pfnSSMR3PutU32(pSSM, (uint32_t)hostPath.length() + 1 /* term. 0 */);
     1683        pVMM->pfnSSMR3PutStrZ(pSSM, hostPath.c_str());
     1684
     1685        pVMM->pfnSSMR3PutBool(pSSM, !!pSF->i_isWritable());
     1686        pVMM->pfnSSMR3PutBool(pSSM, !!pSF->i_isAutoMounted());
    16501687
    16511688        const Utf8Str &rStrAutoMountPoint = pSF->i_getAutoMountPoint();
    1652         SSMR3PutU32(pSSM, (uint32_t)rStrAutoMountPoint.length() + 1 /* term. 0 */);
    1653         SSMR3PutStrZ(pSSM, rStrAutoMountPoint.c_str());
    1654     }
     1689        pVMM->pfnSSMR3PutU32(pSSM, (uint32_t)rStrAutoMountPoint.length() + 1 /* term. 0 */);
     1690        pVMM->pfnSSMR3PutStrZ(pSSM, rStrAutoMountPoint.c_str());
     1691    }
     1692
     1693    return VINF_SUCCESS;
    16551694}
    16561695
    16571696/**
    16581697 * Callback handler to load various console data from the state file.
     1698 *
    16591699 * Called when the VM is being restored from the saved state.
    16601700 *
    1661  * @param pSSM         SSM handle.
    1662  * @param pvUser       pointer to Console
    1663  * @param uVersion     Console unit version.
    1664  *                     Should match sSSMConsoleVer.
    1665  * @param uPass        The data pass.
    1666  *
    1667  * @note Should locks the Console object for writing, if necessary.
     1701 * @returns VBox status code.
     1702 * @param   pSSM         SSM handle.
     1703 * @param   pVMM         The VMM ring-3 vtable.
     1704 * @param   pvUser       pointer to Console
     1705 * @param   uVersion     Console unit version. Should match sSSMConsoleVer.
     1706 * @param   uPass        The data pass.
    16681707 */
    16691708//static
    16701709DECLCALLBACK(int)
    1671 Console::i_loadStateFileExec(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass)
    1672 {
    1673     LogFlowFunc(("\n"));
     1710Console::i_loadStateFileExec(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser, uint32_t uVersion, uint32_t uPass)
     1711{
     1712    LogFlowFunc(("uVersion=%#x uPass=%#x\n", uVersion, uPass));
     1713    Assert(uPass == SSM_PASS_FINAL); RT_NOREF_PV(uPass);
    16741714
    16751715    if (SSM_VERSION_MAJOR_CHANGED(uVersion, CONSOLE_SAVED_STATE_VERSION))
    16761716        return VERR_VERSION_MISMATCH;
    1677     Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
    1678 
    1679     Console *that = static_cast<Console *>(pvUser);
    1680     AssertReturn(that, VERR_INVALID_PARAMETER);
     1717
     1718    Console *pThat = static_cast<Console *>(pvUser);
     1719    AssertReturn(pThat, VERR_INVALID_PARAMETER);
    16811720
    16821721    /* Currently, nothing to do when we've been called from VMR3Load*. */
    1683     return SSMR3SkipToEndOfUnit(pSSM);
     1722    return pVMM->pfnSSMR3SkipToEndOfUnit(pSSM);
    16841723}
    16851724
    16861725/**
    16871726 * Method to load various console data from the state file.
     1727 *
    16881728 * Called from #i_loadDataFromSavedState.
    16891729 *
    16901730 * @param pSSM         SSM handle.
     1731 * @param pVMM         The VMM vtable.
    16911732 * @param u32Version   Console unit version.
    16921733 *                     Should match sSSMConsoleVer.
     
    16941735 * @note Locks the Console object for writing.
    16951736 */
    1696 int Console::i_loadStateFileExecInternal(PSSMHANDLE pSSM, uint32_t u32Version)
     1737int Console::i_loadStateFileExecInternal(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t u32Version)
    16971738{
    16981739    AutoCaller autoCaller(this);
     
    17041745
    17051746    uint32_t size = 0;
    1706     int vrc = SSMR3GetU32(pSSM, &size);
     1747    int vrc = pVMM->pfnSSMR3GetU32(pSSM, &size);
    17071748    AssertRCReturn(vrc, vrc);
    17081749
     
    17171758        char *buf = NULL;
    17181759
    1719         vrc = SSMR3GetU32(pSSM, &cbStr);
     1760        vrc = pVMM->pfnSSMR3GetU32(pSSM, &cbStr);
    17201761        AssertRCReturn(vrc, vrc);
    17211762        buf = new char[cbStr];
    1722         vrc = SSMR3GetStrZ(pSSM, buf, cbStr);
     1763        vrc = pVMM->pfnSSMR3GetStrZ(pSSM, buf, cbStr);
    17231764        AssertRC(vrc);
    17241765        strName = buf;
    17251766        delete[] buf;
    17261767
    1727         vrc = SSMR3GetU32(pSSM, &cbStr);
     1768        vrc = pVMM->pfnSSMR3GetU32(pSSM, &cbStr);
    17281769        AssertRCReturn(vrc, vrc);
    17291770        buf = new char[cbStr];
    1730         vrc = SSMR3GetStrZ(pSSM, buf, cbStr);
     1771        vrc = pVMM->pfnSSMR3GetStrZ(pSSM, buf, cbStr);
    17311772        AssertRC(vrc);
    17321773        strHostPath = buf;
     
    17341775
    17351776        if (u32Version >= CONSOLE_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT)
    1736             SSMR3GetBool(pSSM, &writable);
     1777            pVMM->pfnSSMR3GetBool(pSSM, &writable);
    17371778
    17381779        if (   u32Version >= CONSOLE_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT
    17391780#ifndef VBOX_OSE /* This broke saved state when introduced in r63916 (4.0). */
    1740             && SSMR3HandleRevision(pSSM) >= 63916
     1781            && pVMM->pfnSSMR3HandleRevision(pSSM) >= 63916
    17411782#endif
    17421783           )
    1743             SSMR3GetBool(pSSM, &autoMount);
     1784            pVMM->pfnSSMR3GetBool(pSSM, &autoMount);
    17441785
    17451786        Utf8Str strAutoMountPoint;
    17461787        if (u32Version >= CONSOLE_SAVED_STATE_VERSION)
    17471788        {
    1748             vrc = SSMR3GetU32(pSSM, &cbStr);
     1789            vrc = pVMM->pfnSSMR3GetU32(pSSM, &cbStr);
    17491790            AssertRCReturn(vrc, vrc);
    17501791            vrc = strAutoMountPoint.reserveNoThrow(cbStr);
    17511792            AssertRCReturn(vrc, vrc);
    1752             vrc = SSMR3GetStrZ(pSSM, strAutoMountPoint.mutableRaw(), cbStr);
     1793            vrc = pVMM->pfnSSMR3GetStrZ(pSSM, strAutoMountPoint.mutableRaw(), cbStr);
    17531794            AssertRCReturn(vrc, vrc);
    17541795            strAutoMountPoint.jolt();
     
    22632304    /* protect mpUVM */
    22642305    SafeVMPtr ptrVM(this);
    2265     if (!ptrVM.isOk())
    2266         return ptrVM.rc();
    2267 
    2268     /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
    2269     alock.release();
    2270 
    2271     int vrc = VMR3Reset(ptrVM.rawUVM());
    2272 
    2273     HRESULT rc = RT_SUCCESS(vrc) ? S_OK : setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("Could not reset the machine (%Rrc)"), vrc);
    2274 
    2275     LogFlowThisFunc(("mMachineState=%d, rc=%Rhrc\n", mMachineState, rc));
     2306    HRESULT hrc = ptrVM.rc();
     2307    if (SUCCEEDED(hrc))
     2308    {
     2309        /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
     2310        alock.release();
     2311
     2312        int vrc = ptrVM.vtable()->pfnVMR3Reset(ptrVM.rawUVM());
     2313
     2314        hrc = RT_SUCCESS(vrc) ? S_OK : setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("Could not reset the machine (%Rrc)"), vrc);
     2315    }
     2316
     2317    LogFlowThisFunc(("mMachineState=%d, hrc=%Rhrc\n", mMachineState, hrc));
    22762318    LogFlowThisFuncLeave();
    2277     return rc;
    2278 }
    2279 
    2280 /*static*/ DECLCALLBACK(int) Console::i_unplugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu)
     2319    return hrc;
     2320}
     2321
     2322/*static*/ DECLCALLBACK(int) Console::i_unplugCpu(Console *pThis, PUVM pUVM, PCVMMR3VTABLE pVMM, VMCPUID idCpu)
    22812323{
    22822324    LogFlowFunc(("pThis=%p pVM=%p idCpu=%u\n", pThis, pUVM, idCpu));
     
    22842326    AssertReturn(pThis, VERR_INVALID_PARAMETER);
    22852327
    2286     int vrc = PDMR3DeviceDetach(pUVM, "acpi", 0, idCpu, 0);
     2328    int vrc = pVMM->pfnPDMR3DeviceDetach(pUVM, "acpi", 0, idCpu, 0);
    22872329    Log(("UnplugCpu: rc=%Rrc\n", vrc));
    22882330
     
    22902332}
    22912333
    2292 HRESULT Console::i_doCPURemove(ULONG aCpu, PUVM pUVM)
     2334HRESULT Console::i_doCPURemove(ULONG aCpu, PUVM pUVM, PCVMMR3VTABLE pVMM)
    22932335{
    22942336    HRESULT rc = S_OK;
     
    23262368    /* Check if the CPU is unlocked */
    23272369    PPDMIBASE pBase;
    2328     int vrc = PDMR3QueryDeviceLun(pUVM, "acpi", 0, aCpu, &pBase);
     2370    int vrc = pVMM->pfnPDMR3QueryDeviceLun(pUVM, "acpi", 0, aCpu, &pBase);
    23292371    if (RT_SUCCESS(vrc))
    23302372    {
     
    23342376        /* Notify the guest if possible. */
    23352377        uint32_t idCpuCore, idCpuPackage;
    2336         vrc = VMR3GetCpuCoreAndPackageIdFromCpuId(pUVM, aCpu, &idCpuCore, &idCpuPackage); AssertRC(vrc);
     2378        vrc = pVMM->pfnVMR3GetCpuCoreAndPackageIdFromCpuId(pUVM, aCpu, &idCpuCore, &idCpuPackage); AssertRC(vrc);
    23372379        if (RT_SUCCESS(vrc))
    23382380            vrc = pVmmDevPort->pfnCpuHotUnplug(pVmmDevPort, idCpuCore, idCpuPackage);
     
    23662408         */
    23672409        PVMREQ pReq;
    2368         vrc = VMR3ReqCallU(pUVM, 0, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
    2369                            (PFNRT)i_unplugCpu, 3,
    2370                            this, pUVM, (VMCPUID)aCpu);
     2410        vrc = pVMM->pfnVMR3ReqCallU(pUVM, 0, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
     2411                                    (PFNRT)i_unplugCpu, 4,
     2412                                    this, pUVM, pVMM, (VMCPUID)aCpu);
    23712413
    23722414        if (vrc == VERR_TIMEOUT)
    2373             vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
     2415            vrc = pVMM->pfnVMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    23742416        AssertRC(vrc);
    23752417        if (RT_SUCCESS(vrc))
    23762418            vrc = pReq->iStatus;
    2377         VMR3ReqFree(pReq);
     2419        pVMM->pfnVMR3ReqFree(pReq);
    23782420
    23792421        if (RT_SUCCESS(vrc))
    23802422        {
    23812423            /* Detach it from the VM  */
    2382             vrc = VMR3HotUnplugCpu(pUVM, aCpu);
     2424            vrc = pVMM->pfnVMR3HotUnplugCpu(pUVM, aCpu);
    23832425            AssertRC(vrc);
    23842426        }
     
    23952437}
    23962438
    2397 /*static*/ DECLCALLBACK(int) Console::i_plugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu)
     2439/*static*/ DECLCALLBACK(int) Console::i_plugCpu(Console *pThis, PUVM pUVM, PCVMMR3VTABLE pVMM, VMCPUID idCpu)
    23982440{
    23992441    LogFlowFunc(("pThis=%p uCpu=%u\n", pThis, idCpu));
    2400 
    2401     AssertReturn(pThis, VERR_INVALID_PARAMETER);
    2402 
    2403     int rc = VMR3HotPlugCpu(pUVM, idCpu);
     2442    RT_NOREF(pThis);
     2443
     2444    int rc = pVMM->pfnVMR3HotPlugCpu(pUVM, idCpu);
    24042445    AssertRC(rc);
    24052446
    2406     PCFGMNODE pInst = CFGMR3GetChild(CFGMR3GetRootU(pUVM), "Devices/acpi/0/");
     2447    PCFGMNODE pInst = pVMM->pfnCFGMR3GetChild(pVMM->pfnCFGMR3GetRootU(pUVM), "Devices/acpi/0/");
    24072448    AssertRelease(pInst);
    24082449    /* nuke anything which might have been left behind. */
    2409     CFGMR3RemoveNode(CFGMR3GetChildF(pInst, "LUN#%u", idCpu));
     2450    pVMM->pfnCFGMR3RemoveNode(pVMM->pfnCFGMR3GetChildF(pInst, "LUN#%u", idCpu));
    24102451
    24112452#define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; } } while (0)
     
    24132454    PCFGMNODE pLunL0;
    24142455    PCFGMNODE pCfg;
    2415     rc = CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%u", idCpu);     RC_CHECK();
    2416     rc = CFGMR3InsertString(pLunL0, "Driver",       "ACPICpu"); RC_CHECK();
    2417     rc = CFGMR3InsertNode(pLunL0,   "Config",       &pCfg);     RC_CHECK();
     2456    rc = pVMM->pfnCFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%u", idCpu);    RC_CHECK();
     2457    rc = pVMM->pfnCFGMR3InsertString(pLunL0, "Driver",       "ACPICpu"); RC_CHECK();
     2458    rc = pVMM->pfnCFGMR3InsertNode(pLunL0,   "Config",       &pCfg);     RC_CHECK();
    24182459
    24192460    /*
     
    24212462     */
    24222463    PPDMIBASE pBase;
    2423     rc = PDMR3DeviceAttach(pUVM, "acpi", 0, idCpu, 0, &pBase); RC_CHECK();
     2464    rc = pVMM->pfnPDMR3DeviceAttach(pUVM, "acpi", 0, idCpu, 0, &pBase); RC_CHECK();
    24242465
    24252466    Log(("PlugCpu: rc=%Rrc\n", rc));
    24262467
    2427     CFGMR3Dump(pInst);
     2468    pVMM->pfnCFGMR3Dump(pInst);
    24282469
    24292470#undef RC_CHECK
     
    24322473}
    24332474
    2434 HRESULT Console::i_doCPUAdd(ULONG aCpu, PUVM pUVM)
     2475HRESULT Console::i_doCPUAdd(ULONG aCpu, PUVM pUVM, PCVMMR3VTABLE pVMM)
    24352476{
    24362477    HRESULT rc = S_OK;
     
    24702511     */
    24712512    PVMREQ pReq;
    2472     int vrc = VMR3ReqCallU(pUVM, 0, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
    2473                            (PFNRT)i_plugCpu, 3,
    2474                            this, pUVM, aCpu);
     2513    int vrc = pVMM->pfnVMR3ReqCallU(pUVM, 0, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
     2514                                    (PFNRT)i_plugCpu, 4,
     2515                                    this, pUVM, pVMM, aCpu);
    24752516
    24762517    /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
     
    24782519
    24792520    if (vrc == VERR_TIMEOUT)
    2480         vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
     2521        vrc = pVMM->pfnVMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    24812522    AssertRC(vrc);
    24822523    if (RT_SUCCESS(vrc))
    24832524        vrc = pReq->iStatus;
    2484     VMR3ReqFree(pReq);
     2525    pVMM->pfnVMR3ReqFree(pReq);
    24852526
    24862527    if (RT_SUCCESS(vrc))
     
    24882529        /* Notify the guest if possible. */
    24892530        uint32_t idCpuCore, idCpuPackage;
    2490         vrc = VMR3GetCpuCoreAndPackageIdFromCpuId(pUVM, aCpu, &idCpuCore, &idCpuPackage); AssertRC(vrc);
     2531        vrc = pVMM->pfnVMR3GetCpuCoreAndPackageIdFromCpuId(pUVM, aCpu, &idCpuCore, &idCpuPackage); AssertRC(vrc);
    24912532        if (RT_SUCCESS(vrc))
    24922533            vrc = pDevPort->pfnCpuHotPlug(pDevPort, idCpuCore, idCpuPackage);
     
    25442585    /* get the VM handle. */
    25452586    SafeVMPtr ptrVM(this);
    2546     if (!ptrVM.isOk())
    2547         return ptrVM.rc();
    2548 
    2549     // no need to release lock, as there are no cross-thread callbacks
    2550 
    2551     /* get the acpi device interface and press the button. */
    2552     PPDMIBASE pBase;
    2553     int vrc = PDMR3QueryDeviceLun(ptrVM.rawUVM(), "acpi", 0, 0, &pBase);
    2554     if (RT_SUCCESS(vrc))
    2555     {
    2556         Assert(pBase);
    2557         PPDMIACPIPORT pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIACPIPORT);
    2558         if (pPort)
    2559             vrc = pPort->pfnPowerButtonPress(pPort);
    2560         else
    2561             vrc = VERR_PDM_MISSING_INTERFACE;
    2562     }
    2563 
    2564     HRESULT rc = RT_SUCCESS(vrc) ? S_OK : setErrorBoth(VBOX_E_PDM_ERROR, vrc, tr("Controlled power off failed (%Rrc)"), vrc);
    2565 
    2566     LogFlowThisFunc(("rc=%Rhrc\n", rc));
     2587    HRESULT hrc = ptrVM.rc();
     2588    if (SUCCEEDED(hrc))
     2589    {
     2590        // no need to release lock, as there are no cross-thread callbacks
     2591
     2592        /* get the acpi device interface and press the button. */
     2593        PPDMIBASE pBase = NULL;
     2594        int vrc = ptrVM.vtable()->pfnPDMR3QueryDeviceLun(ptrVM.rawUVM(), "acpi", 0, 0, &pBase);
     2595        if (RT_SUCCESS(vrc))
     2596        {
     2597            Assert(pBase);
     2598            PPDMIACPIPORT pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIACPIPORT);
     2599            if (pPort)
     2600                vrc = pPort->pfnPowerButtonPress(pPort);
     2601            else
     2602                vrc = VERR_PDM_MISSING_INTERFACE;
     2603        }
     2604
     2605        hrc = RT_SUCCESS(vrc) ? S_OK : setErrorBoth(VBOX_E_PDM_ERROR, vrc, tr("Controlled power off failed (%Rrc)"), vrc);
     2606    }
     2607
     2608    LogFlowThisFunc(("hrc=%Rhrc\n", hrc));
    25672609    LogFlowThisFuncLeave();
    2568     return rc;
     2610    return hrc;
    25692611}
    25702612
     
    25852627    /* get the VM handle. */
    25862628    SafeVMPtr ptrVM(this);
    2587     if (!ptrVM.isOk())
    2588         return ptrVM.rc();
    2589 
    2590     // no need to release lock, as there are no cross-thread callbacks
    2591 
    2592     /* get the acpi device interface and check if the button press was handled. */
    2593     PPDMIBASE pBase;
    2594     int vrc = PDMR3QueryDeviceLun(ptrVM.rawUVM(), "acpi", 0, 0, &pBase);
    2595     if (RT_SUCCESS(vrc))
    2596     {
    2597         Assert(pBase);
    2598         PPDMIACPIPORT pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIACPIPORT);
    2599         if (pPort)
    2600         {
    2601             bool fHandled = false;
    2602             vrc = pPort->pfnGetPowerButtonHandled(pPort, &fHandled);
    2603             if (RT_SUCCESS(vrc))
    2604                 *aHandled = fHandled;
    2605         }
    2606         else
    2607             vrc = VERR_PDM_MISSING_INTERFACE;
    2608     }
    2609 
    2610     HRESULT rc = RT_SUCCESS(vrc) ? S_OK
    2611                : setErrorBoth(VBOX_E_PDM_ERROR, vrc,
    2612                               tr("Checking if the ACPI Power Button event was handled by the guest OS failed (%Rrc)"), vrc);
    2613 
    2614     LogFlowThisFunc(("rc=%Rhrc\n", rc));
     2629    HRESULT hrc = ptrVM.rc();
     2630    if (SUCCEEDED(hrc))
     2631    {
     2632        // no need to release lock, as there are no cross-thread callbacks
     2633
     2634        /* get the acpi device interface and check if the button press was handled. */
     2635        PPDMIBASE pBase;
     2636        int vrc = ptrVM.vtable()->pfnPDMR3QueryDeviceLun(ptrVM.rawUVM(), "acpi", 0, 0, &pBase);
     2637        if (RT_SUCCESS(vrc))
     2638        {
     2639            Assert(pBase);
     2640            PPDMIACPIPORT pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIACPIPORT);
     2641            if (pPort)
     2642            {
     2643                bool fHandled = false;
     2644                vrc = pPort->pfnGetPowerButtonHandled(pPort, &fHandled);
     2645                if (RT_SUCCESS(vrc))
     2646                    *aHandled = fHandled;
     2647            }
     2648            else
     2649                vrc = VERR_PDM_MISSING_INTERFACE;
     2650        }
     2651
     2652        hrc = RT_SUCCESS(vrc) ? S_OK
     2653            : setErrorBoth(VBOX_E_PDM_ERROR, vrc,
     2654                           tr("Checking if the ACPI Power Button event was handled by the guest OS failed (%Rrc)"), vrc);
     2655
     2656    }
     2657    LogFlowThisFunc(("hrc=%Rhrc\n", hrc));
    26152658    LogFlowThisFuncLeave();
    2616     return rc;
     2659    return hrc;
    26172660}
    26182661
     
    26352678    /* get the VM handle. */
    26362679    SafeVMPtr ptrVM(this);
    2637     if (!ptrVM.isOk())
    2638         return ptrVM.rc();
    2639 
    2640     // no need to release lock, as there are no cross-thread callbacks
    2641 
    2642     /* get the acpi device interface and query the information. */
    2643     PPDMIBASE pBase;
    2644     int vrc = PDMR3QueryDeviceLun(ptrVM.rawUVM(), "acpi", 0, 0, &pBase);
    2645     if (RT_SUCCESS(vrc))
    2646     {
    2647         Assert(pBase);
    2648         PPDMIACPIPORT pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIACPIPORT);
    2649         if (pPort)
    2650         {
    2651             bool fEntered = false;
    2652             vrc = pPort->pfnGetGuestEnteredACPIMode(pPort, &fEntered);
    2653             if (RT_SUCCESS(vrc))
    2654                 *aEntered = fEntered;
    2655         }
    2656         else
    2657             vrc = VERR_PDM_MISSING_INTERFACE;
     2680    HRESULT hrc = ptrVM.rc();
     2681    if (SUCCEEDED(hrc))
     2682    {
     2683        // no need to release lock, as there are no cross-thread callbacks
     2684
     2685        /* get the acpi device interface and query the information. */
     2686        PPDMIBASE pBase;
     2687        int vrc = ptrVM.vtable()->pfnPDMR3QueryDeviceLun(ptrVM.rawUVM(), "acpi", 0, 0, &pBase);
     2688        if (RT_SUCCESS(vrc))
     2689        {
     2690            Assert(pBase);
     2691            PPDMIACPIPORT pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIACPIPORT);
     2692            if (pPort)
     2693            {
     2694                bool fEntered = false;
     2695                vrc = pPort->pfnGetGuestEnteredACPIMode(pPort, &fEntered);
     2696                if (RT_SUCCESS(vrc))
     2697                    *aEntered = fEntered;
     2698            }
     2699            else
     2700                vrc = VERR_PDM_MISSING_INTERFACE;
     2701        }
    26582702    }
    26592703
    26602704    LogFlowThisFuncLeave();
    2661     return S_OK;
     2705    return hrc;
    26622706}
    26632707
     
    26752719    /* get the VM handle. */
    26762720    SafeVMPtr ptrVM(this);
    2677     if (!ptrVM.isOk())
    2678         return ptrVM.rc();
    2679 
    2680     // no need to release lock, as there are no cross-thread callbacks
    2681 
    2682     /* get the acpi device interface and press the sleep button. */
    2683     PPDMIBASE pBase;
    2684     int vrc = PDMR3QueryDeviceLun(ptrVM.rawUVM(), "acpi", 0, 0, &pBase);
    2685     if (RT_SUCCESS(vrc))
    2686     {
    2687         Assert(pBase);
    2688         PPDMIACPIPORT pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIACPIPORT);
    2689         if (pPort)
    2690             vrc = pPort->pfnSleepButtonPress(pPort);
    2691         else
    2692             vrc = VERR_PDM_MISSING_INTERFACE;
    2693     }
    2694 
    2695     HRESULT rc = RT_SUCCESS(vrc) ? S_OK : setErrorBoth(VBOX_E_PDM_ERROR, vrc, tr("Sending sleep button event failed (%Rrc)"), vrc);
    2696 
    2697     LogFlowThisFunc(("rc=%Rhrc\n", rc));
     2721    HRESULT hrc = ptrVM.rc();
     2722    if (SUCCEEDED(hrc))
     2723    {
     2724        // no need to release lock, as there are no cross-thread callbacks
     2725
     2726        /* get the acpi device interface and press the sleep button. */
     2727        PPDMIBASE pBase = NULL;
     2728        int vrc = ptrVM.vtable()->pfnPDMR3QueryDeviceLun(ptrVM.rawUVM(), "acpi", 0, 0, &pBase);
     2729        if (RT_SUCCESS(vrc))
     2730        {
     2731            Assert(pBase);
     2732            PPDMIACPIPORT pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIACPIPORT);
     2733            if (pPort)
     2734                vrc = pPort->pfnSleepButtonPress(pPort);
     2735            else
     2736                vrc = VERR_PDM_MISSING_INTERFACE;
     2737        }
     2738
     2739        hrc = RT_SUCCESS(vrc) ? S_OK : setErrorBoth(VBOX_E_PDM_ERROR, vrc, tr("Sending sleep button event failed (%Rrc)"), vrc);
     2740    }
     2741
     2742    LogFlowThisFunc(("hrc=%Rhrc\n", hrc));
    26982743    LogFlowThisFuncLeave();
    2699     return rc;
     2744    return hrc;
    27002745}
    27012746
     
    27102755}
    27112756
    2712 HRESULT Console::getDeviceActivity(const std::vector<DeviceType_T> &aType,
    2713                                    std::vector<DeviceActivity_T> &aActivity)
     2757HRESULT Console::getDeviceActivity(const std::vector<DeviceType_T> &aType, std::vector<DeviceActivity_T> &aActivity)
    27142758{
    27152759    /*
     
    27972841    /* Get the VM handle. */
    27982842    SafeVMPtr ptrVM(this);
    2799     if (!ptrVM.isOk())
    2800         return ptrVM.rc();
    2801 
    2802     /* Don't proceed unless we have a USB controller. */
    2803     if (!mfVMHasUsbController)
    2804         return setError(VBOX_E_PDM_ERROR, tr("The virtual machine does not have a USB controller"));
    2805 
    2806     /* release the lock because the USB Proxy service may call us back
    2807      * (via onUSBDeviceAttach()) */
    2808     alock.release();
    2809 
    2810     /* Request the device capture */
    2811     return mControl->CaptureUSBDevice(Bstr(aId.toString()).raw(), Bstr(aCaptureFilename).raw());
     2843    HRESULT hrc = ptrVM.rc();
     2844    if (SUCCEEDED(hrc))
     2845    {
     2846        /* Don't proceed unless we have a USB controller. */
     2847        if (mfVMHasUsbController)
     2848        {
     2849            /* release the lock because the USB Proxy service may call us back
     2850             * (via onUSBDeviceAttach()) */
     2851            alock.release();
     2852
     2853            /* Request the device capture */
     2854            hrc = mControl->CaptureUSBDevice(Bstr(aId.toString()).raw(), Bstr(aCaptureFilename).raw());
     2855        }
     2856        else
     2857            hrc = setError(VBOX_E_PDM_ERROR, tr("The virtual machine does not have a USB controller"));
     2858    }
     2859    return hrc;
    28122860
    28132861#else   /* !VBOX_WITH_USB */
     
    28212869    RT_NOREF(aDevice);
    28222870#ifdef VBOX_WITH_USB
    2823 
    28242871    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    28252872
    28262873    /* Find it. */
    2827     ComObjPtr<OUSBDevice> pUSBDevice;
    2828     USBDeviceList::iterator it = mUSBDevices.begin();
    2829     while (it != mUSBDevices.end())
    2830     {
     2874    for (USBDeviceList::iterator it = mUSBDevices.begin(); it != mUSBDevices.end(); ++it)
    28312875        if ((*it)->i_id() == aId)
    28322876        {
    2833             pUSBDevice = *it;
    2834             break;
    2835         }
    2836         ++it;
    2837     }
    2838 
    2839     if (!pUSBDevice)
    2840         return setError(E_INVALIDARG, tr("USB device with UUID {%RTuuid} is not attached to this machine"), aId.raw());
    2841 
    2842     /* Remove the device from the collection, it is re-added below for failures */
    2843     mUSBDevices.erase(it);
    2844 
    2845     /*
    2846      * Inform the USB device and USB proxy about what's cooking.
    2847      */
    2848     alock.release();
    2849     HRESULT rc = mControl->DetachUSBDevice(Bstr(aId.toString()).raw(), false /* aDone */);
    2850     if (FAILED(rc))
    2851     {
    2852         /* Re-add the device to the collection */
    2853         alock.acquire();
    2854         mUSBDevices.push_back(pUSBDevice);
    2855         return rc;
    2856     }
    2857 
    2858     /* Request the PDM to detach the USB device. */
    2859     rc = i_detachUSBDevice(pUSBDevice);
    2860     if (SUCCEEDED(rc))
    2861     {
    2862         /* Request the device release. Even if it fails, the device will
    2863          * remain as held by proxy, which is OK for us (the VM process). */
    2864         rc = mControl->DetachUSBDevice(Bstr(aId.toString()).raw(), true /* aDone */);
    2865     }
    2866     else
    2867     {
    2868         /* Re-add the device to the collection */
    2869         alock.acquire();
    2870         mUSBDevices.push_back(pUSBDevice);
    2871     }
    2872 
    2873     return rc;
    2874 
     2877            /* Found it! */
     2878            ComObjPtr<OUSBDevice> pUSBDevice(*it);
     2879
     2880            /* Remove the device from the collection, it is re-added below for failures */
     2881            mUSBDevices.erase(it);
     2882
     2883            /*
     2884             * Inform the USB device and USB proxy about what's cooking.
     2885             */
     2886            alock.release();
     2887            HRESULT hrc = mControl->DetachUSBDevice(Bstr(aId.toString()).raw(), false /* aDone */);
     2888            if (SUCCEEDED(hrc))
     2889            {
     2890                /* Request the PDM to detach the USB device. */
     2891                hrc = i_detachUSBDevice(pUSBDevice);
     2892                if (SUCCEEDED(hrc))
     2893                {
     2894                    /* Request the device release. Even if it fails, the device will
     2895                     * remain as held by proxy, which is OK for us (the VM process). */
     2896                    return mControl->DetachUSBDevice(Bstr(aId.toString()).raw(), true /* aDone */);
     2897                }
     2898            }
     2899
     2900            /* Re-add the device to the collection */
     2901            alock.acquire();
     2902            mUSBDevices.push_back(pUSBDevice);
     2903            return hrc;
     2904        }
     2905
     2906    return setError(E_INVALIDARG, tr("USB device with UUID {%RTuuid} is not attached to this machine"), aId.raw());
    28752907
    28762908#else   /* !VBOX_WITH_USB */
     
    28932925    for (size_t i = 0; i < devsvec.size(); ++i)
    28942926    {
    2895         Bstr address;
    2896         rc = devsvec[i]->COMGETTER(Address)(address.asOutParam());
     2927        Bstr bstrAddress;
     2928        rc = devsvec[i]->COMGETTER(Address)(bstrAddress.asOutParam());
    28972929        if (FAILED(rc)) return rc;
    2898         if (address == Bstr(aName))
     2930        if (bstrAddress == aName)
    28992931        {
    29002932            ComObjPtr<OUSBDevice> pUSBDevice;
     
    29232955    if (FAILED(rc)) return rc;
    29242956
     2957    Utf8Str const strId = aId.toString();
    29252958    for (size_t i = 0; i < devsvec.size(); ++i)
    29262959    {
     
    29282961        rc = devsvec[i]->COMGETTER(Id)(id.asOutParam());
    29292962        if (FAILED(rc)) return rc;
    2930         if (Utf8Str(id) == aId.toString())
     2963        if (id == strId)
    29312964        {
    29322965            ComObjPtr<OUSBDevice> pUSBDevice;
     
    29382971    }
    29392972
    2940     return setErrorNoLog(VBOX_E_OBJECT_NOT_FOUND, tr("Could not find a USB device with uuid {%RTuuid}"), Guid(aId).raw());
     2973    return setErrorNoLog(VBOX_E_OBJECT_NOT_FOUND, tr("Could not find a USB device with uuid {%RTuuid}"), aId.raw());
    29412974
    29422975#else   /* !VBOX_WITH_USB */
     
    30513084       )
    30523085    {
    3053         /* if the VM is online and supports shared folders, UNshare this
    3054          * folder. */
     3086        /* if the VM is online and supports shared folders, UNshare this folder. */
    30553087
    30563088        /* first, remove the given folder */
     
    31183150
    31193151                alock.release();
    3120                 vrc = VMR3Resume(ptrVM.rawUVM(), VMRESUMEREASON_RECONFIG);
     3152                vrc = ptrVM.vtable()->pfnVMR3Resume(ptrVM.rawUVM(), VMRESUMEREASON_RECONFIG);
    31213153
    31223154                hrc = RT_SUCCESS(vrc) ? S_OK
     
    32663298
    32673299
    3268 /* static */
    3269 const char *Console::i_storageControllerTypeToStr(StorageControllerType_T enmCtrlType)
     3300/**
     3301 * Converts to PDM device names.
     3302 */
     3303/* static */ const char *Console::i_storageControllerTypeToStr(StorageControllerType_T enmCtrlType)
    32703304{
    32713305    switch (enmCtrlType)
     
    33393373 *
    33403374 * @param pUVM              Safe VM handle.
     3375 * @param pVMM              Safe VMM vtable.
    33413376 * @param pAlock            The automatic lock instance. This is for when we have
    33423377 *                          to leave it in order to avoid deadlocks.
     
    33443379 *                          afterwards.
    33453380 */
    3346 HRESULT Console::i_suspendBeforeConfigChange(PUVM pUVM, AutoWriteLock *pAlock, bool *pfResume)
     3381HRESULT Console::i_suspendBeforeConfigChange(PUVM pUVM, PCVMMR3VTABLE pVMM, AutoWriteLock *pAlock, bool *pfResume)
    33473382{
    33483383    *pfResume = false;
    3349     VMSTATE enmVMState = VMR3GetStateU(pUVM);
     3384
     3385    VMSTATE enmVMState = pVMM->pfnVMR3GetStateU(pUVM);
    33503386    switch (enmVMState)
    33513387    {
     
    33593395            if (pAlock)
    33603396                pAlock->release();
    3361             int vrc = VMR3Suspend(pUVM, VMSUSPENDREASON_RECONFIG);
     3397            int vrc = pVMM->pfnVMR3Suspend(pUVM, VMSUSPENDREASON_RECONFIG);
    33623398            if (pAlock)
    33633399                pAlock->acquire();
     
    33843420                                     0 /* aResultDetail */,
    33853421                                     tr("Invalid state '%s' for changing medium"),
    3386                                      VMR3GetStateName(enmVMState));
     3422                                     pVMM->pfnVMR3GetStateName(enmVMState));
    33873423    }
    33883424
     
    33953431 *
    33963432 * @param pUVM              Safe VM handle.
    3397  */
    3398 void Console::i_resumeAfterConfigChange(PUVM pUVM)
     3433 * @param pVMM              Safe VMM vtable.
     3434 */
     3435void Console::i_resumeAfterConfigChange(PUVM pUVM, PCVMMR3VTABLE pVMM)
    33993436{
    34003437    LogFlowFunc(("Resuming the VM...\n"));
     3438
    34013439    /* disable the callback to prevent Console-level state change */
    34023440    mVMStateChangeCallbackDisabled = true;
    3403     int rc = VMR3Resume(pUVM, VMRESUMEREASON_RECONFIG);
     3441    int rc = pVMM->pfnVMR3Resume(pUVM, VMRESUMEREASON_RECONFIG);
    34043442    mVMStateChangeCallbackDisabled = false;
    34053443    AssertRC(rc);
    34063444    if (RT_FAILURE(rc))
    34073445    {
    3408         VMSTATE enmVMState = VMR3GetStateU(pUVM);
     3446        VMSTATE enmVMState = pVMM->pfnVMR3GetStateU(pUVM);
    34093447        if (enmVMState == VMSTATE_SUSPENDED)
    34103448        {
    34113449            /* too bad, we failed. try to sync the console state with the VMM state */
    3412             i_vmstateChangeCallback(pUVM, VMSTATE_SUSPENDED, enmVMState, this);
     3450            i_vmstateChangeCallback(pUVM, pVMM, VMSTATE_SUSPENDED, enmVMState, this);
    34133451        }
    34143452    }
     
    34213459 * @param fForce            Force medium chance, if it is locked or not.
    34223460 * @param pUVM              Safe VM handle.
     3461 * @param pVMM              Safe VMM vtable.
    34233462 *
    34243463 * @note Locks this object for writing.
    34253464 */
    3426 HRESULT Console::i_doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PUVM pUVM)
     3465HRESULT Console::i_doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PUVM pUVM, PCVMMR3VTABLE pVMM)
    34273466{
    34283467    AutoCaller autoCaller(this);
     
    34873526     */
    34883527    bool fResume = false;
    3489     rc = i_suspendBeforeConfigChange(pUVM, &alock, &fResume);
     3528    rc = i_suspendBeforeConfigChange(pUVM, pVMM, &alock, &fResume);
    34903529    if (FAILED(rc))
    34913530        return rc;
     
    34973536     */
    34983537    PVMREQ pReq;
    3499     int vrc = VMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
    3500                            (PFNRT)i_changeRemovableMedium, 8,
    3501                            this, pUVM, pszDevice, uInstance, enmBus, fUseHostIOCache, aMediumAttachment, fForce);
     3538    int vrc = pVMM->pfnVMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
     3539                                    (PFNRT)i_changeRemovableMedium, 9,
     3540                                    this, pUVM, pVMM, pszDevice, uInstance, enmBus, fUseHostIOCache, aMediumAttachment, fForce);
    35023541
    35033542    /* release the lock before waiting for a result (EMT might wait for it, @bugref{7648})! */
     
    35053544
    35063545    if (vrc == VERR_TIMEOUT)
    3507         vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
     3546        vrc = pVMM->pfnVMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    35083547    AssertRC(vrc);
    35093548    if (RT_SUCCESS(vrc))
    35103549        vrc = pReq->iStatus;
    3511     VMR3ReqFree(pReq);
     3550    pVMM->pfnVMR3ReqFree(pReq);
    35123551
    35133552    if (fResume)
    3514         i_resumeAfterConfigChange(pUVM);
     3553        i_resumeAfterConfigChange(pUVM, pVMM);
    35153554
    35163555    if (RT_SUCCESS(vrc))
     
    35323571 * @param   pThis           Pointer to the Console object.
    35333572 * @param   pUVM            The VM handle.
     3573 * @param   pVMM            The VMM vtable.
    35343574 * @param   pcszDevice      The PDM device name.
    35353575 * @param   uInstance       The PDM device instance.
     
    35443584DECLCALLBACK(int) Console::i_changeRemovableMedium(Console *pThis,
    35453585                                                   PUVM pUVM,
     3586                                                   PCVMMR3VTABLE pVMM,
    35463587                                                   const char *pcszDevice,
    35473588                                                   unsigned uInstance,
     
    35623603     * Check the VM for correct state.
    35633604     */
    3564     VMSTATE enmVMState = VMR3GetStateU(pUVM);
     3605    VMSTATE enmVMState = pVMM->pfnVMR3GetStateU(pUVM);
    35653606    AssertReturn(enmVMState == VMSTATE_SUSPENDED, VERR_INVALID_STATE);
    35663607
     
    35813622                                             false  /* fHotplug */,
    35823623                                             pUVM,
     3624                                             pVMM,
    35833625                                             NULL /* paLedDevType */,
    35843626                                             NULL /* ppLunL0 */);
     
    35933635 * @param aMediumAttachment The medium attachment which is added.
    35943636 * @param pUVM              Safe VM handle.
     3637 * @param pVMM              Safe VMM vtable.
    35953638 * @param fSilent           Flag whether to notify the guest about the attached device.
    35963639 *
    35973640 * @note Locks this object for writing.
    35983641 */
    3599 HRESULT Console::i_doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent)
     3642HRESULT Console::i_doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PUVM pUVM, PCVMMR3VTABLE pVMM, bool fSilent)
    36003643{
    36013644    AutoCaller autoCaller(this);
     
    36373680    }
    36383681    if (pStorageController.isNull())
    3639         return setError(E_FAIL,
    3640                         tr("Could not find storage controller '%ls'"), attCtrlName.raw());
     3682        return setError(E_FAIL, tr("Could not find storage controller '%ls'"), attCtrlName.raw());
    36413683
    36423684    StorageControllerType_T enmCtrlType;
     
    36603702     */
    36613703    bool fResume = false;
    3662     rc = i_suspendBeforeConfigChange(pUVM, &alock, &fResume);
     3704    rc = i_suspendBeforeConfigChange(pUVM, pVMM, &alock, &fResume);
    36633705    if (FAILED(rc))
    36643706        return rc;
     
    36703712     */
    36713713    PVMREQ pReq;
    3672     int vrc = VMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
    3673                            (PFNRT)i_attachStorageDevice, 8,
    3674                            this, pUVM, pszDevice, uInstance, enmBus, fUseHostIOCache, aMediumAttachment, fSilent);
     3714    int vrc = pVMM->pfnVMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
     3715                                    (PFNRT)i_attachStorageDevice, 9,
     3716                                    this, pUVM, pVMM, pszDevice, uInstance, enmBus, fUseHostIOCache, aMediumAttachment, fSilent);
    36753717
    36763718    /* release the lock before waiting for a result (EMT might wait for it, @bugref{7648})! */
     
    36783720
    36793721    if (vrc == VERR_TIMEOUT)
    3680         vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
     3722        vrc = pVMM->pfnVMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    36813723    AssertRC(vrc);
    36823724    if (RT_SUCCESS(vrc))
    36833725        vrc = pReq->iStatus;
    3684     VMR3ReqFree(pReq);
     3726    pVMM->pfnVMR3ReqFree(pReq);
    36853727
    36863728    if (fResume)
    3687         i_resumeAfterConfigChange(pUVM);
     3729        i_resumeAfterConfigChange(pUVM, pVMM);
    36883730
    36893731    if (RT_SUCCESS(vrc))
     
    37063748 * @param   pThis           Pointer to the Console object.
    37073749 * @param   pUVM            The VM handle.
     3750 * @param   pVMM            The VMM vtable.
    37083751 * @param   pcszDevice      The PDM device name.
    37093752 * @param   uInstance       The PDM device instance.
     
    37183761DECLCALLBACK(int) Console::i_attachStorageDevice(Console *pThis,
    37193762                                                 PUVM pUVM,
     3763                                                 PCVMMR3VTABLE pVMM,
    37203764                                                 const char *pcszDevice,
    37213765                                                 unsigned uInstance,
     
    37363780     * Check the VM for correct state.
    37373781     */
    3738     VMSTATE enmVMState = VMR3GetStateU(pUVM);
     3782    VMSTATE enmVMState = pVMM->pfnVMR3GetStateU(pUVM);
    37393783    AssertReturn(enmVMState == VMSTATE_SUSPENDED, VERR_INVALID_STATE);
    37403784
     
    37553799                                             !fSilent /* fHotplug */,
    37563800                                             pUVM,
     3801                                             pVMM,
    37573802                                             NULL /* paLedDevType */,
    37583803                                             NULL);
     
    37663811 * @param aMediumAttachment The medium attachment which is added.
    37673812 * @param pUVM              Safe VM handle.
     3813 * @param pVMM              Safe VMM vtable.
    37683814 * @param fSilent           Flag whether to notify the guest about the detached device.
    37693815 *
    37703816 * @note Locks this object for writing.
    37713817 */
    3772 HRESULT Console::i_doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent)
     3818HRESULT Console::i_doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PUVM pUVM, PCVMMR3VTABLE pVMM, bool fSilent)
    37733819{
    37743820    AutoCaller autoCaller(this);
     
    38103856    }
    38113857    if (pStorageController.isNull())
    3812         return setError(E_FAIL,
    3813                         tr("Could not find storage controller '%ls'"), attCtrlName.raw());
     3858        return setError(E_FAIL, tr("Could not find storage controller '%ls'"), attCtrlName.raw());
    38143859
    38153860    StorageControllerType_T enmCtrlType;
     
    38303875     */
    38313876    bool fResume = false;
    3832     rc = i_suspendBeforeConfigChange(pUVM, &alock, &fResume);
     3877    rc = i_suspendBeforeConfigChange(pUVM, pVMM, &alock, &fResume);
    38333878    if (FAILED(rc))
    38343879        return rc;
     
    38403885     */
    38413886    PVMREQ pReq;
    3842     int vrc = VMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
    3843                            (PFNRT)i_detachStorageDevice, 7,
    3844                            this, pUVM, pszDevice, uInstance, enmBus, aMediumAttachment, fSilent);
     3887    int vrc = pVMM->pfnVMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
     3888                                    (PFNRT)i_detachStorageDevice, 8,
     3889                                    this, pUVM, pVMM, pszDevice, uInstance, enmBus, aMediumAttachment, fSilent);
    38453890
    38463891    /* release the lock before waiting for a result (EMT might wait for it, @bugref{7648})! */
     
    38483893
    38493894    if (vrc == VERR_TIMEOUT)
    3850         vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
     3895        vrc = pVMM->pfnVMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    38513896    AssertRC(vrc);
    38523897    if (RT_SUCCESS(vrc))
    38533898        vrc = pReq->iStatus;
    3854     VMR3ReqFree(pReq);
     3899    pVMM->pfnVMR3ReqFree(pReq);
    38553900
    38563901    if (fResume)
    3857         i_resumeAfterConfigChange(pUVM);
     3902        i_resumeAfterConfigChange(pUVM, pVMM);
    38583903
    38593904    if (RT_SUCCESS(vrc))
     
    38753920 * @param   pThis           Pointer to the Console object.
    38763921 * @param   pUVM            The VM handle.
     3922 * @param   pVMM            The VMM vtable.
    38773923 * @param   pcszDevice      The PDM device name.
    38783924 * @param   uInstance       The PDM device instance.
     
    38863932DECLCALLBACK(int) Console::i_detachStorageDevice(Console *pThis,
    38873933                                                 PUVM pUVM,
     3934                                                 PCVMMR3VTABLE pVMM,
    38883935                                                 const char *pcszDevice,
    38893936                                                 unsigned uInstance,
     
    39033950     * Check the VM for correct state.
    39043951     */
    3905     VMSTATE enmVMState = VMR3GetStateU(pUVM);
     3952    VMSTATE enmVMState = pVMM->pfnVMR3GetStateU(pUVM);
    39063953    AssertReturn(enmVMState == VMSTATE_SUSPENDED, VERR_INVALID_STATE);
    39073954
    39083955    /* Determine the base path for the device instance. */
    39093956    PCFGMNODE pCtlInst;
    3910     pCtlInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "Devices/%s/%u/", pcszDevice, uInstance);
     3957    pCtlInst = pVMM->pfnCFGMR3GetChildF(pVMM->pfnCFGMR3GetRootU(pUVM), "Devices/%s/%u/", pcszDevice, uInstance);
    39113958    AssertReturn(pCtlInst || enmBus == StorageBus_USB, VERR_INTERNAL_ERROR);
    39123959
     
    39323979    {
    39333980        /* First check if the LUN really exists. */
    3934         pLunL0 = CFGMR3GetChildF(pCtlInst, "LUN#%u", uLUN);
     3981        pLunL0 = pVMM->pfnCFGMR3GetChildF(pCtlInst, "LUN#%u", uLUN);
    39353982        if (pLunL0)
    39363983        {
     
    39403987                fFlags |= PDM_TACH_FLAGS_NOT_HOT_PLUG;
    39413988
    3942             rc = PDMR3DeviceDetach(pUVM, pcszDevice, uInstance, uLUN, fFlags);
     3989            rc = pVMM->pfnPDMR3DeviceDetach(pUVM, pcszDevice, uInstance, uLUN, fFlags);
    39433990            if (rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN)
    39443991                rc = VINF_SUCCESS;
    39453992            AssertRCReturn(rc, rc);
    3946             CFGMR3RemoveNode(pLunL0);
     3993            pVMM->pfnCFGMR3RemoveNode(pLunL0);
    39473994
    39483995            Utf8Str devicePath = Utf8StrFmt("%s/%u/LUN#%u", pcszDevice, uInstance, uLUN);
     
    39534000            AssertFailedReturn(VERR_INTERNAL_ERROR);
    39544001
    3955         CFGMR3Dump(pCtlInst);
     4002        pVMM->pfnCFGMR3Dump(pCtlInst);
    39564003    }
    39574004#ifdef VBOX_WITH_USB
     
    39674014
    39684015        AssertReturn(it != pThis->mUSBStorageDevices.end(), VERR_INTERNAL_ERROR);
    3969         rc = PDMR3UsbDetachDevice(pUVM, &it->mUuid);
     4016        rc = pVMM->pfnPDMR3UsbDetachDevice(pUVM, &it->mUuid);
    39704017        AssertRCReturn(rc, rc);
    39714018        pThis->mUSBStorageDevices.erase(it);
     
    40244071                    alock.release();
    40254072
    4026                     PPDMIBASE pBase;
    4027                     int vrc = PDMR3QueryDeviceLun(ptrVM.rawUVM(), pszAdapterName, ulInstance, 0, &pBase);
     4073                    PPDMIBASE pBase = NULL;
     4074                    int vrc = ptrVM.vtable()->pfnPDMR3QueryDeviceLun(ptrVM.rawUVM(), pszAdapterName, ulInstance, 0, &pBase);
    40284075                    if (RT_SUCCESS(vrc))
    40294076                    {
     
    40424089                        if (RT_SUCCESS(vrc) && changeAdapter)
    40434090                        {
    4044                             VMSTATE enmVMState = VMR3GetStateU(ptrVM.rawUVM());
     4091                            VMSTATE enmVMState = mpVMM->pfnVMR3GetStateU(ptrVM.rawUVM());
    40454092                            if (    enmVMState == VMSTATE_RUNNING    /** @todo LiveMigration: Forbid or deal
    40464093                                                                         correctly with the _LS variants */
     
    40534100                                }
    40544101
    4055                                 rc = i_doNetworkAdapterChange(ptrVM.rawUVM(), pszAdapterName, ulInstance, 0, aNetworkAdapter);
     4102                                rc = i_doNetworkAdapterChange(ptrVM.rawUVM(), ptrVM.vtable(), pszAdapterName,
     4103                                                              ulInstance, 0, aNetworkAdapter);
    40564104
    40574105                                if (fTraceEnabled && fCableConnected && pINetCfg)
     
    41334181            const char *pszAdapterName = networkAdapterTypeToName(adapterType);
    41344182            PPDMIBASE pBase;
    4135             int vrc = PDMR3QueryLun(ptrVM.rawUVM(), pszAdapterName, ulInstance, 0, &pBase);
     4183            int vrc = ptrVM.vtable()->pfnPDMR3QueryLun(ptrVM.rawUVM(), pszAdapterName, ulInstance, 0, &pBase);
    41364184            if (RT_FAILURE(vrc))
    41374185            {
     
    42374285            ULONG ulInstanceMax = (ULONG)Global::getMaxNetworkAdapters(enmChipsetType);
    42384286
    4239             notifyNatDnsChange(ptrVM.rawUVM(), "pcnet", ulInstanceMax);
    4240             notifyNatDnsChange(ptrVM.rawUVM(), "e1000", ulInstanceMax);
    4241             notifyNatDnsChange(ptrVM.rawUVM(), "virtio-net", ulInstanceMax);
     4287            notifyNatDnsChange(ptrVM.rawUVM(), ptrVM.vtable(), "pcnet", ulInstanceMax);
     4288            notifyNatDnsChange(ptrVM.rawUVM(), ptrVM.vtable(), "e1000", ulInstanceMax);
     4289            notifyNatDnsChange(ptrVM.rawUVM(), ptrVM.vtable(), "virtio-net", ulInstanceMax);
    42424290        }
    42434291    }
     
    42524300 * change callback.
    42534301 */
    4254 void Console::notifyNatDnsChange(PUVM pUVM, const char *pszDevice, ULONG ulInstanceMax)
     4302void Console::notifyNatDnsChange(PUVM pUVM, PCVMMR3VTABLE pVMM, const char *pszDevice, ULONG ulInstanceMax)
    42554303{
    42564304    Log(("notifyNatDnsChange: looking for DrvNAT attachment on %s device instances\n", pszDevice));
     
    42584306    {
    42594307        PPDMIBASE pBase;
    4260         int rc = PDMR3QueryDriverOnLun(pUVM, pszDevice, ulInstance, 0 /* iLun */, "NAT", &pBase);
     4308        int rc = pVMM->pfnPDMR3QueryDriverOnLun(pUVM, pszDevice, ulInstance, 0 /* iLun */, "NAT", &pBase);
    42614309        if (RT_FAILURE(rc))
    42624310            continue;
     
    44124460        PPDMIBASE pIBase = NULL;
    44134461        PPDMIMEDIA pIMedium = NULL;
    4414         int rc = PDMR3QueryDriverOnLun(ptrVM.rawUVM(), pcszDevice, ulStorageCtrlInst, uLUN, "VD", &pIBase);
     4462        int rc = ptrVM.vtable()->pfnPDMR3QueryDriverOnLun(ptrVM.rawUVM(), pcszDevice, ulStorageCtrlInst, uLUN, "VD", &pIBase);
    44154463        if (RT_SUCCESS(rc))
    44164464        {
     
    45244572            PPDMIBASE pIBase = NULL;
    45254573            PPDMIMEDIA pIMedium = NULL;
    4526             int rc = PDMR3QueryDriverOnLun(ptrVM.rawUVM(), pcszDevice, ulStorageCtrlInst, uLUN, "VD", &pIBase);
     4574            int rc = ptrVM.vtable()->pfnPDMR3QueryDriverOnLun(ptrVM.rawUVM(), pcszDevice, ulStorageCtrlInst, uLUN, "VD", &pIBase);
    45274575            if (RT_SUCCESS(rc))
    45284576            {
     
    46474695            PPDMIBASE pIBase = NULL;
    46484696            PPDMIMEDIA pIMedium = NULL;
    4649             int vrc = PDMR3QueryDriverOnLun(ptrVM.rawUVM(), pcszDevice, ulStorageCtrlInst, uLUN, "VD", &pIBase);
     4697            int vrc = ptrVM.vtable()->pfnPDMR3QueryDriverOnLun(ptrVM.rawUVM(), pcszDevice, ulStorageCtrlInst, uLUN, "VD", &pIBase);
    46504698            if (RT_SUCCESS(vrc))
    46514699            {
     
    48314879 *
    48324880 * @param   pUVM                The VM handle (caller hold this safely).
     4881 * @param   pVMM                The VMM vtable.
    48334882 * @param   pszDevice           The PDM device name.
    48344883 * @param   uInstance           The PDM device instance.
     
    48364885 * @param   aNetworkAdapter     The network adapter whose attachment needs to be changed
    48374886 */
    4838 HRESULT Console::i_doNetworkAdapterChange(PUVM pUVM,
    4839                                           const char *pszDevice,
    4840                                           unsigned uInstance,
    4841                                           unsigned uLun,
    4842                                           INetworkAdapter *aNetworkAdapter)
     4887HRESULT Console::i_doNetworkAdapterChange(PUVM pUVM, PCVMMR3VTABLE pVMM, const char *pszDevice,
     4888                                          unsigned uInstance, unsigned uLun, INetworkAdapter *aNetworkAdapter)
    48434889{
    48444890    LogFlowThisFunc(("pszDevice=%p:{%s} uInstance=%u uLun=%u aNetworkAdapter=%p\n",
     
    48524898     */
    48534899    bool fResume = false;
    4854     HRESULT hr = i_suspendBeforeConfigChange(pUVM, NULL, &fResume);
     4900    HRESULT hr = i_suspendBeforeConfigChange(pUVM, pVMM, NULL, &fResume);
    48554901    if (FAILED(hr))
    48564902        return hr;
     
    48614907     * here to make requests from under the lock in order to serialize them.
    48624908     */
    4863     int rc = VMR3ReqCallWaitU(pUVM, 0 /*idDstCpu*/,
    4864                               (PFNRT)i_changeNetworkAttachment, 6,
    4865                               this, pUVM, pszDevice, uInstance, uLun, aNetworkAdapter);
     4909    int rc = pVMM->pfnVMR3ReqCallWaitU(pUVM, 0 /*idDstCpu*/,
     4910                                       (PFNRT)i_changeNetworkAttachment, 7,
     4911                                       this, pUVM, pVMM, pszDevice, uInstance, uLun, aNetworkAdapter);
    48664912
    48674913    if (fResume)
    4868         i_resumeAfterConfigChange(pUVM);
     4914        i_resumeAfterConfigChange(pUVM, pVMM);
    48694915
    48704916    if (RT_SUCCESS(rc))
     
    48824928 * @param   pThis               Pointer to the Console object.
    48834929 * @param   pUVM                The VM handle.
     4930 * @param   pVMM                The VMM vtable.
    48844931 * @param   pszDevice           The PDM device name.
    48854932 * @param   uInstance           The PDM device instance.
     
    48934940DECLCALLBACK(int) Console::i_changeNetworkAttachment(Console *pThis,
    48944941                                                     PUVM pUVM,
     4942                                                     PCVMMR3VTABLE pVMM,
    48954943                                                     const char *pszDevice,
    48964944                                                     unsigned uInstance,
     
    49274975     * Check the VM for correct state.
    49284976     */
    4929     VMSTATE enmVMState = VMR3GetStateU(pUVM);
    4930     AssertReturn(enmVMState == VMSTATE_SUSPENDED, VERR_INVALID_STATE);
    4931 
    49324977    PCFGMNODE pCfg = NULL;          /* /Devices/Dev/.../Config/ */
    49334978    PCFGMNODE pLunL0 = NULL;        /* /Devices/Dev/0/LUN#0/ */
    4934     PCFGMNODE pInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "Devices/%s/%d/", pszDevice, uInstance);
     4979    PCFGMNODE pInst = pVMM->pfnCFGMR3GetChildF(pVMM->pfnCFGMR3GetRootU(pUVM), "Devices/%s/%d/", pszDevice, uInstance);
    49354980    AssertRelease(pInst);
    49364981
    49374982    int rc = pThis->i_configNetwork(pszDevice, uInstance, uLun, aNetworkAdapter, pCfg, pLunL0, pInst,
    4938                                   true /*fAttachDetach*/, false /*fIgnoreConnectFailure*/);
     4983                                    true /*fAttachDetach*/, false /*fIgnoreConnectFailure*/, pUVM, pVMM);
    49394984
    49404985    LogFlowFunc(("Returning %Rrc\n", rc));
     
    50015046                {
    50025047                    PPDMIBASE pBase;
    5003                     int rc2 = PDMR3QueryDriverOnLun(ptrVM.rawUVM(),
    5004                                                     i_getAudioAdapterDeviceName(aAudioAdapter).c_str(), 0 /* iInstance */,
    5005                                                     ulLUN, "AUDIO", &pBase);
     5048                    int rc2 = ptrVM.vtable()->pfnPDMR3QueryDriverOnLun(ptrVM.rawUVM(),
     5049                                                                       i_getAudioAdapterDeviceName(aAudioAdapter).c_str(),
     5050                                                                       0 /* iInstance */, ulLUN, "AUDIO", &pBase);
    50065051                    if (RT_FAILURE(rc2))
    50075052                        continue;
     
    50095054                    if (pBase)
    50105055                    {
    5011                         PPDMIAUDIOCONNECTOR pAudioCon =
    5012                              (PPDMIAUDIOCONNECTOR)pBase->pfnQueryInterface(pBase, PDMIAUDIOCONNECTOR_IID);
    5013 
     5056                        PPDMIAUDIOCONNECTOR pAudioCon = (PPDMIAUDIOCONNECTOR)pBase->pfnQueryInterface(pBase,
     5057                                                                                                      PDMIAUDIOCONNECTOR_IID);
    50145058                        if (   pAudioCon
    50155059                            && pAudioCon->pfnEnable)
     
    50615105 * @param   pThis               Pointer to the Console object.
    50625106 * @param   pUVM                The VM handle.
     5107 * @param   pVMM                The VMM vtable.
    50635108 * @param   pSerialPort         The serial port whose attachment needs to be changed
    50645109 *
     
    50675112 * @note The VM must not be running.
    50685113 */
    5069 DECLCALLBACK(int) Console::i_changeSerialPortAttachment(Console *pThis, PUVM pUVM,
    5070                                                         ISerialPort *pSerialPort)
     5114DECLCALLBACK(int) Console::i_changeSerialPortAttachment(Console *pThis, PUVM pUVM, PCVMMR3VTABLE pVMM, ISerialPort *pSerialPort)
    50715115{
    50725116    LogFlowFunc(("pThis=%p pUVM=%p pSerialPort=%p\n", pThis, pUVM, pSerialPort));
     
    50825126     * Check the VM for correct state.
    50835127     */
    5084     VMSTATE enmVMState = VMR3GetStateU(pUVM);
     5128    VMSTATE enmVMState = pVMM->pfnVMR3GetStateU(pUVM);
    50855129    AssertReturn(enmVMState == VMSTATE_SUSPENDED, VERR_INVALID_STATE);
    50865130
     
    50985142        if (SUCCEEDED(hrc))
    50995143        {
    5100             PCFGMNODE pInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "Devices/serial/%d/", ulSlot);
     5144            PCFGMNODE pInst = pVMM->pfnCFGMR3GetChildF(pVMM->pfnCFGMR3GetRootU(pUVM), "Devices/serial/%d/", ulSlot);
    51015145            AssertRelease(pInst);
    51025146
     
    51045148            if (pThis->m_aeSerialPortMode[ulSlot] != PortMode_Disconnected)
    51055149            {
    5106                 rc = PDMR3DeviceDetach(pUVM, "serial", ulSlot, 0, 0);
    5107                 PCFGMNODE pLunL0 = CFGMR3GetChildF(pInst, "LUN#0");
    5108                 CFGMR3RemoveNode(pLunL0);
     5150                rc = pVMM->pfnPDMR3DeviceDetach(pUVM, "serial", ulSlot, 0, 0);
     5151                PCFGMNODE pLunL0 = pVMM->pfnCFGMR3GetChildF(pInst, "LUN#0");
     5152                pVMM->pfnCFGMR3RemoveNode(pLunL0);
    51095153            }
    51105154
     
    51285172                         */
    51295173                        PPDMIBASE pBase;
    5130                         rc = PDMR3DeviceAttach(pUVM, "serial", ulSlot, 0, 0, &pBase);
    5131 
    5132                         CFGMR3Dump(pInst);
     5174                        rc = pVMM->pfnPDMR3DeviceAttach(pUVM, "serial", ulSlot, 0, 0, &pBase);
     5175
     5176                        pVMM->pfnCFGMR3Dump(pInst);
    51335177                    }
    51345178                }
     
    51795223                 */
    51805224                bool fResume = false;
    5181                 HRESULT hr = i_suspendBeforeConfigChange(ptrVM.rawUVM(), NULL, &fResume);
     5225                HRESULT hr = i_suspendBeforeConfigChange(ptrVM.rawUVM(), ptrVM.vtable(), NULL, &fResume);
    51825226                if (FAILED(hr))
    51835227                    return hr;
     
    51875231                 * using VM3ReqCallWait.
    51885232                 */
    5189                 int rc = VMR3ReqCallWaitU(ptrVM.rawUVM(), 0 /*idDstCpu*/,
    5190                                           (PFNRT)i_changeSerialPortAttachment, 6,
    5191                                           this, ptrVM.rawUVM(), aSerialPort);
     5233                int rc = ptrVM.vtable()->pfnVMR3ReqCallWaitU(ptrVM.rawUVM(), 0 /*idDstCpu*/,
     5234                                                             (PFNRT)i_changeSerialPortAttachment, 4,
     5235                                                             this, ptrVM.rawUVM(), ptrVM.vtable(), aSerialPort);
    51925236
    51935237                if (fResume)
    5194                     i_resumeAfterConfigChange(ptrVM.rawUVM());
     5238                    i_resumeAfterConfigChange(ptrVM.rawUVM(), ptrVM.vtable());
    51955239                if (RT_SUCCESS(rc))
    51965240                    m_aeSerialPortMode[ulSlot] = eHostMode;
     
    52565300    if (ptrVM.isOk())
    52575301    {
    5258         rc = i_doMediumChange(aMediumAttachment, !!aForce, ptrVM.rawUVM());
     5302        rc = i_doMediumChange(aMediumAttachment, !!aForce, ptrVM.rawUVM(), ptrVM.vtable());
    52595303        ptrVM.release();
    52605304    }
     
    52875331    {
    52885332        if (aRemove)
    5289             rc = i_doCPURemove(aCPU, ptrVM.rawUVM());
     5333            rc = i_doCPURemove(aCPU, ptrVM.rawUVM(), ptrVM.vtable());
    52905334        else
    5291             rc = i_doCPUAdd(aCPU, ptrVM.rawUVM());
     5335            rc = i_doCPUAdd(aCPU, ptrVM.rawUVM(), ptrVM.vtable());
    52925336        ptrVM.release();
    52935337    }
     
    53275371        {
    53285372            /* No need to call in the EMT thread. */
    5329             rc = VMR3SetCpuExecutionCap(ptrVM.rawUVM(), aExecutionCap);
     5373            rc = ptrVM.vtable()->pfnVMR3SetCpuExecutionCap(ptrVM.rawUVM(), aExecutionCap);
    53305374        }
    53315375        else
     
    55755619                            {
    55765620#ifdef VBOX_WITH_AUDIO_VRDE
    5577                                 mAudioVRDE->doAttachDriverViaEmt(mpUVM, NULL /*alock is not held*/);
     5621                                mAudioVRDE->doAttachDriverViaEmt(ptrVM.rawUVM(), ptrVM.vtable(), NULL /*alock is not held*/);
    55785622#endif
    55795623                                mConsoleVRDPServer->EnableConnections();
     
    55845628                            mConsoleVRDPServer->Stop();
    55855629#ifdef VBOX_WITH_AUDIO_VRDE
    5586                             mAudioVRDE->doDetachDriverViaEmt(mpUVM, NULL /*alock is not held*/);
     5630                            mAudioVRDE->doDetachDriverViaEmt(ptrVM.rawUVM(), ptrVM.vtable(), NULL /*alock is not held*/);
    55875631#endif
    55885632                        }
     
    56395683    /* get the acpi device interface and press the sleep button. */
    56405684    PPDMIBASE pBase;
    5641     int vrc = PDMR3QueryDeviceLun(ptrVM.rawUVM(), "acpi", 0, 0, &pBase);
     5685    int vrc = ptrVM.vtable()->pfnPDMR3QueryDeviceLun(ptrVM.rawUVM(), "acpi", 0, 0, &pBase);
    56425686    if (RT_SUCCESS(vrc))
    56435687    {
     
    56755719    if (pDisplay)
    56765720    {
    5677         const bool fIsEnabled =    Recording.mpCtx
    5678                                 && Recording.mpCtx->IsStarted();
     5721        const bool fIsEnabled =    mRecording.mpCtx
     5722                                && mRecording.mpCtx->IsStarted();
    56795723
    56805724        if (RT_BOOL(fEnable) != fIsEnabled)
     
    56825726            LogRel(("Recording: %s\n", fEnable ? "Enabling" : "Disabling"));
    56835727
    5684             if (fEnable)
     5728            SafeVMPtrQuiet ptrVM(this);
     5729            if (ptrVM.isOk())
    56855730            {
    5686                 vrc = i_recordingCreate();
    5687                 if (RT_SUCCESS(vrc))
     5731                if (fEnable)
    56885732                {
     5733                    vrc = i_recordingCreate();
     5734                    if (RT_SUCCESS(vrc))
     5735                    {
    56895736# ifdef VBOX_WITH_AUDIO_RECORDING
    5690                     /* Attach the video recording audio driver if required. */
    5691                     if (   Recording.mpCtx->IsFeatureEnabled(RecordingFeature_Audio)
    5692                         && Recording.mAudioRec)
    5693                     {
    5694                         vrc = Recording.mAudioRec->applyConfiguration(Recording.mpCtx->GetConfig());
    5695                         if (RT_SUCCESS(vrc))
    5696                             vrc = Recording.mAudioRec->doAttachDriverViaEmt(mpUVM, pAutoLock);
     5737                        /* Attach the video recording audio driver if required. */
     5738                        if (   mRecording.mpCtx->IsFeatureEnabled(RecordingFeature_Audio)
     5739                            && mRecording.mAudioRec)
     5740                        {
     5741                            vrc = mRecording.mAudioRec->applyConfiguration(mRecording.mpCtx->GetConfig());
     5742                            if (RT_SUCCESS(vrc))
     5743                                vrc = mRecording.mAudioRec->doAttachDriverViaEmt(ptrVM.rawUVM(), ptrVM.vtable(), pAutoLock);
     5744                        }
     5745# endif
     5746                        if (   RT_SUCCESS(vrc)
     5747                            && mRecording.mpCtx->IsReady()) /* Any video recording (audio and/or video) feature enabled? */
     5748                        {
     5749                            vrc = pDisplay->i_recordingInvalidate();
     5750                            if (RT_SUCCESS(vrc))
     5751                                vrc = i_recordingStart(pAutoLock);
     5752                        }
    56975753                    }
     5754
     5755                    if (RT_FAILURE(vrc))
     5756                        LogRel(("Recording: Failed to enable with %Rrc\n", vrc));
     5757                }
     5758                else
     5759                {
     5760                    i_recordingStop(pAutoLock);
     5761# ifdef VBOX_WITH_AUDIO_RECORDING
     5762                    if (mRecording.mAudioRec)
     5763                        mRecording.mAudioRec->doDetachDriverViaEmt(ptrVM.rawUVM(), ptrVM.vtable(), pAutoLock);
    56985764# endif
    5699                     if (   RT_SUCCESS(vrc)
    5700                         && Recording.mpCtx->IsReady()) /* Any video recording (audio and/or video) feature enabled? */
    5701                     {
    5702                         vrc = pDisplay->i_recordingInvalidate();
    5703                         if (RT_SUCCESS(vrc))
    5704                             vrc = i_recordingStart(pAutoLock);
    5705                     }
     5765                    i_recordingDestroy();
    57065766                }
    5707 
    5708                 if (RT_FAILURE(vrc))
    5709                     LogRel(("Recording: Failed to enable with %Rrc\n", vrc));
    57105767            }
    57115768            else
    5712             {
    5713                 i_recordingStop(pAutoLock);
    5714 # ifdef VBOX_WITH_AUDIO_RECORDING
    5715                 if (Recording.mAudioRec)
    5716                     Recording.mAudioRec->doDetachDriverViaEmt(mpUVM, pAutoLock);
    5717 # endif
    5718                 i_recordingDestroy();
    5719             }
     5769                vrc = VERR_VM_INVALID_VM_STATE;
    57205770
    57215771            if (RT_FAILURE(vrc))
     
    58375887         * (e.g. it may be Saving or Stopping or just PoweredOff) --
    58385888         * autoVMCaller.rc() will return a failure in this case. */
    5839         LogFlowThisFunc(("Attach request ignored (mMachineState=%d).\n",
    5840                           mMachineState));
     5889        LogFlowThisFunc(("Attach request ignored (mMachineState=%d).\n", mMachineState));
    58415890        return ptrVM.rc();
    58425891    }
     
    58515900
    58525901    /* Don't proceed unless there's at least one USB hub. */
    5853     if (!PDMR3UsbHasHub(ptrVM.rawUVM()))
     5902    if (!ptrVM.vtable()->pfnPDMR3UsbHasHub(ptrVM.rawUVM()))
    58545903    {
    58555904        LogFlowThisFunc(("Attach request ignored (no USB controller).\n"));
     
    60006049        {
    60016050            /* No need to call in the EMT thread. */
    6002             Bstr strName;
    6003             rc = aBandwidthGroup->COMGETTER(Name)(strName.asOutParam());
     6051            Bstr bstrName;
     6052            rc = aBandwidthGroup->COMGETTER(Name)(bstrName.asOutParam());
    60046053            if (SUCCEEDED(rc))
    60056054            {
     6055                Utf8Str const strName(bstrName);
    60066056                LONG64 cMax;
    60076057                rc = aBandwidthGroup->COMGETTER(MaxBytesPerSec)(&cMax);
     
    60146064                        int vrc = VINF_SUCCESS;
    60156065                        if (enmType == BandwidthGroupType_Disk)
    6016                             vrc = PDMR3AsyncCompletionBwMgrSetMaxForFile(ptrVM.rawUVM(), Utf8Str(strName).c_str(), (uint32_t)cMax);
     6066                            vrc = ptrVM.vtable()->pfnPDMR3AsyncCompletionBwMgrSetMaxForFile(ptrVM.rawUVM(), strName.c_str(),
     6067                                                                                            (uint32_t)cMax);
    60176068#ifdef VBOX_WITH_NETSHAPER
    60186069                        else if (enmType == BandwidthGroupType_Network)
    6019                             vrc = PDMR3NsBwGroupSetLimit(ptrVM.rawUVM(), Utf8Str(strName).c_str(), cMax);
     6070                            vrc = ptrVM.vtable()->pfnPDMR3NsBwGroupSetLimit(ptrVM.rawUVM(), strName.c_str(), cMax);
    60206071                        else
    60216072                            rc = E_NOTIMPL;
     
    60616112    {
    60626113        if (aRemove)
    6063             rc = i_doStorageDeviceDetach(aMediumAttachment, ptrVM.rawUVM(), RT_BOOL(aSilent));
     6114            rc = i_doStorageDeviceDetach(aMediumAttachment, ptrVM.rawUVM(), ptrVM.vtable(), RT_BOOL(aSilent));
    60646115        else
    6065             rc = i_doStorageDeviceAttach(aMediumAttachment, ptrVM.rawUVM(), RT_BOOL(aSilent));
     6116            rc = i_doStorageDeviceAttach(aMediumAttachment, ptrVM.rawUVM(), ptrVM.vtable(), RT_BOOL(aSilent));
    60666117        ptrVM.release();
    60676118    }
     
    60936144        {
    60946145            mfTurnResetIntoPowerOff = aVal == "1";
    6095             int vrc = VMR3SetPowerOffInsteadOfReset(ptrVM.rawUVM(), mfTurnResetIntoPowerOff);
     6146            int vrc = ptrVM.vtable()->pfnVMR3SetPowerOffInsteadOfReset(ptrVM.rawUVM(), mfTurnResetIntoPowerOff);
    60966147            AssertRC(vrc);
    60976148
     
    64136464    /* Pause the VM, as it might have pending IO on this drive */
    64146465    bool fResume = false;
    6415     rc = i_suspendBeforeConfigChange(ptrVM.rawUVM(), &alock, &fResume);
     6466    rc = i_suspendBeforeConfigChange(ptrVM.rawUVM(), ptrVM.vtable(), &alock, &fResume);
    64166467    if (FAILED(rc))
    64176468        return rc;
     
    64266477
    64276478    alock.release();
    6428     vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY,
    6429                            (PFNRT)i_reconfigureMediumAttachment, 14,
    6430                            this, ptrVM.rawUVM(), pcszDevice, uInstance, enmBus, fUseHostIOCache,
    6431                            fBuiltinIOCache, fInsertDiskIntegrityDrv, true /* fSetupMerge */,
    6432                            aSourceIdx, aTargetIdx, aMediumAttachment, mMachineState, &rc);
     6479    vrc = ptrVM.vtable()->pfnVMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY,
     6480                                              (PFNRT)i_reconfigureMediumAttachment, 15,
     6481                                              this, ptrVM.rawUVM(), ptrVM.vtable(), pcszDevice, uInstance, enmBus,
     6482                                              fUseHostIOCache, fBuiltinIOCache, fInsertDiskIntegrityDrv, true /* fSetupMerge */,
     6483                                              aSourceIdx, aTargetIdx, aMediumAttachment, mMachineState, &rc);
    64336484    /* error handling is after resuming the VM */
    64346485
    64356486    if (fResume)
    6436         i_resumeAfterConfigChange(ptrVM.rawUVM());
     6487        i_resumeAfterConfigChange(ptrVM.rawUVM(), ptrVM.vtable());
    64376488
    64386489    if (RT_FAILURE(vrc))
     
    64436494    PPDMIBASE pIBase = NULL;
    64446495    PPDMIMEDIA pIMedium = NULL;
    6445     vrc = PDMR3QueryDriverOnLun(ptrVM.rawUVM(), pcszDevice, uInstance, uLUN, "VD", &pIBase);
     6496    vrc = ptrVM.vtable()->pfnPDMR3QueryDriverOnLun(ptrVM.rawUVM(), pcszDevice, uInstance, uLUN, "VD", &pIBase);
    64466497    if (RT_SUCCESS(vrc))
    64476498    {
     
    64636514    alock.acquire();
    64646515    /* Pause the VM, as it might have pending IO on this drive */
    6465     rc = i_suspendBeforeConfigChange(ptrVM.rawUVM(), &alock, &fResume);
     6516    rc = i_suspendBeforeConfigChange(ptrVM.rawUVM(), ptrVM.vtable(), &alock, &fResume);
    64666517    if (FAILED(rc))
    64676518        return rc;
     
    64716522    rc = mControl->FinishOnlineMergeMedium();
    64726523
    6473     vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY,
    6474                            (PFNRT)i_reconfigureMediumAttachment, 14,
    6475                            this, ptrVM.rawUVM(), pcszDevice, uInstance, enmBus, fUseHostIOCache,
    6476                            fBuiltinIOCache, fInsertDiskIntegrityDrv, false /* fSetupMerge */,
    6477                            0 /* uMergeSource */, 0 /* uMergeTarget */, aMediumAttachment,
    6478                            mMachineState, &rc);
     6524    vrc = ptrVM.vtable()->pfnVMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY,
     6525                                              (PFNRT)i_reconfigureMediumAttachment, 15,
     6526                                              this, ptrVM.rawUVM(), ptrVM.vtable(), pcszDevice, uInstance, enmBus,
     6527                                              fUseHostIOCache, fBuiltinIOCache, fInsertDiskIntegrityDrv, false /* fSetupMerge */,
     6528                                              0 /* uMergeSource */, 0 /* uMergeTarget */, aMediumAttachment, mMachineState, &rc);
    64796529    /* error handling is after resuming the VM */
    64806530
    64816531    if (fResume)
    6482         i_resumeAfterConfigChange(ptrVM.rawUVM());
     6532        i_resumeAfterConfigChange(ptrVM.rawUVM(), ptrVM.vtable());
    64836533
    64846534    if (RT_FAILURE(vrc))
     
    65226572            throw rc;
    65236573
    6524         rc = mMachine->GetStorageControllerByName(controllerName.raw(),
    6525                                                   pStorageController.asOutParam());
     6574        rc = mMachine->GetStorageControllerByName(controllerName.raw(), pStorageController.asOutParam());
    65266575        if (FAILED(rc))
    65276576            throw rc;
     
    65586607
    65596608        IMediumAttachment *pAttachment = aAttachments[i];
    6560         int vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY,
    6561                                    (PFNRT)i_reconfigureMediumAttachment, 14,
    6562                                    this, ptrVM.rawUVM(), pcszDevice, lInstance, enmBus, fUseHostIOCache,
    6563                                    fBuiltinIOCache, fInsertDiskIntegrityDrv,
    6564                                    false /* fSetupMerge */, 0 /* uMergeSource */, 0 /* uMergeTarget */,
    6565                                    pAttachment, mMachineState, &rc);
     6609        int vrc = ptrVM.vtable()->pfnVMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY,
     6610                                                      (PFNRT)i_reconfigureMediumAttachment, 15,
     6611                                                      this, ptrVM.rawUVM(), ptrVM.vtable(), pcszDevice, lInstance, enmBus,
     6612                                                      fUseHostIOCache, fBuiltinIOCache, fInsertDiskIntegrityDrv,
     6613                                                      false /* fSetupMerge */, 0 /* uMergeSource */, 0 /* uMergeTarget */,
     6614                                                      pAttachment, mMachineState, &rc);
    65666615        if (RT_FAILURE(vrc))
    65676616            throw setErrorBoth(E_FAIL, vrc, "%Rrc", vrc);
     
    65846633
    65856634    RTPROCPRIORITY enmProcPriority = RTPROCPRIORITY_DEFAULT;
    6586     switch(priority)
     6635    switch (priority)
    65876636    {
    65886637        case VMProcPriority_Default:
     
    66066655    int vrc = RTProcSetPriority(enmProcPriority);
    66076656    if (RT_FAILURE(vrc))
    6608         rc = setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("Could not set the priority of the process (%Rrc). Try to set it when VM is not started."), vrc);
     6657        rc = setErrorBoth(VBOX_E_VM_ERROR, vrc,
     6658                          tr("Could not set the priority of the process (%Rrc). Try to set it when VM is not started."), vrc);
    66096659
    66106660    return rc;
     
    66756725    /* get the VM handle. */
    66766726    SafeVMPtr ptrVM(this);
    6677     if (!ptrVM.isOk())
    6678         return ptrVM.rc();
    6679 
    6680     /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
    6681     alock.release();
    6682 
    6683     LogFlowThisFunc(("Sending PAUSE request...\n"));
    6684     if (aReason != Reason_Unspecified)
    6685         LogRel(("Pausing VM execution, reason '%s'\n", ::stringifyReason(aReason)));
    6686 
    6687     /** @todo r=klaus make use of aReason */
    6688     VMSUSPENDREASON enmReason = VMSUSPENDREASON_USER;
    6689     if (aReason == Reason_HostSuspend)
    6690         enmReason = VMSUSPENDREASON_HOST_SUSPEND;
    6691     else if (aReason == Reason_HostBatteryLow)
    6692         enmReason = VMSUSPENDREASON_HOST_BATTERY_LOW;
    6693     int vrc = VMR3Suspend(ptrVM.rawUVM(), enmReason);
    6694 
    6695     HRESULT hrc = S_OK;
    6696     if (RT_FAILURE(vrc))
    6697         hrc = setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("Could not suspend the machine execution (%Rrc)"), vrc);
    6698     else if (   aReason == Reason_HostSuspend
    6699              || aReason == Reason_HostBatteryLow)
    6700     {
    6701         alock.acquire();
    6702         i_removeSecretKeysOnSuspend();
     6727    HRESULT hrc = ptrVM.rc();
     6728    if (SUCCEEDED(hrc))
     6729    {
     6730        /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
     6731        alock.release();
     6732
     6733        LogFlowThisFunc(("Sending PAUSE request...\n"));
     6734        if (aReason != Reason_Unspecified)
     6735            LogRel(("Pausing VM execution, reason '%s'\n", ::stringifyReason(aReason)));
     6736
     6737        /** @todo r=klaus make use of aReason */
     6738        VMSUSPENDREASON enmReason = VMSUSPENDREASON_USER;
     6739        if (aReason == Reason_HostSuspend)
     6740            enmReason = VMSUSPENDREASON_HOST_SUSPEND;
     6741        else if (aReason == Reason_HostBatteryLow)
     6742            enmReason = VMSUSPENDREASON_HOST_BATTERY_LOW;
     6743
     6744        int vrc = ptrVM.vtable()->pfnVMR3Suspend(ptrVM.rawUVM(), enmReason);
     6745
     6746        if (RT_FAILURE(vrc))
     6747            hrc = setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("Could not suspend the machine execution (%Rrc)"), vrc);
     6748        else if (   aReason == Reason_HostSuspend
     6749                 || aReason == Reason_HostBatteryLow)
     6750        {
     6751            alock.acquire();
     6752            i_removeSecretKeysOnSuspend();
     6753        }
    67036754    }
    67046755
     
    67326783
    67336784    int vrc;
    6734     if (VMR3GetStateU(ptrVM.rawUVM()) == VMSTATE_CREATED)
     6785    VMSTATE const enmVMState = mpVMM->pfnVMR3GetStateU(ptrVM.rawUVM());
     6786    if (enmVMState == VMSTATE_CREATED)
    67356787    {
    67366788#ifdef VBOX_WITH_EXTPACK
    6737         vrc = mptrExtPackManager->i_callAllVmPowerOnHooks(this, VMR3GetVM(ptrVM.rawUVM()));
     6789        vrc = mptrExtPackManager->i_callAllVmPowerOnHooks(this, ptrVM.vtable()->pfnVMR3GetVM(ptrVM.rawUVM()));
    67386790#else
    67396791        vrc = VINF_SUCCESS;
    67406792#endif
    67416793        if (RT_SUCCESS(vrc))
    6742             vrc = VMR3PowerOn(ptrVM.rawUVM()); /* (PowerUpPaused) */
     6794            vrc = ptrVM.vtable()->pfnVMR3PowerOn(ptrVM.rawUVM()); /* (PowerUpPaused) */
    67436795    }
    67446796    else
     
    67546806             * Also, don't resume the VM through a host-resume unless it was suspended due to a host-suspend.
    67556807             */
    6756             if (VMR3GetStateU(ptrVM.rawUVM()) != VMSTATE_SUSPENDED)
     6808            if (enmVMState != VMSTATE_SUSPENDED)
    67576809            {
    6758                 LogRel(("Ignoring VM resume request, VM is currently not suspended\n"));
     6810                LogRel(("Ignoring VM resume request, VM is currently not suspended (%d)\n", enmVMState));
    67596811                return S_OK;
    67606812            }
    6761             if (VMR3GetSuspendReason(ptrVM.rawUVM()) != VMSUSPENDREASON_HOST_SUSPEND)
     6813            VMSUSPENDREASON const enmSuspendReason = ptrVM.vtable()->pfnVMR3GetSuspendReason(ptrVM.rawUVM());
     6814            if (enmSuspendReason != VMSUSPENDREASON_HOST_SUSPEND)
    67626815            {
    6763                 LogRel(("Ignoring VM resume request, VM was not suspended due to host-suspend\n"));
     6816                LogRel(("Ignoring VM resume request, VM was not suspended due to host-suspend (%d)\n", enmSuspendReason));
    67646817                return S_OK;
    67656818            }
     
    67736826             * See @bugref{7836}.
    67746827             */
    6775             if (   VMR3GetStateU(ptrVM.rawUVM()) == VMSTATE_SUSPENDED
    6776                 && VMR3GetSuspendReason(ptrVM.rawUVM()) == VMSUSPENDREASON_HOST_SUSPEND)
     6828            if (   enmVMState == VMSTATE_SUSPENDED
     6829                && ptrVM.vtable()->pfnVMR3GetSuspendReason(ptrVM.rawUVM()) == VMSUSPENDREASON_HOST_SUSPEND)
    67776830                return setError(VBOX_E_INVALID_VM_STATE, tr("VM is paused due to host power management"));
    67786831
     
    67836836        if (aReason == Reason_Snapshot)
    67846837            mVMStateChangeCallbackDisabled = true;
    6785         vrc = VMR3Resume(ptrVM.rawUVM(), enmReason);
     6838
     6839        vrc = ptrVM.vtable()->pfnVMR3Resume(ptrVM.rawUVM(), enmReason);
     6840
    67866841        if (aReason == Reason_Snapshot)
    67876842            mVMStateChangeCallbackDisabled = false;
    67886843    }
    67896844
    6790     HRESULT rc = RT_SUCCESS(vrc) ? S_OK
    6791                : setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("Could not resume the machine execution (%Rrc)"), vrc);
    6792 
    6793     LogFlowThisFunc(("rc=%Rhrc\n", rc));
     6845    HRESULT hrc = RT_SUCCESS(vrc) ? S_OK
     6846                : setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("Could not resume the machine execution (%Rrc)"), vrc);
     6847
     6848    LogFlowThisFunc(("hrc=%Rhrc\n", hrc));
    67946849    LogFlowThisFuncLeave();
    6795     return rc;
     6850    return hrc;
    67966851}
    67976852
     
    68066861 * @note Locks this object for writing.
    68076862 */
    6808 HRESULT Console::i_saveState(Reason_T aReason, const ComPtr<IProgress> &aProgress,
    6809                              const ComPtr<ISnapshot> &aSnapshot,
     6863HRESULT Console::i_saveState(Reason_T aReason, const ComPtr<IProgress> &aProgress, const ComPtr<ISnapshot> &aSnapshot,
    68106864                             const Utf8Str &aStateFilePath, bool aPauseVM, bool &aLeftPaused)
    68116865{
     
    68286882        && mMachineState != MachineState_Teleporting
    68296883        && mMachineState != MachineState_TeleportingPausedVM)
    6830     {
    68316884        return setError(VBOX_E_INVALID_VM_STATE,
    68326885                        tr("Cannot save the execution state as the machine is not running or paused (machine state: %s)"),
    68336886                        Global::stringifyMachineState(mMachineState));
    6834     }
    68356887    bool fContinueAfterwards = mMachineState != MachineState_Saving;
    68366888
     
    68596911    /* Get the VM handle early, we need it in several places. */
    68606912    SafeVMPtr ptrVM(this);
    6861     if (!ptrVM.isOk())
    6862         return ptrVM.rc();
    6863 
    6864     bool fPaused = false;
    6865     if (aPauseVM)
    6866     {
    6867         /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
    6868         alock.release();
    6869         VMSUSPENDREASON enmReason = VMSUSPENDREASON_USER;
    6870         if (aReason == Reason_HostSuspend)
    6871             enmReason = VMSUSPENDREASON_HOST_SUSPEND;
    6872         else if (aReason == Reason_HostBatteryLow)
    6873             enmReason = VMSUSPENDREASON_HOST_BATTERY_LOW;
    6874         int vrc = VMR3Suspend(ptrVM.rawUVM(), enmReason);
    6875         alock.acquire();
    6876 
    6877         if (RT_FAILURE(vrc))
    6878             return setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("Could not suspend the machine execution (%Rrc)"), vrc);
    6879         fPaused = true;
    6880     }
    6881 
    6882     LogFlowFunc(("Saving the state to '%s'...\n", aStateFilePath.c_str()));
    6883 
    6884     mpVmm2UserMethods->pISnapshot = aSnapshot;
    6885     mptrCancelableProgress = aProgress;
    6886     alock.release();
    6887     int vrc = VMR3Save(ptrVM.rawUVM(),
    6888                        aStateFilePath.c_str(),
    6889                        fContinueAfterwards,
    6890                        Console::i_stateProgressCallback,
    6891                        static_cast<IProgress *>(aProgress),
    6892                        &aLeftPaused);
    6893     alock.acquire();
    6894     mpVmm2UserMethods->pISnapshot = NULL;
    6895     mptrCancelableProgress.setNull();
    6896     if (RT_FAILURE(vrc))
    6897     {
    6898         if (fPaused)
    6899         {
     6913    HRESULT hrc = ptrVM.rc();
     6914    if (SUCCEEDED(hrc))
     6915    {
     6916        bool fPaused = false;
     6917        if (aPauseVM)
     6918        {
     6919            /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
    69006920            alock.release();
    6901             VMR3Resume(ptrVM.rawUVM(), VMRESUMEREASON_STATE_RESTORED);
     6921            VMSUSPENDREASON enmReason = VMSUSPENDREASON_USER;
     6922            if (aReason == Reason_HostSuspend)
     6923                enmReason = VMSUSPENDREASON_HOST_SUSPEND;
     6924            else if (aReason == Reason_HostBatteryLow)
     6925                enmReason = VMSUSPENDREASON_HOST_BATTERY_LOW;
     6926            int vrc = ptrVM.vtable()->pfnVMR3Suspend(ptrVM.rawUVM(), enmReason);
    69026927            alock.acquire();
    6903         }
    6904         return setErrorBoth(E_FAIL, vrc, tr("Failed to save the machine state to '%s' (%Rrc)"), aStateFilePath.c_str(), vrc);
    6905     }
    6906     Assert(fContinueAfterwards || !aLeftPaused);
    6907 
    6908     if (!fContinueAfterwards)
    6909     {
    6910         /*
    6911          * The machine has been successfully saved, so power it down
    6912          * (vmstateChangeCallback() will set state to Saved on success).
    6913          * Note: we release the VM caller, otherwise it will deadlock.
    6914          */
    6915         ptrVM.release();
    6916         alock.release();
    6917         autoCaller.release();
    6918         HRESULT rc = i_powerDown();
    6919         AssertComRC(rc);
    6920         autoCaller.add();
    6921         alock.acquire();
    6922     }
    6923     else
    6924     {
    6925         if (fPaused)
    6926             aLeftPaused = true;
     6928
     6929            if (RT_SUCCESS(vrc))
     6930                fPaused = true;
     6931            else
     6932                hrc = setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("Could not suspend the machine execution (%Rrc)"), vrc);
     6933        }
     6934        if (SUCCEEDED(hrc))
     6935        {
     6936            LogFlowFunc(("Saving the state to '%s'...\n", aStateFilePath.c_str()));
     6937
     6938            mpVmm2UserMethods->pISnapshot = aSnapshot;
     6939            mptrCancelableProgress = aProgress;
     6940            alock.release();
     6941
     6942            int vrc = ptrVM.vtable()->pfnVMR3Save(ptrVM.rawUVM(),
     6943                                                  aStateFilePath.c_str(),
     6944                                                  fContinueAfterwards,
     6945                                                  Console::i_stateProgressCallback,
     6946                                                  static_cast<IProgress *>(aProgress),
     6947                                                  &aLeftPaused);
     6948
     6949            alock.acquire();
     6950            mpVmm2UserMethods->pISnapshot = NULL;
     6951            mptrCancelableProgress.setNull();
     6952            if (RT_SUCCESS(vrc))
     6953            {
     6954                Assert(fContinueAfterwards || !aLeftPaused);
     6955
     6956                if (!fContinueAfterwards)
     6957                {
     6958                    /*
     6959                     * The machine has been successfully saved, so power it down
     6960                     * (vmstateChangeCallback() will set state to Saved on success).
     6961                     * Note: we release the VM caller, otherwise it will deadlock.
     6962                     */
     6963                    ptrVM.release();
     6964                    alock.release();
     6965                    autoCaller.release();
     6966
     6967                    HRESULT rc = i_powerDown();
     6968                    AssertComRC(rc);
     6969
     6970                    autoCaller.add();
     6971                    alock.acquire();
     6972                }
     6973                else if (fPaused)
     6974                    aLeftPaused = true;
     6975            }
     6976            else
     6977            {
     6978                if (fPaused)
     6979                {
     6980                    alock.release();
     6981                    ptrVM.vtable()->pfnVMR3Resume(ptrVM.rawUVM(), VMRESUMEREASON_STATE_RESTORED);
     6982                    alock.acquire();
     6983                }
     6984                hrc = setErrorBoth(E_FAIL, vrc, tr("Failed to save the machine state to '%s' (%Rrc)"),
     6985                                   aStateFilePath.c_str(), vrc);
     6986            }
     6987        }
    69276988    }
    69286989
     
    69477008    /* Get the VM handle. */
    69487009    SafeVMPtr ptrVM(this);
    6949     if (!ptrVM.isOk())
    6950         return ptrVM.rc();
    6951 
    6952     SSMR3Cancel(ptrVM.rawUVM());
     7010    HRESULT hrc = ptrVM.rc();
     7011    if (SUCCEEDED(hrc))
     7012        ptrVM.vtable()->pfnSSMR3Cancel(ptrVM.rawUVM());
    69537013
    69547014    LogFlowFuncLeave();
    6955     return S_OK;
     7015    return hrc;
    69567016}
    69577017
     
    69677027HRESULT Console::i_recordingSendAudio(const void *pvData, size_t cbData, uint64_t uTimestampMs)
    69687028{
    6969     if (!Recording.mpCtx)
     7029    if (!mRecording.mpCtx)
    69707030        return S_OK;
    69717031
    6972     if (   Recording.mpCtx->IsStarted()
    6973         && Recording.mpCtx->IsFeatureEnabled(RecordingFeature_Audio))
    6974     {
    6975         return Recording.mpCtx->SendAudioFrame(pvData, cbData, uTimestampMs);
    6976     }
     7032    if (   mRecording.mpCtx->IsStarted()
     7033        && mRecording.mpCtx->IsFeatureEnabled(RecordingFeature_Audio))
     7034        return mRecording.mpCtx->SendAudioFrame(pvData, cbData, uTimestampMs);
    69777035
    69787036    return S_OK;
     
    69817039
    69827040#ifdef VBOX_WITH_RECORDING
     7041
    69837042int Console::i_recordingGetSettings(settings::RecordingSettings &Settings)
    69847043{
     
    70437102int Console::i_recordingCreate(void)
    70447103{
    7045     AssertReturn(Recording.mpCtx == NULL, VERR_WRONG_ORDER);
     7104    AssertReturn(mRecording.mpCtx == NULL, VERR_WRONG_ORDER);
    70467105
    70477106    settings::RecordingSettings recordingSettings;
     
    70517110        try
    70527111        {
    7053             Recording.mpCtx = new RecordingContext(this /* pConsole */, recordingSettings);
     7112            mRecording.mpCtx = new RecordingContext(this /* pConsole */, recordingSettings);
    70547113        }
    70557114        catch (std::bad_alloc &)
     
    70727131void Console::i_recordingDestroy(void)
    70737132{
    7074     if (Recording.mpCtx)
    7075     {
    7076         delete Recording.mpCtx;
    7077         Recording.mpCtx = NULL;
     7133    if (mRecording.mpCtx)
     7134    {
     7135        delete mRecording.mpCtx;
     7136        mRecording.mpCtx = NULL;
    70787137    }
    70797138
     
    70897148{
    70907149    RT_NOREF(pAutoLock);
    7091     AssertPtrReturn(Recording.mpCtx, VERR_WRONG_ORDER);
    7092 
    7093     if (Recording.mpCtx->IsStarted())
     7150    AssertPtrReturn(mRecording.mpCtx, VERR_WRONG_ORDER);
     7151
     7152    if (mRecording.mpCtx->IsStarted())
    70947153        return VINF_SUCCESS;
    70957154
    70967155    LogRel(("Recording: Starting ...\n"));
    70977156
    7098     int rc = Recording.mpCtx->Start();
     7157    int rc = mRecording.mpCtx->Start();
    70997158    if (RT_SUCCESS(rc))
    71007159    {
    7101         for (unsigned uScreen = 0; uScreen < Recording.mpCtx->GetStreamCount(); uScreen++)
     7160        for (unsigned uScreen = 0; uScreen < mRecording.mpCtx->GetStreamCount(); uScreen++)
    71027161            mDisplay->i_recordingScreenChanged(uScreen);
    71037162    }
     
    71127171int Console::i_recordingStop(util::AutoWriteLock *pAutoLock /* = NULL */)
    71137172{
    7114     if (   !Recording.mpCtx
    7115         || !Recording.mpCtx->IsStarted())
     7173    if (   !mRecording.mpCtx
     7174        || !mRecording.mpCtx->IsStarted())
    71167175        return VINF_SUCCESS;
    71177176
    71187177    LogRel(("Recording: Stopping ...\n"));
    71197178
    7120     int rc = Recording.mpCtx->Stop();
     7179    int rc = mRecording.mpCtx->Stop();
    71217180    if (RT_SUCCESS(rc))
    71227181    {
    7123         const size_t cStreams = Recording.mpCtx->GetStreamCount();
     7182        const size_t cStreams = mRecording.mpCtx->GetStreamCount();
    71247183        for (unsigned uScreen = 0; uScreen < cStreams; ++uScreen)
    71257184            mDisplay->i_recordingScreenChanged(uScreen);
     
    71417200    return rc;
    71427201}
     7202
    71437203#endif /* VBOX_WITH_RECORDING */
    71447204
     
    71947254
    71957255    MachineState_T enmMachineState = MachineState_Null;
    7196     VMSTATE enmVMState = VMR3GetStateU(ptrVM.rawUVM());
     7256    VMSTATE enmVMState = ptrVM.vtable()->pfnVMR3GetStateU(ptrVM.rawUVM());
    71977257    switch (enmVMState)
    71987258    {
     
    72457305            break;
    72467306        default:
    7247             AssertMsgFailed(("%s\n", VMR3GetStateName(enmVMState)));
     7307            AssertMsgFailed(("%s\n", ptrVM.vtable()->pfnVMR3GetStateName(enmVMState)));
    72487308            enmMachineState = MachineState_PoweredOff;
    72497309    }
     
    72707330
    72717331    if (!mMouse.isNull())
    7272        mMouse->updateMousePointerShape(fVisible, fAlpha, xHot, yHot, width, height,
    7273                                        pu8Shape, cbShape);
     7332       mMouse->updateMousePointerShape(fVisible, fAlpha, xHot, yHot, width, height, pu8Shape, cbShape);
    72747333
    72757334    com::SafeArray<BYTE> shape(cbShape);
     
    72877346{
    72887347    LogFlowThisFunc(("supportsAbsolute=%d supportsRelative=%d needsHostCursor=%d\n",
    7289                       supportsAbsolute, supportsRelative, needsHostCursor));
     7348                     supportsAbsolute, supportsRelative, needsHostCursor));
    72907349
    72917350    AutoCaller autoCaller(this);
     
    74197478
    74207479/**
     7480 * Loads the VMM if needed.
     7481 *
     7482 * @returns COM status.
     7483 * @remarks Caller must write lock the console object.
     7484 */
     7485HRESULT Console::i_loadVMM(void) RT_NOEXCEPT
     7486{
     7487    if (   mhModVMM == NIL_RTLDRMOD
     7488        || mpVMM == NULL)
     7489    {
     7490        Assert(!mpVMM);
     7491
     7492        HRESULT         hrc;
     7493        RTERRINFOSTATIC ErrInfo;
     7494        RTLDRMOD        hModVMM = NIL_RTLDRMOD;
     7495        int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxVMM", &hModVMM, RTLDRLOAD_FLAGS_LOCAL, RTErrInfoInitStatic(&ErrInfo));
     7496        if (RT_SUCCESS(vrc))
     7497        {
     7498            PFNVMMGETVTABLE pfnGetVTable = NULL;
     7499            vrc = RTLdrGetSymbol(hModVMM, VMMR3VTABLE_GETTER_NAME, (void **)&pfnGetVTable);
     7500            if (pfnGetVTable)
     7501            {
     7502                PCVMMR3VTABLE pVMM = pfnGetVTable();
     7503                if (pVMM)
     7504                {
     7505                    if (VMMR3VTABLE_IS_COMPATIBLE(pVMM->uMagicVersion))
     7506                    {
     7507                        if (pVMM->uMagicVersion == pVMM->uMagicVersionEnd)
     7508                        {
     7509                            mhModVMM = hModVMM;
     7510                            mpVMM    = pVMM;
     7511                            LogFunc(("mhLdrVMM=%p phVMM=%p uMagicVersion=%#RX64\n", hModVMM, pVMM, pVMM->uMagicVersion));
     7512                            return S_OK;
     7513                        }
     7514
     7515                        hrc = setErrorVrc(vrc, "Bogus VMM vtable: uMagicVersion=%#RX64 uMagicVersionEnd=%#RX64",
     7516                                          pVMM->uMagicVersion, pVMM->uMagicVersionEnd);
     7517                    }
     7518                    else
     7519                        hrc = setErrorVrc(vrc, "Incompatible of bogus VMM version magic: %#RX64", pVMM->uMagicVersion);
     7520                }
     7521                else
     7522                    hrc = setErrorVrc(vrc, "pfnGetVTable return NULL!");
     7523            }
     7524            else
     7525                hrc = setErrorVrc(vrc, "Failed to locate symbol '%s' in VBoxVMM: %Rrc", VMMR3VTABLE_GETTER_NAME, vrc);
     7526            RTLdrClose(hModVMM);
     7527        }
     7528        else
     7529            hrc = setErrorVrc(vrc, "Failed to load VBoxVMM: %#RTeic", &ErrInfo.Core);
     7530        return hrc;
     7531    }
     7532
     7533    return S_OK;
     7534}
     7535
     7536/**
    74217537 * Increases the usage counter of the mpUVM pointer.
    74227538 *
     
    75027618
    75037619
    7504 HRESULT Console::i_safeVMPtrRetainer(PUVM *a_ppUVM, bool a_Quiet)
     7620/**
     7621 * Helper for SafeVMPtrBase.
     7622 */
     7623HRESULT Console::i_safeVMPtrRetainer(PUVM *a_ppUVM, PCVMMR3VTABLE *a_ppVMM, bool a_Quiet) RT_NOEXCEPT
    75057624{
    75067625    *a_ppUVM = NULL;
     7626    *a_ppVMM = NULL;
    75077627
    75087628    AutoCaller autoCaller(this);
     
    75177637             ? E_ACCESSDENIED
    75187638             : setError(E_ACCESSDENIED, tr("The virtual machine is being powered down"));
    7519     PUVM pUVM = mpUVM;
     7639    PUVM const pUVM = mpUVM;
    75207640    if (!pUVM)
    75217641        return a_Quiet
    75227642             ? E_ACCESSDENIED
    75237643             : setError(E_ACCESSDENIED, tr("The virtual machine is powered off"));
     7644    PCVMMR3VTABLE const pVMM = mpVMM;
     7645    if (!pVMM)
     7646        return a_Quiet
     7647             ? E_ACCESSDENIED
     7648             : setError(E_ACCESSDENIED, tr("No VMM loaded!"));
    75247649
    75257650    /*
    75267651     * Retain a reference to the user mode VM handle and get the global handle.
    75277652     */
    7528     uint32_t cRefs = VMR3RetainUVM(pUVM);
     7653    uint32_t cRefs = pVMM->pfnVMR3RetainUVM(pUVM);
    75297654    if (cRefs == UINT32_MAX)
    75307655        return a_Quiet
     
    75347659    /* done */
    75357660    *a_ppUVM = pUVM;
     7661    *a_ppVMM = pVMM;
    75367662    return S_OK;
    75377663}
     
    75397665void Console::i_safeVMPtrReleaser(PUVM *a_ppUVM)
    75407666{
    7541     if (*a_ppUVM)
    7542         VMR3ReleaseUVM(*a_ppUVM);
     7667    PUVM const pUVM = *a_ppUVM;
    75437668    *a_ppUVM = NULL;
     7669    if (pUVM)
     7670    {
     7671        PCVMMR3VTABLE const pVMM = mpVMM;
     7672        if (pVMM)
     7673            pVMM->pfnVMR3ReleaseUVM(pUVM);
     7674    }
    75447675}
    75457676
     
    76757806#endif
    76767807
     7808    PCVMMR3VTABLE const pVMM = mpVMM;
     7809    AssertPtrReturn(pVMM, E_UNEXPECTED);
     7810
    76777811    ComObjPtr<Progress> pPowerupProgress;
    76787812    bool fBeganPoweringUp = false;
     
    76977831            progressDesc = tr("Starting virtual machine");
    76987832
    7699         Bstr savedStateFile;
    7700 
    77017833        /*
    77027834         * Saved VMs will have to prove that their saved states seem kosher.
    77037835         */
     7836        Utf8Str strSavedStateFile;
    77047837        if (mMachineState == MachineState_Saved || mMachineState == MachineState_AbortedSaved)
    77057838        {
    7706             rc = mMachine->COMGETTER(StateFilePath)(savedStateFile.asOutParam());
     7839            Bstr bstrSavedStateFile;
     7840            rc = mMachine->COMGETTER(StateFilePath)(bstrSavedStateFile.asOutParam());
    77077841            if (FAILED(rc))
    77087842                throw rc;
    7709             ComAssertRet(!savedStateFile.isEmpty(), E_FAIL);
    7710             int vrc = SSMR3ValidateFile(Utf8Str(savedStateFile).c_str(), false /* fChecksumIt */);
     7843            strSavedStateFile = bstrSavedStateFile;
     7844
     7845            ComAssertRet(bstrSavedStateFile.isNotEmpty(), E_FAIL);
     7846            int vrc = pVMM->pfnSSMR3ValidateFile(strSavedStateFile.c_str(), false /* fChecksumIt */);
    77117847            if (RT_FAILURE(vrc))
    77127848            {
     
    77157851                {
    77167852                    case VERR_FILE_NOT_FOUND:
    7717                         errMsg = Utf8StrFmt(tr("VM failed to start because the saved state file '%ls' does not exist."),
    7718                                                savedStateFile.raw());
     7853                        errMsg.printf(tr("VM failed to start because the saved state file '%ls' does not exist."),
     7854                                      strSavedStateFile.c_str());
    77197855                        break;
    77207856                    default:
    7721                         errMsg = Utf8StrFmt(tr("VM failed to start because the saved state file '%ls' is invalid (%Rrc). "
    7722                                                "Delete the saved state prior to starting the VM."), savedStateFile.raw(), vrc);
     7857                        errMsg.printf(tr("VM failed to start because the saved state file '%ls' is invalid (%Rrc). "
     7858                                         "Delete the saved state prior to starting the VM."), strSavedStateFile.c_str(), vrc);
    77237859                        break;
    77247860                }
     
    77787914            throw task->rc();
    77797915
    7780         task->mConfigConstructor = i_configConstructor;
     7916        task->mpfnConfigConstructor = i_configConstructor;
    77817917        task->mSharedFolders = sharedFolders;
    77827918        task->mStartPaused = aPaused;
    77837919        if (mMachineState == MachineState_Saved || mMachineState == MachineState_AbortedSaved)
    7784             try { task->mSavedStateFile = savedStateFile; }
     7920            try { task->mSavedStateFile = strSavedStateFile; }
    77857921            catch (std::bad_alloc &) { throw rc = E_OUTOFMEMORY; }
    77867922        task->mTeleporterEnabled = fTeleporterEnabled;
     
    78077943        }
    78087944
    7809         if (savedStateFile.isEmpty() && !fCurrentSnapshotIsOnline)
     7945        if (strSavedStateFile.isEmpty() && !fCurrentSnapshotIsOnline)
    78107946        {
    78117947            LogFlowThisFunc(("Looking for immutable images to reset\n"));
     
    78948030                vrc = RTDirCreateFullPath(pszDumpDir, 0700);
    78958031                if (RT_FAILURE(vrc))
    7896                     throw setErrorBoth(E_FAIL, vrc, "Failed to setup CoreDumper. Couldn't create dump directory '%s' (%Rrc)\n",
     8032                    throw setErrorBoth(E_FAIL, vrc, tr("Failed to setup CoreDumper. Couldn't create dump directory '%s' (%Rrc)"),
    78978033                                       pszDumpDir, vrc);
    78988034            }
     
    79008036            vrc = RTCoreDumperSetup(pszDumpDir, fCoreFlags);
    79018037            if (RT_FAILURE(vrc))
    7902                 throw setErrorBoth(E_FAIL, vrc, "Failed to setup CoreDumper (%Rrc)", vrc);
     8038                throw setErrorBoth(E_FAIL, vrc, tr("Failed to setup CoreDumper (%Rrc)"), vrc);
    79038039            LogRel(("CoreDumper setup successful. pszDumpDir=%s fFlags=%#x\n", pszDumpDir ? pszDumpDir : ".", fCoreFlags));
    79048040        }
     
    79208056                                        cOperations,
    79218057                                        ulTotalOperationsWeight,
    7922                                         Bstr(tr("Starting Hard Disk operations")).raw(),
     8058                                        tr("Starting Hard Disk operations"),
    79238059                                        1);
    79248060            AssertComRCReturnRC(rc);
     
    79278063                 || mMachineState == MachineState_AbortedSaved
    79288064                 || !fTeleporterEnabled)
    7929         {
    79308065            rc = pPowerupProgress->init(static_cast<IConsole *>(this),
    79318066                                        progressDesc.raw(),
    79328067                                        FALSE /* aCancelable */);
    7933         }
    79348068        else if (fTeleporterEnabled)
    7935         {
    79368069            rc = pPowerupProgress->init(static_cast<IConsole *>(this),
    79378070                                        progressDesc.raw(),
     
    79398072                                        3    /* cOperations */,
    79408073                                        10   /* ulTotalOperationsWeight */,
    7941                                         Bstr(tr("Teleporting virtual machine")).raw(),
     8074                                        tr("Teleporting virtual machine"),
    79428075                                        1    /* ulFirstOperationWeight */);
    7943         }
    79448076
    79458077        if (FAILED(rc))
     
    80098141                    pVirtualBox->COMGETTER(Host)(pHost.asOutParam());
    80108142                    ComPtr<IHostNetworkInterface> pHostInterface;
    8011                     if (!SUCCEEDED(pHost->FindHostNetworkInterfaceByName(hostif.raw(),
    8012                                                                          pHostInterface.asOutParam())))
    8013                     {
     8143                    if (!SUCCEEDED(pHost->FindHostNetworkInterfaceByName(hostif.raw(), pHostInterface.asOutParam())))
    80148144                        throw setError(VBOX_E_HOST_ERROR,
    80158145                                       tr("VM cannot start because the host interface '%ls' does not exist"), hostif.raw());
    8016                     }
    80178146                    break;
    80188147                }
     
    81318260    Assert(mVMDestroying == false);
    81328261
    8133     PUVM     pUVM  = mpUVM;                 Assert(pUVM != NULL);
    8134     uint32_t cRefs = VMR3RetainUVM(pUVM);   Assert(cRefs != UINT32_MAX);  NOREF(cRefs);
     8262    PCVMMR3VTABLE const pVMM = mpVMM;
     8263    AssertPtrReturn(pVMM, E_UNEXPECTED);
     8264    PUVM pUVM = mpUVM;
     8265    AssertPtrReturn(pUVM, E_UNEXPECTED);
     8266
     8267    uint32_t cRefs = pVMM->pfnVMR3RetainUVM(pUVM);
     8268    Assert(cRefs != UINT32_MAX);  NOREF(cRefs);
    81358269
    81368270    AssertMsg(   mMachineState == MachineState_Running
     
    82528386        LogFlowThisFunc(("Powering off the VM...\n"));
    82538387        alock.release();
    8254         vrc = VMR3PowerOff(pUVM);
     8388        vrc = pVMM->pfnVMR3PowerOff(pUVM);
    82558389#ifdef VBOX_WITH_EXTPACK
    8256         mptrExtPackManager->i_callAllVmPowerOffHooks(this, VMR3GetVM(pUVM));
     8390        mptrExtPackManager->i_callAllVmPowerOffHooks(this, pVMM->pfnVMR3GetVM(pUVM));
    82578391#endif
    82588392        alock.acquire();
     
    83188452        /* Set mpUVM to NULL early just in case if some old code is not using
    83198453         * addVMCaller()/releaseVMCaller(). (We have our own ref on pUVM.) */
    8320         VMR3ReleaseUVM(mpUVM);
     8454        pVMM->pfnVMR3ReleaseUVM(mpUVM);
    83218455        mpUVM = NULL;
    83228456
     
    83258459        alock.release();
    83268460
    8327         vrc = VMR3Destroy(pUVM);
     8461        vrc = pVMM->pfnVMR3Destroy(pUVM);
    83288462
    83298463        /* take the lock again */
     
    83788512     */
    83798513    if (pUVM != NULL)
    8380         VMR3ReleaseUVM(pUVM);
     8514        pVMM->pfnVMR3ReleaseUVM(pUVM);
    83818515    else
    83828516        mVMDestroying = false;
     
    83898523 * @note Locks this object for writing.
    83908524 */
    8391 HRESULT Console::i_setMachineState(MachineState_T aMachineState,
    8392                                    bool aUpdateServer /* = true */)
     8525HRESULT Console::i_setMachineState(MachineState_T aMachineState, bool aUpdateServer /* = true */)
    83938526{
    83948527    AutoCaller autoCaller(this);
     
    84548587 * @note The caller must lock this object for writing.
    84558588 */
    8456 HRESULT Console::i_findSharedFolder(const Utf8Str &strName,
    8457                                     ComObjPtr<SharedFolder> &aSharedFolder,
    8458                                     bool aSetError /* = false */)
     8589HRESULT Console::i_findSharedFolder(const Utf8Str &strName, ComObjPtr<SharedFolder> &aSharedFolder, bool aSetError /* = false */)
    84598590{
    84608591    /* sanity check */
     
    84708601    if (aSetError)
    84718602        setError(VBOX_E_FILE_ERROR, tr("Could not find a shared folder named '%s'."), strName.c_str());
    8472 
    84738603    return VBOX_E_FILE_ERROR;
    84748604}
     
    86898819       this also checks that the length is within bounds of a SHFLSTRING.  */
    86908820    if (RTPathCompare(aData.m_strHostPath.c_str(), szAbsHostPath) != 0)
    8691         return setError(E_INVALIDARG,
    8692                         tr("Shared folder path '%s' is not absolute"),
    8693                         aData.m_strHostPath.c_str());
     8821        return setError(E_INVALIDARG, tr("Shared folder path '%s' is not absolute"), aData.m_strHostPath.c_str());
    86948822
    86958823    bool const fMissing = !RTPathExists(szAbsHostPath);
     
    86998827     */
    87008828    if (strName.length() >= _2K)
    8701         return setError(E_INVALIDARG, tr("Shared folder name is too long: %zu bytes", "", strName.length()),
    8702                         strName.length());
     8829        return setError(E_INVALIDARG, tr("Shared folder name is too long: %zu bytes", "", strName.length()), strName.length());
    87038830    if (aData.m_strAutoMountPoint.length() >= RTPATH_MAX)
    87048831        return setError(E_INVALIDARG, tr("Shared folder mount point too long: %zu bytes", "",
     
    87318858
    87328859        else if (fMissing)
    8733             hrc = setError(E_INVALIDARG,
    8734                            tr("Shared folder path '%s' does not exist on the host"),
    8735                            aData.m_strHostPath.c_str());
     8860            hrc = setError(E_INVALIDARG, tr("Shared folder path '%s' does not exist on the host"), aData.m_strHostPath.c_str());
    87368861        else
    87378862            hrc = S_OK;
     
    87828907    parms.u.pointer.size = ShflStringSizeOfBuffer(pMapName);
    87838908
    8784     int vrc = m_pVMMDev->hgcmHostCall("VBoxSharedFolders",
    8785                                       SHFL_FN_REMOVE_MAPPING,
    8786                                       1, &parms);
     8909    int vrc = m_pVMMDev->hgcmHostCall("VBoxSharedFolders", SHFL_FN_REMOVE_MAPPING, 1, &parms);
    87878910    RTMemFree(pMapName);
    87888911    if (RT_FAILURE(vrc))
     
    87988921 *          calls after the VM was destroyed.
    87998922 */
    8800 DECLCALLBACK(void) Console::i_vmstateChangeCallback(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser)
     8923/*static*/ DECLCALLBACK(void)
     8924Console::i_vmstateChangeCallback(PUVM pUVM, PCVMMR3VTABLE pVMM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser)
    88018925{
    88028926    LogFlowFunc(("Changing state from %s to %s (pUVM=%p)\n",
    8803                  VMR3GetStateName(enmOldState), VMR3GetStateName(enmState),     pUVM));
     8927                 pVMM->pfnVMR3GetStateName(enmOldState), pVMM->pfnVMR3GetStateName(enmState), pUVM));
     8928    RT_NOREF(pVMM);
    88048929
    88058930    Console *that = static_cast<Console *>(pvUser);
     
    90739198                default:
    90749199                    AssertMsgFailed(("%s/%s -> %s\n", ::stringifyMachineState(that->mMachineState),
    9075                                     VMR3GetStateName(enmOldState), VMR3GetStateName(enmState) ));
     9200                                    pVMM->pfnVMR3GetStateName(enmOldState), pVMM->pfnVMR3GetStateName(enmState) ));
    90769201                    that->i_setMachineState(MachineState_Paused);
    90779202                    break;
     
    91109235                      || that->mMachineState == MachineState_Teleporting,
    91119236                      ("%s/%s -> %s\n", ::stringifyMachineState(that->mMachineState),
    9112                       VMR3GetStateName(enmOldState), VMR3GetStateName(enmState) ));
     9237                      pVMM->pfnVMR3GetStateName(enmOldState), pVMM->pfnVMR3GetStateName(enmState) ));
    91139238            break;
    91149239
     
    92719396    }
    92729397
    9273     int rc = pVMMDev->hgcmHostCall("VBoxDragAndDropSvc",
    9274                                    DragAndDropSvc::HOST_DND_FN_SET_MODE, 1 /* cParms */, &parm);
     9398    int rc = pVMMDev->hgcmHostCall("VBoxDragAndDropSvc", DragAndDropSvc::HOST_DND_FN_SET_MODE, 1 /* cParms */, &parm);
    92759399    if (RT_FAILURE(rc))
    92769400        LogRel(("Error changing drag and drop mode: %Rrc\n", rc));
     
    92899413 * @note Synchronously calls EMT.
    92909414 */
    9291 HRESULT Console::i_attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs,
    9292                                    const Utf8Str &aCaptureFilename)
     9415HRESULT Console::i_attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs, const Utf8Str &aCaptureFilename)
    92939416{
    92949417    AssertReturn(aHostDevice, E_FAIL);
     
    93019424     * method in EMT (using usbAttachCallback()).
    93029425     */
    9303     Bstr BstrAddress;
    9304     hrc = aHostDevice->COMGETTER(Address)(BstrAddress.asOutParam());
     9426    Bstr bstrAddress;
     9427    hrc = aHostDevice->COMGETTER(Address)(bstrAddress.asOutParam());
    93059428    ComAssertComRCRetRC(hrc);
    9306 
    9307     Utf8Str Address(BstrAddress);
     9429    Utf8Str const Address(bstrAddress);
    93089430
    93099431    Bstr id;
    93109432    hrc = aHostDevice->COMGETTER(Id)(id.asOutParam());
    93119433    ComAssertComRCRetRC(hrc);
    9312     Guid uuid(id);
     9434    Guid const uuid(id);
    93139435
    93149436    BOOL fRemote = FALSE;
     
    93169438    ComAssertComRCRetRC(hrc);
    93179439
    9318     Bstr BstrBackend;
    9319     hrc = aHostDevice->COMGETTER(Backend)(BstrBackend.asOutParam());
     9440    Bstr bstrBackend;
     9441    hrc = aHostDevice->COMGETTER(Backend)(bstrBackend.asOutParam());
    93209442    ComAssertComRCRetRC(hrc);
    9321 
    9322     Utf8Str Backend(BstrBackend);
     9443    Utf8Str const strBackend(bstrBackend);
    93239444
    93249445    /* Get the VM handle. */
     
    93279448        return ptrVM.rc();
    93289449
    9329     LogFlowThisFunc(("Proxying USB device '%s' {%RTuuid}...\n",
    9330                       Address.c_str(), uuid.raw()));
     9450    LogFlowThisFunc(("Proxying USB device '%s' {%RTuuid}...\n", Address.c_str(), uuid.raw()));
    93319451
    93329452    void *pvRemoteBackend = NULL;
     
    93439463    AssertComRCReturnRC(hrc);
    93449464
    9345     int vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(), 0 /* idDstCpu (saved state, see #6232) */,
    9346                                (PFNRT)i_usbAttachCallback, 10,
    9347                                this, ptrVM.rawUVM(), aHostDevice, uuid.raw(), Backend.c_str(),
    9348                                Address.c_str(), pvRemoteBackend, enmSpeed, aMaskedIfs,
    9349                                aCaptureFilename.isEmpty() ? NULL : aCaptureFilename.c_str());
     9465    int vrc = ptrVM.vtable()->pfnVMR3ReqCallWaitU(ptrVM.rawUVM(), 0 /* idDstCpu (saved state, see #6232) */,
     9466                                                  (PFNRT)i_usbAttachCallback, 11,
     9467                                                  this, ptrVM.rawUVM(), ptrVM.vtable(), aHostDevice, uuid.raw(),
     9468                                                  strBackend.c_str(), Address.c_str(), pvRemoteBackend, enmSpeed, aMaskedIfs,
     9469                                                  aCaptureFilename.isEmpty() ? NULL : aCaptureFilename.c_str());
    93509470    if (RT_SUCCESS(vrc))
    93519471    {
     
    93679487    {
    93689488        Log1WarningThisFunc(("Failed to create proxy device for '%s' {%RTuuid} (%Rrc)\n", Address.c_str(), uuid.raw(), vrc));
    9369 
    93709489        switch (vrc)
    93719490        {
     
    93969515//static
    93979516DECLCALLBACK(int)
    9398 Console::i_usbAttachCallback(Console *that, PUVM pUVM, IUSBDevice *aHostDevice, PCRTUUID aUuid, const char *pszBackend,
    9399                              const char *aAddress, void *pvRemoteBackend, USBConnectionSpeed_T aEnmSpeed, ULONG aMaskedIfs,
    9400                              const char *pszCaptureFilename)
     9517Console::i_usbAttachCallback(Console *that, PUVM pUVM, PCVMMR3VTABLE pVMM, IUSBDevice *aHostDevice, PCRTUUID aUuid,
     9518                             const char *pszBackend, const char *aAddress, void *pvRemoteBackend, USBConnectionSpeed_T aEnmSpeed,
     9519                             ULONG aMaskedIfs, const char *pszCaptureFilename)
    94019520{
    94029521    RT_NOREF(aHostDevice);
     
    94189537    }
    94199538
    9420     int vrc = PDMR3UsbCreateProxyDevice(pUVM, aUuid, pszBackend, aAddress, pvRemoteBackend,
    9421                                         enmSpeed, aMaskedIfs, pszCaptureFilename);
     9539    int vrc = pVMM->pfnPDMR3UsbCreateProxyDevice(pUVM, aUuid, pszBackend, aAddress, pvRemoteBackend,
     9540                                                 enmSpeed, aMaskedIfs, pszCaptureFilename);
    94229541    LogFlowFunc(("vrc=%Rrc\n", vrc));
    94239542    LogFlowFuncLeave();
     
    94449563
    94459564    /* if the device is attached, then there must at least one USB hub. */
    9446     AssertReturn(PDMR3UsbHasHub(ptrVM.rawUVM()), E_FAIL);
     9565    AssertReturn(ptrVM.vtable()->pfnPDMR3UsbHasHub(ptrVM.rawUVM()), E_FAIL);
    94479566
    94489567    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    9449     LogFlowThisFunc(("Detaching USB proxy device {%RTuuid}...\n",
    9450                      aHostDevice->i_id().raw()));
     9568    LogFlowThisFunc(("Detaching USB proxy device {%RTuuid}...\n", aHostDevice->i_id().raw()));
    94519569
    94529570    /*
     
    94689586
    94699587    alock.release();
    9470     int vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(), 0 /* idDstCpu (saved state, see #6232) */,
    9471                                (PFNRT)i_usbDetachCallback, 5,
    9472                                this, ptrVM.rawUVM(), pUuid);
     9588    int vrc = ptrVM.vtable()->pfnVMR3ReqCallWaitU(ptrVM.rawUVM(), 0 /* idDstCpu (saved state, see #6232) */,
     9589                                                  (PFNRT)i_usbDetachCallback, 4,
     9590                                                  this, ptrVM.rawUVM(), ptrVM.vtable(), pUuid);
    94739591    if (RT_SUCCESS(vrc))
    94749592    {
     
    94959613//static
    94969614DECLCALLBACK(int)
    9497 Console::i_usbDetachCallback(Console *that, PUVM pUVM, PCRTUUID aUuid)
     9615Console::i_usbDetachCallback(Console *that, PUVM pUVM, PCVMMR3VTABLE pVMM, PCRTUUID aUuid)
    94989616{
    94999617    LogFlowFuncEnter();
     
    95039621    AssertReturn(!that->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE);
    95049622
    9505     int vrc = PDMR3UsbDetachDevice(pUVM, aUuid);
     9623    int vrc = pVMM->pfnPDMR3UsbDetachDevice(pUVM, aUuid);
    95069624
    95079625    LogFlowFunc(("vrc=%Rrc\n", vrc));
     
    95139631/* Note: FreeBSD needs this whether netflt is used or not. */
    95149632#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
     9633
    95159634/**
    95169635 * Helper function to handle host interface device creation and attachment.
     
    97369855    return rc;
    97379856}
     9857
    97389858#endif /* (RT_OS_LINUX || RT_OS_FREEBSD) && !VBOX_WITH_NETFLT */
    97399859
     
    98259945 */
    98269946/*static*/ DECLCALLBACK(void)
    9827 Console::i_genericVMSetErrorCallback(PUVM pUVM, void *pvUser, int rc, RT_SRC_POS_DECL,
    9828                                      const char *pszFormat, va_list args)
     9947Console::i_genericVMSetErrorCallback(PUVM pUVM, void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list args)
    98299948{
    98309949    RT_SRC_POS_NOREF();
     
    98379956
    98389957    /* Append to any the existing error message. */
    9839     if (pErrorText->length())
    9840         *pErrorText = Utf8StrFmt("%s.\n%N (%Rrc)", pErrorText->c_str(),
    9841                                  pszFormat, &va2, rc, rc);
    9842     else
    9843         *pErrorText = Utf8StrFmt("%N (%Rrc)", pszFormat, &va2, rc, rc);
     9958    try
     9959    {
     9960        if (pErrorText->length())
     9961            pErrorText->appendPrintf(".\n%N (%Rrc)", pszFormat, &va2, rc, rc);
     9962        else
     9963            pErrorText->printf("%N (%Rrc)", pszFormat, &va2, rc, rc);
     9964    }
     9965    catch (std::bad_alloc &)
     9966    {
     9967    }
    98449968
    98459969    va_end(va2);
     
    98749998    Utf8Str message(pszFormat, va);
    98759999
    9876     LogRel(("Console: VM runtime error: fatal=%RTbool, errorID=%s message=\"%s\"\n",
    9877             fFatal, pszErrorId, message.c_str()));
    9878 
    9879     that->i_onRuntimeError(BOOL(fFatal), Bstr(pszErrorId).raw(), Bstr(message).raw());
    9880 
     10000    LogRel(("Console: VM runtime error: fatal=%RTbool, errorID=%s message=\"%s\"\n", fFatal, pszErrorId, message.c_str()));
     10001    try
     10002    {
     10003        that->i_onRuntimeError(BOOL(fFatal), Bstr(pszErrorId).raw(), Bstr(message).raw());
     10004    }
     10005    catch (std::bad_alloc &)
     10006    {
     10007    }
    988110008    LogFlowFuncLeave(); NOREF(pUVM);
    988210009}
     
    998610113            RTStrPurgeEncoding((char *)e + e->oSerialNumber);
    998710114
    9988         LogFlowThisFunc(("vendor %04X, product %04X, name = %s\n",
    9989                           e->idVendor, e->idProduct,
    9990                           e->oProduct? (char *)e + e->oProduct: ""));
     10115        LogFlowThisFunc(("vendor %04x, product %04x, name = %s\n",
     10116                         e->idVendor, e->idProduct, e->oProduct ? (char *)e + e->oProduct : ""));
    999110117
    999210118        bool fNewDevice = true;
     
    999610122             ++it)
    999710123        {
    9998             if ((*it)->devId() == e->id
     10124            if (   (*it)->devId() == e->id
    999910125                && (*it)->clientId() == u32ClientId)
    1000010126            {
     
    1001910145
    1002010146            /* Check if the device is ok for current USB filters. */
    10021             BOOL fMatched = FALSE;
     10147            BOOL  fMatched  = FALSE;
    1002210148            ULONG fMaskedIfs = 0;
    10023 
    1002410149            HRESULT hrc = mControl->RunUSBDeviceFilters(pUSBDevice, &fMatched, &fMaskedIfs);
    1002510150
     
    1008810213        pUSBDevice->COMGETTER(Product)(product.asOutParam());
    1008910214
    10090         LogRel(("Remote USB: ---- Vendor %04X. Product %04X. Name = [%ls].\n",
    10091                 vendorId, productId, product.raw()));
     10215        LogRel(("Remote USB: ---- Vendor %04x. Product %04x. Name = [%ls].\n", vendorId, productId, product.raw()));
    1009210216
    1009310217        /* Detach the device from VM. */
     
    1022510349            pConsole->i_onVMProcessPriorityChange(enmVMPriority);
    1022610350
    10227         PVM pVM;
    10228         vrc = VMR3Create(cCpus,
    10229                          pConsole->mpVmm2UserMethods,
    10230                          Console::i_genericVMSetErrorCallback,
    10231                          &pTask->mErrorMsg,
    10232                          pTask->mConfigConstructor,
    10233                          static_cast<Console *>(pConsole),
    10234                          &pVM, NULL);
     10351        PCVMMR3VTABLE pVMM = pConsole->mpVMM;
     10352        PVM           pVM  = NULL;
     10353        vrc = pVMM->pfnVMR3Create(cCpus,
     10354                                  pConsole->mpVmm2UserMethods,
     10355                                  Console::i_genericVMSetErrorCallback,
     10356                                  &pTask->mErrorMsg,
     10357                                  pTask->mpfnConfigConstructor,
     10358                                  static_cast<Console *>(pConsole),
     10359                                  &pVM, NULL);
    1023510360        alock.acquire();
    1023610361        if (RT_SUCCESS(vrc))
    1023710362        {
    10238             do
     10363            do /* break "loop" */
    1023910364            {
    1024010365                /*
    1024110366                 * Register our load/save state file handlers
    1024210367                 */
    10243                 vrc = SSMR3RegisterExternal(pConsole->mpUVM, sSSMConsoleUnit, 0 /*iInstance*/,
    10244                                             CONSOLE_SAVED_STATE_VERSION, 0 /* cbGuess */,
    10245                                             NULL, NULL, NULL,
    10246                                             NULL, i_saveStateFileExec, NULL,
    10247                                             NULL, i_loadStateFileExec, NULL,
    10248                                             static_cast<Console *>(pConsole));
     10368                vrc = pVMM->pfnSSMR3RegisterExternal(pConsole->mpUVM, sSSMConsoleUnit, 0 /*iInstance*/,
     10369                                                     CONSOLE_SAVED_STATE_VERSION, 0 /* cbGuess */,
     10370                                                     NULL, NULL, NULL,
     10371                                                     NULL, i_saveStateFileExec, NULL,
     10372                                                     NULL, i_loadStateFileExec, NULL,
     10373                                                     static_cast<Console *>(pConsole));
    1024910374                AssertRCBreak(vrc);
    1025010375
     
    1030510430                    if (   fVRDEEnabled
    1030610431                        && pConsole->mAudioVRDE)
    10307                         pConsole->mAudioVRDE->doAttachDriverViaEmt(pConsole->mpUVM, &alock);
     10432                        pConsole->mAudioVRDE->doAttachDriverViaEmt(pConsole->mpUVM, pVMM, &alock);
    1030810433                }
    1030910434#endif
     
    1036010485                    LogFlowFunc(("Restoring saved state from '%s'...\n", pTask->mSavedStateFile.c_str()));
    1036110486
    10362                     vrc = VMR3LoadFromFile(pConsole->mpUVM,
    10363                                            pTask->mSavedStateFile.c_str(),
    10364                                            Console::i_stateProgressCallback,
    10365                                            static_cast<IProgress *>(pTask->mProgress));
     10487                    vrc = pVMM->pfnVMR3LoadFromFile(pConsole->mpUVM,
     10488                                                    pTask->mSavedStateFile.c_str(),
     10489                                                    Console::i_stateProgressCallback,
     10490                                                    static_cast<IProgress *>(pTask->mProgress));
    1036610491                    if (RT_SUCCESS(vrc))
    1036710492                    {
     
    1037610501#endif
    1037710502                            if (RT_SUCCESS(vrc))
    10378                                 vrc = VMR3Resume(pConsole->mpUVM, VMRESUMEREASON_STATE_RESTORED);
     10503                                vrc = pVMM->pfnVMR3Resume(pConsole->mpUVM, VMRESUMEREASON_STATE_RESTORED);
    1037910504                            AssertLogRelRC(vrc);
    1038010505                        }
     
    1038410509                    if (RT_FAILURE(vrc))
    1038510510                    {
    10386                         int vrc2 = VMR3PowerOff(pConsole->mpUVM); AssertLogRelRC(vrc2);
     10511                        int vrc2 = pVMM->pfnVMR3PowerOff(pConsole->mpUVM); AssertLogRelRC(vrc2);
    1038710512#ifdef VBOX_WITH_EXTPACK
    1038810513                        pConsole->mptrExtPackManager->i_callAllVmPowerOffHooks(pConsole, pVM);
     
    1039410519                    /* -> ConsoleImplTeleporter.cpp */
    1039510520                    bool fPowerOffOnFailure;
    10396                     rc = pConsole->i_teleporterTrg(pConsole->mpUVM, pMachine, &pTask->mErrorMsg, pTask->mStartPaused,
    10397                                                    pTask->mProgress, &fPowerOffOnFailure);
     10521                    rc = pConsole->i_teleporterTrg(pConsole->mpUVM, pConsole->mpVMM, pMachine, &pTask->mErrorMsg,
     10522                                                   pTask->mStartPaused, pTask->mProgress, &fPowerOffOnFailure);
    1039810523                    if (FAILED(rc) && fPowerOffOnFailure)
    1039910524                    {
    1040010525                        ErrorInfoKeeper eik;
    10401                         int vrc2 = VMR3PowerOff(pConsole->mpUVM); AssertLogRelRC(vrc2);
     10526                        int vrc2 = pVMM->pfnVMR3PowerOff(pConsole->mpUVM); AssertLogRelRC(vrc2);
    1040210527#ifdef VBOX_WITH_EXTPACK
    1040310528                        pConsole->mptrExtPackManager->i_callAllVmPowerOffHooks(pConsole, pVM);
     
    1041510540#endif
    1041610541                    if (RT_SUCCESS(vrc))
    10417                         vrc = VMR3PowerOn(pConsole->mpUVM);
     10542                        vrc = pVMM->pfnVMR3PowerOn(pConsole->mpUVM);
    1041810543                    AssertLogRelRC(vrc);
    1041910544                }
     
    1044510570                 */
    1044610571                alock.release();
    10447                 VMR3AtErrorDeregister(pConsole->mpUVM, Console::i_genericVMSetErrorCallback, &pTask->mErrorMsg);
     10572                pVMM->pfnVMR3AtErrorDeregister(pConsole->mpUVM, Console::i_genericVMSetErrorCallback, &pTask->mErrorMsg);
    1044810573                /** @todo register another VMSetError callback? */
    1044910574                alock.acquire();
     
    1046110586                alock.acquire();
    1046210587            }
    10463             VMR3ReleaseUVM(pConsole->mpUVM);
     10588            pVMM->pfnVMR3ReleaseUVM(pConsole->mpUVM);
    1046410589            pConsole->mpUVM = NULL;
    1046510590        }
     
    1050910634
    1051010635        Assert(pConsole->mpUVM == NULL);
    10511         i_vmstateChangeCallback(NULL, VMSTATE_TERMINATED, VMSTATE_CREATING, pConsole);
     10636        i_vmstateChangeCallback(NULL, pConsole->mpVMM, VMSTATE_TERMINATED, VMSTATE_CREATING, pConsole);
    1051210637    }
    1051310638
     
    1054910674 * @param   pThis                   Reference to the console object.
    1055010675 * @param   pUVM                    The VM handle.
     10676 * @param   pVMM                    The VMM vtable.
    1055110677 * @param   pcszDevice              The name of the controller type.
    1055210678 * @param   uInstance               The instance of the controller.
     
    1056710693DECLCALLBACK(int) Console::i_reconfigureMediumAttachment(Console *pThis,
    1056810694                                                         PUVM pUVM,
     10695                                                         PCVMMR3VTABLE pVMM,
    1056910696                                                         const char *pcszDevice,
    1057010697                                                         unsigned uInstance,
     
    1061110738                                             false /* fHotplug */,
    1061210739                                             pUVM,
     10740                                             pVMM,
    1061310741                                             NULL /* paLedDevType */,
    1061410742                                             NULL /* ppLunL0)*/);
     
    1080410932 */
    1080510933/*static*/ DECLCALLBACK(int)
    10806 Console::i_pdmIfSecKey_KeyRetain(PPDMISECKEY pInterface, const char *pszId, const uint8_t **ppbKey,
    10807                                  size_t *pcbKey)
     10934Console::i_pdmIfSecKey_KeyRetain(PPDMISECKEY pInterface, const char *pszId, const uint8_t **ppbKey, size_t *pcbKey)
    1080810935{
    1080910936    Console *pConsole = ((MYPDMISECKEY *)pInterface)->pConsole;
     
    1105911186     * Validate configuration.
    1106011187     */
    11061     if (!CFGMR3AreValuesValid(pCfg, "papLeds\0pmapMediumAttachments\0DeviceInstance\0pConsole\0First\0Last\0"))
    11062         return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
     11188    PDMDRV_VALIDATE_CONFIG_RETURN(pDrvIns,
     11189                                  "papLeds|"
     11190                                  "pmapMediumAttachments|"
     11191                                  "DeviceInstance|"
     11192                                  "pConsole|"
     11193                                  "First|"
     11194                                  "Last",
     11195                                  "");
    1106311196    AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
    1106411197                    ("Configuration error: Not possible to attach anything to this driver!\n"),
     
    1107711210     * Read config.
    1107811211     */
    11079     int rc = CFGMR3QueryPtr(pCfg, "papLeds", (void **)&pThis->papLeds);
    11080     if (RT_FAILURE(rc))
    11081     {
    11082         AssertMsgFailed(("Configuration error: Failed to query the \"papLeds\" value! rc=%Rrc\n", rc));
    11083         return rc;
    11084     }
    11085 
    11086     rc = CFGMR3QueryPtrDef(pCfg, "pmapMediumAttachments", (void **)&pThis->pmapMediumAttachments, NULL);
    11087     if (RT_FAILURE(rc))
    11088     {
    11089         AssertMsgFailed(("Configuration error: Failed to query the \"pmapMediumAttachments\" value! rc=%Rrc\n", rc));
    11090         return rc;
    11091     }
     11212    PCPDMDRVHLPR3 const pHlp = pDrvIns->pHlpR3;
     11213    int rc = pHlp->pfnCFGMQueryPtr(pCfg, "papLeds", (void **)&pThis->papLeds);
     11214    AssertLogRelMsgRCReturn(rc, ("Configuration error: Failed to query the \"papLeds\" value! rc=%Rrc\n", rc), rc);
     11215
     11216    rc = pHlp->pfnCFGMQueryPtrDef(pCfg, "pmapMediumAttachments", (void **)&pThis->pmapMediumAttachments, NULL);
     11217    AssertLogRelMsgRCReturn(rc, ("Configuration error: Failed to query the \"pmapMediumAttachments\" value! rc=%Rrc\n", rc), rc);
    1109211218    if (pThis->pmapMediumAttachments)
    1109311219    {
    11094         rc = CFGMR3QueryStringAlloc(pCfg, "DeviceInstance", &pThis->pszDeviceInstance);
    11095         if (RT_FAILURE(rc))
    11096         {
    11097             AssertMsgFailed(("Configuration error: Failed to query the \"DeviceInstance\" value! rc=%Rrc\n", rc));
    11098             return rc;
    11099         }
    11100         rc = CFGMR3QueryPtr(pCfg, "pConsole", (void **)&pThis->pConsole);
    11101         if (RT_FAILURE(rc))
    11102         {
    11103             AssertMsgFailed(("Configuration error: Failed to query the \"pConsole\" value! rc=%Rrc\n", rc));
    11104             return rc;
    11105         }
    11106     }
    11107 
    11108     rc = CFGMR3QueryU32(pCfg, "First", &pThis->iFirstLUN);
    11109     if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    11110         pThis->iFirstLUN = 0;
    11111     else if (RT_FAILURE(rc))
    11112     {
    11113         AssertMsgFailed(("Configuration error: Failed to query the \"First\" value! rc=%Rrc\n", rc));
    11114         return rc;
    11115     }
    11116 
    11117     rc = CFGMR3QueryU32(pCfg, "Last", &pThis->iLastLUN);
    11118     if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    11119         pThis->iLastLUN = 0;
    11120     else if (RT_FAILURE(rc))
    11121     {
    11122         AssertMsgFailed(("Configuration error: Failed to query the \"Last\" value! rc=%Rrc\n", rc));
    11123         return rc;
    11124     }
    11125     if (pThis->iFirstLUN > pThis->iLastLUN)
    11126     {
    11127         AssertMsgFailed(("Configuration error: Invalid unit range %u-%u\n", pThis->iFirstLUN, pThis->iLastLUN));
    11128         return VERR_GENERAL_FAILURE;
    11129     }
     11220        rc = pHlp->pfnCFGMQueryStringAlloc(pCfg, "DeviceInstance", &pThis->pszDeviceInstance);
     11221        AssertLogRelMsgRCReturn(rc, ("Configuration error: Failed to query the \"DeviceInstance\" value! rc=%Rrc\n", rc), rc);
     11222        rc = pHlp->pfnCFGMQueryPtr(pCfg, "pConsole", (void **)&pThis->pConsole);
     11223        AssertLogRelMsgRCReturn(rc, ("Configuration error: Failed to query the \"pConsole\" value! rc=%Rrc\n", rc), rc);
     11224    }
     11225
     11226    rc = pHlp->pfnCFGMQueryU32Def(pCfg, "First", &pThis->iFirstLUN, 0);
     11227    AssertLogRelMsgRCReturn(rc, ("Configuration error: Failed to query the \"First\" value! rc=%Rrc\n", rc), rc);
     11228
     11229    rc = pHlp->pfnCFGMQueryU32Def(pCfg, "Last", &pThis->iLastLUN, 0);
     11230    AssertLogRelMsgRCReturn(rc, ("Configuration error: Failed to query the \"Last\" value! rc=%Rrc\n", rc), rc);
     11231
     11232    AssertLogRelMsgReturn(pThis->iFirstLUN <= pThis->iLastLUN,
     11233                          ("Configuration error: Invalid unit range %u-%u\n", pThis->iFirstLUN, pThis->iLastLUN),
     11234                          VERR_INVALID_PARAMETER);
    1113011235
    1113111236    /*
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r93313 r93444  
    6767#include <iprt/stream.h>
    6868
     69#include <VBox/vmm/vmmr3vtable.h>
    6970#include <VBox/vmm/vmapi.h>
    7071#include <VBox/err.h>
     
    292293 * @param   pcszValue       The string value.
    293294 */
    294 static void InsertConfigString(PCFGMNODE pNode,
    295                                const char *pcszName,
    296                                const char *pcszValue)
     295void Console::InsertConfigString(PCFGMNODE pNode, const char *pcszName, const char *pcszValue)
    297296{
    298     int vrc = CFGMR3InsertString(pNode,
    299                                  pcszName,
    300                                  pcszValue);
     297    int vrc = mpVMM->pfnCFGMR3InsertString(pNode, pcszName, pcszValue);
    301298    if (RT_FAILURE(vrc))
    302299        throw ConfigError("CFGMR3InsertString", vrc, pcszName);
     
    310307 * @param   rStrValue       The string value.
    311308 */
    312 static void InsertConfigString(PCFGMNODE pNode,
    313                                const char *pcszName,
    314                                const Utf8Str &rStrValue)
     309void Console::InsertConfigString(PCFGMNODE pNode, const char *pcszName, const Utf8Str &rStrValue)
    315310{
    316     int vrc = CFGMR3InsertStringN(pNode,
    317                                   pcszName,
    318                                   rStrValue.c_str(),
    319                                   rStrValue.length());
     311    int vrc = mpVMM->pfnCFGMR3InsertStringN(pNode, pcszName, rStrValue.c_str(), rStrValue.length());
    320312    if (RT_FAILURE(vrc))
    321313        throw ConfigError("CFGMR3InsertStringLengthKnown", vrc, pcszName);
     
    330322 * @param   rBstrValue      The string value.
    331323 */
    332 static void InsertConfigString(PCFGMNODE pNode,
    333                                const char *pcszName,
    334                                const Bstr &rBstrValue)
     324void Console::InsertConfigString(PCFGMNODE pNode, const char *pcszName, const Bstr &rBstrValue)
    335325{
    336326    InsertConfigString(pNode, pcszName, Utf8Str(rBstrValue));
    337327}
    338328
    339 #ifdef VBOX_WITH_CLOUD_NET
    340329/**
    341330 * Helper that calls CFGMR3InsertPassword and throws an RTCError if that
     
    345334 * @param   rStrValue       The string value.
    346335 */
    347 static void InsertConfigPassword(PCFGMNODE pNode,
    348                                const char *pcszName,
    349                                const Utf8Str &rStrValue)
     336void Console::InsertConfigPassword(PCFGMNODE pNode, const char *pcszName, const Utf8Str &rStrValue)
    350337{
    351     int vrc = CFGMR3InsertPasswordN(pNode,
    352                                     pcszName,
    353                                     rStrValue.c_str(),
    354                                     rStrValue.length());
     338    int vrc = mpVMM->pfnCFGMR3InsertPasswordN(pNode, pcszName, rStrValue.c_str(), rStrValue.length());
    355339    if (RT_FAILURE(vrc))
    356340        throw ConfigError("CFGMR3InsertPasswordLengthKnown", vrc, pcszName);
    357341}
    358 #endif /* VBOX_WITH_CLOUD_NET */
    359342
    360343/**
     
    366349 * @param   cbBytes         See CFGMR3InsertBytes.
    367350 */
    368 static void InsertConfigBytes(PCFGMNODE pNode,
    369                               const char *pcszName,
    370                               const void *pvBytes,
    371                               size_t cbBytes)
     351void Console::InsertConfigBytes(PCFGMNODE pNode, const char *pcszName, const void *pvBytes, size_t cbBytes)
    372352{
    373     int vrc = CFGMR3InsertBytes(pNode,
    374                                 pcszName,
    375                                 pvBytes,
    376                                 cbBytes);
     353    int vrc = mpVMM->pfnCFGMR3InsertBytes(pNode, pcszName, pvBytes, cbBytes);
    377354    if (RT_FAILURE(vrc))
    378355        throw ConfigError("CFGMR3InsertBytes", vrc, pcszName);
     
    387364 * @param   u64Integer      See CFGMR3InsertInteger.
    388365 */
    389 static void InsertConfigInteger(PCFGMNODE pNode,
    390                                 const char *pcszName,
    391                                 uint64_t u64Integer)
     366void Console::InsertConfigInteger(PCFGMNODE pNode, const char *pcszName, uint64_t u64Integer)
    392367{
    393     int vrc = CFGMR3InsertInteger(pNode,
    394                                   pcszName,
    395                                   u64Integer);
     368    int vrc = mpVMM->pfnCFGMR3InsertInteger(pNode, pcszName, u64Integer);
    396369    if (RT_FAILURE(vrc))
    397370        throw ConfigError("CFGMR3InsertInteger", vrc, pcszName);
     
    405378 * @param   ppChild         See CFGMR3InsertNode.
    406379 */
    407 static void InsertConfigNode(PCFGMNODE pNode,
    408                              const char *pcszName,
    409                              PCFGMNODE *ppChild)
     380void Console::InsertConfigNode(PCFGMNODE pNode, const char *pcszName, PCFGMNODE *ppChild)
    410381{
    411     int vrc = CFGMR3InsertNode(pNode, pcszName, ppChild);
     382    int vrc = mpVMM->pfnCFGMR3InsertNode(pNode, pcszName, ppChild);
    412383    if (RT_FAILURE(vrc))
    413384        throw ConfigError("CFGMR3InsertNode", vrc, pcszName);
     
    422393 * @param   ...             Format arguments.
    423394 */
    424 static void InsertConfigNodeF(PCFGMNODE pNode,
    425                               PCFGMNODE *ppChild,
    426                               const char *pszNameFormat,
    427                               ...)
     395void Console::InsertConfigNodeF(PCFGMNODE pNode, PCFGMNODE *ppChild, const char *pszNameFormat, ...)
    428396{
    429397    va_list va;
    430398    va_start(va, pszNameFormat);
    431     int vrc = CFGMR3InsertNodeF(pNode, ppChild, "%N", pszNameFormat, &va);
     399    int vrc = mpVMM->pfnCFGMR3InsertNodeF(pNode, ppChild, "%N", pszNameFormat, &va);
    432400    va_end(va);
    433401    if (RT_FAILURE(vrc))
     
    441409 * @param   pcszName        See CFGMR3RemoveValue.
    442410 */
    443 static void RemoveConfigValue(PCFGMNODE pNode,
    444                               const char *pcszName)
     411void Console::RemoveConfigValue(PCFGMNODE pNode, const char *pcszName)
    445412{
    446     int vrc = CFGMR3RemoveValue(pNode, pcszName);
     413    int vrc = mpVMM->pfnCFGMR3RemoveValue(pNode, pcszName);
    447414    if (RT_FAILURE(vrc))
    448415        throw ConfigError("CFGMR3RemoveValue", vrc, pcszName);
     
    498465#define MAX_BIOS_LUN_COUNT   4
    499466
    500 static int SetBiosDiskInfo(ComPtr<IMachine> pMachine, PCFGMNODE pCfg, PCFGMNODE pBiosCfg,
    501                            Bstr controllerName, const char * const s_apszBiosConfig[4])
     467int Console::SetBiosDiskInfo(ComPtr<IMachine> pMachine, PCFGMNODE pCfg, PCFGMNODE pBiosCfg,
     468                             Bstr controllerName, const char * const s_apszBiosConfig[4])
    502469{
    503470    RT_NOREF(pCfg);
     
    532499        {
    533500            DeviceType_T lType;
    534             hrc = pMediumAtt->COMGETTER(Type)(&lType);                    H();
     501            hrc = pMediumAtt->COMGETTER(Type)(&lType);                  H();
    535502            if (SUCCEEDED(hrc) && lType == DeviceType_HardDisk)
    536503            {
     
    552519        u32MaxPortCount = u32HDCount;
    553520    for (size_t j = 1; j < u32MaxPortCount; j++)
    554         lPortLUN[j] = GetNextUsedPort(lPortUsed,
    555                                       lPortLUN[j-1],
    556                                        u32HDCount);
     521        lPortLUN[j] = GetNextUsedPort(lPortUsed, lPortLUN[j-1], u32HDCount);
    557522    if (pBiosCfg)
    558523    {
     
    595560    if (!mptrExtPackManager->i_isExtPackUsable(s_pszPCIRawExtPackName))
    596561        /* Always fatal! */
    597         return VMR3SetError(pUVM, VERR_NOT_FOUND, RT_SRC_POS,
    598                 N_("Implementation of the PCI passthrough framework not found!\n"
    599                    "The VM cannot be started. To fix this problem, either "
    600                    "install the '%s' or disable PCI passthrough via VBoxManage"),
    601                 s_pszPCIRawExtPackName);
     562        return pVMM->pfnVMR3SetError(pUVM, VERR_NOT_FOUND, RT_SRC_POS,
     563                                     N_("Implementation of the PCI passthrough framework not found!\n"
     564                                        "The VM cannot be started. To fix this problem, either "
     565                                        "install the '%s' or disable PCI passthrough via VBoxManage"),
     566                                     s_pszPCIRawExtPackName);
    602567# endif
    603568
     
    742707
    743708/**
    744  *  Construct the VM configuration tree (CFGM).
     709 * Construct the VM configuration tree (CFGM).
    745710 *
    746  *  This is a callback for VMR3Create() call. It is called from CFGMR3Init()
    747  *  in the emulation thread (EMT). Any per thread COM/XPCOM initialization
    748  *  is done here.
     711 * This is a callback for VMR3Create() call. It is called from CFGMR3Init() in
     712 * the emulation thread (EMT). Any per thread COM/XPCOM initialization is done
     713 * here.
    749714 *
    750  *  @param   pUVM                The user mode VM handle.
    751  *  @param   pVM                 The cross context VM handle.
    752  *  @param   pvConsole           Pointer to the VMPowerUpTask object.
    753  *  @return  VBox status code.
     715 * @returns VBox status code.
     716 * @param   pUVM        The user mode VM handle.
     717 * @param   pVM         The cross context VM handle.
     718 * @param   pVMM        The VMM ring-3 vtable.
     719 * @param   pvConsole   Pointer to the VMPowerUpTask object.
    754720 *
    755  *  @note Locks the Console object for writing.
     721 * @note Locks the Console object for writing.
    756722 */
    757 DECLCALLBACK(int) Console::i_configConstructor(PUVM pUVM, PVM pVM, void *pvConsole)
     723/*static*/ DECLCALLBACK(int)
     724Console::i_configConstructor(PUVM pUVM, PVM pVM, PCVMMR3VTABLE pVMM, void *pvConsole)
    758725{
    759726    LogFlowFuncEnter();
     
    773740     */
    774741    pConsole->mpUVM = pUVM;
    775     VMR3RetainUVM(pUVM);
     742    pVMM->pfnVMR3RetainUVM(pUVM);
    776743    int vrc;
    777744    try
    778745    {
    779         vrc = pConsole->i_configConstructorInner(pUVM, pVM, &alock);
     746        vrc = pConsole->i_configConstructorInner(pUVM, pVM, pVMM, &alock);
    780747    }
    781748    catch (...)
     
    786753    {
    787754        pConsole->mpUVM = NULL;
    788         VMR3ReleaseUVM(pUVM);
     755        pVMM->pfnVMR3ReleaseUVM(pUVM);
    789756    }
    790757
     
    799766 * @param   pUVM        The user mode VM handle.
    800767 * @param   pVM         The cross context VM handle.
     768 * @param   pVMM        The VMM vtable.
    801769 * @param   pAlock      The automatic lock instance.  This is for when we have
    802770 *                      to leave it in order to avoid deadlocks (ext packs and
    803771 *                      more).
    804772 */
    805 int Console::i_configConstructorInner(PUVM pUVM, PVM pVM, AutoWriteLock *pAlock)
     773int Console::i_configConstructorInner(PUVM pUVM, PVM pVM, PCVMMR3VTABLE pVMM, AutoWriteLock *pAlock)
    806774{
    807775    RT_NOREF(pVM /* when everything is disabled */);
     
    850818    uint32_t cbMcfgLength  = 0;
    851819
    852     ParavirtProvider_T paravirtProvider;
    853     hrc = pMachine->GetEffectiveParavirtProvider(&paravirtProvider);                        H();
     820    ParavirtProvider_T enmParavirtProvider;
     821    hrc = pMachine->GetEffectiveParavirtProvider(&enmParavirtProvider);                     H();
    854822
    855823    Bstr strParavirtDebug;
     
    925893    {
    926894        if (chipsetType != ChipsetType_ICH9)
    927             return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
    928                                 N_("IOMMU uses MSIs which requires the ICH9 chipset implementation."));
     895            return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
     896                                         N_("IOMMU uses MSIs which requires the ICH9 chipset implementation."));
    929897        if (!fIOAPIC)
    930             return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
    931                             N_("IOMMU requires an I/O APIC for remapping interrupts."));
     898            return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
     899                                         N_("IOMMU requires an I/O APIC for remapping interrupts."));
    932900    }
    933901#else
     
    935903#endif
    936904    Assert(iommuType != IommuType_Automatic);
    937     BusAssignmentManager *pBusMgr = mBusMgr = BusAssignmentManager::createInstance(chipsetType, iommuType);
     905    BusAssignmentManager *pBusMgr = mBusMgr = BusAssignmentManager::createInstance(pVMM, chipsetType, iommuType);
    938906
    939907    ULONG cCpus = 1;
     
    987955     * This is the only node in the tree.
    988956     */
    989     PCFGMNODE pRoot = CFGMR3GetRootU(pUVM);
     957    PCFGMNODE pRoot = pVMM->pfnCFGMR3GetRootU(pUVM);
    990958    Assert(pRoot);
    991959
     
    11881156        {
    11891157            if (fIsGuest64Bit)
    1190                 return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS, N_("Cannot disable the APIC for a 64-bit guest."));
     1158                return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
     1159                                             N_("Cannot disable the APIC for a 64-bit guest."));
    11911160            if (cCpus > 1)
    1192                 return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS, N_("Cannot disable the APIC for an SMP guest."));
     1161                return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
     1162                                             N_("Cannot disable the APIC for an SMP guest."));
    11931163            if (fIOAPIC)
    1194             {
    1195                 return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
    1196                                     N_("Cannot disable the APIC when the I/O APIC is present."));
    1197             }
     1164                return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
     1165                                             N_("Cannot disable the APIC when the I/O APIC is present."));
    11981166        }
    11991167
     
    13341302        const char *pcszParavirtProvider;
    13351303        bool fGimDeviceNeeded = true;
    1336         switch (paravirtProvider)
     1304        switch (enmParavirtProvider)
    13371305        {
    13381306            case ParavirtProvider_None:
     
    13541322
    13551323            default:
    1356                 AssertMsgFailed(("Invalid paravirtProvider=%d\n", paravirtProvider));
    1357                 return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS, N_("Invalid paravirt. provider '%d'"),
    1358                                     paravirtProvider);
     1324                AssertMsgFailed(("Invalid enmParavirtProvider=%d\n", enmParavirtProvider));
     1325                return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS, N_("Invalid paravirt. provider '%d'"),
     1326                                             enmParavirtProvider);
    13591327        }
    13601328        InsertConfigString(pParavirtNode, "Provider", pcszParavirtProvider);
     
    13691337        {
    13701338            /* Hyper-V debug options. */
    1371             if (paravirtProvider == ParavirtProvider_HyperV)
     1339            if (enmParavirtProvider == ParavirtProvider_HyperV)
    13721340            {
    13731341                bool         fGimHvDebug = false;
     
    14091377                    {
    14101378                        AssertMsgFailed(("Unrecognized Hyper-V debug option '%s'\n", strKey.c_str()));
    1411                         return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
    1412                                             N_("Unrecognized Hyper-V debug option '%s' in '%s'"), strKey.c_str(),
    1413                                             strDebugOptions.c_str());
     1379                        return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
     1380                                                     N_("Unrecognized Hyper-V debug option '%s' in '%s'"), strKey.c_str(),
     1381                                                     strDebugOptions.c_str());
    14141382                    }
    14151383                }
     
    15031471
    15041472            if (strName.isEmpty())
    1505                 return VMR3SetError(pUVM, VERR_CFGM_NO_NODE, RT_SRC_POS,
    1506                                     N_("No bandwidth group name specified"));
     1473                return pVMM->pfnVMR3SetError(pUVM, VERR_CFGM_NO_NODE, RT_SRC_POS, N_("No bandwidth group name specified"));
    15071474
    15081475            if (enmType == BandwidthGroupType_Disk)
     
    16421609                    }
    16431610                    else
    1644                         return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
    1645                                             N_("Failed to find PCI address of the assigned IOMMU device!"));
     1611                        return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
     1612                                                     N_("Failed to find PCI address of the assigned IOMMU device!"));
    16461613                }
    16471614
     
    18531820            default:
    18541821                AssertMsgFailed(("Invalid graphicsController=%d\n", enmGraphicsController));
    1855                 return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
    1856                                     N_("Invalid graphics controller type '%d'"), enmGraphicsController);
     1822                return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
     1823                                             N_("Invalid graphics controller type '%d'"), enmGraphicsController);
    18571824        }
    18581825
     
    18931860            InsertConfigInteger(pBiosCfg,  "McfgLength", cbMcfgLength);
    18941861
    1895             DeviceType_T bootDevice;
    18961862            AssertMsgReturn(SchemaDefs::MaxBootPosition <= 9, ("Too many boot devices %d\n", SchemaDefs::MaxBootPosition),
    18971863                            VERR_INVALID_PARAMETER);
     
    18991865            for (ULONG pos = 1; pos <= SchemaDefs::MaxBootPosition; ++pos)
    19001866            {
    1901                 hrc = pMachine->GetBootOrder(pos, &bootDevice);                             H();
     1867                DeviceType_T enmBootDevice;
     1868                hrc = pMachine->GetBootOrder(pos, &enmBootDevice);                          H();
    19021869
    19031870                char szParamName[] = "BootDeviceX";
     
    19051872
    19061873                const char *pszBootDevice;
    1907                 switch (bootDevice)
     1874                switch (enmBootDevice)
    19081875                {
    19091876                    case DeviceType_Null:
     
    19231890                        break;
    19241891                    default:
    1925                         AssertMsgFailed(("Invalid bootDevice=%d\n", bootDevice));
    1926                         return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
    1927                                             N_("Invalid boot device '%d'"), bootDevice);
     1892                        AssertMsgFailed(("Invalid enmBootDevice=%d\n", enmBootDevice));
     1893                        return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
     1894                                                     N_("Invalid boot device '%d'"), enmBootDevice);
    19281895                }
    19291896                InsertConfigString(pBiosCfg, szParamName, pszBootDevice);
     
    21472114                        /* Always fatal! Up to VBox 4.0.4 we allowed to start the VM anyway
    21482115                         * but this induced problems when the user saved + restored the VM! */
    2149                         return VMR3SetError(pUVM, VERR_NOT_FOUND, RT_SRC_POS,
     2116                        return pVMM->pfnVMR3SetError(pUVM, VERR_NOT_FOUND, RT_SRC_POS,
    21502117                                N_("Implementation of the USB 2.0 controller not found!\n"
    21512118                                   "Because the USB 2.0 controller state is part of the saved "
     
    21982165                    {
    21992166                        /* Always fatal. */
    2200                         return VMR3SetError(pUVM, VERR_NOT_FOUND, RT_SRC_POS,
     2167                        return pVMM->pfnVMR3SetError(pUVM, VERR_NOT_FOUND, RT_SRC_POS,
    22012168                                N_("Implementation of the USB 3.0 controller not found!\n"
    22022169                                   "Because the USB 3.0 controller state is part of the saved "
     
    25352502                    }
    25362503                    else
    2537                         return VMR3SetError(pUVM, VERR_NOT_FOUND, RT_SRC_POS,
     2504                        return pVMM->pfnVMR3SetError(pUVM, VERR_NOT_FOUND, RT_SRC_POS,
    25382505                                N_("There is no USB controller enabled but there\n"
    25392506                                   "is at least one USB storage device configured for this VM.\n"
     
    26122579                                              false /* fHotplug */,
    26132580                                              pUVM,
     2581                                              pVMM,
    26142582                                              paLedDevType,
    26152583                                              NULL /* ppLunL0 */);
     
    26762644                default:
    26772645                    AssertMsgFailed(("Invalid network adapter type '%d' for slot '%d'", adapterType, uInstance));
    2678                     return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
    2679                                         N_("Invalid network adapter type '%d' for slot '%d'"), adapterType, uInstance);
     2646                    return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
     2647                                                 N_("Invalid network adapter type '%d' for slot '%d'"), adapterType, uInstance);
    26802648            }
    26812649
     
    28352803                                 pInst,
    28362804                                 false /*fAttachDetach*/,
    2837                                  fIgnoreConnectFailure);
     2805                                 fIgnoreConnectFailure,
     2806                                 pUVM,
     2807                                 pVMM);
    28382808            if (RT_FAILURE(rc))
    28392809                return rc;
     
    32533223            AudioDriverCfg DrvCfgVideoRec(pszAudioDevice, 0 /* Instance */, idxAudioLun, "AudioVideoRec",
    32543224                                          false /*a_fEnabledIn*/, true /*a_fEnabledOut*/);
    3255             rc = Recording.mAudioRec->InitializeConfig(&DrvCfgVideoRec);
     3225            rc = mRecording.mAudioRec->InitializeConfig(&DrvCfgVideoRec);
    32563226            AssertRCStmt(rc, throw ConfigError(__FUNCTION__, rc, "Recording.mAudioRec->InitializeConfig failed"));
    32573227            idxAudioLun++;
     
    35533523                    }
    35543524                    else
    3555                         return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
    3556                                             N_("AMD IOMMU is enabled, but the I/O APIC is not assigned a PCI address!"));
     3525                        return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
     3526                                                     N_("AMD IOMMU is enabled, but the I/O APIC is not assigned a PCI address!"));
    35573527                }
    35583528            }
     
    35713541                    }
    35723542                    else
    3573                         return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
    3574                                             N_("Intel IOMMU is enabled, but the I/O APIC is not assigned a PCI address!"));
     3543                        return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
     3544                                                     N_("Intel IOMMU is enabled, but the I/O APIC is not assigned a PCI address!"));
    35753545                }
    35763546            }
     
    37313701    {
    37323702        // InsertConfig threw something:
    3733         VMR3SetError(pUVM, x.m_vrc, RT_SRC_POS, "Caught ConfigError: %Rrc - %s", x.m_vrc, x.what());
     3703        pVMM->pfnVMR3SetError(pUVM, x.m_vrc, RT_SRC_POS, "Caught ConfigError: %Rrc - %s", x.m_vrc, x.what());
    37343704        return x.m_vrc;
    37353705    }
     
    37703740     * Register VM state change handler.
    37713741     */
    3772     int rc2 = VMR3AtStateRegister(pUVM, Console::i_vmstateChangeCallback, this);
     3742    int rc2 = pVMM->pfnVMR3AtStateRegister(pUVM, Console::i_vmstateChangeCallback, this);
    37733743    AssertRC(rc2);
    37743744    if (RT_SUCCESS(rc))
     
    37783748     * Register VM runtime error handler.
    37793749     */
    3780     rc2 = VMR3AtRuntimeErrorRegister(pUVM, Console::i_atVMRuntimeErrorCallback, this);
     3750    rc2 = pVMM->pfnVMR3AtRuntimeErrorRegister(pUVM, Console::i_atVMRuntimeErrorCallback, this);
    37813751    AssertRC(rc2);
    37823752    if (RT_SUCCESS(rc))
     
    39823952            if (i2 < cGlobalValues)
    39833953                // this is still one of the global values:
    3984                 hrc = pVirtualBox->GetExtraData(Bstr(strKey).raw(),
    3985                                                 bstrExtraDataValue.asOutParam());
     3954                hrc = pVirtualBox->GetExtraData(Bstr(strKey).raw(), bstrExtraDataValue.asOutParam());
    39863955            else
    3987                 hrc = pMachine->GetExtraData(Bstr(strKey).raw(),
    3988                                              bstrExtraDataValue.asOutParam());
     3956                hrc = pMachine->GetExtraData(Bstr(strKey).raw(), bstrExtraDataValue.asOutParam());
    39893957            if (FAILED(hrc))
    39903958                LogRel(("Warning: Cannot get extra data key %s, rc = %Rhrc\n", strKey.c_str(), hrc));
     
    40123980
    40133981                /* does the node already exist? */
    4014                 pNode = CFGMR3GetChild(pRoot, pszExtraDataKey);
     3982                pNode = mpVMM->pfnCFGMR3GetChild(pRoot, pszExtraDataKey);
    40153983                if (pNode)
    4016                     CFGMR3RemoveValue(pNode, pszCFGMValueName);
     3984                    mpVMM->pfnCFGMR3RemoveValue(pNode, pszCFGMValueName);
    40173985                else
    40183986                {
    40193987                    /* create the node */
    4020                     rc = CFGMR3InsertNode(pRoot, pszExtraDataKey, &pNode);
     3988                    rc = mpVMM->pfnCFGMR3InsertNode(pRoot, pszExtraDataKey, &pNode);
    40213989                    if (RT_FAILURE(rc))
    40223990                    {
     
    40334001                pszCFGMValueName = pszExtraDataKey;
    40344002                pszExtraDataKey--;
    4035                 CFGMR3RemoveValue(pNode, pszCFGMValueName);
     4003                mpVMM->pfnCFGMR3RemoveValue(pNode, pszCFGMValueName);
    40364004            }
    40374005
     
    40424010             */
    40434011            Utf8Str strCFGMValueUtf8(bstrExtraDataValue);
    4044             if (!strCFGMValueUtf8.isEmpty())
     4012            if (strCFGMValueUtf8.isNotEmpty())
    40454013            {
    40464014                uint64_t u64Value;
     
    40484016                /* check for type prefix first. */
    40494017                if (!strncmp(strCFGMValueUtf8.c_str(), RT_STR_TUPLE("string:")))
    4050                     InsertConfigString(pNode, pszCFGMValueName, strCFGMValueUtf8.c_str() + sizeof("string:") - 1);
     4018                    rc = mpVMM->pfnCFGMR3InsertString(pNode, pszCFGMValueName, strCFGMValueUtf8.c_str() + sizeof("string:") - 1);
    40514019                else if (!strncmp(strCFGMValueUtf8.c_str(), RT_STR_TUPLE("integer:")))
    40524020                {
    40534021                    rc = RTStrToUInt64Full(strCFGMValueUtf8.c_str() + sizeof("integer:") - 1, 0, &u64Value);
    40544022                    if (RT_SUCCESS(rc))
    4055                         rc = CFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
     4023                        rc = mpVMM->pfnCFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
    40564024                }
    40574025                else if (!strncmp(strCFGMValueUtf8.c_str(), RT_STR_TUPLE("bytes:")))
     
    40664034                            rc = RTBase64Decode(pszBase64, pvBytes, cbValue, NULL, NULL);
    40674035                            if (RT_SUCCESS(rc))
    4068                                 rc = CFGMR3InsertBytes(pNode, pszCFGMValueName, pvBytes, cbValue);
     4036                                rc = mpVMM->pfnCFGMR3InsertBytes(pNode, pszCFGMValueName, pvBytes, cbValue);
    40694037                            RTMemTmpFree(pvBytes);
    40704038                        }
     
    40734041                    }
    40744042                    else if (cbValue == 0)
    4075                         rc = CFGMR3InsertBytes(pNode, pszCFGMValueName, NULL, 0);
     4043                        rc = mpVMM->pfnCFGMR3InsertBytes(pNode, pszCFGMValueName, NULL, 0);
    40764044                    else
    40774045                        rc = VERR_INVALID_BASE64_ENCODING;
     
    40794047                /* auto detect type. */
    40804048                else if (RT_SUCCESS(RTStrToUInt64Full(strCFGMValueUtf8.c_str(), 0, &u64Value)))
    4081                     rc = CFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
     4049                    rc = mpVMM->pfnCFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
    40824050                else
    4083                     InsertConfigString(pNode, pszCFGMValueName, strCFGMValueUtf8);
     4051                    rc = mpVMM->pfnCFGMR3InsertString(pNode, pszCFGMValueName, strCFGMValueUtf8.c_str());
    40844052                AssertLogRelMsgRCBreak(rc, ("failed to insert CFGM value '%s' to key '%s'\n",
    40854053                                            strCFGMValueUtf8.c_str(), pszExtraDataKey));
     
    43504318    if (uCaps & MediumFormatCapabilities_File)
    43514319    {
    4352         Bstr strFile;
    4353         hrc = pMedium->COMGETTER(Location)(strFile.asOutParam());                   H();
    4354         Utf8Str utfFile = Utf8Str(strFile);
    4355         Bstr strSnap;
     4320        Bstr bstrFile;
     4321        hrc = pMedium->COMGETTER(Location)(bstrFile.asOutParam());                  H();
     4322        Utf8Str const strFile(bstrFile);
     4323
     4324        Bstr bstrSnap;
    43564325        ComPtr<IMachine> pMachine = i_machine();
    4357         hrc = pMachine->COMGETTER(SnapshotFolder)(strSnap.asOutParam());            H();
    4358         Utf8Str utfSnap = Utf8Str(strSnap);
     4326        hrc = pMachine->COMGETTER(SnapshotFolder)(bstrSnap.asOutParam());           H();
     4327        Utf8Str const strSnap(bstrSnap);
     4328
    43594329        RTFSTYPE enmFsTypeFile = RTFSTYPE_UNKNOWN;
    4360         RTFSTYPE enmFsTypeSnap = RTFSTYPE_UNKNOWN;
    4361         int rc2 = RTFsQueryType(utfFile.c_str(), &enmFsTypeFile);
    4362         AssertMsgRCReturn(rc2, ("Querying the file type of '%s' failed!\n", utfFile.c_str()), rc2);
     4330        int rc2 = RTFsQueryType(strFile.c_str(), &enmFsTypeFile);
     4331        AssertMsgRCReturn(rc2, ("Querying the file type of '%s' failed!\n", strFile.c_str()), rc2);
     4332
    43634333        /* Ignore the error code. On error, the file system type is still 'unknown' so
    43644334         * none of the following paths are taken. This can happen for new VMs which
    43654335         * still don't have a snapshot folder. */
    4366         (void)RTFsQueryType(utfSnap.c_str(), &enmFsTypeSnap);
     4336        RTFSTYPE enmFsTypeSnap = RTFSTYPE_UNKNOWN;
     4337        (void)RTFsQueryType(strSnap.c_str(), &enmFsTypeSnap);
    43674338        if (!mfSnapshotFolderDiskTypeShown)
    43684339        {
    4369             LogRel(("File system of '%s' (snapshots) is %s\n",
    4370                     utfSnap.c_str(), RTFsTypeName(enmFsTypeSnap)));
     4340            LogRel(("File system of '%s' (snapshots) is %s\n", strSnap.c_str(), RTFsTypeName(enmFsTypeSnap)));
    43714341            mfSnapshotFolderDiskTypeShown = true;
    43724342        }
    4373         LogRel(("File system of '%s' is %s\n", utfFile.c_str(), RTFsTypeName(enmFsTypeFile)));
     4343        LogRel(("File system of '%s' is %s\n", strFile.c_str(), RTFsTypeName(enmFsTypeFile)));
    43744344        LONG64 i64Size;
    43754345        hrc = pMedium->COMGETTER(LogicalSize)(&i64Size);                            H();
     
    43814351            uint64_t u64Print = formatDiskSize((uint64_t)i64Size, &pszUnit);
    43824352            i_atVMRuntimeErrorCallbackF(0, "FatPartitionDetected",
    4383                     N_("The medium '%ls' has a logical size of %RU64%s "
    4384                     "but the file system the medium is located on seems "
    4385                     "to be FAT(32) which cannot handle files bigger than 4GB.\n"
    4386                     "We strongly recommend to put all your virtual disk images and "
    4387                     "the snapshot folder onto an NTFS partition"),
    4388                     strFile.raw(), u64Print, pszUnit);
     4353                                        N_("The medium '%s' has a logical size of %RU64%s "
     4354                                           "but the file system the medium is located on seems "
     4355                                           "to be FAT(32) which cannot handle files bigger than 4GB.\n"
     4356                                           "We strongly recommend to put all your virtual disk images and "
     4357                                           "the snapshot folder onto an NTFS partition"),
     4358                                        strFile.c_str(), u64Print, pszUnit);
    43894359        }
    43904360#else /* !RT_OS_WINDOWS */
     
    43964366        {
    43974367            RTFILE file;
    4398             int rc = RTFileOpen(&file, utfFile.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     4368            int rc = RTFileOpen(&file, strFile.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    43994369            if (RT_SUCCESS(rc))
    44004370            {
     
    44124382                    uint64_t u64PrintMax = formatDiskSize(maxSize, &pszUnitMax);
    44134383                    i_atVMRuntimeErrorCallbackF(0, "FatPartitionDetected", /* <= not exact but ... */
    4414                             N_("The medium '%ls' has a logical size of %RU64%s "
    4415                             "but the file system the medium is located on can "
    4416                             "only handle files up to %RU64%s in theory.\n"
    4417                             "We strongly recommend to put all your virtual disk "
    4418                             "images and the snapshot folder onto a proper "
    4419                             "file system (e.g. ext3) with a sufficient size"),
    4420                             strFile.raw(), u64PrintSiz, pszUnitSiz, u64PrintMax, pszUnitMax);
     4384                                                N_("The medium '%s' has a logical size of %RU64%s "
     4385                                                   "but the file system the medium is located on can "
     4386                                                   "only handle files up to %RU64%s in theory.\n"
     4387                                                   "We strongly recommend to put all your virtual disk "
     4388                                                   "images and the snapshot folder onto a proper "
     4389                                                   "file system (e.g. ext3) with a sufficient size"),
     4390                                                strFile.c_str(), u64PrintSiz, pszUnitSiz, u64PrintMax, pszUnitMax);
    44214391                }
    44224392            }
     
    44364406            i_atVMRuntimeErrorCallbackF(0, "FatPartitionDetected",
    44374407#ifdef RT_OS_WINDOWS
    4438                     N_("The snapshot folder of this VM '%ls' seems to be located on "
    4439                     "a FAT(32) file system. The logical size of the medium '%ls' "
    4440                     "(%RU64%s) is bigger than the maximum file size this file "
    4441                     "system can handle (4GB).\n"
    4442                     "We strongly recommend to put all your virtual disk images and "
    4443                     "the snapshot folder onto an NTFS partition"),
     4408                                        N_("The snapshot folder of this VM '%s' seems to be located on "
     4409                                           "a FAT(32) file system. The logical size of the medium '%s' "
     4410                                           "(%RU64%s) is bigger than the maximum file size this file "
     4411                                           "system can handle (4GB).\n"
     4412                                           "We strongly recommend to put all your virtual disk images and "
     4413                                           "the snapshot folder onto an NTFS partition"),
    44444414#else
    4445                     N_("The snapshot folder of this VM '%ls' seems to be located on "
    4446                         "a FAT(32) file system. The logical size of the medium '%ls' "
    4447                         "(%RU64%s) is bigger than the maximum file size this file "
    4448                         "system can handle (4GB).\n"
    4449                         "We strongly recommend to put all your virtual disk images and "
    4450                         "the snapshot folder onto a proper file system (e.g. ext3)"),
     4415                                        N_("The snapshot folder of this VM '%s' seems to be located on "
     4416                                            "a FAT(32) file system. The logical size of the medium '%s' "
     4417                                            "(%RU64%s) is bigger than the maximum file size this file "
     4418                                            "system can handle (4GB).\n"
     4419                                            "We strongly recommend to put all your virtual disk images and "
     4420                                            "the snapshot folder onto a proper file system (e.g. ext3)"),
    44514421#endif
    4452                     strSnap.raw(), strFile.raw(), u64Print, pszUnit);
     4422                                        strSnap.c_str(), strFile.c_str(), u64Print, pszUnit);
    44534423            /* Show this particular warning only once */
    44544424            mfSnapshotFolderSizeWarningShown = true;
     
    44764446            {
    44774447                i_atVMRuntimeErrorCallbackF(0, "Ext4PartitionDetected",
    4478                         N_("The host I/O cache for at least one controller is disabled "
    4479                            "and the medium '%ls' for this VM "
    4480                            "is located on an %s partition. There is a known Linux "
    4481                            "kernel bug which can lead to the corruption of the virtual "
    4482                            "disk image under these conditions.\n"
    4483                            "Either enable the host I/O cache permanently in the VM "
    4484                            "settings or put the disk image and the snapshot folder "
    4485                            "onto a different file system.\n"
    4486                            "The host I/O cache will now be enabled for this medium"),
    4487                         strFile.raw(), enmFsTypeFile == RTFSTYPE_EXT4 ? "ext4" : "xfs");
     4448                                            N_("The host I/O cache for at least one controller is disabled "
     4449                                               "and the medium '%s' for this VM "
     4450                                               "is located on an %s partition. There is a known Linux "
     4451                                               "kernel bug which can lead to the corruption of the virtual "
     4452                                               "disk image under these conditions.\n"
     4453                                               "Either enable the host I/O cache permanently in the VM "
     4454                                               "settings or put the disk image and the snapshot folder "
     4455                                               "onto a different file system.\n"
     4456                                               "The host I/O cache will now be enabled for this medium"),
     4457                                            strFile.c_str(), enmFsTypeFile == RTFSTYPE_EXT4 ? "ext4" : "xfs");
    44884458                *pfUseHostIOCache = true;
    44894459            }
     
    44934463            {
    44944464                i_atVMRuntimeErrorCallbackF(0, "Ext4PartitionDetected",
    4495                         N_("The host I/O cache for at least one controller is disabled "
    4496                            "and the snapshot folder for this VM "
    4497                            "is located on an %s partition. There is a known Linux "
    4498                            "kernel bug which can lead to the corruption of the virtual "
    4499                            "disk image under these conditions.\n"
    4500                            "Either enable the host I/O cache permanently in the VM "
    4501                            "settings or put the disk image and the snapshot folder "
    4502                            "onto a different file system.\n"
    4503                            "The host I/O cache will now be enabled for this medium"),
    4504                         enmFsTypeSnap == RTFSTYPE_EXT4 ? "ext4" : "xfs");
     4465                                            N_("The host I/O cache for at least one controller is disabled "
     4466                                               "and the snapshot folder for this VM "
     4467                                               "is located on an %s partition. There is a known Linux "
     4468                                               "kernel bug which can lead to the corruption of the virtual "
     4469                                               "disk image under these conditions.\n"
     4470                                               "Either enable the host I/O cache permanently in the VM "
     4471                                               "settings or put the disk image and the snapshot folder "
     4472                                               "onto a different file system.\n"
     4473                                               "The host I/O cache will now be enabled for this medium"),
     4474                                            enmFsTypeSnap == RTFSTYPE_EXT4 ? "ext4" : "xfs");
    45054475                *pfUseHostIOCache = true;
    45064476                mfSnapshotFolderExt4WarningShown = true;
     
    45224492        {
    45234493            i_atVMRuntimeErrorCallbackF(0, "Linux2618TooOld",
    4524                     N_("The host I/O cache for at least one controller is disabled. "
    4525                        "There is a known Linux kernel bug which can lead to kernel "
    4526                        "oopses under heavy load. To our knowledge this bug affects "
    4527                        "all 2.6.18 kernels.\n"
    4528                        "Either enable the host I/O cache permanently in the VM "
    4529                        "settings or switch to a newer host kernel.\n"
    4530                        "The host I/O cache will now be enabled for this medium"));
     4494                                        N_("The host I/O cache for at least one controller is disabled. "
     4495                                           "There is a known Linux kernel bug which can lead to kernel "
     4496                                           "oopses under heavy load. To our knowledge this bug affects "
     4497                                           "all 2.6.18 kernels.\n"
     4498                                           "Either enable the host I/O cache permanently in the VM "
     4499                                           "settings or switch to a newer host kernel.\n"
     4500                                           "The host I/O cache will now be enabled for this medium"));
    45314501            *pfUseHostIOCache = true;
    45324502        }
     
    45424512 *
    45434513 * @returns VBox status code.
    4544  * @param   pUVM       The usermode VM handle.
    4545  * @param   enmBus     The storage bus.
    4546  * @param   enmDevType The device type.
    4547  * @param   pcszDevice The device emulation.
    4548  * @param   uInstance  Instance of the device.
    4549  * @param   uLUN       The LUN on the device.
    4550  * @param   fForceUnmount  Whether to force unmounting.
     4514 * @param   pUVM            The usermode VM handle.
     4515 * @param   pVMM            The VMM vtable.
     4516 * @param   enmBus          The storage bus.
     4517 * @param   enmDevType      The device type.
     4518 * @param   pcszDevice      The device emulation.
     4519 * @param   uInstance       Instance of the device.
     4520 * @param   uLUN            The LUN on the device.
     4521 * @param   fForceUnmount   Whether to force unmounting.
    45514522 */
    4552 int Console::i_unmountMediumFromGuest(PUVM pUVM, StorageBus_T enmBus, DeviceType_T enmDevType,
     4523int Console::i_unmountMediumFromGuest(PUVM pUVM, PCVMMR3VTABLE pVMM, StorageBus_T enmBus, DeviceType_T enmDevType,
    45534524                                      const char *pcszDevice, unsigned uInstance, unsigned uLUN,
    4554                                       bool fForceUnmount)
     4525                                      bool fForceUnmount) RT_NOEXCEPT
    45554526{
    45564527    /* Unmount existing media only for floppy and DVD drives. */
     
    45584529    PPDMIBASE pBase;
    45594530    if (enmBus == StorageBus_USB)
    4560         rc = PDMR3UsbQueryDriverOnLun(pUVM, pcszDevice, uInstance, uLUN, "SCSI", &pBase);
     4531        rc = pVMM->pfnPDMR3UsbQueryDriverOnLun(pUVM, pcszDevice, uInstance, uLUN, "SCSI", &pBase);
    45614532    else if (   (enmBus == StorageBus_SAS || enmBus == StorageBus_SCSI || enmBus == StorageBus_VirtioSCSI)
    45624533             || (enmBus == StorageBus_SATA && enmDevType == DeviceType_DVD))
    4563         rc = PDMR3QueryDriverOnLun(pUVM, pcszDevice, uInstance, uLUN, "SCSI", &pBase);
     4534        rc = pVMM->pfnPDMR3QueryDriverOnLun(pUVM, pcszDevice, uInstance, uLUN, "SCSI", &pBase);
    45644535    else /* IDE or Floppy */
    4565         rc = PDMR3QueryLun(pUVM, pcszDevice, uInstance, uLUN, &pBase);
     4536        rc = pVMM->pfnPDMR3QueryLun(pUVM, pcszDevice, uInstance, uLUN, &pBase);
    45664537
    45674538    if (RT_FAILURE(rc))
     
    45934564 *
    45944565 * @returns VBox status code.
    4595  * @param   pCtlInst      The controler instance node in the CFGM tree.
    4596  * @param   pcszDevice    The device name.
    4597  * @param   uInstance     The device instance.
    4598  * @param   uLUN          The device LUN.
    4599  * @param   enmBus        The storage bus.
    4600  * @param   fAttachDetach Flag whether this is a change while the VM is running
    4601  * @param   fHotplug      Flag whether the guest should be notified about the device change.
    4602  * @param   fForceUnmount Flag whether to force unmounting the medium even if it is locked.
    4603  * @param   pUVM          The usermode VM handle.
    4604  * @param   enmDevType    The device type.
    4605  * @param   ppLunL0       Where to store the node to attach the new config to on success.
     4566 * @param   pCtlInst        The controler instance node in the CFGM tree.
     4567 * @param   pcszDevice      The device name.
     4568 * @param   uInstance       The device instance.
     4569 * @param   uLUN            The device LUN.
     4570 * @param   enmBus          The storage bus.
     4571 * @param   fAttachDetach   Flag whether this is a change while the VM is running
     4572 * @param   fHotplug        Flag whether the guest should be notified about the device change.
     4573 * @param   fForceUnmount   Flag whether to force unmounting the medium even if it is locked.
     4574 * @param   pUVM            The usermode VM handle.
     4575 * @param   pVMM            The VMM vtable.
     4576 * @param   enmDevType      The device type.
     4577 * @param   ppLunL0         Where to store the node to attach the new config to on success.
    46064578 */
    46074579int Console::i_removeMediumDriverFromVm(PCFGMNODE pCtlInst,
     
    46144586                                        bool fForceUnmount,
    46154587                                        PUVM pUVM,
     4588                                        PCVMMR3VTABLE pVMM,
    46164589                                        DeviceType_T enmDevType,
    46174590                                        PCFGMNODE *ppLunL0)
     
    46214594
    46224595    /* First check if the LUN already exists. */
    4623     PCFGMNODE pLunL0 = CFGMR3GetChildF(pCtlInst, "LUN#%u", uLUN);
     4596    PCFGMNODE pLunL0 = pVMM->pfnCFGMR3GetChildF(pCtlInst, "LUN#%u", uLUN);
    46244597    AssertReturn(!RT_VALID_PTR(pLunL0) || fAttachDetach, VERR_INTERNAL_ERROR);
    46254598
     
    46334606            && !fHotplug)
    46344607        {
    4635             rc = i_unmountMediumFromGuest(pUVM, enmBus, enmDevType, pcszDevice,
    4636                                           uInstance, uLUN, fForceUnmount);
     4608            rc = i_unmountMediumFromGuest(pUVM, pVMM, enmBus, enmDevType, pcszDevice, uInstance, uLUN, fForceUnmount);
    46374609            if (RT_FAILURE(rc))
    46384610                return rc;
     
    46524624        {
    46534625            /* Get the current attached driver we have to detach. */
    4654             PCFGMNODE pDrvLun = CFGMR3GetChildF(pCtlInst, "LUN#%u/AttachedDriver/", uLUN);
     4626            PCFGMNODE pDrvLun = pVMM->pfnCFGMR3GetChildF(pCtlInst, "LUN#%u/AttachedDriver/", uLUN);
    46554627            if (pDrvLun)
    46564628            {
    46574629                char szDriver[128];
    46584630                RT_ZERO(szDriver);
    4659                 rc  = CFGMR3QueryString(pDrvLun, "Driver", &szDriver[0], sizeof(szDriver));
     4631                rc  = pVMM->pfnCFGMR3QueryString(pDrvLun, "Driver", &szDriver[0], sizeof(szDriver));
    46604632                if (RT_SUCCESS(rc))
    46614633                    pszDriverDetach = RTStrDup(&szDriver[0]);
     
    46664638
    46674639        if (enmBus == StorageBus_USB)
    4668             rc = PDMR3UsbDriverDetach(pUVM, pcszDevice, uInstance, uLUN,
    4669                                       pszDriverDetach, 0 /* iOccurence */,
    4670                                       fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG);
     4640            rc = pVMM->pfnPDMR3UsbDriverDetach(pUVM, pcszDevice, uInstance, uLUN, pszDriverDetach,
     4641                                               0 /* iOccurence */, fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG);
    46714642        else
    4672             rc = PDMR3DriverDetach(pUVM, pcszDevice, uInstance, uLUN,
    4673                                    pszDriverDetach, 0 /* iOccurence */,
    4674                                    fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG);
     4643            rc = pVMM->pfnPDMR3DriverDetach(pUVM, pcszDevice, uInstance, uLUN, pszDriverDetach,
     4644                                            0 /* iOccurence */, fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG);
    46754645
    46764646        if (pszDriverDetach)
     
    46784648            RTStrFree(pszDriverDetach);
    46794649            /* Remove the complete node and create new for the new config. */
    4680             CFGMR3RemoveNode(pLunL0);
    4681             pLunL0 = CFGMR3GetChildF(pCtlInst, "LUN#%u", uLUN);
     4650            pVMM->pfnCFGMR3RemoveNode(pLunL0);
     4651            pLunL0 = pVMM->pfnCFGMR3GetChildF(pCtlInst, "LUN#%u", uLUN);
    46824652            if (pLunL0)
    46834653            {
     
    47084678        {
    47094679            fAddLun = true;
    4710             CFGMR3RemoveNode(pLunL0);
     4680            pVMM->pfnCFGMR3RemoveNode(pLunL0);
    47114681        }
    47124682    }
     
    47174687    {
    47184688        if (fAddLun)
    4719             InsertConfigNode(pCtlInst, Utf8StrFmt("LUN#%u", uLUN).c_str(), &pLunL0);
     4689            InsertConfigNodeF(pCtlInst, &pLunL0, "LUN#%u", uLUN);
    47204690    }
    47214691    catch (ConfigError &x)
     
    47474717                                      bool fHotplug,
    47484718                                      PUVM pUVM,
     4719                                      PCVMMR3VTABLE pVMM,
    47494720                                      DeviceType_T *paLedDevType,
    47504721                                      PCFGMNODE *ppLunL0)
     
    47814752        /* Determine the base path for the device instance. */
    47824753        if (enmBus != StorageBus_USB)
    4783             pCtlInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "Devices/%s/%u/", pcszDevice, uInstance);
     4754            pCtlInst = pVMM->pfnCFGMR3GetChildF(pVMM->pfnCFGMR3GetRootU(pUVM), "Devices/%s/%u/", pcszDevice, uInstance);
    47844755        else
    47854756        {
    47864757            /* If we hotplug a USB device create a new CFGM tree. */
    47874758            if (!fHotplug)
    4788                 pCtlInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "USB/%s/", pcszDevice);
     4759                pCtlInst = pVMM->pfnCFGMR3GetChildF(pVMM->pfnCFGMR3GetRootU(pUVM), "USB/%s/", pcszDevice);
    47894760            else
    4790                 pCtlInst = CFGMR3CreateTree(pUVM);
     4761                pCtlInst = pVMM->pfnCFGMR3CreateTree(pUVM);
    47914762        }
    47924763        AssertReturn(pCtlInst, VERR_INTERNAL_ERROR);
     
    48004771            {
    48014772                if (!fAttachDetach)
    4802                     InsertConfigNode(pCtlInst, Utf8StrFmt("%d", lPort).c_str(), &pCtlInst);
     4773                    InsertConfigNodeF(pCtlInst, &pCtlInst, "%d", lPort);
    48034774                else
    4804                     pCtlInst = CFGMR3GetChildF(pCtlInst, "%d/", lPort);
     4775                    pCtlInst = pVMM->pfnCFGMR3GetChildF(pCtlInst, "%d/", lPort);
    48054776            }
    48064777
     
    48344805
    48354806        rc = i_removeMediumDriverFromVm(pCtlInst, pcszDevice, uInstance, uLUN, enmBus, fAttachDetach,
    4836                                         fHotplug, fForceUnmount, pUVM, lType, &pLunL0);
     4807                                        fHotplug, fForceUnmount, pUVM, pVMM, lType, &pLunL0);
    48374808        if (RT_FAILURE(rc))
    48384809            return rc;
     
    48724843                 * Informative logging.
    48734844                 */
    4874                 Bstr strFile;
    4875                 hrc = ptrMedium->COMGETTER(Location)(strFile.asOutParam());                 H();
    4876                 Utf8Str utfFile = Utf8Str(strFile);
     4845                Bstr bstrFile;
     4846                hrc = ptrMedium->COMGETTER(Location)(bstrFile.asOutParam());                H();
     4847                Utf8Str strFile(bstrFile);
    48774848                RTFSTYPE enmFsTypeFile = RTFSTYPE_UNKNOWN;
    4878                 (void)RTFsQueryType(utfFile.c_str(), &enmFsTypeFile);
     4849                (void)RTFsQueryType(strFile.c_str(), &enmFsTypeFile);
    48794850                LogRel(("File system of '%s' (%s) is %s\n",
    4880                        utfFile.c_str(), lType == DeviceType_DVD ? "DVD" : "Floppy",
    4881                        RTFsTypeName(enmFsTypeFile)));
     4851                       strFile.c_str(), lType == DeviceType_DVD ? "DVD" : "Floppy", RTFsTypeName(enmFsTypeFile)));
    48824852            }
    48834853
     
    48894859
    48904860        ComObjPtr<IBandwidthGroup> pBwGroup;
    4891         Bstr strBwGroup;
     4861        Bstr bstrBwGroup;
    48924862        hrc = pMediumAtt->COMGETTER(BandwidthGroup)(pBwGroup.asOutParam());                 H();
    48934863
    48944864        if (!pBwGroup.isNull())
    48954865        {
    4896             hrc = pBwGroup->COMGETTER(Name)(strBwGroup.asOutParam());                       H();
     4866            hrc = pBwGroup->COMGETTER(Name)(bstrBwGroup.asOutParam());                      H();
    48974867        }
    48984868
     
    49184888                            uMergeSource,
    49194889                            uMergeTarget,
    4920                             strBwGroup.isEmpty() ? NULL : Utf8Str(strBwGroup).c_str(),
     4890                            bstrBwGroup.isEmpty() ? NULL : Utf8Str(bstrBwGroup).c_str(),
    49214891                            !!fDiscard,
    49224892                            !!fNonRotational,
     
    49374907                    RTUuidCreate(&UsbMsd.mUuid);
    49384908                    UsbMsd.iPort = uInstance;
    4939                     rc = PDMR3UsbCreateEmulatedDevice(pUVM, pcszDevice, pCtlInst, &UsbMsd.mUuid, NULL);
     4909                    rc = pVMM->pfnPDMR3UsbCreateEmulatedDevice(pUVM, pcszDevice, pCtlInst, &UsbMsd.mUuid, NULL);
    49404910                    if (RT_SUCCESS(rc))
    49414911                        mUSBStorageDevices.push_back(UsbMsd);
    49424912                }
    49434913                else
    4944                     rc = PDMR3UsbDriverAttach(pUVM, pcszDevice, uInstance, uLUN,
    4945                                               fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/);
     4914                    rc = pVMM->pfnPDMR3UsbDriverAttach(pUVM, pcszDevice, uInstance, uLUN,
     4915                                                       fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/);
    49464916            }
    49474917            else if (   !fHotplug
    49484918                     && (   (enmBus == StorageBus_SAS || enmBus == StorageBus_SCSI || enmBus == StorageBus_VirtioSCSI)
    49494919                         || (enmBus == StorageBus_SATA && lType == DeviceType_DVD)))
    4950                 rc = PDMR3DriverAttach(pUVM, pcszDevice, uInstance, uLUN,
    4951                                        fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/);
     4920                rc = pVMM->pfnPDMR3DriverAttach(pUVM, pcszDevice, uInstance, uLUN,
     4921                                                fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/);
    49524922            else
    4953                 rc = PDMR3DeviceAttach(pUVM, pcszDevice, uInstance, uLUN,
    4954                                        fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/);
     4923                rc = pVMM->pfnPDMR3DeviceAttach(pUVM, pcszDevice, uInstance, uLUN,
     4924                                                fHotplug ? 0 : PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/);
    49554925            AssertRCReturn(rc, rc);
    49564926
     
    49604930             */
    49614931            PPDMIBASE pIBase = NULL;
    4962             rc = PDMR3QueryDriverOnLun(pUVM, pcszDevice, uInstance, uLUN, "VD", &pIBase);
     4932            rc = pVMM->pfnPDMR3QueryDriverOnLun(pUVM, pcszDevice, uInstance, uLUN, "VD", &pIBase);
    49634933            if (RT_SUCCESS(rc) && pIBase)
    49644934            {
     
    49824952        if (   aMachineState != MachineState_Starting
    49834953            && aMachineState != MachineState_Restoring)
    4984             CFGMR3Dump(pLunL0 ? pLunL0 : pCtlInst);
     4954            pVMM->pfnCFGMR3Dump(pLunL0 ? pLunL0 : pCtlInst);
    49854955    }
    49864956    catch (ConfigError &x)
     
    53135283                        break;
    53145284
    5315                     PCFGMNODE pCfgFilterConfig = CFGMR3GetChild(pVDC, strFilter.c_str());
     5285                    PCFGMNODE pCfgFilterConfig = mpVMM->pfnCFGMR3GetChild(pVDC, strFilter.c_str());
    53165286                    if (!pCfgFilterConfig)
    53175287                        InsertConfigNode(pVDC, strFilter.c_str(), &pCfgFilterConfig);
     
    53395309
    53405310/**
    5341  *  Construct the Network configuration tree
     5311 * Construct the Network configuration tree
    53425312 *
    5343  *  @returns VBox status code.
     5313 * @returns VBox status code.
    53445314 *
    5345  *  @param   pszDevice           The PDM device name.
    5346  *  @param   uInstance           The PDM device instance.
    5347  *  @param   uLun                The PDM LUN number of the drive.
    5348  *  @param   aNetworkAdapter     The network adapter whose attachment needs to be changed
    5349  *  @param   pCfg                Configuration node for the device
    5350  *  @param   pLunL0              To store the pointer to the LUN#0.
    5351  *  @param   pInst               The instance CFGM node
    5352  *  @param   fAttachDetach       To determine if the network attachment should
    5353  *                               be attached/detached after/before
    5354  *                               configuration.
    5355  *  @param   fIgnoreConnectFailure
    5356  *                               True if connection failures should be ignored
    5357  *                               (makes only sense for bridged/host-only networks).
     5315 * @param   pszDevice           The PDM device name.
     5316 * @param   uInstance           The PDM device instance.
     5317 * @param   uLun                The PDM LUN number of the drive.
     5318 * @param   aNetworkAdapter     The network adapter whose attachment needs to be changed
     5319 * @param   pCfg                Configuration node for the device
     5320 * @param   pLunL0              To store the pointer to the LUN#0.
     5321 * @param   pInst               The instance CFGM node
     5322 * @param   fAttachDetach       To determine if the network attachment should
     5323 *                              be attached/detached after/before
     5324 *                              configuration.
     5325 * @param   fIgnoreConnectFailure
     5326 *                              True if connection failures should be ignored
     5327 *                              (makes only sense for bridged/host-only networks).
     5328 * @param   pUVM                The usermode VM handle.
     5329 * @param   pVMM                The VMM vtable.
    53585330 *
    5359  *  @note   Locks this object for writing.
    5360  *  @thread EMT
     5331 * @note   Locks this object for writing.
     5332 * @thread EMT
    53615333 */
    53625334int Console::i_configNetwork(const char *pszDevice,
     
    53685340                             PCFGMNODE pInst,
    53695341                             bool fAttachDetach,
    5370                              bool fIgnoreConnectFailure)
     5342                             bool fIgnoreConnectFailure,
     5343                             PUVM pUVM,
     5344                             PCVMMR3VTABLE pVMM)
    53715345{
    53725346    RT_NOREF(fIgnoreConnectFailure);
     
    54195393        if (fAttachDetach)
    54205394        {
    5421             rc = PDMR3DeviceDetach(mpUVM, pszDevice, uInstance, uLun, 0 /*fFlags*/);
     5395            rc = pVMM->pfnPDMR3DeviceDetach(pUVM, pszDevice, uInstance, uLun, 0 /*fFlags*/);
    54225396            if (rc == VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN)
    54235397                rc = VINF_SUCCESS;
     
    54255399
    54265400            /* Nuke anything which might have been left behind. */
    5427             CFGMR3RemoveNode(CFGMR3GetChildF(pInst, "LUN#%u", uLun));
     5401            pVMM->pfnCFGMR3RemoveNode(pVMM->pfnCFGMR3GetChildF(pInst, "LUN#%u", uLun));
    54285402        }
    54295403
     
    54345408#ifdef VBOX_WITH_NETSHAPER
    54355409        ComObjPtr<IBandwidthGroup> pBwGroup;
    5436         Bstr strBwGroup;
     5410        Bstr bstrBwGroup;
    54375411        hrc = aNetworkAdapter->COMGETTER(BandwidthGroup)(pBwGroup.asOutParam());            H();
    54385412
    54395413        if (!pBwGroup.isNull())
    54405414        {
    5441             hrc = pBwGroup->COMGETTER(Name)(strBwGroup.asOutParam());                       H();
     5415            hrc = pBwGroup->COMGETTER(Name)(bstrBwGroup.asOutParam());                      H();
    54425416        }
    54435417#endif /* VBOX_WITH_NETSHAPER */
     
    54515425         */
    54525426#ifdef VBOX_WITH_NETSHAPER
    5453         if (!strBwGroup.isEmpty() && eAttachmentType != NetworkAttachmentType_Null)
     5427        if (bstrBwGroup.isNotEmpty() && eAttachmentType != NetworkAttachmentType_Null)
    54545428        {
    54555429            InsertConfigString(pLunL0, "Driver", "NetShaper");
    54565430            InsertConfigNode(pLunL0, "Config", &pCfg);
    5457             InsertConfigString(pCfg, "BwGroup", strBwGroup);
     5431            InsertConfigString(pCfg, "BwGroup", bstrBwGroup);
    54585432            InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
    54595433        }
     
    56405614                    {
    56415615                        case E_ACCESSDENIED:
    5642                             return VMSetError(VMR3GetVM(mpUVM), VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,  N_(
    5643                                             "Failed to open '/dev/net/tun' for read/write access. Please check the "
    5644                                             "permissions of that node. Either run 'chmod 0666 /dev/net/tun' or "
    5645                                             "change the group of that node and make yourself a member of that group. Make "
    5646                                             "sure that these changes are permanent, especially if you are "
    5647                                             "using udev"));
     5616                            return pVMM->pfnVMR3SetError(pUVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,  N_(
     5617                                                         "Failed to open '/dev/net/tun' for read/write access. Please check the "
     5618                                                         "permissions of that node. Either run 'chmod 0666 /dev/net/tun' or "
     5619                                                         "change the group of that node and make yourself a member of that group. "
     5620                                                         "Make sure that these changes are permanent, especially if you are "
     5621                                                         "using udev"));
    56485622                        default:
    56495623                            AssertMsgFailed(("Could not attach to host interface! Bad!\n"));
    5650                             return VMSetError(VMR3GetVM(mpUVM), VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
    5651                                             "Failed to initialize Host Interface Networking"));
     5624                            return pVMM->pfnVMR3SetError(pUVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
     5625                                                         N_("Failed to initialize Host Interface Networking"));
    56525626                    }
    56535627                }
     
    56825656                {
    56835657                    AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: FindByName failed, rc=%Rhrc (0x%x)\n", hrc, hrc));
    5684                     return VMSetError(VMR3GetVM(mpUVM), VERR_INTERNAL_ERROR, RT_SRC_POS,
    5685                                       N_("Nonexistent host networking interface, name '%ls'"),
    5686                                       BridgedIfName.raw());
     5658                    return pVMM->pfnVMR3SetError(pUVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
     5659                                                 N_("Nonexistent host networking interface, name '%ls'"),
     5660                                                 BridgedIfName.raw());
    56875661                }
    56885662
     
    57415715
    57425716                if (eIfType != HostNetworkInterfaceType_Bridged)
    5743                 {
    5744                     return VMSetError(VMR3GetVM(mpUVM), VERR_INTERNAL_ERROR, RT_SRC_POS,
    5745                                       N_("Interface ('%ls') is not a Bridged Adapter interface"),
    5746                                       BridgedIfName.raw());
    5747                 }
     5717                    return pVMM->pfnVMR3SetError(pUVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
     5718                                                 N_("Interface ('%ls') is not a Bridged Adapter interface"),
     5719                                                 BridgedIfName.raw());
    57485720
    57495721                hrc = hostInterface->COMGETTER(Id)(bstr.asOutParam());
     
    58425814                        {
    58435815                            case E_ACCESSDENIED:
    5844                                 return VMSetError(VMR3GetVM(mpUVM), VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,  N_(
    5845                                                 "Failed to open '/dev/%s' for read/write access.  Please check the "
    5846                                                 "permissions of that node, and that the net.link.tap.user_open "
    5847                                                 "sysctl is set.  Either run 'chmod 0666 /dev/%s' or "
    5848                                                 "change the group of that node to vboxusers and make yourself "
    5849                                                 "a member of that group.  Make sure that these changes are permanent."),
    5850                                                 pszBridgedIfName, pszBridgedIfName);
     5816                                return pVMM->pfnVMR3SetError(pUVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,  N_(
     5817                                                             "Failed to open '/dev/%s' for read/write access.  Please check the "
     5818                                                             "permissions of that node, and that the net.link.tap.user_open "
     5819                                                             "sysctl is set.  Either run 'chmod 0666 /dev/%s' or change the "
     5820                                                             "group of that node to vboxusers and make yourself a member of "
     5821                                                             "that group.  Make sure that these changes are permanent."),
     5822                                                             pszBridgedIfName, pszBridgedIfName);
    58515823                            default:
    58525824                                AssertMsgFailed(("Could not attach to tap interface! Bad!\n"));
    5853                                 return VMSetError(VMR3GetVM(mpUVM), VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
    5854                                                 "Failed to initialize Host Interface Networking"));
     5825                                return pVMM->pfnVMR3SetError(pUVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
     5826                                                             N_("Failed to initialize Host Interface Networking"));
    58555827                        }
    58565828                    }
     
    61236095                    }
    61246096                }
    6125                 return VMSetError(VMR3GetVM(mpUVM), VERR_NOT_FOUND, RT_SRC_POS,
    6126                                   N_("Host-only adapters are no longer supported!\n"
    6127                                      "For your convenience a host-only network named '%ls' has been "
    6128                                      "created with network mask '%ls' and IP address range '%ls' - '%ls'.\n"
    6129                                      "To fix this problem, switch to 'Host-only Network' "
    6130                                      "attachment type in the VM settings.\n"),
    6131                                   bstrNetworkName.raw(), bstrNetworkMask.raw(),
    6132                                   bstrLowerIP.raw(), bstrUpperIP.raw());
     6097                return pVMM->pfnVMR3SetError(pUVM, VERR_NOT_FOUND, RT_SRC_POS,
     6098                                             N_("Host-only adapters are no longer supported!\n"
     6099                                                "For your convenience a host-only network named '%ls' has been "
     6100                                                "created with network mask '%ls' and IP address range '%ls' - '%ls'.\n"
     6101                                                "To fix this problem, switch to 'Host-only Network' "
     6102                                                "attachment type in the VM settings.\n"),
     6103                                             bstrNetworkName.raw(), bstrNetworkMask.raw(),
     6104                                             bstrLowerIP.raw(), bstrUpperIP.raw());
    61336105#endif /* VBOX_WITH_VMNET */
    61346106                ComPtr<IHostNetworkInterface> hostInterface;
     
    61386110                {
    61396111                    LogRel(("NetworkAttachmentType_HostOnly: FindByName failed, rc (0x%x)\n", rc));
    6140                     return VMSetError(VMR3GetVM(mpUVM), VERR_INTERNAL_ERROR, RT_SRC_POS,
    6141                                       N_("Nonexistent host networking interface, name '%ls'"),
    6142                                       HostOnlyName.raw());
     6112                    return pVMM->pfnVMR3SetError(pUVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
     6113                                                N_("Nonexistent host networking interface, name '%ls'"), HostOnlyName.raw());
    61436114                }
    61446115
     
    61636134
    61646135                if (eIfType != HostNetworkInterfaceType_HostOnly)
    6165                     return VMSetError(VMR3GetVM(mpUVM), VERR_INTERNAL_ERROR, RT_SRC_POS,
    6166                                       N_("Interface ('%ls') is not a Host-Only Adapter interface"),
    6167                                       HostOnlyName.raw());
     6136                    return pVMM->pfnVMR3SetError(pUVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
     6137                                                 N_("Interface ('%ls') is not a Host-Only Adapter interface"),
     6138                                                 HostOnlyName.raw());
    61686139
    61696140                hrc = hostInterface->COMGETTER(Id)(bstr.asOutParam());
     
    63926363# endif
    63936364                {
    6394                     return VMSetError(VMR3GetVM(mpUVM), VERR_NOT_FOUND, RT_SRC_POS,
    6395                             N_("Implementation of the cloud network attachment not found!\n"
    6396                                 "To fix this problem, either install the '%s' or switch to "
    6397                                 "another network attachment type in the VM settings.\n"
    6398                                 ),
    6399                             s_pszCloudExtPackName);
     6365                    return pVMM->pfnVMR3SetError(pUVM, VERR_NOT_FOUND, RT_SRC_POS,
     6366                                                 N_("Implementation of the cloud network attachment not found!\n"
     6367                                                    "To fix this problem, either install the '%s' or switch to "
     6368                                                    "another network attachment type in the VM settings."),
     6369                                                 s_pszCloudExtPackName);
    64006370                }
    64016371
     
    64086378                {
    64096379                    if (hrc == E_NOTIMPL)
    6410                         return VMSetError(VMR3GetVM(mpUVM), VERR_NOT_FOUND, RT_SRC_POS,
    6411                                 N_("Failed to generate a key pair due to missing libssh\n"
    6412                                     "To fix this problem, either build VirtualBox with libssh "
    6413                                     "support or switch to another network attachment type in "
    6414                                     "the VM settings.\n"));
    6415                     else
    6416                         return VMSetError(VMR3GetVM(mpUVM), VERR_INTERNAL_ERROR, RT_SRC_POS,
    6417                                 N_("Failed to generate a key pair due to libssh error!\n"));
     6380                        return pVMM->pfnVMR3SetError(pUVM, VERR_NOT_FOUND, RT_SRC_POS,
     6381                                                     N_("Failed to generate a key pair due to missing libssh\n"
     6382                                                        "To fix this problem, either build VirtualBox with libssh "
     6383                                                        "support or switch to another network attachment type in "
     6384                                                        "the VM settings."));
     6385                    return pVMM->pfnVMR3SetError(pUVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
     6386                                                 N_("Failed to generate a key pair due to libssh error!"));
    64186387                }
    64196388                hrc = startCloudGateway(virtualBox, network, mGateway);                      H();
     
    64446413                {
    64456414                    LogRel(("NetworkAttachmentType_HostOnlyNetwork: FindByName failed, hrc (0x%x)\n", hrc));
    6446                     return VMSetError(VMR3GetVM(mpUVM), VERR_INTERNAL_ERROR, RT_SRC_POS,
    6447                                       N_("Nonexistent host-only network '%ls'"),
    6448                                       bstr.raw());
     6415                    return pVMM->pfnVMR3SetError(pUVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
     6416                                                 N_("Nonexistent host-only network '%ls'"), bstr.raw());
    64496417                }
    64506418                hrc = network->COMGETTER(Id)(bstrId.asOutParam());                               H();
     
    65016469                    if (fAttachDetach)
    65026470                    {
    6503                         rc = PDMR3DriverAttach(mpUVM, pszDevice, uInstance, uLun, 0 /*fFlags*/, NULL /* ppBase */);
     6471                        rc = pVMM->pfnPDMR3DriverAttach(mpUVM, pszDevice, uInstance, uLun, 0 /*fFlags*/, NULL /* ppBase */);
    65046472                        //AssertRC(rc);
    65056473                    }
     
    65256493                         */
    65266494                        ComPtr<IDHCPServer> dhcpServer;
    6527                         hrc = virtualBox->FindDHCPServerByNetworkName(networkName.raw(),
    6528                                                                       dhcpServer.asOutParam());
     6495                        hrc = virtualBox->FindDHCPServerByNetworkName(networkName.raw(), dhcpServer.asOutParam());
    65296496                        if (SUCCEEDED(hrc))
    65306497                        {
     
    65396506
    65406507                            if (fEnabledDhcp)
    6541                                 hrc = dhcpServer->Start(trunkName.raw(),
    6542                                                         trunkType.raw());
     6508                                hrc = dhcpServer->Start(trunkName.raw(), trunkType.raw());
    65436509                        }
    65446510                        else
  • trunk/src/VBox/Main/src-client/ConsoleImplTeleporter.cpp

    r93410 r93444  
    4040#include <VBox/vmm/vmapi.h>
    4141#include <VBox/vmm/ssm.h>
     42#include <VBox/vmm/vmmr3vtable.h>
    4243#include <VBox/err.h>
    4344#include <VBox/version.h>
     
    5960    ComPtr<Console>     mptrConsole;
    6061    PUVM                mpUVM;
     62    PCVMMR3VTABLE       mpVMM;
    6163    ComObjPtr<Progress> mptrProgress;
    6264    Utf8Str             mstrPassword;
     
    7375    /** @} */
    7476
    75     TeleporterState(Console *pConsole, PUVM pUVM, Progress *pProgress, bool fIsSource)
     77    TeleporterState(Console *pConsole, PUVM pUVM, PCVMMR3VTABLE pVMM, Progress *pProgress, bool fIsSource)
    7678        : mptrConsole(pConsole)
    7779        , mpUVM(pUVM)
     80        , mpVMM(pVMM)
    7881        , mptrProgress(pProgress)
    7982        , mfIsSource(fIsSource)
     
    8588        , mfIOError(false)
    8689    {
    87         VMR3RetainUVM(mpUVM);
     90        pVMM->pfnVMR3RetainUVM(mpUVM);
    8891    }
    8992
    9093    ~TeleporterState()
    9194    {
    92         VMR3ReleaseUVM(mpUVM);
     95        if (mpVMM)
     96            mpVMM->pfnVMR3ReleaseUVM(mpUVM);
    9397        mpUVM = NULL;
    9498    }
     
    109113    bool                mfUnlockedMedia;
    110114
    111     TeleporterStateSrc(Console *pConsole, PUVM pUVM, Progress *pProgress, MachineState_T enmOldMachineState)
    112         : TeleporterState(pConsole, pUVM, pProgress, true /*fIsSource*/)
     115    TeleporterStateSrc(Console *pConsole, PUVM pUVM, PCVMMR3VTABLE pVMM, Progress *pProgress, MachineState_T enmOldMachineState)
     116        : TeleporterState(pConsole, pUVM, pVMM, pProgress, true /*fIsSource*/)
    113117        , muPort(UINT32_MAX)
    114118        , mcMsMaxDowntime(250)
     
    135139    Utf8Str                     mErrorText;
    136140
    137     TeleporterStateTrg(Console *pConsole, PUVM pUVM, Progress *pProgress,
     141    TeleporterStateTrg(Console *pConsole, PUVM pUVM, PCVMMR3VTABLE pVMM, Progress *pProgress,
    138142                       IMachine *pMachine, IInternalMachineControl *pControl,
    139143                       PRTTIMERLR phTimerLR, bool fStartPaused)
    140         : TeleporterState(pConsole, pUVM, pProgress, false /*fIsSource*/)
     144        : TeleporterState(pConsole, pUVM, pVMM, pProgress, false /*fIsSource*/)
    141145        , mpMachine(pMachine)
    142146        , mpControl(pControl)
     
    233237 */
    234238HRESULT
    235 Console::i_teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich,
    236                                 const char *pszNAckMsg /*= NULL*/)
     239Console::i_teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich, const char *pszNAckMsg /*= NULL*/)
    237240{
    238241    char szMsg[256];
     
    581584{
    582585    TeleporterState *pState = (TeleporterState *)pvUser;
    583     SSMR3Cancel(pState->mpUVM);
     586    pState->mpVMM->pfnSSMR3Cancel(pState->mpUVM);
    584587    if (!pState->mfIsSource)
    585588    {
     
    605608            if (SUCCEEDED(hrc) && fCanceled)
    606609            {
    607                 SSMR3Cancel(pState->mpUVM);
     610                pState->mpVMM->pfnSSMR3Cancel(pState->mpUVM);
    608611                return VERR_SSM_CANCELLED;
    609612            }
     
    694697    RTSocketRetain(pState->mhSocket);
    695698    void *pvUser = static_cast<void *>(static_cast<TeleporterState *>(pState));
    696     vrc = VMR3Teleport(pState->mpUVM,
    697                        pState->mcMsMaxDowntime,
    698                        &g_teleporterTcpOps,         pvUser,
    699                        teleporterProgressCallback,  pvUser,
    700                        &pState->mfSuspendedByUs);
     699    vrc = pState->mpVMM->pfnVMR3Teleport(pState->mpUVM,
     700                                         pState->mcMsMaxDowntime,
     701                                         &g_teleporterTcpOps,         pvUser,
     702                                         teleporterProgressCallback,  pvUser,
     703                                         &pState->mfSuspendedByUs);
    701704    RTSocketRelease(pState->mhSocket);
    702705    if (RT_FAILURE(vrc))
     
    804807    pState->mptrConsole->mptrCancelableProgress.setNull();
    805808
    806     VMSTATE const        enmVMState      = VMR3GetStateU(pState->mpUVM);
     809    VMSTATE const        enmVMState      = pState->mpVMM->pfnVMR3GetStateU(pState->mpUVM);
    807810    MachineState_T const enmMachineState = pState->mptrConsole->mMachineState;
    808811    if (SUCCEEDED(hrc))
     
    814817         *       powerDown.
    815818         */
    816         AssertLogRelMsg(enmVMState == VMSTATE_SUSPENDED, ("%s\n", VMR3GetStateName(enmVMState)));
     819        AssertLogRelMsg(enmVMState == VMSTATE_SUSPENDED, ("%s\n", pState->mpVMM->pfnVMR3GetStateName(enmVMState)));
    817820        AssertLogRelMsg(enmMachineState == MachineState_TeleportingPausedVM, ("%s\n", ::stringifyMachineState(enmMachineState)));
    818821
     
    890893
    891894                default:
    892                     AssertMsgFailed(("%s\n", VMR3GetStateName(enmVMState)));
     895                    AssertMsgFailed(("%s\n", pState->mpVMM->pfnVMR3GetStateName(enmVMState)));
    893896                    RT_FALL_THRU();
    894897                case VMSTATE_SUSPENDED:
     
    903906                        {
    904907                            autoLock.release();
    905                             int rc = VMR3Resume(pState->mpUVM, VMRESUMEREASON_TELEPORT_FAILED);
     908                            int rc = pState->mpVMM->pfnVMR3Resume(pState->mpUVM, VMRESUMEREASON_TELEPORT_FAILED);
    906909                            AssertLogRelMsgRC(rc, ("VMR3Resume -> %Rrc\n", rc));
    907910                            autoLock.acquire();
     
    988991        return hrc;
    989992
    990     TeleporterStateSrc *pState = new TeleporterStateSrc(this, mpUVM, ptrProgress, mMachineState);
     993    TeleporterStateSrc *pState = new TeleporterStateSrc(this, mpUVM, mpVMM, ptrProgress, mMachineState);
    991994    pState->mstrPassword    = strPassword;
    992995    pState->mstrHostname    = aHostname;
     
    10301033 * @returns VBox status code.
    10311034 * @param   pUVM                The user-mode VM handle
     1035 * @param   pVMM                The VMM vtable.
    10321036 * @param   pMachine            The IMachine for the virtual machine.
    10331037 * @param   pErrorMsg           Pointer to the error string for VMSetError.
     
    10411045 * @todo    Check that all the possible failure paths sets error info...
    10421046 */
    1043 HRESULT Console::i_teleporterTrg(PUVM pUVM, IMachine *pMachine, Utf8Str *pErrorMsg, bool fStartPaused,
     1047HRESULT Console::i_teleporterTrg(PUVM pUVM, PCVMMR3VTABLE pVMM, IMachine *pMachine, Utf8Str *pErrorMsg, bool fStartPaused,
    10441048                                 Progress *pProgress, bool *pfPowerOffOnFailure)
    10451049{
    1046     LogThisFunc(("pUVM=%p pMachine=%p fStartPaused=%RTbool pProgress=%p\n", pUVM, pMachine, fStartPaused, pProgress));
     1050    LogThisFunc(("pUVM=%p pVMM=%p pMachine=%p fStartPaused=%RTbool pProgress=%p\n", pUVM, pVMM, pMachine, fStartPaused, pProgress));
    10471051
    10481052    *pfPowerOffOnFailure = true;
     
    11131117             * Do the job, when it returns we're done.
    11141118             */
    1115             TeleporterStateTrg theState(this, pUVM, pProgress, pMachine, mControl, &hTimerLR, fStartPaused);
     1119            TeleporterStateTrg theState(this, pUVM, pVMM, pProgress, pMachine, mControl, &hTimerLR, fStartPaused);
    11161120            theState.mstrPassword      = strPassword;
    11171121            theState.mhServer          = hServer;
     
    11371141                        else
    11381142                        {
    1139                             VMSTATE enmVMState = VMR3GetStateU(pUVM);
     1143                            VMSTATE enmVMState = pVMM->pfnVMR3GetStateU(pUVM);
    11401144                            if (    enmVMState != VMSTATE_OFF
    11411145                                &&  enmVMState != VMSTATE_POWERING_OFF)
     
    13461350                break;
    13471351
    1348             int vrc2 = VMR3AtErrorRegister(pState->mpUVM,
    1349                                            Console::i_genericVMSetErrorCallback, &pState->mErrorText); AssertRC(vrc2);
     1352            int vrc2 = pState->mpVMM->pfnVMR3AtErrorRegister(pState->mpUVM, Console::i_genericVMSetErrorCallback,
     1353                                                             &pState->mErrorText);
     1354            AssertRC(vrc2);
    13501355            RTSocketRetain(pState->mhSocket); /* For concurrent access by I/O thread and EMT. */
    13511356            pState->moffStream = 0;
    13521357
    13531358            void *pvUser2 = static_cast<void *>(static_cast<TeleporterState *>(pState));
    1354             vrc = VMR3LoadFromStream(pState->mpUVM,
    1355                                      &g_teleporterTcpOps, pvUser2,
    1356                                      teleporterProgressCallback, pvUser2);
     1359            vrc = pState->mpVMM->pfnVMR3LoadFromStream(pState->mpUVM,
     1360                                                       &g_teleporterTcpOps, pvUser2,
     1361                                                       teleporterProgressCallback, pvUser2);
    13571362
    13581363            RTSocketRelease(pState->mhSocket);
    1359             vrc2 = VMR3AtErrorDeregister(pState->mpUVM, Console::i_genericVMSetErrorCallback, &pState->mErrorText);
     1364            vrc2 = pState->mpVMM->pfnVMR3AtErrorDeregister(pState->mpUVM, Console::i_genericVMSetErrorCallback, &pState->mErrorText);
    13601365            AssertRC(vrc2);
    13611366
     
    14211426                {
    14221427                    if (!strcmp(szCmd, "hand-over-resume"))
    1423                         vrc = VMR3Resume(pState->mpUVM, VMRESUMEREASON_TELEPORTED);
     1428                        vrc = pState->mpVMM->pfnVMR3Resume(pState->mpUVM, VMRESUMEREASON_TELEPORTED);
    14241429                    else
    14251430                        pState->mptrConsole->i_setMachineState(MachineState_Paused);
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r93115 r93444  
    3838#include <iprt/alloca.h>
    3939
     40#include <VBox/vmm/vmmr3vtable.h>
    4041#include <VBox/vmm/pdmdrv.h>
    4142
     
    226227}
    227228
    228 DECLCALLBACK(void) Display::i_displaySSMSaveScreenshot(PSSMHANDLE pSSM, void *pvUser)
    229 {
    230     Display *that = static_cast<Display*>(pvUser);
     229/**
     230 * @callback_method_impl{FNSSMEXTSAVEEXEC}
     231 */
     232DECLCALLBACK(int) Display::i_displaySSMSaveScreenshot(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser)
     233{
     234    Display * const pThat = static_cast<Display *>(pvUser);
     235    AssertPtrReturn(pThat, VERR_INVALID_POINTER);
    231236
    232237    /* 32bpp small RGB image. */
     
    242247    uint32_t cyPNG = 0;
    243248
    244     Console::SafeVMPtr ptrVM(that->mParent);
     249    Console::SafeVMPtr ptrVM(pThat->mParent);
    245250    if (ptrVM.isOk())
    246251    {
     
    252257        uint32_t cy = 0;
    253258        bool fFreeMem = false;
    254         int rc = Display::i_displayTakeScreenshotEMT(that, VBOX_VIDEO_PRIMARY_SCREEN, &pbData, &cbData, &cx, &cy, &fFreeMem);
     259        int rc = Display::i_displayTakeScreenshotEMT(pThat, VBOX_VIDEO_PRIMARY_SCREEN, &pbData, &cbData, &cx, &cy, &fFreeMem);
    255260
    256261        /*
     
    280285                RTMemFree(pbData);
    281286            else
    282                 that->mpDrv->pUpPort->pfnFreeScreenshot(that->mpDrv->pUpPort, pbData);
     287                pThat->mpDrv->pUpPort->pfnFreeScreenshot(pThat->mpDrv->pUpPort, pbData);
    283288        }
    284289    }
     
    303308     *    [image data]
    304309     */
    305     SSMR3PutU32(pSSM, 2); /* Write thumbnail and PNG screenshot. */
     310    pVMM->pfnSSMR3PutU32(pSSM, 2); /* Write thumbnail and PNG screenshot. */
    306311
    307312    /* First block. */
    308     SSMR3PutU32(pSSM, (uint32_t)(cbThumbnail + 2 * sizeof(uint32_t)));
    309     SSMR3PutU32(pSSM, 0); /* Block type: thumbnail. */
     313    pVMM->pfnSSMR3PutU32(pSSM, (uint32_t)(cbThumbnail + 2 * sizeof(uint32_t)));
     314    pVMM->pfnSSMR3PutU32(pSSM, 0); /* Block type: thumbnail. */
    310315
    311316    if (cbThumbnail)
    312317    {
    313         SSMR3PutU32(pSSM, cxThumbnail);
    314         SSMR3PutU32(pSSM, cyThumbnail);
    315         SSMR3PutMem(pSSM, pu8Thumbnail, cbThumbnail);
     318        pVMM->pfnSSMR3PutU32(pSSM, cxThumbnail);
     319        pVMM->pfnSSMR3PutU32(pSSM, cyThumbnail);
     320        pVMM->pfnSSMR3PutMem(pSSM, pu8Thumbnail, cbThumbnail);
    316321    }
    317322
    318323    /* Second block. */
    319     SSMR3PutU32(pSSM, (uint32_t)(cbPNG + 2 * sizeof(uint32_t)));
    320     SSMR3PutU32(pSSM, 1); /* Block type: png. */
     324    pVMM->pfnSSMR3PutU32(pSSM, (uint32_t)(cbPNG + 2 * sizeof(uint32_t)));
     325    pVMM->pfnSSMR3PutU32(pSSM, 1); /* Block type: png. */
    321326
    322327    if (cbPNG)
    323328    {
    324         SSMR3PutU32(pSSM, cxPNG);
    325         SSMR3PutU32(pSSM, cyPNG);
    326         SSMR3PutMem(pSSM, pu8PNG, cbPNG);
     329        pVMM->pfnSSMR3PutU32(pSSM, cxPNG);
     330        pVMM->pfnSSMR3PutU32(pSSM, cyPNG);
     331        pVMM->pfnSSMR3PutMem(pSSM, pu8PNG, cbPNG);
    327332    }
    328333
    329334    RTMemFree(pu8PNG);
    330335    RTMemFree(pu8Thumbnail);
    331 }
    332 
     336
     337    return VINF_SUCCESS;
     338}
     339
     340/**
     341 * @callback_method_impl{FNSSMEXTLOADEXEC}
     342 */
    333343DECLCALLBACK(int)
    334 Display::i_displaySSMLoadScreenshot(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass)
    335 {
    336     RT_NOREF(pvUser);
     344Display::i_displaySSMLoadScreenshot(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser, uint32_t uVersion, uint32_t uPass)
     345{
     346    Display * const pThat = static_cast<Display *>(pvUser);
     347    AssertPtrReturn(pThat, VERR_INVALID_POINTER);
     348    Assert(uPass == SSM_PASS_FINAL); RT_NOREF_PV(uPass);
     349
    337350    if (uVersion != sSSMDisplayScreenshotVer)
    338351        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    339     Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
    340352
    341353    /* Skip data. */
    342354    uint32_t cBlocks;
    343     int rc = SSMR3GetU32(pSSM, &cBlocks);
    344     AssertRCReturn(rc, rc);
     355    int vrc = pVMM->pfnSSMR3GetU32(pSSM, &cBlocks);
     356    AssertRCReturn(vrc, vrc);
    345357
    346358    for (uint32_t i = 0; i < cBlocks; i++)
    347359    {
    348360        uint32_t cbBlock;
    349         rc = SSMR3GetU32(pSSM, &cbBlock);
    350         AssertRCBreak(rc);
     361        vrc = pVMM->pfnSSMR3GetU32(pSSM, &cbBlock);
     362        AssertRCReturn(vrc, vrc);
    351363
    352364        uint32_t typeOfBlock;
    353         rc = SSMR3GetU32(pSSM, &typeOfBlock);
    354         AssertRCBreak(rc);
     365        vrc = pVMM->pfnSSMR3GetU32(pSSM, &typeOfBlock);
     366        AssertRCReturn(vrc, vrc);
    355367
    356368        LogRelFlowFunc(("[%d] type %d, size %d bytes\n", i, typeOfBlock, cbBlock));
     
    358370        /* Note: displaySSMSaveScreenshot writes size of a block = 8 and
    359371         * do not write any data if the image size was 0.
    360          * @todo Fix and increase saved state version.
    361372         */
     373        /** @todo Fix and increase saved state version. */
    362374        if (cbBlock > 2 * sizeof(uint32_t))
    363375        {
    364             rc = SSMR3Skip(pSSM, cbBlock);
    365             AssertRCBreak(rc);
     376            vrc = pVMM->pfnSSMR3Skip(pSSM, cbBlock);
     377            AssertRCReturn(vrc, vrc);
    366378        }
    367379    }
    368380
    369     return rc;
     381    return vrc;
    370382}
    371383
    372384/**
    373  * Save/Load some important guest state
     385 * @callback_method_impl{FNSSMEXTSAVEEXEC, Save some important guest state}
    374386 */
    375 DECLCALLBACK(void)
    376 Display::i_displaySSMSave(PSSMHANDLE pSSM, void *pvUser)
    377 {
    378     Display *that = static_cast<Display*>(pvUser);
    379 
    380     SSMR3PutU32(pSSM, that->mcMonitors);
    381     for (unsigned i = 0; i < that->mcMonitors; i++)
    382     {
    383         SSMR3PutU32(pSSM, that->maFramebuffers[i].u32Offset);
    384         SSMR3PutU32(pSSM, that->maFramebuffers[i].u32MaxFramebufferSize);
    385         SSMR3PutU32(pSSM, that->maFramebuffers[i].u32InformationSize);
    386         SSMR3PutU32(pSSM, that->maFramebuffers[i].w);
    387         SSMR3PutU32(pSSM, that->maFramebuffers[i].h);
    388         SSMR3PutS32(pSSM, that->maFramebuffers[i].xOrigin);
    389         SSMR3PutS32(pSSM, that->maFramebuffers[i].yOrigin);
    390         SSMR3PutU32(pSSM, that->maFramebuffers[i].flags);
    391     }
    392     SSMR3PutS32(pSSM, that->xInputMappingOrigin);
    393     SSMR3PutS32(pSSM, that->yInputMappingOrigin);
    394     SSMR3PutU32(pSSM, that->cxInputMapping);
    395     SSMR3PutU32(pSSM, that->cyInputMapping);
    396     SSMR3PutU32(pSSM, that->mfGuestVBVACapabilities);
    397     SSMR3PutU32(pSSM, that->mfHostCursorCapabilities);
    398 }
    399 
    400 DECLCALLBACK(int)
    401 Display::i_displaySSMLoad(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass)
    402 {
    403     Display *that = static_cast<Display*>(pvUser);
     387/*static*/ DECLCALLBACK(int)
     388Display::i_displaySSMSave(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser)
     389{
     390    Display * const pThat = static_cast<Display *>(pvUser);
     391    AssertPtrReturn(pThat, VERR_INVALID_POINTER);
     392
     393    pVMM->pfnSSMR3PutU32(pSSM, pThat->mcMonitors);
     394    for (unsigned i = 0; i < pThat->mcMonitors; i++)
     395    {
     396        pVMM->pfnSSMR3PutU32(pSSM, pThat->maFramebuffers[i].u32Offset);
     397        pVMM->pfnSSMR3PutU32(pSSM, pThat->maFramebuffers[i].u32MaxFramebufferSize);
     398        pVMM->pfnSSMR3PutU32(pSSM, pThat->maFramebuffers[i].u32InformationSize);
     399        pVMM->pfnSSMR3PutU32(pSSM, pThat->maFramebuffers[i].w);
     400        pVMM->pfnSSMR3PutU32(pSSM, pThat->maFramebuffers[i].h);
     401        pVMM->pfnSSMR3PutS32(pSSM, pThat->maFramebuffers[i].xOrigin);
     402        pVMM->pfnSSMR3PutS32(pSSM, pThat->maFramebuffers[i].yOrigin);
     403        pVMM->pfnSSMR3PutU32(pSSM, pThat->maFramebuffers[i].flags);
     404    }
     405    pVMM->pfnSSMR3PutS32(pSSM, pThat->xInputMappingOrigin);
     406    pVMM->pfnSSMR3PutS32(pSSM, pThat->yInputMappingOrigin);
     407    pVMM->pfnSSMR3PutU32(pSSM, pThat->cxInputMapping);
     408    pVMM->pfnSSMR3PutU32(pSSM, pThat->cyInputMapping);
     409    pVMM->pfnSSMR3PutU32(pSSM, pThat->mfGuestVBVACapabilities);
     410    return pVMM->pfnSSMR3PutU32(pSSM, pThat->mfHostCursorCapabilities);
     411}
     412
     413/**
     414 * @callback_method_impl{FNSSMEXTLOADEXEC, Load some important guest state}
     415 */
     416/*static*/ DECLCALLBACK(int)
     417Display::i_displaySSMLoad(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser, uint32_t uVersion, uint32_t uPass)
     418{
     419    Display * const pThat = static_cast<Display *>(pvUser);
     420    AssertPtrReturn(pThat, VERR_INVALID_POINTER);
    404421
    405422    if (   uVersion != sSSMDisplayVer
     
    412429
    413430    uint32_t cMonitors;
    414     int rc = SSMR3GetU32(pSSM, &cMonitors);
     431    int rc = pVMM->pfnSSMR3GetU32(pSSM, &cMonitors);
    415432    AssertRCReturn(rc, rc);
    416     if (cMonitors != that->mcMonitors)
    417         return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Number of monitors changed (%d->%d)!"), cMonitors, that->mcMonitors);
     433    if (cMonitors != pThat->mcMonitors)
     434        return pVMM->pfnSSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Number of monitors changed (%d->%d)!"), cMonitors, pThat->mcMonitors);
    418435
    419436    for (uint32_t i = 0; i < cMonitors; i++)
    420437    {
    421         SSMR3GetU32(pSSM, &that->maFramebuffers[i].u32Offset);
    422         SSMR3GetU32(pSSM, &that->maFramebuffers[i].u32MaxFramebufferSize);
    423         SSMR3GetU32(pSSM, &that->maFramebuffers[i].u32InformationSize);
     438        pVMM->pfnSSMR3GetU32(pSSM, &pThat->maFramebuffers[i].u32Offset);
     439        pVMM->pfnSSMR3GetU32(pSSM, &pThat->maFramebuffers[i].u32MaxFramebufferSize);
     440        pVMM->pfnSSMR3GetU32(pSSM, &pThat->maFramebuffers[i].u32InformationSize);
    424441        if (   uVersion == sSSMDisplayVer2
    425442            || uVersion == sSSMDisplayVer3
     
    429446            uint32_t w;
    430447            uint32_t h;
    431             SSMR3GetU32(pSSM, &w);
    432             SSMR3GetU32(pSSM, &h);
    433             that->maFramebuffers[i].w = w;
    434             that->maFramebuffers[i].h = h;
     448            pVMM->pfnSSMR3GetU32(pSSM, &w);
     449            rc = pVMM->pfnSSMR3GetU32(pSSM, &h);
     450            AssertRCReturn(rc, rc);
     451            pThat->maFramebuffers[i].w = w;
     452            pThat->maFramebuffers[i].h = h;
    435453        }
    436454        if (   uVersion == sSSMDisplayVer3
     
    441459            int32_t yOrigin;
    442460            uint32_t flags;
    443             SSMR3GetS32(pSSM, &xOrigin);
    444             SSMR3GetS32(pSSM, &yOrigin);
    445             SSMR3GetU32(pSSM, &flags);
    446             that->maFramebuffers[i].xOrigin = xOrigin;
    447             that->maFramebuffers[i].yOrigin = yOrigin;
    448             that->maFramebuffers[i].flags = (uint16_t)flags;
    449             that->maFramebuffers[i].fDisabled = (that->maFramebuffers[i].flags & VBVA_SCREEN_F_DISABLED) != 0;
     461            pVMM->pfnSSMR3GetS32(pSSM, &xOrigin);
     462            pVMM->pfnSSMR3GetS32(pSSM, &yOrigin);
     463            rc = pVMM->pfnSSMR3GetU32(pSSM, &flags);
     464            AssertRCReturn(rc, rc);
     465            pThat->maFramebuffers[i].xOrigin = xOrigin;
     466            pThat->maFramebuffers[i].yOrigin = yOrigin;
     467            pThat->maFramebuffers[i].flags = (uint16_t)flags;
     468            pThat->maFramebuffers[i].fDisabled = (pThat->maFramebuffers[i].flags & VBVA_SCREEN_F_DISABLED) != 0;
    450469        }
    451470    }
     
    453472        || uVersion == sSSMDisplayVer5)
    454473    {
    455         SSMR3GetS32(pSSM, &that->xInputMappingOrigin);
    456         SSMR3GetS32(pSSM, &that->yInputMappingOrigin);
    457         SSMR3GetU32(pSSM, &that->cxInputMapping);
    458         SSMR3GetU32(pSSM, &that->cyInputMapping);
     474        pVMM->pfnSSMR3GetS32(pSSM, &pThat->xInputMappingOrigin);
     475        pVMM->pfnSSMR3GetS32(pSSM, &pThat->yInputMappingOrigin);
     476        pVMM->pfnSSMR3GetU32(pSSM, &pThat->cxInputMapping);
     477        pVMM->pfnSSMR3GetU32(pSSM, &pThat->cyInputMapping);
    459478    }
    460479    if (uVersion == sSSMDisplayVer5)
    461480    {
    462         SSMR3GetU32(pSSM, &that->mfGuestVBVACapabilities);
    463         SSMR3GetU32(pSSM, &that->mfHostCursorCapabilities);
     481        pVMM->pfnSSMR3GetU32(pSSM, &pThat->mfGuestVBVACapabilities);
     482        pVMM->pfnSSMR3GetU32(pSSM, &pThat->mfHostCursorCapabilities);
    464483    }
    465484
     
    598617int Display::i_registerSSM(PUVM pUVM)
    599618{
     619    PCVMMR3VTABLE const pVMM = mParent->i_getVMMVTable();
     620    AssertPtrReturn(pVMM, VERR_INTERNAL_ERROR_3);
     621
    600622    /* Version 2 adds width and height of the framebuffer; version 3 adds
    601623     * the framebuffer offset in the virtual desktop and the framebuffer flags;
     
    603625     * guest VBVA and host cursor capabilities.
    604626     */
    605     int rc = SSMR3RegisterExternal(pUVM, "DisplayData", 0, sSSMDisplayVer5,
    606                                    mcMonitors * sizeof(uint32_t) * 8 + sizeof(uint32_t),
    607                                    NULL, NULL, NULL,
    608                                    NULL, i_displaySSMSave, NULL,
    609                                    NULL, i_displaySSMLoad, NULL, this);
     627    int rc = pVMM->pfnSSMR3RegisterExternal(pUVM, "DisplayData", 0, sSSMDisplayVer5,
     628                                            mcMonitors * sizeof(uint32_t) * 8 + sizeof(uint32_t),
     629                                            NULL, NULL, NULL,
     630                                            NULL, i_displaySSMSave, NULL,
     631                                            NULL, i_displaySSMLoad, NULL, this);
    610632    AssertRCReturn(rc, rc);
    611633
     
    614636     * 3 * sizeof(uint32_t *) due to a code mistake.
    615637     */
    616     rc = SSMR3RegisterExternal(pUVM, "DisplayData", 12 /*uInstance*/, sSSMDisplayVer, 0 /*cbGuess*/,
    617                                NULL, NULL, NULL,
    618                                NULL, NULL, NULL,
    619                                NULL, i_displaySSMLoad, NULL, this);
     638    rc = pVMM->pfnSSMR3RegisterExternal(pUVM, "DisplayData", 12 /*uInstance*/, sSSMDisplayVer, 0 /*cbGuess*/,
     639                                        NULL, NULL, NULL,
     640                                        NULL, NULL, NULL,
     641                                        NULL, i_displaySSMLoad, NULL, this);
    620642    AssertRCReturn(rc, rc);
    621643
    622     rc = SSMR3RegisterExternal(pUVM, "DisplayData", 24 /*uInstance*/, sSSMDisplayVer, 0 /*cbGuess*/,
    623                                NULL, NULL, NULL,
    624                                NULL, NULL, NULL,
    625                                NULL, i_displaySSMLoad, NULL, this);
     644    rc = pVMM->pfnSSMR3RegisterExternal(pUVM, "DisplayData", 24 /*uInstance*/, sSSMDisplayVer, 0 /*cbGuess*/,
     645                                        NULL, NULL, NULL,
     646                                        NULL, NULL, NULL,
     647                                        NULL, i_displaySSMLoad, NULL, this);
    626648    AssertRCReturn(rc, rc);
    627649
    628650    /* uInstance is an arbitrary value greater than 1024. Such a value will ensure a quick seek in saved state file. */
    629     rc = SSMR3RegisterExternal(pUVM, "DisplayScreenshot", 1100 /*uInstance*/, sSSMDisplayScreenshotVer, 0 /*cbGuess*/,
    630                                NULL, NULL, NULL,
    631                                NULL, i_displaySSMSaveScreenshot, NULL,
    632                                NULL, i_displaySSMLoadScreenshot, NULL, this);
     651    rc = pVMM->pfnSSMR3RegisterExternal(pUVM, "DisplayScreenshot", 1100 /*uInstance*/, sSSMDisplayScreenshotVer, 0 /*cbGuess*/,
     652                                        NULL, NULL, NULL,
     653                                        NULL, i_displaySSMSaveScreenshot, NULL,
     654                                        NULL, i_displaySSMLoadScreenshot, NULL, this);
    633655
    634656    AssertRCReturn(rc, rc);
     
    15751597    Console::SafeVMPtrQuiet ptrVM(mParent);
    15761598    if (ptrVM.isOk())
    1577     {
    1578         VMR3ReqCallNoWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::i_InvalidateAndUpdateEMT,
    1579                            3, this, aScreenId, false);
    1580     }
     1599        ptrVM.vtable()->pfnVMR3ReqCallNoWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::i_InvalidateAndUpdateEMT,
     1600                                              3, this, aScreenId, false);
    15811601
    15821602    LogRelFlowFunc(("Attached to %d %RTuuid\n", aScreenId, aId.raw()));
     
    16911711                                    aChangeOrigin ? aOriginY : ~0,
    16921712                                    RT_BOOL(aEnabled),
    1693                                        (  mfGuestVBVACapabilities
    1694                                         & VBVACAPS_VIDEO_MODE_HINTS)
     1713                                       (mfGuestVBVACapabilities & VBVACAPS_VIDEO_MODE_HINTS)
    16951714                                    && aNotify);
    16961715    if (   mfGuestVBVACapabilities & VBVACAPS_VIDEO_MODE_HINTS
    16971716        && !(mfGuestVBVACapabilities & VBVACAPS_IRQ)
    16981717        && aNotify)
    1699     {
    17001718        mParent->i_sendACPIMonitorHotPlugEvent();
    1701     }
    17021719
    17031720    /* We currently never suppress the VMMDev hint if the guest has requested
     
    18751892}
    18761893
    1877 static int i_displayTakeScreenshot(PUVM pUVM, Display *pDisplay, struct DRVMAINDISPLAY *pDrv, ULONG aScreenId,
    1878                                    BYTE *address, ULONG width, ULONG height)
     1894static int i_displayTakeScreenshot(PUVM pUVM, PCVMMR3VTABLE pVMM, Display *pDisplay, struct DRVMAINDISPLAY *pDrv,
     1895                                   ULONG aScreenId, BYTE *address, ULONG width, ULONG height)
    18791896{
    18801897    uint8_t *pbData = NULL;
     
    18911908                 it would be nice to have an accurate screenshot for the bug
    18921909                 report if the VM deadlocks. */
    1893         vrc = VMR3ReqPriorityCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)Display::i_displayTakeScreenshotEMT, 7,
    1894                                        pDisplay, aScreenId, &pbData, &cbData, &cx, &cy, &fFreeMem);
     1910        vrc = pVMM->pfnVMR3ReqPriorityCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)Display::i_displayTakeScreenshotEMT, 7,
     1911                                                pDisplay, aScreenId, &pbData, &cbData, &cx, &cy, &fFreeMem);
    18951912        if (vrc != VERR_TRY_AGAIN)
    18961913        {
     
    19681985        return ptrVM.rc();
    19691986
    1970     int vrc = i_displayTakeScreenshot(ptrVM.rawUVM(), this, mpDrv, aScreenId, aAddress, aWidth, aHeight);
    1971 
     1987    int vrc = i_displayTakeScreenshot(ptrVM.rawUVM(), ptrVM.vtable(), this, mpDrv, aScreenId, aAddress, aWidth, aHeight);
    19721988    if (RT_SUCCESS(vrc))
    19731989    {
     
    19862002            size_t cPixels = aWidth * aHeight;
    19872003            while (cPixels--)
    1988             {
    19892004                *pu32++ |= UINT32_C(0xFF000000);
    1990             }
    19912005        }
    19922006        else if (aBitmapFormat == BitmapFormat_RGBA)
     
    20202034                }
    20212035                else
    2022                 {
    2023                     rc = setError(E_FAIL,
    2024                                   tr("PNG is larger than 32bpp bitmap"));
    2025                 }
     2036                    rc = setError(E_FAIL, tr("PNG is larger than 32bpp bitmap"));
    20262037            }
    20272038            else
     
    22852296     * dirty conversion work.
    22862297     */
    2287     int vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::i_drawToScreenEMT, 7,
    2288                                this, aScreenId, aAddress, aX, aY, aWidth, aHeight);
     2298    int vrc = ptrVM.vtable()->pfnVMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::i_drawToScreenEMT, 7,
     2299                                                  this, aScreenId, aAddress, aX, aY, aWidth, aHeight);
    22892300
    22902301    /*
     
    23252336        if (   !pFBInfo->fVBVAEnabled
    23262337            && uScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
    2327         {
    23282338            pDisplay->mpDrv->pUpPort->pfnUpdateDisplayAll(pDisplay->mpDrv->pUpPort, /* fFailOnResize = */ true);
    2329         }
    23302339        else
    23312340        {
     
    23772386                         */
    23782387                        if (ulWidth == pFBInfo->w && ulHeight == pFBInfo->h)
    2379                         {
    23802388                            pDisplay->mpDrv->pUpPort->pfnCopyRect(pDisplay->mpDrv->pUpPort,
    23812389                                                                  width, height,
     
    23882396                                                                  u32DstWidth, u32DstHeight,
    23892397                                                                  u32DstLineSize, u32DstBitsPerPixel);
    2390                         }
    23912398                    }
    23922399                }
     
    24182425
    24192426    Console::SafeVMPtr ptrVM(mParent);
    2420     if (!ptrVM.isOk())
    2421         return ptrVM.rc();
    2422 
    2423     HRESULT rc = S_OK;
    2424 
    2425     LogRelFlowFunc(("Sending DPYUPDATE request\n"));
    2426 
    2427     /* Have to release the lock when calling EMT.  */
    2428     alock.release();
    2429 
    2430     int vrc = VMR3ReqCallNoWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::i_InvalidateAndUpdateEMT,
    2431                                  3, this, 0, true);
    2432     alock.acquire();
    2433 
    2434     if (RT_FAILURE(vrc))
    2435         rc = setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("Could not invalidate and update the screen (%Rrc)"), vrc);
    2436 
    2437     LogRelFlowFunc(("rc=%Rhrc\n", rc));
    2438     return rc;
     2427    HRESULT hrc = ptrVM.rc();
     2428    if (SUCCEEDED(hrc))
     2429    {
     2430        LogRelFlowFunc(("Sending DPYUPDATE request\n"));
     2431
     2432        /* Have to release the lock when calling EMT.  */
     2433        alock.release();
     2434
     2435        int vrc = ptrVM.vtable()->pfnVMR3ReqCallNoWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::i_InvalidateAndUpdateEMT,
     2436                                                        3, this, 0, true);
     2437        alock.acquire();
     2438
     2439        if (RT_FAILURE(vrc))
     2440            hrc = setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("Could not invalidate and update the screen (%Rrc)"), vrc);
     2441    }
     2442
     2443    LogRelFlowFunc(("hrc=%Rhrc\n", hrc));
     2444    return hrc;
    24392445}
    24402446
     
    24432449    LogRelFlowFunc(("\n"));
    24442450
    2445     HRESULT rc = S_OK;
    2446 
    24472451    Console::SafeVMPtr ptrVM(mParent);
    2448     if (!ptrVM.isOk())
    2449         return ptrVM.rc();
    2450 
    2451     int vrc = VMR3ReqCallNoWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::i_InvalidateAndUpdateEMT,
    2452                                  3, this, aScreenId, false);
    2453     if (RT_FAILURE(vrc))
    2454         rc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Could not invalidate and update the screen %d (%Rrc)"), aScreenId, vrc);
    2455 
    2456     LogRelFlowFunc(("rc=%Rhrc\n", rc));
    2457     return rc;
     2452    HRESULT hrc = ptrVM.rc();
     2453    if (SUCCEEDED(hrc))
     2454    {
     2455        int vrc = ptrVM.vtable()->pfnVMR3ReqCallNoWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::i_InvalidateAndUpdateEMT,
     2456                                                        3, this, aScreenId, false);
     2457        if (RT_FAILURE(vrc))
     2458            hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Could not invalidate and update the screen %d (%Rrc)"), aScreenId, vrc);
     2459    }
     2460
     2461    LogRelFlowFunc(("hrc=%Rhrc\n", hrc));
     2462    return hrc;
    24582463}
    24592464
     
    24972502
    24982503    if (aScreenId >= mcMonitors)
    2499         return setError(E_INVALIDARG, tr("QuerySourceBitmap: Invalid screen %d (total %d)"),
    2500                         aScreenId, mcMonitors);
     2504        return setError(E_INVALIDARG, tr("QuerySourceBitmap: Invalid screen %d (total %d)"), aScreenId, mcMonitors);
    25012505
    25022506    if (!mfSourceBitmapEnabled)
     
    25722576    {
    25732577        if (fSetRenderVRAM)
    2574         {
    25752578            mpDrv->pUpPort->pfnSetRenderVRAM(mpDrv->pUpPort, true);
    2576         }
    25772579
    25782580        if (fInvalidate)
     
    37343736DECLCALLBACK(int) Display::i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
    37353737{
    3736     RT_NOREF(fFlags);
    37373738    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
     3739    RT_NOREF(fFlags, pCfg);
    37383740    PDRVMAINDISPLAY pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINDISPLAY);
    37393741    LogRelFlowFunc(("iInstance=%d\n", pDrvIns->iInstance));
     
    37423744     * Validate configuration.
    37433745     */
    3744     if (!CFGMR3AreValuesValid(pCfg, ""))
    3745         return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
     3746    PDMDRV_VALIDATE_CONFIG_RETURN(pDrvIns, "", "");
    37463747    AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
    37473748                    ("Configuration error: Not possible to attach anything to this driver!\n"),
  • trunk/src/VBox/Main/src-client/DrvAudioRec.cpp

    r93115 r93444  
    9696#include <VBox/vmm/pdmaudioifs.h>
    9797#include <VBox/vmm/pdmaudioinline.h>
     98#include <VBox/vmm/vmmr3vtable.h>
    9899#include <VBox/err.h>
    99100
     
    321322
    322323
    323 /**
    324  * @copydoc AudioDriver::configureDriver
    325  */
    326 int AudioVideoRec::configureDriver(PCFGMNODE pLunCfg)
    327 {
    328     int rc = CFGMR3InsertInteger(pLunCfg, "Object",    (uintptr_t)mpConsole->i_recordingGetAudioDrv());
    329     AssertRCReturn(rc, rc);
    330     rc = CFGMR3InsertInteger(pLunCfg, "ObjectConsole", (uintptr_t)mpConsole);
     324int AudioVideoRec::configureDriver(PCFGMNODE pLunCfg, PCVMMR3VTABLE pVMM)
     325{
     326    int rc = pVMM->pfnCFGMR3InsertInteger(pLunCfg, "Object",    (uintptr_t)mpConsole->i_recordingGetAudioDrv());
     327    AssertRCReturn(rc, rc);
     328    rc = pVMM->pfnCFGMR3InsertInteger(pLunCfg, "ObjectConsole", (uintptr_t)mpConsole);
    331329    AssertRCReturn(rc, rc);
    332330
     
    335333    const settings::RecordingScreenSettings &Screen0Settings = mVideoRecCfg.mapScreens[0];
    336334
    337     rc = CFGMR3InsertInteger(pLunCfg, "ContainerType", (uint64_t)Screen0Settings.enmDest);
     335    rc = pVMM->pfnCFGMR3InsertInteger(pLunCfg, "ContainerType", (uint64_t)Screen0Settings.enmDest);
    338336    AssertRCReturn(rc, rc);
    339337    if (Screen0Settings.enmDest == RecordingDestination_File)
    340338    {
    341         rc = CFGMR3InsertString(pLunCfg, "ContainerFileName", Utf8Str(Screen0Settings.File.strName).c_str());
     339        rc = pVMM->pfnCFGMR3InsertString(pLunCfg, "ContainerFileName", Utf8Str(Screen0Settings.File.strName).c_str());
    342340        AssertRCReturn(rc, rc);
    343341    }
    344     rc = CFGMR3InsertInteger(pLunCfg, "CodecHz", Screen0Settings.Audio.uHz);
    345     AssertRCReturn(rc, rc);
    346     rc = CFGMR3InsertInteger(pLunCfg, "CodecBits", Screen0Settings.Audio.cBits);
    347     AssertRCReturn(rc, rc);
    348     rc = CFGMR3InsertInteger(pLunCfg, "CodecChannels", Screen0Settings.Audio.cChannels);
    349     AssertRCReturn(rc, rc);
    350     rc = CFGMR3InsertInteger(pLunCfg, "CodecBitrate", 0); /* Let Opus decide for now. */
    351     AssertRCReturn(rc, rc);
    352 
    353     return AudioDriver::configureDriver(pLunCfg);
     342    rc = pVMM->pfnCFGMR3InsertInteger(pLunCfg, "CodecHz", Screen0Settings.Audio.uHz);
     343    AssertRCReturn(rc, rc);
     344    rc = pVMM->pfnCFGMR3InsertInteger(pLunCfg, "CodecBits", Screen0Settings.Audio.cBits);
     345    AssertRCReturn(rc, rc);
     346    rc = pVMM->pfnCFGMR3InsertInteger(pLunCfg, "CodecChannels", Screen0Settings.Audio.cChannels);
     347    AssertRCReturn(rc, rc);
     348    rc = pVMM->pfnCFGMR3InsertInteger(pLunCfg, "CodecBitrate", 0); /* Let Opus decide for now. */
     349    AssertRCReturn(rc, rc);
     350
     351    return AudioDriver::configureDriver(pLunCfg, pVMM);
    354352}
    355353
     
    11281126
    11291127    /*
     1128     * Read configuration.
     1129     */
     1130    PCPDMDRVHLPR3 const pHlp = pDrvIns->pHlpR3;
     1131    /** @todo validate it.    */
     1132
     1133    /*
    11301134     * Get the Console object pointer.
    11311135     */
     1136    /** @todo No pointers!  */
    11321137    void *pvUser;
    1133     int rc = CFGMR3QueryPtr(pCfg, "ObjectConsole", &pvUser); /** @todo r=andy Get rid of this hack and use IHostAudio::SetCallback. */
     1138    int rc = pHlp->pfnCFGMQueryPtr(pCfg, "ObjectConsole", &pvUser); /** @todo r=andy Get rid of this hack and use IHostAudio::SetCallback. */
    11341139    AssertRCReturn(rc, rc);
    11351140
     
    11411146     * Get the pointer to the audio driver instance.
    11421147     */
    1143     rc = CFGMR3QueryPtr(pCfg, "Object", &pvUser); /** @todo r=andy Get rid of this hack and use IHostAudio::SetCallback. */
     1148    rc = pHlp->pfnCFGMQueryPtr(pCfg, "Object", &pvUser); /** @todo r=andy Get rid of this hack and use IHostAudio::SetCallback. */
    11441149    AssertRCReturn(rc, rc);
    11451150
     
    11561161    RT_ZERO(pThis->CodecParms);
    11571162
    1158     rc = CFGMR3QueryU32(pCfg, "ContainerType", (uint32_t *)&pConParams->enmType);
     1163    rc = pHlp->pfnCFGMQueryU32(pCfg, "ContainerType", (uint32_t *)&pConParams->enmType);
    11591164    AssertRCReturn(rc, rc);
    11601165
     
    11621167    {
    11631168        case AVRECCONTAINERTYPE_WEBM:
    1164             rc = CFGMR3QueryStringAlloc(pCfg, "ContainerFileName", &pConParams->WebM.pszFile);
     1169            rc = pHlp->pfnCFGMQueryStringAlloc(pCfg, "ContainerFileName", &pConParams->WebM.pszFile);
    11651170            AssertRCReturn(rc, rc);
    11661171            break;
     
    11711176
    11721177    uint32_t uHz = 0;
    1173     rc = CFGMR3QueryU32(pCfg, "CodecHz", &uHz);
     1178    rc = pHlp->pfnCFGMQueryU32(pCfg, "CodecHz", &uHz);
    11741179    AssertRCReturn(rc, rc);
    11751180
    11761181    uint8_t cSampleBits = 0;
    1177     rc = CFGMR3QueryU8(pCfg,  "CodecBits", &cSampleBits); /** @todo CodecBits != CodecBytes */
     1182    rc = pHlp->pfnCFGMQueryU8(pCfg,  "CodecBits", &cSampleBits); /** @todo CodecBits != CodecBytes */
    11781183    AssertRCReturn(rc, rc);
    11791184
    11801185    uint8_t cChannels = 0;
    1181     rc = CFGMR3QueryU8(pCfg,  "CodecChannels", &cChannels);
     1186    rc = pHlp->pfnCFGMQueryU8(pCfg,  "CodecChannels", &cChannels);
    11821187    AssertRCReturn(rc, rc);
    11831188
     
    11861191                    ("Configuration error: Audio configuration is invalid!\n"), VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES); /** @todo wrong status code. */
    11871192
    1188     rc = CFGMR3QueryU32(pCfg, "CodecBitrate", &pCodecParms->uBitrate);
     1193    rc = pHlp->pfnCFGMQueryU32(pCfg, "CodecBitrate", &pCodecParms->uBitrate);
    11891194    AssertRCReturn(rc, rc);
    11901195
  • trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp

    r93115 r93444  
    3636#include <VBox/vmm/pdmaudioifs.h>
    3737#include <VBox/vmm/pdmaudioinline.h>
     38#include <VBox/vmm/vmmr3vtable.h>
    3839#include <VBox/RemoteDesktop/VRDE.h>
    3940#include <VBox/err.h>
     
    111112
    112113
    113 /**
    114  * @copydoc AudioDriver::configureDriver
    115  */
    116 int AudioVRDE::configureDriver(PCFGMNODE pLunCfg)
    117 {
    118     int rc = CFGMR3InsertInteger(pLunCfg, "Object", (uintptr_t)this);
     114int AudioVRDE::configureDriver(PCFGMNODE pLunCfg, PCVMMR3VTABLE pVMM)
     115{
     116    int rc = pVMM->pfnCFGMR3InsertInteger(pLunCfg, "Object", (uintptr_t)this);
    119117    AssertRCReturn(rc, rc);
    120     CFGMR3InsertInteger(pLunCfg, "ObjectVRDPServer", (uintptr_t)mpConsole->i_consoleVRDPServer());
     118
     119    rc = pVMM->pfnCFGMR3InsertInteger(pLunCfg, "ObjectVRDPServer", (uintptr_t)mpConsole->i_consoleVRDPServer());
    121120    AssertRCReturn(rc, rc);
    122121
    123     return AudioDriver::configureDriver(pLunCfg);
     122    return AudioDriver::configureDriver(pLunCfg, pVMM);
    124123}
    125124
     
    749748     */
    750749    void *pvUser;
    751     int rc = CFGMR3QueryPtr(pCfg, "ObjectVRDPServer", &pvUser); /** @todo r=andy Get rid of this hack and use IHostAudio::SetCallback. */
     750    int rc = pDrvIns->pHlpR3->pfnCFGMQueryPtr(pCfg, "ObjectVRDPServer", &pvUser); /** @todo r=andy Get rid of this hack and use IHostAudio::SetCallback. */
    752751    AssertMsgRCReturn(rc, ("Confguration error: No/bad \"ObjectVRDPServer\" value, rc=%Rrc\n", rc), rc);
    753752
     
    762761     */
    763762    pvUser = NULL;
    764     rc = CFGMR3QueryPtr(pCfg, "Object", &pvUser); /** @todo r=andy Get rid of this hack and use IHostAudio::SetCallback. */
     763    rc = pDrvIns->pHlpR3->pfnCFGMQueryPtr(pCfg, "Object", &pvUser); /** @todo r=andy Get rid of this hack and use IHostAudio::SetCallback. */
    765764    AssertMsgRCReturn(rc, ("Confguration error: No/bad \"Object\" value, rc=%Rrc\n", rc), rc);
    766765
  • trunk/src/VBox/Main/src-client/EmulatedUSBImpl.cpp

    r93115 r93444  
    2323
    2424#include <VBox/vmm/pdmusb.h>
     25#include <VBox/vmm/vmmr3vtable.h>
    2526
    2627
     
    3940class EUSBWEBCAM /* : public EUSBDEVICE */
    4041{
    41     private:
    42         int32_t volatile mcRefs;
    43 
    44         EmulatedUSB *mpEmulatedUSB;
    45 
    46         RTUUID mUuid;
    47         char mszUuid[RTUUID_STR_LENGTH];
    48 
    49         Utf8Str mPath;
    50         Utf8Str mSettings;
    51 
    52         EUSBSettingsMap mDevSettings;
    53         EUSBSettingsMap mDrvSettings;
    54 
    55         void *mpvObject;
    56 
    57         static DECLCALLBACK(int) emulatedWebcamAttach(PUVM pUVM, EUSBWEBCAM *pThis, const char *pszDriver);
    58         static DECLCALLBACK(int) emulatedWebcamDetach(PUVM pUVM, EUSBWEBCAM *pThis);
    59 
    60         HRESULT settingsParse(void);
    61 
    62         ~EUSBWEBCAM()
    63         {
    64         }
    65 
    66     public:
    67         EUSBWEBCAM()
    68             :
    69             mcRefs(1),
    70             mpEmulatedUSB(NULL),
    71             mpvObject(NULL),
    72             enmStatus(EUSBDEVICE_CREATED)
    73         {
    74             RT_ZERO(mUuid);
    75             RT_ZERO(mszUuid);
    76         }
    77 
    78         int32_t AddRef(void)
    79         {
    80             return ASMAtomicIncS32(&mcRefs);
    81         }
    82 
    83         void Release(void)
    84         {
    85             int32_t c = ASMAtomicDecS32(&mcRefs);
    86             if (c == 0)
    87             {
    88                 delete this;
    89             }
    90         }
    91 
    92         HRESULT Initialize(Console *pConsole,
    93                            EmulatedUSB *pEmulatedUSB,
    94                            const com::Utf8Str *aPath,
    95                            const com::Utf8Str *aSettings,
    96                            void *pvObject);
    97         HRESULT Attach(Console *pConsole,
    98                        PUVM pUVM,
    99                        const char *pszDriver);
    100         HRESULT Detach(Console *pConsole,
    101                        PUVM pUVM);
    102 
    103         bool HasId(const char *pszId) { return RTStrCmp(pszId, mszUuid) == 0;}
    104 
    105         EUSBDEVICESTATUS enmStatus;
     42private:
     43    int32_t volatile mcRefs;
     44
     45    EmulatedUSB *mpEmulatedUSB;
     46
     47    RTUUID mUuid;
     48    char mszUuid[RTUUID_STR_LENGTH];
     49
     50    Utf8Str mPath;
     51    Utf8Str mSettings;
     52
     53    EUSBSettingsMap mDevSettings;
     54    EUSBSettingsMap mDrvSettings;
     55
     56    void *mpvObject;
     57
     58    static DECLCALLBACK(int) emulatedWebcamAttach(PUVM pUVM, PCVMMR3VTABLE pVMM, EUSBWEBCAM *pThis, const char *pszDriver);
     59    static DECLCALLBACK(int) emulatedWebcamDetach(PUVM pUVM, PCVMMR3VTABLE pVMM, EUSBWEBCAM *pThis);
     60
     61    HRESULT settingsParse(void);
     62
     63    ~EUSBWEBCAM()
     64    {
     65    }
     66
     67public:
     68    EUSBWEBCAM()
     69        :
     70        mcRefs(1),
     71        mpEmulatedUSB(NULL),
     72        mpvObject(NULL),
     73        enmStatus(EUSBDEVICE_CREATED)
     74    {
     75        RT_ZERO(mUuid);
     76        RT_ZERO(mszUuid);
     77    }
     78
     79    int32_t AddRef(void)
     80    {
     81        return ASMAtomicIncS32(&mcRefs);
     82    }
     83
     84    void Release(void)
     85    {
     86        int32_t c = ASMAtomicDecS32(&mcRefs);
     87        if (c == 0)
     88        {
     89            delete this;
     90        }
     91    }
     92
     93    HRESULT Initialize(Console *pConsole,
     94                       EmulatedUSB *pEmulatedUSB,
     95                       const com::Utf8Str *aPath,
     96                       const com::Utf8Str *aSettings,
     97                       void *pvObject);
     98    HRESULT Attach(Console *pConsole, PUVM pUVM, PCVMMR3VTABLE pVMM, const char *pszDriver);
     99    HRESULT Detach(Console *pConsole, PUVM pUVM, PCVMMR3VTABLE pVMM);
     100
     101    bool HasId(const char *pszId) { return RTStrCmp(pszId, mszUuid) == 0;}
     102
     103    EUSBDEVICESTATUS enmStatus;
    106104};
    107105
    108 static int emulatedWebcamInsertSettings(PCFGMNODE pConfig, EUSBSettingsMap *pSettings)
    109 {
    110     int rc = VINF_SUCCESS;
    111 
    112     EUSBSettingsMap::const_iterator it;
    113     for (it = pSettings->begin(); it != pSettings->end(); ++it)
     106
     107static int emulatedWebcamInsertSettings(PCFGMNODE pConfig, PCVMMR3VTABLE pVMM, EUSBSettingsMap *pSettings)
     108{
     109    for (EUSBSettingsMap::const_iterator it = pSettings->begin(); it != pSettings->end(); ++it)
    114110    {
    115111        /* Convert some well known settings for backward compatibility. */
     112        int rc;
    116113        if (   RTStrCmp(it->first.c_str(), "MaxPayloadTransferSize") == 0
    117114            || RTStrCmp(it->first.c_str(), "MaxFramerate") == 0)
     
    120117            rc = RTStrToUInt32Full(it->second.c_str(), 10, &u32);
    121118            if (rc == VINF_SUCCESS)
    122             {
    123                 rc = CFGMR3InsertInteger(pConfig, it->first.c_str(), u32);
    124             }
    125             else
    126             {
    127                 if (RT_SUCCESS(rc)) /* VWRN_* */
    128                 {
    129                     rc = VERR_INVALID_PARAMETER;
    130                 }
    131             }
     119                rc = pVMM->pfnCFGMR3InsertInteger(pConfig, it->first.c_str(), u32);
     120            else if (RT_SUCCESS(rc)) /* VWRN_* */
     121                rc = VERR_INVALID_PARAMETER;
    132122        }
    133123        else
    134         {
    135             rc = CFGMR3InsertString(pConfig, it->first.c_str(), it->second.c_str());
    136         }
    137 
     124            rc = pVMM->pfnCFGMR3InsertString(pConfig, it->first.c_str(), it->second.c_str());
    138125        if (RT_FAILURE(rc))
    139         {
    140             break;
    141         }
    142     }
    143 
    144     return rc;
    145 }
    146 
    147 /* static */ DECLCALLBACK(int) EUSBWEBCAM::emulatedWebcamAttach(PUVM pUVM, EUSBWEBCAM *pThis, const char *pszDriver)
    148 {
    149     PCFGMNODE pInstance = CFGMR3CreateTree(pUVM);
     126            return rc;
     127    }
     128
     129    return VINF_SUCCESS;
     130}
     131
     132/*static*/ DECLCALLBACK(int)
     133EUSBWEBCAM::emulatedWebcamAttach(PUVM pUVM, PCVMMR3VTABLE pVMM, EUSBWEBCAM *pThis, const char *pszDriver)
     134{
     135    PCFGMNODE pInstance = pVMM->pfnCFGMR3CreateTree(pUVM);
    150136    PCFGMNODE pConfig;
    151     CFGMR3InsertNode(pInstance,   "Config", &pConfig);
    152     int rc = emulatedWebcamInsertSettings(pConfig, &pThis->mDevSettings);
    153     if (RT_FAILURE(rc))
    154         return rc;
     137    int rc = pVMM->pfnCFGMR3InsertNode(pInstance,   "Config", &pConfig);
     138    AssertRCReturn(rc, rc);
     139    rc = emulatedWebcamInsertSettings(pConfig, pVMM, &pThis->mDevSettings);
     140    AssertRCReturn(rc, rc);
     141
    155142    PCFGMNODE pEUSB;
    156     CFGMR3InsertNode(pConfig,       "EmulatedUSB", &pEUSB);
    157     CFGMR3InsertString(pEUSB,         "Id", pThis->mszUuid);
    158     CFGMR3InsertInteger(pEUSB,        "pfnCallback", (uintptr_t)EmulatedUSB::i_eusbCallback);
    159     CFGMR3InsertInteger(pEUSB,        "pvCallback", (uintptr_t)pThis->mpEmulatedUSB);
     143    rc = pVMM->pfnCFGMR3InsertNode(pConfig,       "EmulatedUSB", &pEUSB);
     144    AssertRCReturn(rc, rc);
     145    rc = pVMM->pfnCFGMR3InsertString(pEUSB,         "Id", pThis->mszUuid);
     146    AssertRCReturn(rc, rc);
     147    /** @todo BUGBUG: No pointers via CFGM in 7.0!   */
     148    rc = pVMM->pfnCFGMR3InsertInteger(pEUSB,        "pfnCallback", (uintptr_t)EmulatedUSB::i_eusbCallback);
     149    AssertRCReturn(rc, rc);
     150    rc = pVMM->pfnCFGMR3InsertInteger(pEUSB,        "pvCallback", (uintptr_t)pThis->mpEmulatedUSB);
     151    AssertRCReturn(rc, rc);
    160152
    161153    PCFGMNODE pLunL0;
    162     CFGMR3InsertNode(pInstance,   "LUN#0", &pLunL0);
    163     CFGMR3InsertString(pLunL0,      "Driver", pszDriver);
    164     CFGMR3InsertNode(pLunL0,        "Config", &pConfig);
    165     CFGMR3InsertString(pConfig,       "DevicePath", pThis->mPath.c_str());
    166     CFGMR3InsertInteger(pConfig,      "Object", (uintptr_t)pThis->mpvObject);
    167     rc = emulatedWebcamInsertSettings(pConfig, &pThis->mDrvSettings);
    168     if (RT_FAILURE(rc))
    169         return rc;
     154    rc = pVMM->pfnCFGMR3InsertNode(pInstance,   "LUN#0", &pLunL0);
     155    AssertRCReturn(rc, rc);
     156    rc = pVMM->pfnCFGMR3InsertString(pLunL0,      "Driver", pszDriver);
     157    AssertRCReturn(rc, rc);
     158    rc = pVMM->pfnCFGMR3InsertNode(pLunL0,        "Config", &pConfig);
     159    AssertRCReturn(rc, rc);
     160    rc = pVMM->pfnCFGMR3InsertString(pConfig,       "DevicePath", pThis->mPath.c_str());
     161    AssertRCReturn(rc, rc);
     162    /** @todo BUGBUG: No pointers via CFGM in 7.0!   */
     163    rc = pVMM->pfnCFGMR3InsertInteger(pConfig,      "Object", (uintptr_t)pThis->mpvObject);
     164    AssertRCReturn(rc, rc);
     165    rc = emulatedWebcamInsertSettings(pConfig, pVMM, &pThis->mDrvSettings);
     166    AssertRCReturn(rc, rc);
    170167
    171168    /* pInstance will be used by PDM and deallocated on error. */
    172     rc = PDMR3UsbCreateEmulatedDevice(pUVM, "Webcam", pInstance, &pThis->mUuid, NULL);
     169    rc = pVMM->pfnPDMR3UsbCreateEmulatedDevice(pUVM, "Webcam", pInstance, &pThis->mUuid, NULL);
    173170    LogRelFlowFunc(("PDMR3UsbCreateEmulatedDevice %Rrc\n", rc));
    174171    return rc;
    175172}
    176173
    177 /* static */ DECLCALLBACK(int) EUSBWEBCAM::emulatedWebcamDetach(PUVM pUVM, EUSBWEBCAM *pThis)
    178 {
    179     return PDMR3UsbDetachDevice(pUVM, &pThis->mUuid);
     174/*static*/ DECLCALLBACK(int)
     175EUSBWEBCAM::emulatedWebcamDetach(PUVM pUVM, PCVMMR3VTABLE pVMM, EUSBWEBCAM *pThis)
     176{
     177    return pVMM->pfnPDMR3UsbDetachDevice(pUVM, &pThis->mUuid);
    180178}
    181179
     
    189187
    190188    int vrc = RTUuidCreate(&mUuid);
    191     if (RT_SUCCESS(vrc))
    192     {
    193         RTStrPrintf(mszUuid, sizeof(mszUuid), "%RTuuid", &mUuid);
    194         hrc = mPath.assignEx(*aPath);
     189    AssertRCReturn(vrc, pConsole->setError(vrc, EmulatedUSB::tr("Init emulated USB webcam (RTUuidCreate -> %Rrc)"), vrc));
     190
     191    RTStrPrintf(mszUuid, sizeof(mszUuid), "%RTuuid", &mUuid);
     192    hrc = mPath.assignEx(*aPath);
     193    if (SUCCEEDED(hrc))
     194    {
     195        hrc = mSettings.assignEx(*aSettings);
    195196        if (SUCCEEDED(hrc))
    196197        {
    197             hrc = mSettings.assignEx(*aSettings);
    198         }
    199 
    200         if (SUCCEEDED(hrc))
    201         {
    202198            hrc = settingsParse();
    203 
    204199            if (SUCCEEDED(hrc))
    205200            {
     
    208203            }
    209204        }
    210     }
    211 
    212     if (SUCCEEDED(hrc) && RT_FAILURE(vrc))
    213     {
    214         LogFlowThisFunc(("%Rrc\n", vrc));
    215         hrc = pConsole->setErrorBoth(VBOX_E_IPRT_ERROR, vrc, EmulatedUSB::tr("Init emulated USB webcam (%Rrc)"), vrc);
    216205    }
    217206
     
    246235            }
    247236
    248             char *pszEq = RTStrStr(pszSrc, "=");
     237            char *pszEq = strchr(pszSrc, '=');
    249238            if (!pszEq)
    250239            {
     
    253242            }
    254243
    255             char *pszEnd = RTStrStr(pszEq, ";");
     244            char *pszEnd = strchr(pszEq, ';');
    256245            if (!pszEnd)
    257             {
    258246                pszEnd = pszEq + strlen(pszEq);
    259             }
    260247
    261248            *pszEq = 0;
     
    267254            {
    268255                if (fDev)
    269                 {
    270256                    mDevSettings[pszSrc] = &pszEq[1];
    271                 }
    272257                if (fDrv)
    273                 {
    274258                    mDrvSettings[pszSrc] = &pszEq[1];
    275                 }
    276259            }
    277260
     
    281264            pszSrc = pszEnd;
    282265            if (*pszSrc == ';')
    283             {
    284266                pszSrc++;
    285             }
    286267        }
    287268
     
    299280}
    300281
    301 HRESULT EUSBWEBCAM::Attach(Console *pConsole,
    302                            PUVM pUVM,
    303                            const char *pszDriver)
    304 {
    305     HRESULT hrc = S_OK;
    306 
    307     int  vrc = VMR3ReqCallWaitU(pUVM, 0 /* idDstCpu (saved state, see #6232) */,
    308                                 (PFNRT)emulatedWebcamAttach, 3,
    309                                 pUVM, this, pszDriver);
    310 
    311     if (SUCCEEDED(hrc) && RT_FAILURE(vrc))
    312     {
    313         LogFlowThisFunc(("%Rrc\n", vrc));
    314         hrc = pConsole->setErrorBoth(VBOX_E_VM_ERROR, vrc, EmulatedUSB::tr("Attach emulated USB webcam (%Rrc)"), vrc);
    315     }
    316 
    317     return hrc;
    318 }
    319 
    320 HRESULT EUSBWEBCAM::Detach(Console *pConsole,
    321                            PUVM pUVM)
    322 {
    323     HRESULT hrc = S_OK;
    324 
    325     int vrc = VMR3ReqCallWaitU(pUVM, 0 /* idDstCpu (saved state, see #6232) */,
    326                               (PFNRT)emulatedWebcamDetach, 2,
    327                               pUVM, this);
    328 
    329     if (SUCCEEDED(hrc) && RT_FAILURE(vrc))
    330     {
    331         LogFlowThisFunc(("%Rrc\n", vrc));
    332         hrc = pConsole->setErrorBoth(VBOX_E_VM_ERROR, vrc, EmulatedUSB::tr("Detach emulated USB webcam (%Rrc)"), vrc);
    333     }
    334 
    335     return hrc;
     282HRESULT EUSBWEBCAM::Attach(Console *pConsole, PUVM pUVM, PCVMMR3VTABLE pVMM, const char *pszDriver)
     283{
     284    int vrc = pVMM->pfnVMR3ReqCallWaitU(pUVM, 0 /* idDstCpu (saved state, see #6232) */,
     285                                        (PFNRT)emulatedWebcamAttach, 4,
     286                                        pUVM, pVMM, this, pszDriver);
     287    if (RT_SUCCESS(vrc))
     288        return S_OK;
     289    LogFlowThisFunc(("%Rrc\n", vrc));
     290    return pConsole->setErrorBoth(VBOX_E_VM_ERROR, vrc, EmulatedUSB::tr("Attach emulated USB webcam (%Rrc)"), vrc);
     291}
     292
     293HRESULT EUSBWEBCAM::Detach(Console *pConsole, PUVM pUVM, PCVMMR3VTABLE pVMM)
     294{
     295    int vrc = pVMM->pfnVMR3ReqCallWaitU(pUVM, 0 /* idDstCpu (saved state, see #6232) */,
     296                                        (PFNRT)emulatedWebcamDetach, 3,
     297                                        pUVM, pVMM, this);
     298    if (RT_SUCCESS(vrc))
     299        return S_OK;
     300    LogFlowThisFunc(("%Rrc\n", vrc));
     301    return pConsole->setErrorBoth(VBOX_E_VM_ERROR, vrc, EmulatedUSB::tr("Detach emulated USB webcam (%Rrc)"), vrc);
    336302}
    337303
     
    488454
    489455            if (SUCCEEDED(hrc))
    490             {
    491                 hrc = p->Attach(m.pConsole, ptrVM.rawUVM(), pszDriver);
    492             }
     456                hrc = p->Attach(m.pConsole, ptrVM.rawUVM(), ptrVM.vtable(), pszDriver);
    493457
    494458            AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    495459            if (SUCCEEDED(hrc))
    496             {
    497460                p->enmStatus = EUSBDEVICE_ATTACHED;
    498             }
    499             else
    500             {
    501                 if (p->enmStatus != EUSBDEVICE_CREATED)
    502                 {
    503                     m.webcams.erase(path);
    504                 }
    505             }
     461            else if (p->enmStatus != EUSBDEVICE_CREATED)
     462                m.webcams.erase(path);
    506463            alock.release();
    507464
     
    551508        if (p)
    552509        {
    553             hrc = p->Detach(m.pConsole, ptrVM.rawUVM());
     510            hrc = p->Detach(m.pConsole, ptrVM.rawUVM(), ptrVM.vtable());
    554511            p->Release();
    555512        }
     
    567524}
    568525
    569 /* static */ DECLCALLBACK(int) EmulatedUSB::eusbCallbackEMT(EmulatedUSB *pThis, char *pszId, uint32_t iEvent,
    570                                                             void *pvData, uint32_t cbData)
     526/*static*/ DECLCALLBACK(int)
     527EmulatedUSB::eusbCallbackEMT(EmulatedUSB *pThis, char *pszId, uint32_t iEvent, void *pvData, uint32_t cbData)
    571528{
    572529    LogRelFlowFunc(("id %s event %d, data %p %d\n", pszId, iEvent, pvData, cbData));
     
    604561}
    605562
    606 /* static */ DECLCALLBACK(int) EmulatedUSB::i_eusbCallback(void *pv, const char *pszId, uint32_t iEvent,
    607                                                           const void *pvData, uint32_t cbData)
     563/* static */ DECLCALLBACK(int)
     564EmulatedUSB::i_eusbCallback(void *pv, const char *pszId, uint32_t iEvent, const void *pvData, uint32_t cbData)
    608565{
    609566    /* Make a copy of parameters, forward to EMT and leave the callback to not hold any lock in the device. */
    610567    int rc = VINF_SUCCESS;
    611 
    612     void *pvIdCopy = NULL;
    613568    void *pvDataCopy = NULL;
    614569    if (cbData > 0)
     
    616571       pvDataCopy = RTMemDup(pvData, cbData);
    617572       if (!pvDataCopy)
    618        {
    619573           rc = VERR_NO_MEMORY;
    620        }
    621     }
    622 
     574    }
    623575    if (RT_SUCCESS(rc))
    624576    {
    625         pvIdCopy = RTMemDup(pszId, strlen(pszId) + 1);
    626         if (!pvIdCopy)
    627         {
     577        void *pvIdCopy = RTMemDup(pszId, strlen(pszId) + 1);
     578        if (pvIdCopy)
     579        {
     580            if (RT_SUCCESS(rc))
     581            {
     582                EmulatedUSB *pThis = (EmulatedUSB *)pv;
     583                Console::SafeVMPtr ptrVM(pThis->m.pConsole);
     584                if (ptrVM.isOk())
     585                {
     586                    /* No wait. */
     587                    rc = ptrVM.vtable()->pfnVMR3ReqCallNoWaitU(ptrVM.rawUVM(), 0 /* idDstCpu */,
     588                                                               (PFNRT)EmulatedUSB::eusbCallbackEMT, 5,
     589                                                               pThis, pvIdCopy, iEvent, pvDataCopy, cbData);
     590                    if (RT_SUCCESS(rc))
     591                        return rc;
     592                }
     593                else
     594                    rc = VERR_INVALID_STATE;
     595            }
     596            RTMemFree(pvIdCopy);
     597        }
     598        else
    628599            rc = VERR_NO_MEMORY;
    629         }
    630     }
    631 
    632     if (RT_SUCCESS(rc))
    633     {
    634         EmulatedUSB *pThis = (EmulatedUSB *)pv;
    635         Console::SafeVMPtr ptrVM(pThis->m.pConsole);
    636         if (ptrVM.isOk())
    637         {
    638             /* No wait. */
    639             rc = VMR3ReqCallNoWaitU(ptrVM.rawUVM(), 0 /* idDstCpu */,
    640                                     (PFNRT)EmulatedUSB::eusbCallbackEMT, 5,
    641                                     pThis, pvIdCopy, iEvent, pvDataCopy, cbData);
    642         }
    643         else
    644         {
    645             rc = VERR_INVALID_STATE;
    646         }
    647     }
    648 
    649     if (RT_FAILURE(rc))
    650     {
    651         RTMemFree(pvIdCopy);
    652600        RTMemFree(pvDataCopy);
    653601    }
    654 
    655602    return rc;
    656603}
  • trunk/src/VBox/Main/src-client/GuestImpl.cpp

    r93115 r93444  
    4141#include <iprt/timer.h>
    4242#include <VBox/vmm/pgm.h>
     43#include <VBox/vmm/vmmr3vtable.h>
    4344#include <VBox/version.h>
    4445
     
    311312            /* Query the missing per-VM memory statistics. */
    312313            uint64_t cbTotalMemIgn, cbPrivateMemIgn, cbZeroMemIgn;
    313             rc = PGMR3QueryMemoryStats(ptrVM.rawUVM(), &cbTotalMemIgn, &cbPrivateMemIgn, &cbSharedMem, &cbZeroMemIgn);
     314            rc = ptrVM.vtable()->pfnPGMR3QueryMemoryStats(ptrVM.rawUVM(), &cbTotalMemIgn, &cbPrivateMemIgn,
     315                                                          &cbSharedMem, &cbZeroMemIgn);
    314316            if (rc == VINF_SUCCESS)
    315317                validStats |= pm::VMSTATMASK_GUEST_MEMSHARED;
     
    318320        if (mCollectVMMStats)
    319321        {
    320             rc = PGMR3QueryGlobalMemoryStats(ptrVM.rawUVM(), &cbAllocTotal, &cbFreeTotal, &cbBalloonedTotal, &cbSharedTotal);
     322            rc = ptrVM.vtable()->pfnPGMR3QueryGlobalMemoryStats(ptrVM.rawUVM(), &cbAllocTotal, &cbFreeTotal,
     323                                                                &cbBalloonedTotal, &cbSharedTotal);
    321324            AssertRC(rc);
    322325            if (rc == VINF_SUCCESS)
     
    328331        uint64_t uTxPrev = mNetStatTx;
    329332        mNetStatRx = mNetStatTx = 0;
    330         rc = STAMR3Enum(ptrVM.rawUVM(), "/Public/Net/*/Bytes*", i_staticEnumStatsCallback, this);
     333        rc = ptrVM.vtable()->pfnSTAMR3Enum(ptrVM.rawUVM(), "/Public/Net/*/Bytes*", i_staticEnumStatsCallback, this);
    331334        AssertRC(rc);
    332335
     
    706709
    707710    uint64_t cbFreeTotal, cbAllocTotal, cbBalloonedTotal, cbSharedTotal;
    708     int rc = PGMR3QueryGlobalMemoryStats(ptrVM.rawUVM(), &cbAllocTotal, &cbFreeTotal, &cbBalloonedTotal, &cbSharedTotal);
     711    int rc = ptrVM.vtable()->pfnPGMR3QueryGlobalMemoryStats(ptrVM.rawUVM(), &cbAllocTotal, &cbFreeTotal,
     712                                                            &cbBalloonedTotal, &cbSharedTotal);
    709713    AssertRCReturn(rc, E_FAIL);
    710714
     
    716720    /* Query the missing per-VM memory statistics. */
    717721    uint64_t cbTotalMemIgn, cbPrivateMemIgn, cbSharedMem, cbZeroMemIgn;
    718     rc = PGMR3QueryMemoryStats(ptrVM.rawUVM(), &cbTotalMemIgn, &cbPrivateMemIgn, &cbSharedMem, &cbZeroMemIgn);
     722    rc = ptrVM.vtable()->pfnPGMR3QueryMemoryStats(ptrVM.rawUVM(), &cbTotalMemIgn, &cbPrivateMemIgn, &cbSharedMem, &cbZeroMemIgn);
    719723    AssertRCReturn(rc, E_FAIL);
    720724    *aMemShared = (ULONG)(cbSharedMem / _1K);
  • trunk/src/VBox/Main/src-client/HGCM.cpp

    r93115 r93444  
    2626#include <VBox/vmm/ssm.h>
    2727#include <VBox/vmm/stam.h>
     28#include <VBox/vmm/vmmr3vtable.h>
    2829#include <VBox/sup.h>
    2930#include <VBox/AssertGuest.h>
     
    124125
    125126        PUVM m_pUVM;
     127        PCVMMR3VTABLE m_pVMM;
    126128        PPDMIHGCMPORT m_pHgcmPort;
    127129
     
    139141         * Main HGCM thread methods.
    140142         */
    141         int instanceCreate(const char *pszServiceLibrary, const char *pszServiceName, PUVM pUVM, PPDMIHGCMPORT pHgcmPort);
     143        int instanceCreate(const char *pszServiceLibrary, const char *pszServiceName,
     144                           PUVM pUVM, PCVMMR3VTABLE pVMM, PPDMIHGCMPORT pHgcmPort);
     145        void registerStatistics(const char *pszServiceName, PUVM pUVM, PCVMMR3VTABLE pVMM);
    142146        void instanceDestroy(void);
    143147
    144         int saveClientState(uint32_t u32ClientId, PSSMHANDLE pSSM);
    145         int loadClientState(uint32_t u32ClientId, PSSMHANDLE pSSM, uint32_t uVersion);
     148        int saveClientState(uint32_t u32ClientId, PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM);
     149        int loadClientState(uint32_t u32ClientId, PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion);
    146150
    147151        HGCMService();
     
    167171         * Main HGCM thread methods.
    168172         */
    169         static int LoadService(const char *pszServiceLibrary, const char *pszServiceName, PUVM pUVM, PPDMIHGCMPORT pHgcmPort);
     173        static int LoadService(const char *pszServiceLibrary, const char *pszServiceName,
     174                               PUVM pUVM, PCVMMR3VTABLE pVMM, PPDMIHGCMPORT pHgcmPort);
    170175        void UnloadService(bool fUvmIsInvalid);
    171176
     
    178183        static void Reset(void);
    179184
    180         static int SaveState(PSSMHANDLE pSSM);
    181         static int LoadState(PSSMHANDLE pSSM, uint32_t uVersion);
     185        static int SaveState(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM);
     186        static int LoadState(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion);
    182187
    183188        int CreateAndConnectClient(uint32_t *pu32ClientIdOut, uint32_t u32ClientIdIn, uint32_t fRequestor, bool fRestoring);
     
    324329    m_hExtension (NULL),
    325330    m_pUVM       (NULL),
     331    m_pVMM       (NULL),
    326332    m_pHgcmPort  (NULL)
    327333{
     
    587593{
    588594    public:
    589         PSSMHANDLE  pSSM;
    590         uint32_t    uVersion;
    591         uint32_t    u32ClientId;
     595        PSSMHANDLE      pSSM;
     596        PCVMMR3VTABLE   pVMM;
     597        uint32_t        uVersion;
     598        uint32_t        u32ClientId;
    592599};
    593600
     
    808815                    bool fHaveClientState = pSvc->m_fntable.pfnLoadState != NULL;
    809816                    if (pMsg->uVersion > HGCM_SAVED_STATE_VERSION_V2)
    810                         rc = SSMR3GetBool(pMsg->pSSM, &fHaveClientState);
     817                        rc = pMsg->pVMM->pfnSSMR3GetBool(pMsg->pSSM, &fHaveClientState);
    811818                    else
    812819                        rc = VINF_SUCCESS;
     
    815822                        if (pSvc->m_fntable.pfnLoadState)
    816823                            rc = pSvc->m_fntable.pfnLoadState(pSvc->m_fntable.pvService, pMsg->u32ClientId,
    817                                                               HGCM_CLIENT_DATA(pSvc, pClient), pMsg->pSSM,
     824                                                              HGCM_CLIENT_DATA(pSvc, pClient), pMsg->pSSM, pMsg->pVMM,
    818825                                                              fHaveClientState ? pMsg->uVersion : 0);
    819826                        else
     
    840847                if (pClient)
    841848                {
    842                     SSMR3PutU32(pMsg->pSSM, pClient->fRequestor); /* Quicker to save this here than in the message sender. */
    843                     rc = SSMR3PutBool(pMsg->pSSM, pSvc->m_fntable.pfnSaveState != NULL);
     849                    pMsg->pVMM->pfnSSMR3PutU32(pMsg->pSSM, pClient->fRequestor); /* Quicker to save this here than in the message sender. */
     850                    rc = pMsg->pVMM->pfnSSMR3PutBool(pMsg->pSSM, pSvc->m_fntable.pfnSaveState != NULL);
    844851                    if (RT_SUCCESS(rc) && pSvc->m_fntable.pfnSaveState)
    845852                    {
    846853                        g_fSaveState = true;
    847854                        rc = pSvc->m_fntable.pfnSaveState(pSvc->m_fntable.pvService, pMsg->u32ClientId,
    848                                                           HGCM_CLIENT_DATA(pSvc, pClient), pMsg->pSSM);
     855                                                          HGCM_CLIENT_DATA(pSvc, pClient), pMsg->pSSM, pMsg->pVMM);
    849856                        g_fSaveState = false;
    850857                    }
     
    10241031     AssertPtrReturn(pService, VERR_INVALID_PARAMETER);
    10251032
    1026      return STAMR3RegisterVU(pService->m_pUVM, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
     1033     if (pService->m_pUVM)
     1034         return pService->m_pVMM->pfnSTAMR3RegisterVU(pService->m_pUVM, pvSample, enmType, enmVisibility,
     1035                                                      enmUnit, pszDesc, pszName, va);
     1036     return VINF_SUCCESS;
    10271037}
    10281038
     
    10361046
    10371047     if (pService->m_pUVM)
    1038          return STAMR3DeregisterV(pService->m_pUVM, pszPatFmt, va);
     1048         return pService->m_pVMM->pfnSTAMR3DeregisterV(pService->m_pUVM, pszPatFmt, va);
    10391049     return VINF_SUCCESS;
    10401050}
     
    10491059     AssertPtrReturn(pService, VERR_INVALID_PARAMETER);
    10501060
    1051      return DBGFR3InfoRegisterExternal(pService->m_pUVM, pszName, pszDesc, pfnHandler, pvUser);
     1061     if (pService->m_pUVM)
     1062         return pService->m_pVMM->pfnDBGFR3InfoRegisterExternal(pService->m_pUVM, pszName, pszDesc, pfnHandler, pvUser);
     1063     return VINF_SUCCESS;
    10521064}
    10531065
     
    10601072     AssertPtrReturn(pService, VERR_INVALID_PARAMETER);
    10611073     if (pService->m_pUVM)
    1062          return DBGFR3InfoDeregisterExternal(pService->m_pUVM, pszName);
     1074         return pService->m_pVMM->pfnDBGFR3InfoDeregisterExternal(pService->m_pUVM, pszName);
    10631075     return VINF_SUCCESS;
    10641076}
     
    11171129 */
    11181130
    1119 int HGCMService::instanceCreate(const char *pszServiceLibrary, const char *pszServiceName, PUVM pUVM, PPDMIHGCMPORT pHgcmPort)
     1131int HGCMService::instanceCreate(const char *pszServiceLibrary, const char *pszServiceName,
     1132                                PUVM pUVM, PCVMMR3VTABLE pVMM, PPDMIHGCMPORT pHgcmPort)
    11201133{
    11211134    LogFlowFunc(("name %s, lib %s\n", pszServiceName, pszServiceLibrary));
     1135
    11221136    /* The maximum length of the thread name, allowed by the RT is 15. */
    11231137    char szThreadName[16];
     
    11291143        RTStrCopy(szThreadName, sizeof(szThreadName), pszServiceName);
    11301144
    1131     int rc = hgcmThreadCreate(&m_pThread, szThreadName, hgcmServiceThread, this, pszServiceName, pUVM);
    1132 
     1145    int rc = hgcmThreadCreate(&m_pThread, szThreadName, hgcmServiceThread, this, pszServiceName, pUVM, pVMM);
    11331146    if (RT_SUCCESS(rc))
    11341147    {
     
    11491162        {
    11501163            m_pUVM = pUVM;
     1164            m_pVMM = pVMM;
    11511165            m_pHgcmPort = pHgcmPort;
    11521166
    1153             /* Register statistics: */
    1154             STAMR3RegisterFU(pUVM, &m_StatHandleMsg, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_OCCURENCE,
    1155                              "Message handling", "/HGCM/%s/Msg", pszServiceName);
    1156             STAMR3RegisterFU(pUVM, &m_StatTooManyCalls, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
    1157                              "Too many calls (per client)", "/HGCM/%s/TooManyCalls", pszServiceName);
    1158             STAMR3RegisterFU(pUVM, &m_StatTooManyClients, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
    1159                              "Too many clients", "/HGCM/%s/TooManyClients", pszServiceName);
    1160             STAMR3RegisterFU(pUVM, &m_cClients, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
    1161                              "Number of clients", "/HGCM/%s/Clients", pszServiceName);
    1162             STAMR3RegisterFU(pUVM, &m_acClients[HGCM_CLIENT_CATEGORY_KERNEL], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
    1163                              STAMUNIT_OCCURENCES, "Number of kernel clients", "/HGCM/%s/Clients/Kernel", pszServiceName);
    1164             STAMR3RegisterFU(pUVM, &m_acClients[HGCM_CLIENT_CATEGORY_ROOT], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
    1165                              STAMUNIT_OCCURENCES, "Number of root/admin clients", "/HGCM/%s/Clients/Root", pszServiceName);
    1166             STAMR3RegisterFU(pUVM, &m_acClients[HGCM_CLIENT_CATEGORY_USER], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
    1167                              STAMUNIT_OCCURENCES, "Number of regular user clients", "/HGCM/%s/Clients/User", pszServiceName);
    1168             STAMR3RegisterFU(pUVM, &m_fntable.acMaxClients[HGCM_CLIENT_CATEGORY_KERNEL], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
    1169                              STAMUNIT_OCCURENCES, "Max number of kernel clients", "/HGCM/%s/Clients/KernelMax", pszServiceName);
    1170             STAMR3RegisterFU(pUVM, &m_fntable.acMaxClients[HGCM_CLIENT_CATEGORY_ROOT], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
    1171                              STAMUNIT_OCCURENCES, "Max number of root clients", "/HGCM/%s/Clients/RootMax", pszServiceName);
    1172             STAMR3RegisterFU(pUVM, &m_fntable.acMaxClients[HGCM_CLIENT_CATEGORY_USER], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
    1173                              STAMUNIT_OCCURENCES, "Max number of user clients", "/HGCM/%s/Clients/UserMax", pszServiceName);
    1174             STAMR3RegisterFU(pUVM, &m_fntable.idxLegacyClientCategory, STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
    1175                              STAMUNIT_OCCURENCES, "Legacy client mapping", "/HGCM/%s/Clients/LegacyClientMapping", pszServiceName);
    1176             STAMR3RegisterFU(pUVM, &m_fntable.acMaxCallsPerClient[HGCM_CLIENT_CATEGORY_KERNEL], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
    1177                              STAMUNIT_OCCURENCES, "Max number of call per kernel client", "/HGCM/%s/MaxCallsKernelClient", pszServiceName);
    1178             STAMR3RegisterFU(pUVM, &m_fntable.acMaxCallsPerClient[HGCM_CLIENT_CATEGORY_ROOT], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
    1179                              STAMUNIT_OCCURENCES, "Max number of call per root client", "/HGCM/%s/MaxCallsRootClient", pszServiceName);
    1180             STAMR3RegisterFU(pUVM, &m_fntable.acMaxCallsPerClient[HGCM_CLIENT_CATEGORY_USER], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
    1181                              STAMUNIT_OCCURENCES, "Max number of call per user client", "/HGCM/%s/MaxCallsUserClient", pszServiceName);
     1167            registerStatistics(pszServiceName, pUVM, pVMM);
    11821168
    11831169            /* Initialize service helpers table. */
     
    12181204}
    12191205
     1206/** Called by HGCMService::instanceCreate to register statistics. */
     1207void HGCMService::registerStatistics(const char *pszServiceName, PUVM pUVM, PCVMMR3VTABLE pVMM)
     1208{
     1209    pVMM->pfnSTAMR3RegisterFU(pUVM, &m_StatHandleMsg, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_OCCURENCE,
     1210                              "Message handling", "/HGCM/%s/Msg", pszServiceName);
     1211    pVMM->pfnSTAMR3RegisterFU(pUVM, &m_StatTooManyCalls, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
     1212                              "Too many calls (per client)", "/HGCM/%s/TooManyCalls", pszServiceName);
     1213    pVMM->pfnSTAMR3RegisterFU(pUVM, &m_StatTooManyClients, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
     1214                              "Too many clients", "/HGCM/%s/TooManyClients", pszServiceName);
     1215    pVMM->pfnSTAMR3RegisterFU(pUVM, &m_cClients, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
     1216                              "Number of clients", "/HGCM/%s/Clients", pszServiceName);
     1217    pVMM->pfnSTAMR3RegisterFU(pUVM, &m_acClients[HGCM_CLIENT_CATEGORY_KERNEL], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
     1218                              STAMUNIT_OCCURENCES, "Number of kernel clients", "/HGCM/%s/Clients/Kernel", pszServiceName);
     1219    pVMM->pfnSTAMR3RegisterFU(pUVM, &m_acClients[HGCM_CLIENT_CATEGORY_ROOT], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
     1220                              STAMUNIT_OCCURENCES, "Number of root/admin clients", "/HGCM/%s/Clients/Root", pszServiceName);
     1221    pVMM->pfnSTAMR3RegisterFU(pUVM, &m_acClients[HGCM_CLIENT_CATEGORY_USER], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
     1222                              STAMUNIT_OCCURENCES, "Number of regular user clients", "/HGCM/%s/Clients/User", pszServiceName);
     1223    pVMM->pfnSTAMR3RegisterFU(pUVM, &m_fntable.acMaxClients[HGCM_CLIENT_CATEGORY_KERNEL], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
     1224                              STAMUNIT_OCCURENCES, "Max number of kernel clients", "/HGCM/%s/Clients/KernelMax", pszServiceName);
     1225    pVMM->pfnSTAMR3RegisterFU(pUVM, &m_fntable.acMaxClients[HGCM_CLIENT_CATEGORY_ROOT], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
     1226                              STAMUNIT_OCCURENCES, "Max number of root clients", "/HGCM/%s/Clients/RootMax", pszServiceName);
     1227    pVMM->pfnSTAMR3RegisterFU(pUVM, &m_fntable.acMaxClients[HGCM_CLIENT_CATEGORY_USER], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
     1228                              STAMUNIT_OCCURENCES, "Max number of user clients", "/HGCM/%s/Clients/UserMax", pszServiceName);
     1229    pVMM->pfnSTAMR3RegisterFU(pUVM, &m_fntable.idxLegacyClientCategory, STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
     1230                              STAMUNIT_OCCURENCES, "Legacy client mapping", "/HGCM/%s/Clients/LegacyClientMapping", pszServiceName);
     1231    pVMM->pfnSTAMR3RegisterFU(pUVM, &m_fntable.acMaxCallsPerClient[HGCM_CLIENT_CATEGORY_KERNEL], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
     1232                              STAMUNIT_OCCURENCES, "Max number of call per kernel client", "/HGCM/%s/MaxCallsKernelClient", pszServiceName);
     1233    pVMM->pfnSTAMR3RegisterFU(pUVM, &m_fntable.acMaxCallsPerClient[HGCM_CLIENT_CATEGORY_ROOT], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
     1234                              STAMUNIT_OCCURENCES, "Max number of call per root client", "/HGCM/%s/MaxCallsRootClient", pszServiceName);
     1235    pVMM->pfnSTAMR3RegisterFU(pUVM, &m_fntable.acMaxCallsPerClient[HGCM_CLIENT_CATEGORY_USER], STAMTYPE_U32, STAMVISIBILITY_ALWAYS,
     1236                              STAMUNIT_OCCURENCES, "Max number of call per user client", "/HGCM/%s/MaxCallsUserClient", pszServiceName);
     1237}
     1238
    12201239void HGCMService::instanceDestroy(void)
    12211240{
     
    12341253
    12351254    if (m_pszSvcName && m_pUVM)
    1236         STAMR3DeregisterF(m_pUVM, "/HGCM/%s/*", m_pszSvcName);
     1255        m_pVMM->pfnSTAMR3DeregisterF(m_pUVM, "/HGCM/%s/*", m_pszSvcName);
    12371256    m_pUVM = NULL;
    12381257    m_pHgcmPort = NULL;
     
    12511270}
    12521271
    1253 int HGCMService::saveClientState(uint32_t u32ClientId, PSSMHANDLE pSSM)
     1272int HGCMService::saveClientState(uint32_t u32ClientId, PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM)
    12541273{
    12551274    LogFlowFunc(("%s\n", m_pszSvcName));
     
    12641283        pMsg->u32ClientId = u32ClientId;
    12651284        pMsg->pSSM        = pSSM;
     1285        pMsg->pVMM        = pVMM;
    12661286
    12671287        rc = hgcmMsgSend(pMsg);
     
    12721292}
    12731293
    1274 int HGCMService::loadClientState(uint32_t u32ClientId, PSSMHANDLE pSSM, uint32_t uVersion)
     1294int HGCMService::loadClientState(uint32_t u32ClientId, PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion)
    12751295{
    12761296    LogFlowFunc(("%s\n", m_pszSvcName));
     
    12841304
    12851305        pMsg->pSSM        = pSSM;
     1306        pMsg->pVMM        = pVMM;
    12861307        pMsg->uVersion    = uVersion;
    12871308        pMsg->u32ClientId = u32ClientId;
     
    13001321 * @param   pszServiceName     The name of the service.
    13011322 * @param   pUVM               The user mode VM handle (for statistics and such).
     1323 * @param   pVMM               The VMM vtable (for statistics and such).
    13021324 * @param   pHgcmPort          The VMMDev HGCM port interface.
    13031325 *
     
    13061328 */
    13071329/* static */ int HGCMService::LoadService(const char *pszServiceLibrary, const char *pszServiceName,
    1308                                           PUVM pUVM, PPDMIHGCMPORT pHgcmPort)
     1330                                          PUVM pUVM, PCVMMR3VTABLE pVMM, PPDMIHGCMPORT pHgcmPort)
    13091331{
    13101332    LogFlowFunc(("lib %s, name = %s, pUVM = %p\n", pszServiceLibrary, pszServiceName, pUVM));
     
    13331355        {
    13341356            /* Load the library and call the initialization entry point. */
    1335             rc = pSvc->instanceCreate(pszServiceLibrary, pszServiceName, pUVM, pHgcmPort);
    1336 
     1357            rc = pSvc->instanceCreate(pszServiceLibrary, pszServiceName, pUVM, pVMM, pHgcmPort);
    13371358            if (RT_SUCCESS(rc))
    13381359            {
     
    13421363
    13431364                if (sm_pSvcListHead)
    1344                 {
    13451365                    sm_pSvcListHead->m_pSvcPrev = pSvc;
    1346                 }
    13471366                else
    1348                 {
    13491367                    sm_pSvcListTail = pSvc;
    1350                 }
    13511368
    13521369                sm_pSvcListHead = pSvc;
     
    15311548 *
    15321549 * @param pSSM  The saved state context.
    1533  * @return VBox rc.
     1550 * @param pVMM  The VMM vtable.
     1551 * @return VBox status code.
    15341552 * @thread main HGCM
    15351553 */
    1536 /* static */ int HGCMService::SaveState(PSSMHANDLE pSSM)
     1554/* static */ int HGCMService::SaveState(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM)
    15371555{
    15381556    /* Save the current handle count and restore afterwards to avoid client id conflicts. */
    1539     int rc = SSMR3PutU32(pSSM, hgcmObjQueryHandleCount());
     1557    int rc = pVMM->pfnSSMR3PutU32(pSSM, hgcmObjQueryHandleCount());
    15401558    AssertRCReturn(rc, rc);
    15411559
     
    15431561
    15441562    /* Save number of services. */
    1545     rc = SSMR3PutU32(pSSM, sm_cServices);
     1563    rc = pVMM->pfnSSMR3PutU32(pSSM, sm_cServices);
    15461564    AssertRCReturn(rc, rc);
    15471565
     
    15541572
    15551573        /* Save the length of the service name. */
    1556         rc = SSMR3PutU32(pSSM, (uint32_t) strlen(pSvc->m_pszSvcName) + 1);
     1574        rc = pVMM->pfnSSMR3PutU32(pSSM, (uint32_t) strlen(pSvc->m_pszSvcName) + 1);
    15571575        AssertRCReturn(rc, rc);
    15581576
    15591577        /* Save the name of the service. */
    1560         rc = SSMR3PutStrZ(pSSM, pSvc->m_pszSvcName);
     1578        rc = pVMM->pfnSSMR3PutStrZ(pSSM, pSvc->m_pszSvcName);
    15611579        AssertRCReturn(rc, rc);
    15621580
    15631581        /* Save the number of clients. */
    1564         rc = SSMR3PutU32(pSSM, pSvc->m_cClients);
     1582        rc = pVMM->pfnSSMR3PutU32(pSSM, pSvc->m_cClients);
    15651583        AssertRCReturn(rc, rc);
    15661584
     
    15781596
    15791597            /* Save the client id. (fRequestor is saved via SVC_MSG_SAVESTATE for convenience.) */
    1580             rc = SSMR3PutU32(pSSM, u32ClientId);
     1598            rc = pVMM->pfnSSMR3PutU32(pSSM, u32ClientId);
    15811599            AssertRCReturn(rc, rc);
    15821600
    15831601            /* Call the service, so the operation is executed by the service thread. */
    1584             rc = pSvc->saveClientState(u32ClientId, pSSM);
     1602            rc = pSvc->saveClientState(u32ClientId, pSSM, pVMM);
    15851603            AssertRCReturn(rc, rc);
    15861604        }
     
    15951613 *
    15961614 * @param pSSM      The saved state handle.
     1615 * @param pVMM      The VMM vtable.
    15971616 * @param uVersion  The state version being loaded.
    1598  * @return VBox rc.
     1617 * @return VBox status code.
    15991618 * @thread main HGCM
    16001619 */
    1601 /* static */ int HGCMService::LoadState(PSSMHANDLE pSSM, uint32_t uVersion)
     1620/* static */ int HGCMService::LoadState(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion)
    16021621{
    16031622    /* Restore handle count to avoid client id conflicts. */
    16041623    uint32_t u32;
    16051624
    1606     int rc = SSMR3GetU32(pSSM, &u32);
     1625    int rc = pVMM->pfnSSMR3GetU32(pSSM, &u32);
    16071626    AssertRCReturn(rc, rc);
    16081627
     
    16121631    uint32_t cServices;
    16131632
    1614     rc = SSMR3GetU32(pSSM, &cServices);
     1633    rc = pVMM->pfnSSMR3GetU32(pSSM, &cServices);
    16151634    AssertRCReturn(rc, rc);
    16161635
     
    16201639    {
    16211640        /* Get the length of the service name. */
    1622         rc = SSMR3GetU32(pSSM, &u32);
     1641        rc = pVMM->pfnSSMR3GetU32(pSSM, &u32);
    16231642        AssertRCReturn(rc, rc);
    16241643        AssertReturn(u32 <= VBOX_HGCM_SVC_NAME_MAX_BYTES, VERR_SSM_UNEXPECTED_DATA);
     
    16261645        /* Get the service name. */
    16271646        char szServiceName[VBOX_HGCM_SVC_NAME_MAX_BYTES];
    1628         rc = SSMR3GetStrZ(pSSM, szServiceName, u32);
     1647        rc = pVMM->pfnSSMR3GetStrZ(pSSM, szServiceName, u32);
    16291648        AssertRCReturn(rc, rc);
    16301649
     
    16381657        /* Get the number of clients. */
    16391658        uint32_t cClients;
    1640         rc = SSMR3GetU32(pSSM, &cClients);
     1659        rc = pVMM->pfnSSMR3GetU32(pSSM, &cClients);
    16411660        if (RT_FAILURE(rc))
    16421661        {
     
    16511670               but restored here in time for calling CreateAndConnectClient). */
    16521671            uint32_t u32ClientId;
    1653             rc = SSMR3GetU32(pSSM, &u32ClientId);
     1672            rc = pVMM->pfnSSMR3GetU32(pSSM, &u32ClientId);
    16541673            uint32_t fRequestor = VMMDEV_REQUESTOR_LEGACY;
    16551674            if (RT_SUCCESS(rc) && uVersion > HGCM_SAVED_STATE_VERSION_V2)
    1656                 rc = SSMR3GetU32(pSSM, &fRequestor);
     1675                rc = pVMM->pfnSSMR3GetU32(pSSM, &fRequestor);
    16571676            AssertLogRelMsgRCReturnStmt(rc, ("rc=%Rrc, %s\n", rc, szServiceName), pSvc->ReleaseService(), rc);
    16581677
     
    16621681
    16631682            /* Call the service, so the operation is executed by the service thread. */
    1664             rc = pSvc->loadClientState(u32ClientId, pSSM, uVersion);
     1683            rc = pSvc->loadClientState(u32ClientId, pSSM, pVMM, uVersion);
    16651684            AssertLogRelMsgRCReturnStmt(rc, ("rc=%Rrc, %s\n", rc, szServiceName), pSvc->ReleaseService(), rc);
    16661685        }
     
    22002219        /** The user mode VM handle (for statistics and such). */
    22012220        PUVM pUVM;
     2221        /** The VMM vtable (for statistics and such). */
     2222        PCVMMR3VTABLE pVMM;
    22022223        /** The HGCM port on the VMMDev device (for session ID and such). */
    22032224        PPDMIHGCMPORT pHgcmPort;
     
    22222243        /** Saved state handle. */
    22232244        PSSMHANDLE pSSM;
     2245        /** The VMM vtable. */
     2246        PCVMMR3VTABLE pVMM;
    22242247        /** The HGCM saved state version being loaded (ignore for save). */
    22252248        uint32_t uVersion;
     
    23732396                             pMsg->pszServiceName, pMsg->pszServiceLibrary, pMsg->pUVM));
    23742397
    2375                 rc = HGCMService::LoadService(pMsg->pszServiceLibrary, pMsg->pszServiceName, pMsg->pUVM, pMsg->pHgcmPort);
     2398                rc = HGCMService::LoadService(pMsg->pszServiceLibrary, pMsg->pszServiceName,
     2399                                              pMsg->pUVM, pMsg->pVMM, pMsg->pHgcmPort);
    23762400            } break;
    23772401
     
    24212445                LogFlowFunc(("HGCM_MSG_LOADSTATE\n"));
    24222446
    2423                 rc = HGCMService::LoadState(pMsg->pSSM, pMsg->uVersion);
     2447                rc = HGCMService::LoadState(pMsg->pSSM, pMsg->pVMM, pMsg->uVersion);
    24242448            } break;
    24252449
     
    24302454                LogFlowFunc(("HGCM_MSG_SAVESTATE\n"));
    24312455
    2432                 rc = HGCMService::SaveState(pMsg->pSSM);
     2456                rc = HGCMService::SaveState(pMsg->pSSM, pMsg->pVMM);
    24332457            } break;
    24342458
     
    25382562 * @param pszServiceName     The name to be assigned to the service.
    25392563 * @param pUVM               The user mode VM handle (for statistics and such).
     2564 * @param pVMM               The VMM vtable (for statistics and such).
    25402565 * @param pHgcmPort          The HGCM port on the VMMDev device (for session ID and such).
    25412566 * @return VBox rc.
     
    25442569                 const char *pszServiceName,
    25452570                 PUVM pUVM,
     2571                 PCVMMR3VTABLE pVMM,
    25462572                 PPDMIHGCMPORT pHgcmPort)
    25472573{
     
    25492575
    25502576    if (!pszServiceLibrary || !pszServiceName)
    2551     {
    25522577        return VERR_INVALID_PARAMETER;
    2553     }
    25542578
    25552579    /* Forward the request to the main hgcm thread. */
    25562580    HGCMMsgCore *pCoreMsg;
    25572581    int rc = hgcmMsgAlloc(g_pHgcmThread, &pCoreMsg, HGCM_MSG_LOAD, hgcmMainMessageAlloc);
    2558 
    25592582    if (RT_SUCCESS(rc))
    25602583    {
     
    25652588        pMsg->pszServiceName    = pszServiceName;
    25662589        pMsg->pUVM              = pUVM;
     2590        pMsg->pVMM              = pVMM;
    25672591        pMsg->pHgcmPort         = pHgcmPort;
    25682592
     
    27242748 *
    27252749 * @param pSSM     The SSM handle.
     2750 * @param pVMM      The VMM vtable.
    27262751 * @param idMsg    The message to be sent: HGCM_MSG_SAVESTATE or HGCM_MSG_LOADSTATE.
    27272752 * @param uVersion The state version being loaded.
    27282753 * @return VBox rc.
    27292754 */
    2730 static int hgcmHostLoadSaveState(PSSMHANDLE pSSM, uint32_t idMsg, uint32_t uVersion)
    2731 {
    2732     LogFlowFunc(("pSSM = %p, idMsg = %d, uVersion = uVersion\n", pSSM, idMsg));
     2755static int hgcmHostLoadSaveState(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t idMsg, uint32_t uVersion)
     2756{
     2757    LogFlowFunc(("pSSM = %p, pVMM = %p, idMsg = %d, uVersion = %#x\n", pSSM, pVMM, idMsg, uVersion));
    27332758
    27342759    HGCMMsgCore *pCoreMsg;
    27352760    int rc = hgcmMsgAlloc(g_pHgcmThread, &pCoreMsg, idMsg, hgcmMainMessageAlloc);
    2736 
    27372761    if (RT_SUCCESS(rc))
    27382762    {
     
    27412765
    27422766        pMsg->pSSM = pSSM;
     2767        pMsg->pVMM = pVMM;
    27432768        pMsg->uVersion = uVersion;
    27442769
     
    27522777/** Save the state of services.
    27532778 *
    2754  * @param pSSM     The SSM handle.
    2755  * @return VBox rc.
    2756  */
    2757 int HGCMHostSaveState(PSSMHANDLE pSSM)
    2758 {
    2759     return hgcmHostLoadSaveState(pSSM, HGCM_MSG_SAVESTATE, HGCM_SAVED_STATE_VERSION);
     2779 * @param pSSM      The SSM handle.
     2780 * @param pVMM      The VMM vtable.
     2781 * @return VBox status code.
     2782 */
     2783int HGCMHostSaveState(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM)
     2784{
     2785    return hgcmHostLoadSaveState(pSSM, pVMM, HGCM_MSG_SAVESTATE, HGCM_SAVED_STATE_VERSION);
    27602786}
    27612787
    27622788/** Load the state of services.
    27632789 *
    2764  * @param pSSM     The SSM handle.
    2765  * @param uVersion The state version being loaded.
    2766  * @return VBox rc.
    2767  */
    2768 int HGCMHostLoadState(PSSMHANDLE pSSM, uint32_t uVersion)
    2769 {
    2770     return hgcmHostLoadSaveState(pSSM, HGCM_MSG_LOADSTATE, uVersion);
     2790 * @param pSSM      The SSM handle.
     2791 * @param pVMM      The VMM vtable.
     2792 * @param uVersion  The state version being loaded.
     2793 * @return VBox status code.
     2794 */
     2795int HGCMHostLoadState(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion)
     2796{
     2797    return hgcmHostLoadSaveState(pSSM, pVMM, HGCM_MSG_LOADSTATE, uVersion);
    27712798}
    27722799
     
    29532980         */
    29542981
    2955         rc = hgcmThreadCreate(&g_pHgcmThread, "MainHGCMthread", hgcmThread, NULL /*pvUser*/, NULL /*pszStatsSubDir*/, NULL /*pUVM*/);
     2982        rc = hgcmThreadCreate(&g_pHgcmThread, "MainHGCMthread", hgcmThread, NULL /*pvUser*/,
     2983                              NULL /*pszStatsSubDir*/, NULL /*pUVM*/, NULL /*pVMM*/);
    29562984
    29572985        if (RT_FAILURE(rc))
  • trunk/src/VBox/Main/src-client/HGCMThread.cpp

    r93115 r93444  
    2323#include <VBox/err.h>
    2424#include <VBox/vmm/stam.h>
     25#include <VBox/vmm/vmmr3vtable.h>
    2526#include <iprt/semaphore.h>
    2627#include <iprt/thread.h>
     
    142143        int WaitForTermination (void);
    143144
    144         int Initialize(const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser, const char *pszStatsSubDir, PUVM pUVM);
     145        int Initialize(const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser,
     146                       const char *pszStatsSubDir, PUVM pUVM, PCVMMR3VTABLE pVMM);
    145147
    146148        int MsgAlloc(HGCMMsgCore **pMsg, uint32_t u32MsgId, PFNHGCMNEWMSGALLOC pfnNewMessage);
     
    266268}
    267269
    268 int HGCMThread::Initialize(const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser, const char *pszStatsSubDir, PUVM pUVM)
     270int HGCMThread::Initialize(const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser,
     271                           const char *pszStatsSubDir, PUVM pUVM, PCVMMR3VTABLE pVMM)
    269272{
    270273    int rc = RTSemEventCreate(&m_eventThread);
     
    296299                    if (pUVM)
    297300                    {
    298                         STAMR3RegisterFU(pUVM, &m_StatPostMsgNoPending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
    299                                          "Times a message was appended to an empty input queue.",
    300                                          "/HGCM/%s/PostMsg0Pending", pszStatsSubDir);
    301                         STAMR3RegisterFU(pUVM, &m_StatPostMsgOnePending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
    302                                          "Times a message was appended to input queue with only one pending message.",
    303                                          "/HGCM/%s/PostMsg1Pending", pszStatsSubDir);
    304                         STAMR3RegisterFU(pUVM, &m_StatPostMsgTwoPending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
    305                                          "Times a message was appended to input queue with only one pending message.",
    306                                          "/HGCM/%s/PostMsg2Pending", pszStatsSubDir);
    307                         STAMR3RegisterFU(pUVM, &m_StatPostMsgThreePending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
    308                                          "Times a message was appended to input queue with only one pending message.",
    309                                          "/HGCM/%s/PostMsg3Pending", pszStatsSubDir);
    310                         STAMR3RegisterFU(pUVM, &m_StatPostMsgManyPending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
    311                                          "Times a message was appended to input queue with only one pending message.",
    312                                          "/HGCM/%s/PostMsgManyPending", pszStatsSubDir);
     301                        pVMM->pfnSTAMR3RegisterFU(pUVM, &m_StatPostMsgNoPending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
     302                                                  STAMUNIT_COUNT, "Times a message was appended to an empty input queue.",
     303                                                  "/HGCM/%s/PostMsg0Pending", pszStatsSubDir);
     304                        pVMM->pfnSTAMR3RegisterFU(pUVM, &m_StatPostMsgOnePending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
     305                                                  STAMUNIT_COUNT,
     306                                                  "Times a message was appended to input queue with only one pending message.",
     307                                                  "/HGCM/%s/PostMsg1Pending", pszStatsSubDir);
     308                        pVMM->pfnSTAMR3RegisterFU(pUVM, &m_StatPostMsgTwoPending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
     309                                                  STAMUNIT_COUNT,
     310                                                  "Times a message was appended to input queue with only one pending message.",
     311                                                  "/HGCM/%s/PostMsg2Pending", pszStatsSubDir);
     312                        pVMM->pfnSTAMR3RegisterFU(pUVM, &m_StatPostMsgThreePending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
     313                                                  STAMUNIT_COUNT,
     314                                                  "Times a message was appended to input queue with only one pending message.",
     315                                                  "/HGCM/%s/PostMsg3Pending", pszStatsSubDir);
     316                        pVMM->pfnSTAMR3RegisterFU(pUVM, &m_StatPostMsgManyPending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
     317                                                  STAMUNIT_COUNT,
     318                                                  "Times a message was appended to input queue with only one pending message.",
     319                                                  "/HGCM/%s/PostMsgManyPending", pszStatsSubDir);
    313320                    }
    314321
     
    627634
    628635int hgcmThreadCreate(HGCMThread **ppThread, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser,
    629                      const char *pszStatsSubDir, PUVM pUVM)
     636                     const char *pszStatsSubDir, PUVM pUVM, PCVMMR3VTABLE pVMM)
    630637{
    631638    LogFlow(("MAIN::hgcmThreadCreate\n"));
     
    640647
    641648        /* Initialize the object. */
    642         rc = pThread->Initialize(pszThreadName, pfnThread, pvUser, pszStatsSubDir, pUVM);
     649        rc = pThread->Initialize(pszThreadName, pfnThread, pvUser, pszStatsSubDir, pUVM, pVMM);
    643650        if (RT_SUCCESS(rc))
    644651        {
  • trunk/src/VBox/Main/src-client/KeyboardImpl.cpp

    r93115 r93444  
    429429DECLCALLBACK(int) Keyboard::i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
    430430{
    431     RT_NOREF(fFlags);
    432431    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
     432    RT_NOREF(fFlags, pCfg);
    433433    PDRVMAINKEYBOARD pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINKEYBOARD);
    434434    LogFlow(("Keyboard::drvConstruct: iInstance=%d\n", pDrvIns->iInstance));
     
    437437     * Validate configuration.
    438438     */
    439     if (!CFGMR3AreValuesValid(pCfg, ""))
    440         return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
     439    PDMDRV_VALIDATE_CONFIG_RETURN(pDrvIns, "", "");
    441440    AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
    442441                    ("Configuration error: Not possible to attach anything to this driver!\n"),
  • trunk/src/VBox/Main/src-client/MachineDebuggerImpl.cpp

    r93115 r93444  
    3131#include "AutoCaller.h"
    3232
     33#include <VBox/vmm/vmmr3vtable.h>
    3334#include <VBox/vmm/em.h>
    3435#include <VBox/vmm/uvm.h>
     
    131132        && uPercentage == 100)
    132133    {
    133         vrc = DBGFR3SampleReportDumpToFile(pThis->m_hSampleReport, pThis->m_strFilename.c_str());
    134         DBGFR3SampleReportRelease(pThis->m_hSampleReport);
     134        PCVMMR3VTABLE const pVMM = pThis->mParent->i_getVMMVTable();
     135        AssertPtrReturn(pVMM, VERR_INTERNAL_ERROR_3);
     136
     137        vrc = pVMM->pfnDBGFR3SampleReportDumpToFile(pThis->m_hSampleReport, pThis->m_strFilename.c_str());
     138        pVMM->pfnDBGFR3SampleReportRelease(pThis->m_hSampleReport);
    135139        pThis->m_hSampleReport = NULL;
    136140        if (RT_SUCCESS(vrc))
     
    216220            hrc = ptrVM.rc();
    217221            if (SUCCEEDED(hrc))
    218                 EMR3QueryExecutionPolicy(ptrVM.rawUVM(), enmPolicy, &fEnforced);
     222                ptrVM.vtable()->pfnEMR3QueryExecutionPolicy(ptrVM.rawUVM(), enmPolicy, &fEnforced);
    219223            *pfEnforced = fEnforced;
    220224        }
     
    245249            if (SUCCEEDED(hrc))
    246250            {
    247                 int vrc = EMR3SetExecutionPolicy(ptrVM.rawUVM(), enmPolicy, fEnforce != FALSE);
     251                int vrc = ptrVM.vtable()->pfnEMR3SetExecutionPolicy(ptrVM.rawUVM(), enmPolicy, fEnforce != FALSE);
    248252                if (RT_FAILURE(vrc))
    249253                    hrc = setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("EMR3SetExecutionPolicy failed with %Rrc"), vrc);
     
    420424
    421425#ifdef LOG_ENABLED
    422     int vrc = DBGFR3LogModifyFlags(ptrVM.rawUVM(), aLogEnabled ? "enabled" : "disabled");
     426    int vrc = ptrVM.vtable()->pfnDBGFR3LogModifyFlags(ptrVM.rawUVM(), aLogEnabled ? "enabled" : "disabled");
    423427    if (RT_FAILURE(vrc))
    424428    {
     
    520524    {
    521525        uint8_t bEngine = UINT8_MAX;
    522         int rc = EMR3QueryMainExecutionEngine(ptrVM.rawUVM(), &bEngine);
     526        int rc = ptrVM.vtable()->pfnEMR3QueryMainExecutionEngine(ptrVM.rawUVM(), &bEngine);
    523527        if (RT_SUCCESS(rc))
    524528            switch (bEngine)
     
    550554    {
    551555        uint8_t bEngine = UINT8_MAX;
    552         int rc = EMR3QueryMainExecutionEngine(ptrVM.rawUVM(), &bEngine);
     556        int rc = ptrVM.vtable()->pfnEMR3QueryMainExecutionEngine(ptrVM.rawUVM(), &bEngine);
    553557        *aHWVirtExEnabled = RT_SUCCESS(rc) && bEngine == VM_EXEC_ENGINE_HW_VIRT;
    554558    }
     
    568572
    569573    Console::SafeVMPtrQuiet ptrVM(mParent);
    570 
    571574    if (ptrVM.isOk())
    572         *aHWVirtExNestedPagingEnabled = HMR3IsNestedPagingActive(ptrVM.rawUVM());
     575        *aHWVirtExNestedPagingEnabled = ptrVM.vtable()->pfnHMR3IsNestedPagingActive(ptrVM.rawUVM());
    573576    else
    574577        *aHWVirtExNestedPagingEnabled = false;
     
    588591
    589592    Console::SafeVMPtrQuiet ptrVM(mParent);
    590 
    591593    if (ptrVM.isOk())
    592         *aHWVirtExVPIDEnabled = HMR3IsVpidActive(ptrVM.rawUVM());
     594        *aHWVirtExVPIDEnabled = ptrVM.vtable()->pfnHMR3IsVpidActive(ptrVM.rawUVM());
    593595    else
    594596        *aHWVirtExVPIDEnabled = false;
     
    608610
    609611    Console::SafeVMPtrQuiet ptrVM(mParent);
    610 
    611612    if (ptrVM.isOk())
    612         *aHWVirtExUXEnabled = HMR3IsUXActive(ptrVM.rawUVM());
     613        *aHWVirtExUXEnabled = ptrVM.vtable()->pfnHMR3IsUXActive(ptrVM.rawUVM());
    613614    else
    614615        *aHWVirtExUXEnabled = false;
     
    621622    LogFlowThisFunc(("\n"));
    622623    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     624
    623625    Console::SafeVMPtr ptrVM(mParent);
    624626    HRESULT hrc = ptrVM.rc();
     
    629631         */
    630632        char szName[64];
    631         int vrc = DBGFR3OSQueryNameAndVersion(ptrVM.rawUVM(), szName, sizeof(szName), NULL, 0);
     633        int vrc = ptrVM.vtable()->pfnDBGFR3OSQueryNameAndVersion(ptrVM.rawUVM(), szName, sizeof(szName), NULL, 0);
    632634        if (RT_SUCCESS(vrc))
    633         {
    634             try
    635             {
    636                 Bstr bstrName(szName);
    637                 aOSName = Utf8Str(bstrName);
    638             }
    639             catch (std::bad_alloc &)
    640             {
    641                 hrc = E_OUTOFMEMORY;
    642             }
    643         }
     635            hrc = aOSName.assignEx(szName);
    644636        else
    645637            hrc = setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("DBGFR3OSQueryNameAndVersion failed with %Rrc"), vrc);
     
    652644    LogFlowThisFunc(("\n"));
    653645    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     646
    654647    Console::SafeVMPtr ptrVM(mParent);
    655648    HRESULT hrc = ptrVM.rc();
     
    660653         */
    661654        char szVersion[256];
    662         int vrc = DBGFR3OSQueryNameAndVersion(ptrVM.rawUVM(), NULL, 0, szVersion, sizeof(szVersion));
     655        int vrc = ptrVM.vtable()->pfnDBGFR3OSQueryNameAndVersion(ptrVM.rawUVM(), NULL, 0, szVersion, sizeof(szVersion));
    663656        if (RT_SUCCESS(vrc))
    664         {
    665             try
    666             {
    667                 Bstr bstrVersion(szVersion);
    668                 aOSVersion = Utf8Str(bstrVersion);
    669             }
    670             catch (std::bad_alloc &)
    671             {
    672                 hrc = E_OUTOFMEMORY;
    673             }
    674         }
     657            hrc = aOSVersion.assignEx(szVersion);
    675658        else
    676659            hrc = setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("DBGFR3OSQueryNameAndVersion failed with %Rrc"), vrc);
     
    690673
    691674    Console::SafeVMPtrQuiet ptrVM(mParent);
    692 
    693675    if (ptrVM.isOk())
    694676    {
    695677        uint32_t cr4;
    696         int rc = DBGFR3RegCpuQueryU32(ptrVM.rawUVM(), 0 /*idCpu*/,  DBGFREG_CR4, &cr4); AssertRC(rc);
     678        int rc = ptrVM.vtable()->pfnDBGFR3RegCpuQueryU32(ptrVM.rawUVM(), 0 /*idCpu*/,  DBGFREG_CR4, &cr4); AssertRC(rc);
    697679        *aPAEEnabled = RT_BOOL(cr4 & X86_CR4_PAE);
    698680    }
     
    716698    HRESULT hrc = ptrVM.rc();
    717699    if (SUCCEEDED(hrc))
    718         *aVirtualTimeRate = TMR3GetWarpDrive(ptrVM.rawUVM());
     700        *aVirtualTimeRate = ptrVM.vtable()->pfnTMR3GetWarpDrive(ptrVM.rawUVM());
    719701
    720702    return hrc;
     
    743725        if (SUCCEEDED(hrc))
    744726        {
    745             int vrc = TMR3SetWarpDrive(ptrVM.rawUVM(), aVirtualTimeRate);
     727            int vrc = ptrVM.vtable()->pfnTMR3SetWarpDrive(ptrVM.rawUVM(), aVirtualTimeRate);
    746728            if (RT_FAILURE(vrc))
    747729                hrc = setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("TMR3SetWarpDrive(, %u) failed with rc=%Rrc"), aVirtualTimeRate, vrc);
     
    772754    if (SUCCEEDED(hrc))
    773755    {
    774         VMR3RetainUVM(ptrVM.rawUVM());
     756        ptrVM.vtable()->pfnVMR3RetainUVM(ptrVM.rawUVM());
    775757        *aVM = (intptr_t)ptrVM.rawUVM();
    776758    }
     
    796778    HRESULT hrc = ptrVM.rc();
    797779    if (SUCCEEDED(hrc))
    798         *aUptime = (int64_t)TMR3TimeVirtGetMilli(ptrVM.rawUVM());
     780        *aUptime = (int64_t)ptrVM.vtable()->pfnTMR3TimeVirtGetMilli(ptrVM.rawUVM());
    799781
    800782    return hrc;
     
    814796    if (SUCCEEDED(hrc))
    815797    {
    816         int vrc = DBGFR3CoreWrite(ptrVM.rawUVM(), aFilename.c_str(), false /*fReplaceFile*/);
     798        int vrc = ptrVM.vtable()->pfnDBGFR3CoreWrite(ptrVM.rawUVM(), aFilename.c_str(), false /*fReplaceFile*/);
    817799        if (RT_SUCCESS(vrc))
    818800            hrc = S_OK;
     
    921903 * @param   pHlp                The help structure to init.
    922904 */
    923 static void MachineDebuggerInfoInit(PMACHINEDEBUGGERINOFHLP pHlp)
     905static void MachineDebuggerInfoInit(PMACHINEDEBUGGERINOFHLP pHlp, PCVMMR3VTABLE pVMM)
    924906{
    925907    pHlp->Core.pfnPrintf        = MachineDebuggerInfoPrintf;
    926908    pHlp->Core.pfnPrintfV       = MachineDebuggerInfoPrintfV;
    927     pHlp->Core.pfnGetOptError   = DBGFR3InfoGenericGetOptError;
     909    pHlp->Core.pfnGetOptError   = pVMM->pfnDBGFR3InfoGenericGetOptError;
    928910    pHlp->pszBuf                = NULL;
    929911    pHlp->cbBuf                 = 0;
     
    962944             */
    963945            MACHINEDEBUGGERINOFHLP Hlp;
    964             MachineDebuggerInfoInit(&Hlp);
    965             int vrc = DBGFR3Info(ptrVM.rawUVM(),  aName.c_str(),  aArgs.c_str(), &Hlp.Core);
     946            MachineDebuggerInfoInit(&Hlp, ptrVM.vtable());
     947            int vrc = ptrVM.vtable()->pfnDBGFR3Info(ptrVM.rawUVM(),  aName.c_str(),  aArgs.c_str(), &Hlp.Core);
    966948            if (RT_SUCCESS(vrc))
    967949            {
    968950                if (!Hlp.fOutOfMemory)
    969                 {
    970                     /*
    971                      * Convert the info string, watching out for allocation errors.
    972                      */
    973                     try
    974                     {
    975                         Bstr bstrInfo(Hlp.pszBuf);
    976                         aInfo = bstrInfo;
    977                     }
    978                     catch (std::bad_alloc &)
    979                     {
    980                         hrc = E_OUTOFMEMORY;
    981                     }
    982                 }
     951                    hrc = aInfo.assignEx(Hlp.pszBuf);
    983952                else
    984953                    hrc = E_OUTOFMEMORY;
     
    1001970    if (SUCCEEDED(hrc))
    1002971    {
    1003         int vrc = DBGFR3InjectNMI(ptrVM.rawUVM(), 0);
     972        int vrc = ptrVM.vtable()->pfnDBGFR3InjectNMI(ptrVM.rawUVM(), 0);
    1004973        if (RT_SUCCESS(vrc))
    1005974            hrc = S_OK;
     
    1018987    if (SUCCEEDED(hrc))
    1019988    {
    1020         int vrc = DBGFR3LogModifyFlags(ptrVM.rawUVM(), aSettings.c_str());
     989        int vrc = ptrVM.vtable()->pfnDBGFR3LogModifyFlags(ptrVM.rawUVM(), aSettings.c_str());
    1021990        if (RT_SUCCESS(vrc))
    1022991            hrc = S_OK;
     
    10351004    if (SUCCEEDED(hrc))
    10361005    {
    1037         int vrc = DBGFR3LogModifyGroups(ptrVM.rawUVM(), aSettings.c_str());
     1006        int vrc = ptrVM.vtable()->pfnDBGFR3LogModifyGroups(ptrVM.rawUVM(), aSettings.c_str());
    10381007        if (RT_SUCCESS(vrc))
    10391008            hrc = S_OK;
     
    10521021    if (SUCCEEDED(hrc))
    10531022    {
    1054         int vrc = DBGFR3LogModifyDestinations(ptrVM.rawUVM(), aSettings.c_str());
     1023        int vrc = ptrVM.vtable()->pfnDBGFR3LogModifyDestinations(ptrVM.rawUVM(), aSettings.c_str());
    10551024        if (RT_SUCCESS(vrc))
    10561025            hrc = S_OK;
     
    11001069        if (aName.equals("all"))
    11011070        {
    1102             DBGFR3PlugInLoadAll(ptrVM.rawUVM());
    1103             try
    1104             {
    1105                 aPlugInName = "all";
    1106                 hrc = S_OK;
    1107             }
    1108             catch (std::bad_alloc &)
    1109             {
    1110                 hrc = E_OUTOFMEMORY;
    1111             }
     1071            ptrVM.vtable()->pfnDBGFR3PlugInLoadAll(ptrVM.rawUVM());
     1072            hrc = aPlugInName.assignEx("all");
    11121073        }
    11131074        else
     
    11151076            RTERRINFOSTATIC ErrInfo;
    11161077            char            szName[80];
    1117             int vrc = DBGFR3PlugInLoad(ptrVM.rawUVM(), aName.c_str(), szName, sizeof(szName), RTErrInfoInitStatic(&ErrInfo));
     1078            int vrc = ptrVM.vtable()->pfnDBGFR3PlugInLoad(ptrVM.rawUVM(), aName.c_str(), szName, sizeof(szName), RTErrInfoInitStatic(&ErrInfo));
    11181079            if (RT_SUCCESS(vrc))
    1119             {
    1120                 try
    1121                 {
    1122                     aPlugInName = szName;
    1123                     hrc = S_OK;
    1124                 }
    1125                 catch (std::bad_alloc &)
    1126                 {
    1127                     hrc = E_OUTOFMEMORY;
    1128                 }
    1129             }
     1080                hrc = aPlugInName.assignEx(szName);
    11301081            else
    11311082                hrc = setErrorVrc(vrc, "%s", ErrInfo.szMsg);
     
    11511102        if (aName.equals("all"))
    11521103        {
    1153             DBGFR3PlugInUnloadAll(ptrVM.rawUVM());
     1104            ptrVM.vtable()->pfnDBGFR3PlugInUnloadAll(ptrVM.rawUVM());
    11541105            hrc = S_OK;
    11551106        }
    11561107        else
    11571108        {
    1158             int vrc = DBGFR3PlugInUnload(ptrVM.rawUVM(), aName.c_str());
     1109            int vrc = ptrVM.vtable()->pfnDBGFR3PlugInUnload(ptrVM.rawUVM(), aName.c_str());
    11591110            if (RT_SUCCESS(vrc))
    11601111                hrc = S_OK;
     
    11851136         */
    11861137        char szName[64];
    1187         int vrc = DBGFR3OSDetect(ptrVM.rawUVM(), szName, sizeof(szName));
     1138        int vrc = ptrVM.vtable()->pfnDBGFR3OSDetect(ptrVM.rawUVM(), szName, sizeof(szName));
    11881139        if (RT_SUCCESS(vrc) && vrc != VINF_DBGF_OS_NOT_DETCTED)
    1189         {
    1190             try
    1191             {
    1192                 aOs = szName;
    1193             }
    1194             catch (std::bad_alloc &)
    1195             {
    1196                 hrc = E_OUTOFMEMORY;
    1197             }
    1198         }
     1140            hrc = aOs.assignEx(szName);
    11991141        else
    12001142            hrc = setErrorBoth(VBOX_E_VM_ERROR, vrc, tr("DBGFR3OSDetect failed with %Rrc"), vrc);
     
    12131155    if (SUCCEEDED(hrc))
    12141156    {
    1215         PDBGFOSIDMESG pDmesg = (PDBGFOSIDMESG)DBGFR3OSQueryInterface(ptrVM.rawUVM(), DBGFOSINTERFACE_DMESG);
     1157        PDBGFOSIDMESG pDmesg = (PDBGFOSIDMESG)ptrVM.vtable()->pfnDBGFR3OSQueryInterface(ptrVM.rawUVM(), DBGFOSINTERFACE_DMESG);
    12161158        if (pDmesg)
    12171159        {
     
    12501192}
    12511193
    1252 /**
    1253  * Formats a register value.
    1254  *
    1255  * This is used by both register getter methods.
    1256  *
    1257  * @returns
    1258  * @param   a_pbstr             The output Bstr variable.
    1259  * @param   a_pValue            The value to format.
    1260  * @param   a_enmType           The type of the value.
    1261  */
    1262 DECLINLINE(HRESULT) formatRegisterValue(Bstr *a_pbstr, PCDBGFREGVAL a_pValue, DBGFREGVALTYPE a_enmType)
    1263 {
    1264     char szHex[160];
    1265     ssize_t cch = DBGFR3RegFormatValue(szHex, sizeof(szHex), a_pValue, a_enmType, true /*fSpecial*/);
    1266     if (RT_UNLIKELY(cch <= 0))
    1267         return E_UNEXPECTED;
    1268     *a_pbstr = szHex;
    1269     return S_OK;
    1270 }
    1271 
    12721194HRESULT MachineDebugger::getRegister(ULONG aCpuId, const com::Utf8Str &aName, com::Utf8Str &aValue)
    12731195{
     
    12861208        DBGFREGVAL      Value;
    12871209        DBGFREGVALTYPE  enmType;
    1288         int vrc = DBGFR3RegNmQuery(ptrVM.rawUVM(), aCpuId, aName.c_str(), &Value, &enmType);
     1210        int vrc = ptrVM.vtable()->pfnDBGFR3RegNmQuery(ptrVM.rawUVM(), aCpuId, aName.c_str(), &Value, &enmType);
    12891211        if (RT_SUCCESS(vrc))
    12901212        {
    1291             try
    1292             {
    1293                 Bstr bstrValue;
    1294                 hrc = formatRegisterValue(&bstrValue, &Value, enmType);
    1295                 if (SUCCEEDED(hrc))
    1296                     aValue = Utf8Str(bstrValue);
    1297             }
    1298             catch (std::bad_alloc &)
    1299             {
    1300                 hrc = E_OUTOFMEMORY;
    1301             }
     1213            char szHex[160];
     1214            ssize_t cch = ptrVM.vtable()->pfnDBGFR3RegFormatValue(szHex, sizeof(szHex), &Value, enmType, true /*fSpecial*/);
     1215            if (cch > 0)
     1216                hrc = aValue.assignEx(szHex);
     1217            else
     1218                hrc = E_UNEXPECTED;
    13021219        }
    13031220        else if (vrc == VERR_DBGF_REGISTER_NOT_FOUND)
     
    13311248         */
    13321249        size_t cRegs;
    1333         int vrc = DBGFR3RegNmQueryAllCount(ptrVM.rawUVM(), &cRegs);
     1250        int vrc = ptrVM.vtable()->pfnDBGFR3RegNmQueryAllCount(ptrVM.rawUVM(), &cRegs);
    13341251        if (RT_SUCCESS(vrc))
    13351252        {
     
    13371254            if (paRegs)
    13381255            {
    1339                 vrc = DBGFR3RegNmQueryAll(ptrVM.rawUVM(), paRegs, cRegs);
     1256                vrc = ptrVM.vtable()->pfnDBGFR3RegNmQueryAll(ptrVM.rawUVM(), paRegs, cRegs);
    13401257                if (RT_SUCCESS(vrc))
    13411258                {
     
    13481265                            char szHex[160];
    13491266                            szHex[159] = szHex[0] = '\0';
    1350                             ssize_t cch = DBGFR3RegFormatValue(szHex, sizeof(szHex), &paRegs[iReg].Val,
    1351                                                                paRegs[iReg].enmType, true /*fSpecial*/);
     1267                            ssize_t cch = ptrVM.vtable()->pfnDBGFR3RegFormatValue(szHex, sizeof(szHex), &paRegs[iReg].Val,
     1268                                                                                  paRegs[iReg].enmType, true /*fSpecial*/);
    13521269                            Assert(cch > 0); NOREF(cch);
    1353                             aNames[iReg] = Utf8Str(paRegs[iReg].pszName);
    1354                             aValues[iReg] = Utf8Str(szHex);
     1270                            aNames[iReg]  = paRegs[iReg].pszName;
     1271                            aValues[iReg] = szHex;
    13551272                        }
    13561273                    }
     
    14111328        if (aCpuId != 0)
    14121329        {
    1413             VMSTATE enmVmState = VMR3GetStateU(ptrVM.rawUVM());
     1330            VMSTATE enmVmState = ptrVM.vtable()->pfnVMR3GetStateU(ptrVM.rawUVM());
    14141331            if (   enmVmState == VMSTATE_RUNNING
    14151332                || enmVmState == VMSTATE_RUNNING_LS)
    14161333            {
    14171334                alock.release();
    1418                 vrc = VMR3Suspend(ptrVM.rawUVM(), VMSUSPENDREASON_USER);
     1335                vrc = ptrVM.vtable()->pfnVMR3Suspend(ptrVM.rawUVM(), VMSUSPENDREASON_USER);
    14191336                alock.acquire();
    14201337                fPaused = RT_SUCCESS(vrc);
     
    14241341        {
    14251342            PCDBGFSTACKFRAME pFirstFrame;
    1426             vrc = DBGFR3StackWalkBegin(ptrVM.rawUVM(), aCpuId, DBGFCODETYPE_GUEST, &pFirstFrame);
     1343            vrc = ptrVM.vtable()->pfnDBGFR3StackWalkBegin(ptrVM.rawUVM(), aCpuId, DBGFCODETYPE_GUEST, &pFirstFrame);
    14271344            if (RT_SUCCESS(vrc))
    14281345            {
     
    14351352                    for (PCDBGFSTACKFRAME pFrame = pFirstFrame;
    14361353                         pFrame;
    1437                          pFrame = DBGFR3StackWalkNext(pFrame))
     1354                         pFrame = ptrVM.vtable()->pfnDBGFR3StackWalkNext(pFrame))
    14381355                    {
    14391356                        uint32_t const fCurBitFlags = pFrame->fFlags & (DBGFSTACKFRAME_FLAGS_16BIT | DBGFSTACKFRAME_FLAGS_32BIT | DBGFSTACKFRAME_FLAGS_64BIT);
     
    14421359                            if (fCurBitFlags != fBitFlags)
    14431360                                aStack.append("SS:BP     Ret SS:BP Ret CS:EIP    Arg0     Arg1     Arg2     Arg3     CS:EIP / Symbol [line]\n");
    1444                             aStack.append(Utf8StrFmt("%04RX16:%04RX16 %04RX16:%04RX16 %04RX32:%08RX32 %08RX32 %08RX32 %08RX32 %08RX32",
    1445                                                      pFrame->AddrFrame.Sel,
    1446                                                      (uint16_t)pFrame->AddrFrame.off,
    1447                                                      pFrame->AddrReturnFrame.Sel,
    1448                                                      (uint16_t)pFrame->AddrReturnFrame.off,
    1449                                                      (uint32_t)pFrame->AddrReturnPC.Sel,
    1450                                                      (uint32_t)pFrame->AddrReturnPC.off,
    1451                                                      pFrame->Args.au32[0],
    1452                                                      pFrame->Args.au32[1],
    1453                                                      pFrame->Args.au32[2],
    1454                                                      pFrame->Args.au32[3]));
     1361                            aStack.appendPrintf("%04RX16:%04RX16 %04RX16:%04RX16 %04RX32:%08RX32 %08RX32 %08RX32 %08RX32 %08RX32",
     1362                                                pFrame->AddrFrame.Sel,
     1363                                                (uint16_t)pFrame->AddrFrame.off,
     1364                                                pFrame->AddrReturnFrame.Sel,
     1365                                                (uint16_t)pFrame->AddrReturnFrame.off,
     1366                                                (uint32_t)pFrame->AddrReturnPC.Sel,
     1367                                                (uint32_t)pFrame->AddrReturnPC.off,
     1368                                                pFrame->Args.au32[0],
     1369                                                pFrame->Args.au32[1],
     1370                                                pFrame->Args.au32[2],
     1371                                                pFrame->Args.au32[3]);
    14551372                        }
    14561373                        else if (fCurBitFlags & DBGFSTACKFRAME_FLAGS_32BIT)
     
    14581375                            if (fCurBitFlags != fBitFlags)
    14591376                                aStack.append("EBP      Ret EBP  Ret CS:EIP    Arg0     Arg1     Arg2     Arg3     CS:EIP / Symbol [line]\n");
    1460                             aStack.append(Utf8StrFmt("%08RX32 %08RX32 %04RX32:%08RX32 %08RX32 %08RX32 %08RX32 %08RX32",
    1461                                                      (uint32_t)pFrame->AddrFrame.off,
    1462                                                      (uint32_t)pFrame->AddrReturnFrame.off,
    1463                                                      (uint32_t)pFrame->AddrReturnPC.Sel,
    1464                                                      (uint32_t)pFrame->AddrReturnPC.off,
    1465                                                      pFrame->Args.au32[0],
    1466                                                      pFrame->Args.au32[1],
    1467                                                      pFrame->Args.au32[2],
    1468                                                      pFrame->Args.au32[3]));
     1377                            aStack.appendPrintf("%08RX32 %08RX32 %04RX32:%08RX32 %08RX32 %08RX32 %08RX32 %08RX32",
     1378                                                (uint32_t)pFrame->AddrFrame.off,
     1379                                                (uint32_t)pFrame->AddrReturnFrame.off,
     1380                                                (uint32_t)pFrame->AddrReturnPC.Sel,
     1381                                                (uint32_t)pFrame->AddrReturnPC.off,
     1382                                                pFrame->Args.au32[0],
     1383                                                pFrame->Args.au32[1],
     1384                                                pFrame->Args.au32[2],
     1385                                                pFrame->Args.au32[3]);
    14691386                        }
    14701387                        else if (fCurBitFlags & DBGFSTACKFRAME_FLAGS_64BIT)
     
    14721389                            if (fCurBitFlags != fBitFlags)
    14731390                                aStack.append("RBP              Ret SS:RBP            Ret RIP          CS:RIP / Symbol [line]\n");
    1474                             aStack.append(Utf8StrFmt("%016RX64 %04RX16:%016RX64 %016RX64",
    1475                                                      (uint64_t)pFrame->AddrFrame.off,
    1476                                                      pFrame->AddrReturnFrame.Sel,
    1477                                                      (uint64_t)pFrame->AddrReturnFrame.off,
    1478                                                      (uint64_t)pFrame->AddrReturnPC.off));
     1391                            aStack.appendPrintf("%016RX64 %04RX16:%016RX64 %016RX64",
     1392                                                (uint64_t)pFrame->AddrFrame.off,
     1393                                                pFrame->AddrReturnFrame.Sel,
     1394                                                (uint64_t)pFrame->AddrReturnFrame.off,
     1395                                                (uint64_t)pFrame->AddrReturnPC.off);
    14791396                        }
    14801397
    14811398                        if (!pFrame->pSymPC)
    1482                             aStack.append(Utf8StrFmt(fCurBitFlags & DBGFSTACKFRAME_FLAGS_64BIT
    1483                                                      ? " %RTsel:%016RGv"
    1484                                                      : fCurBitFlags & DBGFSTACKFRAME_FLAGS_32BIT
    1485                                                      ? " %RTsel:%08RGv"
    1486                                                      : " %RTsel:%04RGv"
    1487                                                      , pFrame->AddrPC.Sel, pFrame->AddrPC.off));
     1399                            aStack.appendPrintf(fCurBitFlags & DBGFSTACKFRAME_FLAGS_64BIT
     1400                                                ? " %RTsel:%016RGv"
     1401                                                : fCurBitFlags & DBGFSTACKFRAME_FLAGS_32BIT
     1402                                                ? " %RTsel:%08RGv"
     1403                                                : " %RTsel:%04RGv"
     1404                                                , pFrame->AddrPC.Sel, pFrame->AddrPC.off);
    14881405                        else
    14891406                        {
    14901407                            RTGCINTPTR offDisp = pFrame->AddrPC.FlatPtr - pFrame->pSymPC->Value; /** @todo this isn't 100% correct for segmented stuff. */
    14911408                            if (offDisp > 0)
    1492                                 aStack.append(Utf8StrFmt(" %s+%llx", pFrame->pSymPC->szName, (int64_t)offDisp));
     1409                                aStack.appendPrintf(" %s+%llx", pFrame->pSymPC->szName, (int64_t)offDisp);
    14931410                            else if (offDisp < 0)
    1494                                 aStack.append(Utf8StrFmt(" %s-%llx", pFrame->pSymPC->szName, -(int64_t)offDisp));
     1411                                aStack.appendPrintf(" %s-%llx", pFrame->pSymPC->szName, -(int64_t)offDisp);
    14951412                            else
    1496                                 aStack.append(Utf8StrFmt(" %s", pFrame->pSymPC->szName));
     1413                                aStack.appendPrintf(" %s", pFrame->pSymPC->szName);
    14971414                        }
    14981415                        if (pFrame->pLinePC)
    1499                             aStack.append(Utf8StrFmt(" [%s @ 0i%d]", pFrame->pLinePC->szFilename, pFrame->pLinePC->uLineNo));
    1500                         aStack.append(Utf8StrFmt("\n"));
     1416                            aStack.appendPrintf(" [%s @ 0i%d]", pFrame->pLinePC->szFilename, pFrame->pLinePC->uLineNo);
     1417                        aStack.append("\n");
    15011418
    15021419                        fBitFlags = fCurBitFlags;
     
    15081425                }
    15091426
    1510                 DBGFR3StackWalkEnd(pFirstFrame);
     1427                ptrVM.vtable()->pfnDBGFR3StackWalkEnd(pFirstFrame);
    15111428            }
    15121429            else
     
    15191436            {
    15201437                alock.release();
    1521                 VMR3Resume(ptrVM.rawUVM(), VMRESUMEREASON_USER);
     1438                ptrVM.vtable()->pfnVMR3Resume(ptrVM.rawUVM(), VMRESUMEREASON_USER);
    15221439            }
    15231440        }
     
    15381455{
    15391456    Console::SafeVMPtrQuiet ptrVM(mParent);
    1540 
    15411457    if (!ptrVM.isOk())
    15421458        return setError(VBOX_E_INVALID_VM_STATE, tr("Machine is not running"));
    15431459
    1544     STAMR3Reset(ptrVM.rawUVM(), aPattern.c_str());
     1460    ptrVM.vtable()->pfnSTAMR3Reset(ptrVM.rawUVM(), aPattern.c_str());
    15451461
    15461462    return S_OK;
     
    15561472{
    15571473    Console::SafeVMPtrQuiet ptrVM(mParent);
    1558 
    15591474    if (!ptrVM.isOk())
    15601475        return setError(VBOX_E_INVALID_VM_STATE, tr("Machine is not running"));
    15611476
    1562     STAMR3Dump(ptrVM.rawUVM(), aPattern.c_str());
     1477    ptrVM.vtable()->pfnSTAMR3Dump(ptrVM.rawUVM(), aPattern.c_str());
    15631478
    15641479    return S_OK;
     
    15801495
    15811496    char *pszSnapshot;
    1582     int vrc = STAMR3Snapshot(ptrVM.rawUVM(), aPattern.c_str(), &pszSnapshot, NULL,
    1583                              !!aWithDescriptions);
     1497    int vrc = ptrVM.vtable()->pfnSTAMR3Snapshot(ptrVM.rawUVM(), aPattern.c_str(), &pszSnapshot, NULL, !!aWithDescriptions);
    15841498    if (RT_FAILURE(vrc))
    15851499        return vrc == VERR_NO_MEMORY ? E_OUTOFMEMORY : E_FAIL;
     
    15891503     * Until that's done, this method is kind of useless for debugger statistics GUI because
    15901504     * of the amount statistics in a debug build. */
    1591     aStats = Utf8Str(pszSnapshot);
    1592     STAMR3SnapshotFree(ptrVM.rawUVM(), pszSnapshot);
    1593 
    1594     return S_OK;
     1505    HRESULT hrc = aStats.assignEx(pszSnapshot);
     1506    ptrVM.vtable()->pfnSTAMR3SnapshotFree(ptrVM.rawUVM(), pszSnapshot);
     1507
     1508    return hrc;
    15951509}
    15961510
     
    16071521        uint8_t uPctOther     = 0;
    16081522        uint64_t msInterval   = 0;
    1609         int vrc = TMR3GetCpuLoadPercents(ptrVM.rawUVM(), aCpuId >= UINT32_MAX / 2 ? VMCPUID_ALL : aCpuId,
    1610                                          &msInterval, &uPctExecuting, &uPctHalted, &uPctOther);
     1523        int vrc = ptrVM.vtable()->pfnTMR3GetCpuLoadPercents(ptrVM.rawUVM(), aCpuId >= UINT32_MAX / 2 ? VMCPUID_ALL : aCpuId,
     1524                                                            &msInterval, &uPctExecuting, &uPctHalted, &uPctOther);
    16111525        if (RT_SUCCESS(vrc))
    16121526        {
     
    16411555            m_strFilename = aFilename;
    16421556
    1643             int vrc = DBGFR3SampleReportCreate(ptrVM.rawUVM(), aUsInterval, DBGF_SAMPLE_REPORT_F_STACK_REVERSE, &m_hSampleReport);
     1557            int vrc = ptrVM.vtable()->pfnDBGFR3SampleReportCreate(ptrVM.rawUVM(), aUsInterval,
     1558                                                                  DBGF_SAMPLE_REPORT_F_STACK_REVERSE, &m_hSampleReport);
    16441559            if (RT_SUCCESS(vrc))
    16451560            {
     
    16521567                    if (SUCCEEDED(hrc))
    16531568                    {
    1654                         vrc = DBGFR3SampleReportStart(m_hSampleReport, aUsSampleTime, i_dbgfProgressCallback, static_cast<MachineDebugger*>(this));
     1569                        vrc = ptrVM.vtable()->pfnDBGFR3SampleReportStart(m_hSampleReport, aUsSampleTime, i_dbgfProgressCallback,
     1570                                                                         static_cast<MachineDebugger*>(this));
    16551571                        if (RT_SUCCESS(vrc))
    16561572                            hrc = m_Progress.queryInterfaceTo(pProgress.asOutParam());
     
    16621578                if (FAILED(hrc))
    16631579                {
    1664                     DBGFR3SampleReportRelease(m_hSampleReport);
     1580                    ptrVM.vtable()->pfnDBGFR3SampleReportRelease(m_hSampleReport);
    16651581                    m_hSampleReport = NULL;
    16661582                }
  • trunk/src/VBox/Main/src-client/MouseImpl.cpp

    r93115 r93444  
    12341234DECLCALLBACK(int) Mouse::i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
    12351235{
    1236     RT_NOREF(fFlags);
    12371236    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
     1237    RT_NOREF(fFlags, pCfg);
    12381238    PDRVMAINMOUSE pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINMOUSE);
    12391239    LogFlow(("drvMainMouse_Construct: iInstance=%d\n", pDrvIns->iInstance));
     
    12421242     * Validate configuration.
    12431243     */
    1244     if (!CFGMR3AreValuesValid(pCfg, ""))
    1245         return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
     1244    PDMDRV_VALIDATE_CONFIG_RETURN(pDrvIns, "", "");
    12461245    AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
    12471246                    ("Configuration error: Not possible to attach anything to this driver!\n"),
  • trunk/src/VBox/Main/src-client/SessionImpl.cpp

    r93410 r93444  
    345345        AssertComRCReturn(rc, rc);
    346346
    347         rc = mConsole->init(aMachine, mControl, aLockType);
     347        rc = mConsole->initWithMachine(aMachine, mControl, aLockType);
    348348        AssertComRCReturn(rc, rc);
    349349    }
  • trunk/src/VBox/Main/src-client/UsbCardReader.cpp

    r93115 r93444  
    18771877    pThis->hReqQCardReaderCmd = NIL_RTREQQUEUE;
    18781878
    1879     if (!CFGMR3AreValuesValid(pCfg, "Object\0"))
    1880         return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
     1879    PDMDRV_VALIDATE_CONFIG_RETURN(pDrvIns, "Object", "");
    18811880    AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
    18821881                    ("Configuration error: Not possible to attach anything to this driver!\n"),
     
    18841883
    18851884    void *pv;
    1886     int rc = CFGMR3QueryPtr(pCfg, "Object", &pv);
     1885    int rc = pDrvIns->pHlpR3->pfnCFGMQueryPtr(pCfg, "Object", &pv);
    18871886    AssertMsgRCReturn(rc, ("Configuration error: No/bad \"Object\" value! rc=%Rrc\n", rc), rc);
    18881887
  • trunk/src/VBox/Main/src-client/UsbWebcamInterface.cpp

    r93115 r93444  
    405405
    406406    void *pv = NULL;
    407     int rc = CFGMR3QueryPtr(pCfg, "Object", &pv);
     407    int rc = pDrvIns->pHlpR3->pfnCFGMQueryPtr(pCfg, "Object", &pv);
    408408    if (!RT_VALID_PTR(pv))
    409409         rc = VERR_INVALID_PARAMETER;
    410     AssertMsgReturn(RT_SUCCESS(rc),
    411                     ("Configuration error: No/bad \"Object\" %p value! rc=%Rrc\n", pv, rc), rc);
     410    AssertMsgRCReturn(rc, ("Configuration error: No/bad \"Object\" %p value! rc=%Rrc\n", pv, rc), rc);
    412411
    413412    /* Everything ok. Initialize. */
  • trunk/src/VBox/Main/src-client/VMMDevInterface.cpp

    r93115 r93444  
    684684 * @param   pSSM            SSM operation handle.
    685685 */
    686 static DECLCALLBACK(int) iface_hgcmSave(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM)
    687 {
    688     RT_NOREF(pDrvIns);
     686/*static*/ DECLCALLBACK(int) VMMDev::hgcmSave(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM)
     687{
     688    PDRVMAINVMMDEV pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
    689689    Log9(("Enter\n"));
    690     return HGCMHostSaveState(pSSM);
     690
     691    AssertReturn(pThis->pVMMDev, VERR_INTERNAL_ERROR_2);
     692    Console::SafeVMPtrQuiet ptrVM(pThis->pVMMDev->mParent);
     693    AssertReturn(ptrVM.isOk(), VERR_INTERNAL_ERROR_3);
     694    return HGCMHostSaveState(pSSM, ptrVM.vtable());
    691695}
    692696
     
    701705 * @param   uPass           The data pass.
    702706 */
    703 static DECLCALLBACK(int) iface_hgcmLoad(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
    704 {
    705     RT_NOREF(pDrvIns);
     707/*static*/ DECLCALLBACK(int) VMMDev::hgcmLoad(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
     708{
     709    PDRVMAINVMMDEV pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
    706710    LogFlowFunc(("Enter\n"));
    707711
     
    711715    Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
    712716
    713     return HGCMHostLoadState(pSSM, uVersion);
     717    AssertReturn(pThis->pVMMDev, VERR_INTERNAL_ERROR_2);
     718    Console::SafeVMPtrQuiet ptrVM(pThis->pVMMDev->mParent);
     719    AssertReturn(ptrVM.isOk(), VERR_INTERNAL_ERROR_3);
     720    return HGCMHostLoadState(pSSM, ptrVM.vtable(), uVersion);
    714721}
    715722
     
    728735           );
    729736    Console::SafeVMPtrQuiet ptrVM(mParent);
    730     return HGCMHostLoad(pszServiceLibrary, pszServiceName, ptrVM.rawUVM(), mpDrv ? mpDrv->pHGCMPort : NULL);
     737    return HGCMHostLoad(pszServiceLibrary, pszServiceName, ptrVM.rawUVM(), ptrVM.vtable(), mpDrv ? mpDrv->pHGCMPort : NULL);
    731738}
    732739
     
    10481055 * @interface_method_impl{PDMDRVREG,pfnConstruct}
    10491056 */
    1050 DECLCALLBACK(int) VMMDev::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags)
    1051 {
    1052     RT_NOREF(fFlags);
     1057DECLCALLBACK(int) VMMDev::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
     1058{
    10531059    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
     1060    RT_NOREF(fFlags, pCfg);
    10541061    PDRVMAINVMMDEV pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
    10551062    LogFlow(("Keyboard::drvConstruct: iInstance=%d\n", pDrvIns->iInstance));
     
    10581065     * Validate configuration.
    10591066     */
    1060     if (!CFGMR3AreValuesValid(pCfgHandle, ""))
    1061         return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
     1067    PDMDRV_VALIDATE_CONFIG_RETURN(pDrvIns, "", "");
    10621068    AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
    10631069                    ("Configuration error: Not possible to attach anything to this driver!\n"),
     
    11111117     */
    11121118    com::Guid uuid(VMMDEV_OID);
    1113     pThis->pVMMDev = (VMMDev*)PDMDrvHlpQueryGenericUserObject(pDrvIns, uuid.raw());
     1119    pThis->pVMMDev = (VMMDev *)PDMDrvHlpQueryGenericUserObject(pDrvIns, uuid.raw());
    11141120    if (!pThis->pVMMDev)
    11151121    {
     
    11861192    rc = PDMDrvHlpSSMRegisterEx(pDrvIns, HGCM_SAVED_STATE_VERSION, 4096 /* bad guess */,
    11871193                                NULL, NULL, NULL,
    1188                                 NULL, iface_hgcmSave, NULL,
    1189                                 NULL, iface_hgcmLoad, NULL);
     1194                                NULL, VMMDev::hgcmSave, NULL,
     1195                                NULL, VMMDev::hgcmLoad, NULL);
    11901196    if (RT_FAILURE(rc))
    11911197        return rc;
  • trunk/src/VBox/VMM/Makefile.kmk

    r93419 r93444  
    8989VBoxVMM_SOURCES  = \
    9090        VBoxVMM.d \
     91       VMMR3/VMMR3VTable.cpp \
    9192        VMMR3/APIC.cpp \
    9293        VMMR3/CFGM.cpp \
  • trunk/src/VBox/VMM/VMMR3/CFGM.cpp

    r93393 r93444  
    6363#include <VBox/vmm/vm.h>
    6464#include <VBox/vmm/uvm.h>
     65#include <VBox/vmm/vmmr3vtable.h>
    6566#include <VBox/err.h>
    6667
     
    225226     */
    226227    if (pfnCFGMConstructor)
    227         rc = pfnCFGMConstructor(pVM->pUVM, pVM, pvUser);
     228        rc = pfnCFGMConstructor(pVM->pUVM, pVM, VMMR3GetVTable(), pvUser);
    228229    else
    229230        rc = CFGMR3ConstructDefaultTree(pVM);
  • trunk/src/VBox/VMM/VMMR3/PGM.cpp

    r93115 r93444  
    19391939 * a snapshot has been created.
    19401940 */
    1941 static DECLCALLBACK(void) pgmR3ResetNoMorePhysWritesFlag(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser)
     1941static DECLCALLBACK(void) pgmR3ResetNoMorePhysWritesFlag(PUVM pUVM, PCVMMR3VTABLE pVMM, VMSTATE enmState,
     1942                                                         VMSTATE enmOldState, void *pvUser)
    19421943{
    19431944    if (   enmState == VMSTATE_RUNNING
    19441945        || enmState == VMSTATE_RESUMING)
    19451946        pUVM->pVM->pgm.s.fNoMorePhysWrites = false;
    1946     NOREF(enmOldState); NOREF(pvUser);
     1947    RT_NOREF(pVMM, enmOldState, pvUser);
    19471948}
    19481949#endif
  • trunk/src/VBox/VMM/VMMR3/SSM.cpp

    r93115 r93444  
    153153#include <VBox/vmm/vm.h>
    154154#include <VBox/vmm/uvm.h>
     155#include <VBox/vmm/vmmr3vtable.h>
    155156#include <VBox/err.h>
    156157#include <VBox/log.h>
     
    45494550                    break;
    45504551                case SSMUNITTYPE_EXTERNAL:
    4551                     rc = pUnit->u.External.pfnSaveDone(pSSM, pUnit->u.External.pvUser);
     4552                    rc = pUnit->u.External.pfnSaveDone(pSSM, VMMR3GetVTable(), pUnit->u.External.pvUser);
    45524553                    break;
    45534554                default:
     
    49014902                break;
    49024903            case SSMUNITTYPE_EXTERNAL:
    4903                 pUnit->u.External.pfnSaveExec(pSSM, pUnit->u.External.pvUser);
    4904                 rc = pSSM->rc;
     4904                rc = pUnit->u.External.pfnSaveExec(pSSM, VMMR3GetVTable(), pUnit->u.External.pvUser);
    49054905                break;
    49064906            default:
     
    49944994                    break;
    49954995                case SSMUNITTYPE_EXTERNAL:
    4996                     rc = pUnit->u.External.pfnSavePrep(pSSM, pUnit->u.External.pvUser);
     4996                    rc = pUnit->u.External.pfnSavePrep(pSSM, VMMR3GetVTable(), pUnit->u.External.pvUser);
    49974997                    break;
    49984998                default:
     
    53405340                    break;
    53415341                case SSMUNITTYPE_EXTERNAL:
    5342                     rc = pUnit->u.External.pfnLiveVote(pSSM, pUnit->u.External.pvUser, uPass);
     5342                    rc = pUnit->u.External.pfnLiveVote(pSSM, VMMR3GetVTable(), pUnit->u.External.pvUser, uPass);
    53435343                    break;
    53445344                default:
     
    54835483                break;
    54845484            case SSMUNITTYPE_EXTERNAL:
    5485                 rc = pUnit->u.External.pfnLiveExec(pSSM, pUnit->u.External.pvUser, uPass);
     5485                rc = pUnit->u.External.pfnLiveExec(pSSM, VMMR3GetVTable(), pUnit->u.External.pvUser, uPass);
    54865486                break;
    54875487            default:
     
    56455645                    break;
    56465646                case SSMUNITTYPE_EXTERNAL:
    5647                     rc = pUnit->u.External.pfnLivePrep(pSSM, pUnit->u.External.pvUser);
     5647                    rc = pUnit->u.External.pfnLivePrep(pSSM, VMMR3GetVTable(), pUnit->u.External.pvUser);
    56485648                    break;
    56495649                default:
     
    86258625                                break;
    86268626                            case SSMUNITTYPE_EXTERNAL:
    8627                                 rc = pUnit->u.External.pfnLoadExec(pSSM, pUnit->u.External.pvUser, UnitHdr.u32Version, SSM_PASS_FINAL);
     8627                                rc = pUnit->u.External.pfnLoadExec(pSSM, VMMR3GetVTable(), pUnit->u.External.pvUser,
     8628                                                                   UnitHdr.u32Version, SSM_PASS_FINAL);
    86288629                                break;
    86298630                            default:
     
    88938894                    break;
    88948895                case SSMUNITTYPE_EXTERNAL:
    8895                     rc = pUnit->u.External.pfnLoadExec(pSSM, pUnit->u.External.pvUser, UnitHdr.u32Version, UnitHdr.u32Pass);
     8896                    rc = pUnit->u.External.pfnLoadExec(pSSM, VMMR3GetVTable(), pUnit->u.External.pvUser,
     8897                                                       UnitHdr.u32Version, UnitHdr.u32Pass);
    88968898                    break;
    88978899                default:
     
    90779079                        break;
    90789080                    case SSMUNITTYPE_EXTERNAL:
    9079                         rc = pUnit->u.External.pfnLoadPrep(&Handle, pUnit->u.External.pvUser);
     9081                        rc = pUnit->u.External.pfnLoadPrep(&Handle, VMMR3GetVTable(), pUnit->u.External.pvUser);
    90809082                        break;
    90819083                    default:
     
    91539155                        break;
    91549156                    case SSMUNITTYPE_EXTERNAL:
    9155                         rc = pUnit->u.External.pfnLoadDone(&Handle, pUnit->u.External.pvUser);
     9157                        rc = pUnit->u.External.pfnLoadDone(&Handle, VMMR3GetVTable(), pUnit->u.External.pvUser);
    91569158                        break;
    91579159                    default:
  • trunk/src/VBox/VMM/VMMR3/VM.cpp

    r93115 r93444  
    6868#include "VMInternal.h"
    6969#include <VBox/vmm/vmcc.h>
     70#include <VBox/vmm/vmmr3vtable.h>
    7071
    7172#include <VBox/sup.h>
     
    31673168    for (PVMATSTATE pCur = pUVM->vm.s.pAtState; pCur; pCur = pCur->pNext)
    31683169    {
    3169         pCur->pfnAtState(pUVM, enmStateNew, enmStateOld, pCur->pvUser);
     3170        pCur->pfnAtState(pUVM, VMMR3GetVTable(), enmStateNew, enmStateOld, pCur->pvUser);
    31703171        if (    enmStateNew     != VMSTATE_DESTROYING
    31713172            &&  pVM->enmVMState == VMSTATE_DESTROYING)
  • trunk/src/VBox/VMM/testcase/tstAnimate.cpp

    r93115 r93444  
    319319
    320320/**
    321  * Creates the default configuration.
     321 * @callback_method_impl{FNCFGMCONSTRUCTOR, Creates the default configuration.}
     322 *
    322323 * This assumes an empty tree.
    323  *
    324  * @returns VBox status code.
    325  * @param   pVM     Pointer to the VM.
    326324 */
    327 static DECLCALLBACK(int) cfgmR3CreateDefault(PUVM pUVM, PVM pVM, void *pvUser)
    328 {
    329     RT_NOREF1(pUVM);
     325static DECLCALLBACK(int) cfgmR3CreateDefault(PUVM pUVM, PVM pVM, PCVMMR3VTABLE pVMM, void *pvUser)
     326{
     327    RT_NOREF(pUVM, pVMM);
    330328    uint64_t cbMem = *(uint64_t *)pvUser;
    331329    int rc;
  • trunk/src/VBox/VMM/testcase/tstVMREQ.cpp

    r93115 r93444  
    210210
    211211static DECLCALLBACK(int)
    212 tstVMREQConfigConstructor(PUVM pUVM, PVM pVM, void *pvUser)
    213 {
    214     RT_NOREF2(pUVM, pvUser);
     212tstVMREQConfigConstructor(PUVM pUVM, PVM pVM, PCVMMR3VTABLE pVMM, void *pvUser)
     213{
     214    RT_NOREF(pUVM, pVMM, pvUser);
    215215    return CFGMR3ConstructDefaultTree(pVM);
    216216}
Note: See TracChangeset for help on using the changeset viewer.

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