VirtualBox

Changeset 68828 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Sep 22, 2017 2:15:57 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
118082
Message:

ExtPack: Split up main module of extension pack, have a mandatory one for VBoxSVC and an optional one for the VM process. This finally eliminates the need to drag VBoxVMM into VBoxSVC on some platforms. Many other small cleanups, including reliably calling the unload hook from within a VM process, copy/paste with forgotten adjustments (e.g. extpacks still talking about skeleton) and spelling fixes.

Location:
trunk/src/VBox/Main
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ExtPackManagerImpl.h

    r63147 r68828  
    55
    66/*
    7  * Copyright (C) 2010-2016 Oracle Corporation
     7 * Copyright (C) 2010-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3131
    3232
    33 #if !defined(VBOX_COM_INPROC)
     33#ifndef VBOX_COM_INPROC
    3434/**
    3535 * An extension pack file.
     
    8787    friend class ExtPackInstallTask;
    8888};
    89 #endif
     89#endif /* !VBOX_COM_INPROC */
    9090
    9191
     
    110110    /** @name Internal interfaces used by ExtPackManager.
    111111     * @{ */
     112#ifndef VBOX_COM_INPROC
    112113    bool        i_callInstalledHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock, PRTERRINFO pErrInfo);
    113114    HRESULT     i_callUninstallHookAndClose(IVirtualBox *a_pVirtualBox, bool a_fForcedRemoval);
    114115    bool        i_callVirtualBoxReadyHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock);
     116#endif
     117#ifdef VBOX_COM_INPROC
    115118    bool        i_callConsoleReadyHook(IConsole *a_pConsole, AutoWriteLock *a_pLock);
     119#endif
     120#ifndef VBOX_COM_INPROC
    116121    bool        i_callVmCreatedHook(IVirtualBox *a_pVirtualBox, IMachine *a_pMachine, AutoWriteLock *a_pLock);
     122#endif
     123#ifdef VBOX_COM_INPROC
    117124    bool        i_callVmConfigureVmmHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc);
    118125    bool        i_callVmPowerOnHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc);
    119126    bool        i_callVmPowerOffHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock);
     127#endif
    120128    HRESULT     i_checkVrde(void);
    121129    HRESULT     i_getVrdpLibraryName(Utf8Str *a_pstrVrdeLibrary);
     
    197205    /** @name Internal interfaces used by other Main classes.
    198206     * @{ */
    199 #if !defined(VBOX_COM_INPROC)
     207#ifndef VBOX_COM_INPROC
    200208    HRESULT     i_doInstall(ExtPackFile *a_pExtPackFile, bool a_fReplace, Utf8Str const *a_pstrDisplayInfo);
    201209    HRESULT     i_doUninstall(const Utf8Str *a_pstrName, bool a_fForcedRemoval, const Utf8Str *a_pstrDisplayInfo);
    202 #endif
    203210    void        i_callAllVirtualBoxReadyHooks(void);
     211#endif
     212#ifdef VBOX_COM_INPROC
    204213    void        i_callAllConsoleReadyHooks(IConsole *a_pConsole);
     214#endif
     215#ifndef VBOX_COM_INPROC
    205216    void        i_callAllVmCreatedHooks(IMachine *a_pMachine);
     217#endif
     218#ifdef VBOX_COM_INPROC
    206219    int         i_callAllVmConfigureVmmHooks(IConsole *a_pConsole, PVM a_pVM);
    207220    int         i_callAllVmPowerOnHooks(IConsole *a_pConsole, PVM a_pVM);
    208221    void        i_callAllVmPowerOffHooks(IConsole *a_pConsole, PVM a_pVM);
     222#endif
    209223    HRESULT     i_checkVrdeExtPack(Utf8Str const *a_pstrExtPack);
    210224    int         i_getVrdeLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary);
  • trunk/src/VBox/Main/include/ExtPackUtil.h

    r62485 r68828  
    55
    66/*
    7  * Copyright (C) 2010-2016 Oracle Corporation
     7 * Copyright (C) 2010-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    100100    /** The name of the main module. */
    101101    RTCString               strMainModule;
     102    /** The name of the main VM module, empty if none. */
     103    RTCString               strMainVMModule;
    102104    /** The name of the VRDE module, empty if none. */
    103105    RTCString               strVrdeModule;
  • trunk/src/VBox/Main/src-all/ExtPackManagerImpl.cpp

    r66294 r68828  
    4646#include "Global.h"
    4747#include "ProgressImpl.h"
    48 #if defined(VBOX_COM_INPROC)
     48#ifdef VBOX_COM_INPROC
    4949# include "ConsoleImpl.h"
    5050#else
     
    8585};
    8686
    87 #if !defined(VBOX_COM_INPROC)
     87#ifndef VBOX_COM_INPROC
    8888/**
    8989 * Private extension pack data.
     
    132132    /** Pointer back to the extension pack object (for Hlp methods). */
    133133    ExtPack            *pThis;
    134     /** The extension pack registration structure. */
     134#ifndef VBOX_COM_INPROC
     135    /** The extension pack main registration structure. */
    135136    PCVBOXEXTPACKREG    pReg;
     137#else
     138    /** The extension pack main VM registration structure. */
     139    PCVBOXEXTPACKVMREG  pReg;
     140#endif
    136141    /** The current context. */
    137142    VBOXEXTPACKCTX      enmContext;
     
    157162    /** The list of installed extension packs. */
    158163    ExtPackList         llInstalledExtPacks;
    159 #if !defined(VBOX_COM_INPROC)
     164#ifndef VBOX_COM_INPROC
    160165    /** Pointer to the VirtualBox object, our parent. */
    161166    VirtualBox         *pVirtualBox;
     
    163168    /** The current context. */
    164169    VBOXEXTPACKCTX      enmContext;
    165 #if !defined(RT_OS_WINDOWS) && !defined(RT_OS_DARWIN)
    166     /** File handle for the VBoxVMM libary which we slurp because ExtPacks depend on it. */
    167     RTLDRMOD            hVBoxVMM;
    168 #endif
    169170
    170171    RTMEMEF_NEW_AND_DELETE_OPERATORS();
    171172};
    172173
    173 #if !defined(VBOX_COM_INPROC)
     174#ifndef VBOX_COM_INPROC
    174175
    175176/**
     
    821822
    822823
     824#ifndef VBOX_COM_INPROC
    823825/**
    824826 * Calls the installed hook.
     
    895897    if (    m != NULL
    896898        &&  m->fUsable
     899        &&  m->hMainMod != NIL_RTLDRMOD
    897900        && !m->fMadeReadyCall)
    898901    {
     
    909912    return false;
    910913}
    911 
     914#endif /* !VBOX_COM_INPROC */
     915
     916#ifdef VBOX_COM_INPROC
    912917/**
    913918 * Calls the pfnConsoleReady hook.
     
    921926    if (    m != NULL
    922927        &&  m->fUsable
     928        &&  m->hMainMod != NIL_RTLDRMOD
    923929        && !m->fMadeReadyCall)
    924930    {
     
    935941    return false;
    936942}
    937 
     943#endif /* VBOX_COM_INPROC */
     944
     945#ifndef VBOX_COM_INPROC
    938946/**
    939947 * Calls the pfnVMCreate hook.
     
    947955{
    948956    if (   m != NULL
     957        && m->hMainMod != NIL_RTLDRMOD
    949958        && m->fUsable)
    950959    {
     
    960969    return false;
    961970}
    962 
     971#endif /* !VBOX_COM_INPROC */
     972
     973#ifdef VBOX_COM_INPROC
    963974/**
    964975 * Calls the pfnVMConfigureVMM hook.
     
    976987    *a_pvrc = VINF_SUCCESS;
    977988    if (   m != NULL
     989        && m->hMainMod != NIL_RTLDRMOD
    978990        && m->fUsable)
    979991    {
     
    10081020    *a_pvrc = VINF_SUCCESS;
    10091021    if (   m != NULL
     1022        && m->hMainMod != NIL_RTLDRMOD
    10101023        && m->fUsable)
    10111024    {
     
    10361049{
    10371050    if (   m != NULL
     1051        && m->hMainMod != NIL_RTLDRMOD
    10381052        && m->fUsable)
    10391053    {
     
    10491063    return false;
    10501064}
     1065#endif /* !VBOX_COM_INPROC */
    10511066
    10521067/**
     
    12851300     * Load the main DLL and call the predefined entry point.
    12861301     */
     1302#ifndef VBOX_COM_INPROC
     1303    const char *pszMainModule = m->Desc.strMainModule.c_str();
     1304#else
     1305    const char *pszMainModule = m->Desc.strMainVMModule.c_str();
     1306    if (m->Desc.strMainVMModule.isEmpty())
     1307    {
     1308        /*
     1309         * We're good! The main module for VM processes is optional.
     1310         */
     1311        m->fUsable = true;
     1312        m->strWhyUnusable.setNull();
     1313        return;
     1314    }
     1315#endif
    12871316    bool fIsNative;
    1288     if (!i_findModule(m->Desc.strMainModule.c_str(), NULL /* default extension */, VBOXEXTPACKMODKIND_R3,
     1317    if (!i_findModule(pszMainModule, NULL /* default extension */, VBOXEXTPACKMODKIND_R3,
    12891318                      &m->strMainModPath, &fIsNative, &m->ObjInfoMainMod))
    12901319    {
    1291         m->strWhyUnusable.printf(tr("Failed to locate the main module ('%s')"), m->Desc.strMainModule.c_str());
     1320        m->strWhyUnusable.printf(tr("Failed to locate the main module ('%s')"), pszMainModule);
    12921321        return;
    12931322    }
     
    13201349     * Resolve the predefined entry point.
    13211350     */
     1351#ifndef VBOX_COM_INPROC
     1352    const char *pszMainEntryPoint = VBOX_EXTPACK_MAIN_MOD_ENTRY_POINT;
    13221353    PFNVBOXEXTPACKREGISTER pfnRegistration;
    1323     vrc = RTLdrGetSymbol(m->hMainMod, VBOX_EXTPACK_MAIN_MOD_ENTRY_POINT, (void **)&pfnRegistration);
     1354    uint32_t uVersion = VBOXEXTPACKREG_VERSION;
     1355#else
     1356    const char *pszMainEntryPoint = VBOX_EXTPACK_MAIN_VM_MOD_ENTRY_POINT;
     1357    PFNVBOXEXTPACKVMREGISTER pfnRegistration;
     1358    uint32_t uVersion = VBOXEXTPACKVMREG_VERSION;
     1359#endif
     1360    vrc = RTLdrGetSymbol(m->hMainMod, pszMainEntryPoint, (void **)&pfnRegistration);
    13241361    if (RT_SUCCESS(vrc))
    13251362    {
     
    13301367            && VALID_PTR(m->pReg))
    13311368        {
    1332             if (   VBOXEXTPACK_IS_MAJOR_VER_EQUAL(m->pReg->u32Version, VBOXEXTPACKREG_VERSION)
     1369            if (   VBOXEXTPACK_IS_MAJOR_VER_EQUAL(m->pReg->u32Version, uVersion)
    13331370                && m->pReg->u32EndMarker == m->pReg->u32Version)
    13341371            {
     1372#ifndef VBOX_COM_INPROC
    13351373                if (   (!m->pReg->pfnInstalled       || RT_VALID_PTR(m->pReg->pfnInstalled))
    13361374                    && (!m->pReg->pfnUninstall       || RT_VALID_PTR(m->pReg->pfnUninstall))
    13371375                    && (!m->pReg->pfnVirtualBoxReady || RT_VALID_PTR(m->pReg->pfnVirtualBoxReady))
    1338                     && (!m->pReg->pfnConsoleReady    || RT_VALID_PTR(m->pReg->pfnConsoleReady))
    13391376                    && (!m->pReg->pfnUnload          || RT_VALID_PTR(m->pReg->pfnUnload))
    13401377                    && (!m->pReg->pfnVMCreated       || RT_VALID_PTR(m->pReg->pfnVMCreated))
     1378                    && (!m->pReg->pfnQueryObject     || RT_VALID_PTR(m->pReg->pfnQueryObject))
     1379                    )
     1380                {
     1381                    /*
     1382                     * We're good!
     1383                     */
     1384                    m->fUsable = true;
     1385                    m->strWhyUnusable.setNull();
     1386                    return;
     1387                }
     1388#else
     1389                if (   (!m->pReg->pfnConsoleReady    || RT_VALID_PTR(m->pReg->pfnConsoleReady))
     1390                    && (!m->pReg->pfnUnload          || RT_VALID_PTR(m->pReg->pfnUnload))
    13411391                    && (!m->pReg->pfnVMConfigureVMM  || RT_VALID_PTR(m->pReg->pfnVMConfigureVMM))
    13421392                    && (!m->pReg->pfnVMPowerOn       || RT_VALID_PTR(m->pReg->pfnVMPowerOn))
     
    13521402                    return;
    13531403                }
    1354 
    1355                 m->strWhyUnusable = tr("The registration structure contains on or more invalid function pointers");
     1404#endif
     1405
     1406                m->strWhyUnusable = tr("The registration structure contains one or more invalid function pointers");
    13561407            }
    13571408            else
     
    13611412        else
    13621413            m->strWhyUnusable.printf(tr("%s returned %Rrc, pReg=%p ErrInfo='%s'"),
    1363                                      VBOX_EXTPACK_MAIN_MOD_ENTRY_POINT, vrc, m->pReg, ErrInfo.Core.pszMsg);
     1414                                     pszMainEntryPoint, vrc, m->pReg, ErrInfo.Core.pszMsg);
    13641415        m->pReg = NULL;
    13651416    }
    13661417    else
    13671418        m->strWhyUnusable.printf(tr("Failed to resolve exported symbol '%s' in the main module: %Rrc"),
    1368                                  VBOX_EXTPACK_MAIN_MOD_ENTRY_POINT, vrc);
     1419                                 pszMainEntryPoint, vrc);
    13691420
    13701421    RTLdrClose(m->hMainMod);
     
    19041955#else
    19051956    RT_NOREF_PV(a_pVirtualBox);
    1906 #endif
    1907 
    1908     /*
    1909      * Slurp in VBoxVMM which is used by VBoxPuelMain.
    1910      */
    1911 #if !defined(RT_OS_WINDOWS) && !defined(RT_OS_DARWIN)
    1912     if (a_enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON)
    1913     {
    1914         int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxVMM", &m->hVBoxVMM, RTLDRLOAD_FLAGS_GLOBAL, NULL);
    1915         if (RT_FAILURE(vrc))
    1916             m->hVBoxVMM = NIL_RTLDRMOD;
    1917         /* cleanup in ::uninit()? */
    1918     }
    19191957#endif
    19201958
     
    20432081    AssertReturn(m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON, E_UNEXPECTED);
    20442082
    2045 #if !defined(VBOX_COM_INPROC)
     2083#ifndef VBOX_COM_INPROC
    20462084    /* The API can optionally take a ::SHA-256=<hex-digest> attribute at the
    20472085       end of the file name.  This is just a temporary measure for
     
    20772115    Assert(m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON);
    20782116
    2079 #if !defined(VBOX_COM_INPROC)
     2117#ifndef VBOX_COM_INPROC
    20802118
    20812119    HRESULT hrc;
     
    24362474}
    24372475
    2438 #if !defined(VBOX_COM_INPROC)
     2476#ifndef VBOX_COM_INPROC
    24392477
    24402478/**
     
    28592897#endif /* !VBOX_COM_INPROC */
    28602898
     2899#ifdef VBOX_COM_INPROC
    28612900/**
    28622901 * Calls the pfnConsoleReady hook for all working extension packs.
     
    28842923    }
    28852924}
    2886 
    2887 #if !defined(VBOX_COM_INPROC)
     2925#endif
     2926
     2927#ifndef VBOX_COM_INPROC
    28882928/**
    28892929 * Calls the pfnVMCreated hook for all working extension packs.
     
    29062946#endif
    29072947
     2948#ifdef VBOX_COM_INPROC
    29082949/**
    29092950 * Calls the pfnVMConfigureVMM hook for all working extension packs.
     
    29833024        (*it)->i_callVmPowerOffHook(a_pConsole, a_pVM, &autoLock);
    29843025}
     3026#endif
    29853027
    29863028
  • trunk/src/VBox/Main/src-all/ExtPackUtil.cpp

    r65088 r68828  
    55
    66/*
    7  * Copyright (C) 2010-2016 Oracle Corporation
     7 * Copyright (C) 2010-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    7474    a_pExtPackDesc->uRevision = 0;
    7575    a_pExtPackDesc->strMainModule.setNull();
     76    a_pExtPackDesc->strMainVMModule.setNull();
    7677    a_pExtPackDesc->strVrdeModule.setNull();
    7778    a_pExtPackDesc->cPlugIns = 0;
     
    164165
    165166    /*
     167     * The main VM module, optional.
     168     * Accept both none and empty as tokens of no main VM module.
     169     */
     170    const char *pszMainVMModule = NULL;
     171    const xml::ElementNode *pMainVMModuleElm = pVBoxExtPackElm->findChildElement("MainVMModule");
     172    if (pMainVMModuleElm)
     173    {
     174        pszMainVMModule = pMainVMModuleElm->getValue();
     175        if (!pszMainVMModule || *pszMainVMModule == '\0')
     176            pszMainVMModule = NULL;
     177        else if (!VBoxExtPackIsValidModuleString(pszMainVMModule))
     178            return &(new RTCString("Invalid main VM module string: "))->append(pszMainVMModule);
     179    }
     180
     181    /*
    166182     * The VRDE module, optional.
    167183     * Accept both none and empty as tokens of no VRDE module.
     
    205221    a_pExtPackDesc->uRevision       = uRevision;
    206222    a_pExtPackDesc->strMainModule   = pszMainModule;
     223    a_pExtPackDesc->strMainVMModule = pszMainVMModule;
    207224    a_pExtPackDesc->strVrdeModule   = pszVrdeModule;
    208225    a_pExtPackDesc->cPlugIns        = cPlugIns;
     
    362379    a_pExtPackDesc->uRevision = 0;
    363380    a_pExtPackDesc->strMainModule.setNull();
     381    a_pExtPackDesc->strMainVMModule.setNull();
    364382    a_pExtPackDesc->strVrdeModule.setNull();
    365383    a_pExtPackDesc->cPlugIns = 0;
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r68804 r68828  
    825825    // we don't perform uninit() as it's possible that some pending event refers to this source
    826826    unconst(mEventSource).setNull();
     827
     828#ifdef VBOX_WITH_EXTPACK
     829    unconst(mptrExtPackManager).setNull();
     830#endif
    827831
    828832    LogFlowThisFuncLeave();
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