VirtualBox

Changeset 68986 in vbox


Ignore:
Timestamp:
Oct 4, 2017 2:37:38 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
118254
Message:

VMM: Add new QueryGenericObject entry to VMM2USER callback table, for querying API objects by UUID.
PDM: Add new QueryGenericUserObject entry to trusted DevHlp callback table, for querying API objects by UUID from PDM devices.
Main/Session+Console+Machine+Snapshot: Implement this callback and provide the console and snapshot objects this way.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmdev.h

    r68594 r68986  
    18781878
    18791879/** Current PDMDEVHLPR3 version number. */
    1880 #define PDM_DEVHLPR3_VERSION                    PDM_VERSION_MAKE_PP(0xffe7, 21, 0)
     1880#define PDM_DEVHLPR3_VERSION                    PDM_VERSION_MAKE_PP(0xffe7, 22, 0)
    18811881
    18821882/**
     
    34813481    DECLR3CALLBACKMEMBER(PSUPDRVSESSION, pfnGetSupDrvSession,(PPDMDEVINS pDevIns));
    34823482
     3483    /**
     3484     * Queries a generic object from the VMM user.
     3485     *
     3486     * @returns Pointer to the object if found, NULL if not.
     3487     * @param   pDevIns             The device instance.
     3488     * @param   pUuid               The UUID of what's being queried.  The UUIDs and
     3489     *                              the usage conventions are defined by the user.
     3490     *
     3491     * @note    It is strictly forbidden to call this internally in VBox!  This
     3492     *          interface is exclusively for hacks in externally developed devices.
     3493     */
     3494    DECLR3CALLBACKMEMBER(void *, pfnQueryGenericUserObject,(PPDMDEVINS pDevIns, PCRTUUID pUuid));
     3495
    34833496    /** @} */
    34843497
     
    53595372}
    53605373
     5374/**
     5375 * @copydoc PDMDEVHLPR3::pfnQueryGenericUserObject
     5376 */
     5377DECLINLINE(void *) PDMDevHlpQueryGenericUserObject(PPDMDEVINS pDevIns, PCRTUUID pUuid)
     5378{
     5379    return pDevIns->pHlpR3->pfnQueryGenericUserObject(pDevIns, pUuid);
     5380}
     5381
    53615382#endif /* IN_RING3 */
    53625383#ifdef IN_RING0
  • trunk/include/VBox/vmm/vmm.h

    r68011 r68986  
    237237    DECLR3CALLBACKMEMBER(void, pfnNotifyResetTurnedIntoPowerOff,(PCVMM2USERMETHODS pThis, PUVM pUVM));
    238238
     239    /**
     240     * Generic object query by UUID.
     241     *
     242     * @returns pointer to queried the object on success, NULL if not found.
     243     *
     244     * @param   pThis       Pointer to the callback method table.
     245     * @param   pUVM        The user mode VM handle.
     246     * @param   pUuid       The UUID of what's being queried.  The UUIDs and the
     247     *                      usage conventions are defined by the user.
     248     *
     249     * @remarks This is optional and shall be set to NULL if not wanted.
     250     */
     251    DECLR3CALLBACKMEMBER(void *, pfnQueryGenericObject,(PCVMM2USERMETHODS pThis, PUVM pUVM, PCRTUUID pUuid));
     252
    239253    /** Magic value (VMM2USERMETHODS_MAGIC) marking the end of the structure. */
    240254    uint32_t    u32EndMagic;
     
    244258#define VMM2USERMETHODS_MAGIC         UINT32_C(0x18830703)
    245259/** The VMM2USERMETHODS structure version. */
    246 #define VMM2USERMETHODS_VERSION       UINT32_C(0x00020001)
     260#define VMM2USERMETHODS_VERSION       UINT32_C(0x00030000)
    247261
    248262
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r68979 r68986  
    2035020350        <desc>Progress object to track the operation completion.</desc>
    2035120351      </param>
     20352      <param name="snapshot" type="ISnapshot" dir="in">
     20353        <desc>Snapshot object for which this save state operation is executed.</desc>
     20354      </param>
    2035220355      <param name="stateFilePath" type="wstring" dir="in">
    2035320356        <desc>File path the VM process must save the execution state to.</desc>
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r68944 r68986  
    229229    HRESULT i_pause(Reason_T aReason);
    230230    HRESULT i_resume(Reason_T aReason, AutoWriteLock &alock);
    231     HRESULT i_saveState(Reason_T aReason, const ComPtr<IProgress> &aProgress, const Utf8Str &aStateFilePath, bool fPauseVM, bool &fLeftPaused);
     231    HRESULT i_saveState(Reason_T aReason, const ComPtr<IProgress> &aProgress,
     232                        const ComPtr<ISnapshot> &aSnapshot,
     233                        const Utf8Str &aStateFilePath, bool fPauseVM, bool &fLeftPaused);
    232234    HRESULT i_cancelSaveState();
    233235
     
    777779    static DECLCALLBACK(void)   i_vmm2User_NotifyPdmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM);
    778780    static DECLCALLBACK(void)   i_vmm2User_NotifyResetTurnedIntoPowerOff(PCVMM2USERMETHODS pThis, PUVM pUVM);
     781    static DECLCALLBACK(void *) i_vmm2User_QueryGenericObject(PCVMM2USERMETHODS pThis, PUVM pUVM, PCRTUUID pUuid);
    779782
    780783    static DECLCALLBACK(void *) i_drvStatus_QueryInterface(PPDMIBASE pInterface, const char *pszIID);
     
    909912    {
    910913        Console *pConsole;
     914        /** The in-progress snapshot. */
     915        ISnapshot *pISnapshot;
    911916    } *mpVmm2UserMethods;
    912917
  • trunk/src/VBox/Main/include/SessionImpl.h

    r68485 r68986  
    55
    66/*
    7  * Copyright (C) 2006-2016 Oracle Corporation
     7 * Copyright (C) 2006-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    137137    HRESULT saveStateWithReason(Reason_T aReason,
    138138                                const ComPtr<IProgress> &aProgress,
     139                                const ComPtr<ISnapshot> &aSnapshot,
    139140                                const Utf8Str &aStateFilePath,
    140141                                BOOL aPauseVM,
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r68975 r68986  
    446446    pVmm2UserMethods->pfnNotifyPdmtTerm = Console::i_vmm2User_NotifyPdmtTerm;
    447447    pVmm2UserMethods->pfnNotifyResetTurnedIntoPowerOff = Console::i_vmm2User_NotifyResetTurnedIntoPowerOff;
     448    pVmm2UserMethods->pfnQueryGenericObject = Console::i_vmm2User_QueryGenericObject;
    448449    pVmm2UserMethods->u32EndMagic       = VMM2USERMETHODS_MAGIC;
    449450    pVmm2UserMethods->pConsole          = this;
     
    65766577 * @note Locks this object for writing.
    65776578 */
    6578 HRESULT Console::i_saveState(Reason_T aReason, const ComPtr<IProgress> &aProgress, const Utf8Str &aStateFilePath, bool aPauseVM, bool &aLeftPaused)
     6579HRESULT Console::i_saveState(Reason_T aReason, const ComPtr<IProgress> &aProgress,
     6580                             const ComPtr<ISnapshot> &aSnapshot,
     6581                             const Utf8Str &aStateFilePath, bool aPauseVM, bool &aLeftPaused)
    65796582{
    65806583    LogFlowThisFuncEnter();
     
    65836586    AssertReturn(!aProgress.isNull(), E_INVALIDARG);
    65846587    AssertReturn(!aStateFilePath.isEmpty(), E_INVALIDARG);
     6588    Assert(aSnapshot.isNull() || aReason == Reason_Snapshot);
    65856589
    65866590    AutoCaller autoCaller(this);
     
    66506654    LogFlowFunc(("Saving the state to '%s'...\n", aStateFilePath.c_str()));
    66516655
     6656    mpVmm2UserMethods->pISnapshot = aSnapshot;
    66526657    mptrCancelableProgress = aProgress;
    66536658    alock.release();
     
    66596664                       &aLeftPaused);
    66606665    alock.acquire();
     6666    mpVmm2UserMethods->pISnapshot = NULL;
    66616667    mptrCancelableProgress.setNull();
    66626668    if (RT_FAILURE(vrc))
     
    1033510341}
    1033610342
    10337 
     10343/**
     10344 * @interface_method_impl{VMM2USERMETHODS,pfnQueryGenericObject}
     10345 */
     10346/*static*/ DECLCALLBACK(void *)
     10347Console::i_vmm2User_QueryGenericObject(PCVMM2USERMETHODS pThis, PUVM pUVM, PCRTUUID pUuid)
     10348{
     10349    Console *pConsole = ((MYVMM2USERMETHODS *)pThis)->pConsole;
     10350    NOREF(pUVM);
     10351
     10352    /* To simplify comparison we copy the UUID into a com::Guid object. */
     10353    com::Guid const UuidCopy(*pUuid);
     10354
     10355    if (UuidCopy == COM_IIDOF(IConsole))
     10356    {
     10357        IConsole *pIConsole = static_cast<IConsole *>(pConsole);
     10358        return pIConsole;
     10359    }
     10360
     10361    if (UuidCopy == COM_IIDOF(IMachine))
     10362    {
     10363        IMachine *pIMachine = pConsole->mMachine;
     10364        return pIMachine;
     10365    }
     10366
     10367    if (UuidCopy == COM_IIDOF(ISnapshot))
     10368        return ((MYVMM2USERMETHODS *)pThis)->pISnapshot;
     10369
     10370    return NULL;
     10371}
    1033810372
    1033910373
  • trunk/src/VBox/Main/src-client/SessionImpl.cpp

    r68485 r68986  
    55
    66/*
    7  * Copyright (C) 2006-2016 Oracle Corporation
     7 * Copyright (C) 2006-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    10671067}
    10681068
    1069 HRESULT Session::saveStateWithReason(Reason_T aReason, const ComPtr<IProgress> &aProgress, const Utf8Str &aStateFilePath,
     1069HRESULT Session::saveStateWithReason(Reason_T aReason,
     1070                                     const ComPtr<IProgress> &aProgress,
     1071                                     const ComPtr<ISnapshot> &aSnapshot,
     1072                                     const Utf8Str &aStateFilePath,
    10701073                                     BOOL aPauseVM, BOOL *aLeftPaused)
    10711074{
     
    10771080
    10781081    bool fLeftPaused = false;
    1079     HRESULT rc = mConsole->i_saveState(aReason, aProgress, aStateFilePath, !!aPauseVM, fLeftPaused);
     1082    HRESULT rc = mConsole->i_saveState(aReason, aProgress, aSnapshot, aStateFilePath, !!aPauseVM, fLeftPaused);
    10801083    if (aLeftPaused)
    10811084        *aLeftPaused = fLeftPaused;
    10821085    return rc;
    10831086#else
    1084     RT_NOREF(aReason, aProgress, aStateFilePath, aPauseVM, aLeftPaused);
     1087    RT_NOREF(aReason, aProgress, aSnapshot, aStateFilePath, aPauseVM, aLeftPaused);
    10851088    AssertFailed();
    10861089    return E_NOTIMPL;
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r68956 r68986  
    1298412984        alock.release();
    1298512985        BOOL fSuspendedBySave;
    12986         rc = directControl->SaveStateWithReason(task.m_enmReason, task.m_pProgress, Bstr(task.m_strStateFilePath).raw(), task.m_machineStateBackup != MachineState_Paused, &fSuspendedBySave);
     12986        rc = directControl->SaveStateWithReason(task.m_enmReason, task.m_pProgress, NULL, Bstr(task.m_strStateFilePath).raw(), task.m_machineStateBackup != MachineState_Paused, &fSuspendedBySave);
    1298712987        Assert(!fSuspendedBySave);
    1298812988        alock.acquire();
  • trunk/src/VBox/Main/src-server/SnapshotImpl.cpp

    r67885 r68986  
    17351735                rc = task.m_pDirectControl->SaveStateWithReason(Reason_Snapshot,
    17361736                                                                task.m_pProgress,
     1737                                                                task.m_pSnapshot,
    17371738                                                                Bstr(task.m_strStateFilePath).raw(),
    17381739                                                                task.m_fPause,
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r68594 r68986  
    815815    LogFlow(("pdmR3DevHlp_GetSupDrvSession: caller='%s'/%d: returns %#p\n", pDevIns->pReg->szName, pDevIns->iInstance, pSession));
    816816    return pSession;
     817}
     818
     819
     820/** @interface_method_impl{PDMDEVHLPR3,pfnQueryGenericUserObject} */
     821static DECLCALLBACK(void *) pdmR3DevHlp_QueryGenericUserObject(PPDMDEVINS pDevIns, PCRTUUID pUuid)
     822{
     823    PDMDEV_ASSERT_DEVINS(pDevIns);
     824    LogFlow(("pdmR3DevHlp_QueryGenericUserObject: caller='%s'/%d: pUuid=%p:%RTuuid\n",
     825             pDevIns->pReg->szName, pDevIns->iInstance, pUuid, pUuid));
     826
     827#if defined(DEBUG_bird) || defined(DEBUG_ramshankar) || defined(DEBUG_sunlover) || defined(DEBUG_michael) || defined(DEBUG_andy)
     828    AssertMsgFailed(("'%s' wants %RTuuid - external only interface!\n", pDevIns->pReg->szName, pUuid))
     829#endif
     830
     831    void *pvRet;
     832    PUVM  pUVM = pDevIns->Internal.s.pVMR3->pUVM;
     833    if (pUVM->pVmm2UserMethods->pfnQueryGenericObject)
     834        pvRet = pUVM->pVmm2UserMethods->pfnQueryGenericObject(pUVM->pVmm2UserMethods, pUVM, pUuid);
     835    else
     836        pvRet = NULL;
     837
     838    LogRel(("pdmR3DevHlp_QueryGenericUserObject: caller='%s'/%d: returns %#p for %RTuuid\n",
     839            pDevIns->pReg->szName, pDevIns->iInstance, pvRet, pUuid));
     840    return pvRet;
    817841}
    818842
     
    37283752    pdmR3DevHlp_TMTimeVirtGetNano,
    37293753    pdmR3DevHlp_GetSupDrvSession,
     3754    pdmR3DevHlp_QueryGenericUserObject,
    37303755    PDM_DEVHLPR3_VERSION /* the end */
    37313756};
     
    38613886    AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pReg->szName, pDevIns->iInstance));
    38623887    return (PSUPDRVSESSION)0;
     3888}
     3889
     3890
     3891/** @interface_method_impl{PDMDEVHLPR3,pfnQueryGenericUserObject} */
     3892static DECLCALLBACK(void *) pdmR3DevHlp_Untrusted_QueryGenericUserObject(PPDMDEVINS pDevIns, PCRTUUID pUuid)
     3893{
     3894    PDMDEV_ASSERT_DEVINS(pDevIns);
     3895    AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d %RTuuid\n",
     3896                            pDevIns->pReg->szName, pDevIns->iInstance, pUuid));
     3897    return NULL;
    38633898}
    38643899
     
    39874022    pdmR3DevHlp_TMTimeVirtGetNano,
    39884023    pdmR3DevHlp_Untrusted_GetSupDrvSession,
     4024    pdmR3DevHlp_Untrusted_QueryGenericUserObject,
    39894025    PDM_DEVHLPR3_VERSION /* the end */
    39904026};
Note: See TracChangeset for help on using the changeset viewer.

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