VirtualBox

Changeset 52596 in vbox


Ignore:
Timestamp:
Sep 4, 2014 4:45:50 PM (10 years ago)
Author:
vboxsync
Message:

Storage/VD + Main/ExtPackManager+VirtualBox+SystemProperties: restructure previous change to fit better into the extpack design (using existing hooks) by using two new extpack helper functions

Location:
trunk
Files:
7 edited

Legend:

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

    r48313 r52596  
    44
    55/*
    6  * Copyright (C) 2010-2013 Oracle Corporation
     6 * Copyright (C) 2010-2014 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    150150    DECLR3CALLBACKMEMBER(VBOXEXTPACKCTX, pfnGetContext,(PCVBOXEXTPACKHLP pHlp));
    151151
     152    /**
     153     * Loads a HGCM service provided by an extension pack.
     154     *
     155     * @returns VBox status code.
     156     * @param   pHlp            Pointer to this helper structure.
     157     * @param   pConsole        Pointer to the VM's console object.
     158     * @param   pszServiceLibrary Name of the library file containing the
     159     *                          service implementation, without extension.
     160     * @param   pszServiceName  Name of HGCM service.
     161     */
    152162    DECLR3CALLBACKMEMBER(int, pfnLoadHGCMService,(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IConsole) *pConsole,
    153163                                                  const char *pszServiceLibrary, const char *pszServiceName));
     164
     165    /**
     166     * Loads a VD plugin provided by an extension pack.
     167     *
     168     * This makes sense only in the context of the per-user service (VBoxSVC).
     169     *
     170     * @returns VBox status code.
     171     * @param   pHlp            Pointer to this helper structure.
     172     * @param   pVirtualBox     Pointer to the VirtualBox object.
     173     * @param   pszPluginLibrary Name of the library file containing the plugin
     174     *                          implementation, without extension.
     175     */
     176    DECLR3CALLBACKMEMBER(int, pfnLoadVDPlugin,(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox,
     177                                               const char *pszPluginLibrary));
     178
     179    /**
     180     * Unloads a VD plugin provided by an extension pack.
     181     *
     182     * This makes sense only in the context of the per-user service (VBoxSVC).
     183     *
     184     * @returns VBox status code.
     185     * @param   pHlp            Pointer to this helper structure.
     186     * @param   pVirtualBox     Pointer to the VirtualBox object.
     187     * @param   pszPluginLibrary Name of the library file containing the plugin
     188     *                          implementation, without extension.
     189     */
     190    DECLR3CALLBACKMEMBER(int, pfnUnloadVDPlugin,(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox,
     191                                                 const char *pszPluginLibrary));
    154192
    155193    DECLR3CALLBACKMEMBER(int, pfnReserved1,(PCVBOXEXTPACKHLP pHlp)); /**< Reserved for minor structure revisions. */
     
    159197    DECLR3CALLBACKMEMBER(int, pfnReserved5,(PCVBOXEXTPACKHLP pHlp)); /**< Reserved for minor structure revisions. */
    160198    DECLR3CALLBACKMEMBER(int, pfnReserved6,(PCVBOXEXTPACKHLP pHlp)); /**< Reserved for minor structure revisions. */
    161     DECLR3CALLBACKMEMBER(int, pfnReserved7,(PCVBOXEXTPACKHLP pHlp)); /**< Reserved for minor structure revisions. */
    162     DECLR3CALLBACKMEMBER(int, pfnReserved8,(PCVBOXEXTPACKHLP pHlp)); /**< Reserved for minor structure revisions. */
    163199
    164200    /** End of structure marker (VBOXEXTPACKHLP_VERSION). */
     
    166202} VBOXEXTPACKHLP;
    167203/** Current version of the VBOXEXTPACKHLP structure.  */
    168 #define VBOXEXTPACKHLP_VERSION          RT_MAKE_U32(1, 1)
     204#define VBOXEXTPACKHLP_VERSION          RT_MAKE_U32(2, 1)
    169205
    170206
  • trunk/src/VBox/Main/include/ExtPackManagerImpl.h

    r50914 r52596  
    55
    66/*
    7  * Copyright (C) 2010-2013 Oracle Corporation
     7 * Copyright (C) 2010-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    135135    static DECLCALLBACK(VBOXEXTPACKCTX) i_hlpGetContext(PCVBOXEXTPACKHLP pHlp);
    136136    static DECLCALLBACK(int)    i_hlpLoadHGCMService(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IConsole) *pConsole, const char *pszServiceLibrary, const char *pszServiceName);
     137    static DECLCALLBACK(int)    i_hlpLoadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary);
     138    static DECLCALLBACK(int)    i_hlpUnloadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary);
    137139    static DECLCALLBACK(int)    i_hlpReservedN(PCVBOXEXTPACKHLP pHlp);
    138140    /** @}  */
  • trunk/src/VBox/Main/include/SystemPropertiesImpl.h

    r52585 r52596  
    5353    ComObjPtr<MediumFormat> i_mediumFormatFromExtension(const Utf8Str &aExt);
    5454
    55     void i_extPackInstallNotify(const char *pszExtPackName);
    56     void i_extPackUninstallNotify(const char *pszExtPackName);
     55    int i_loadVDPlugin(const char *pszPluginLibrary);
     56    int i_unloadVDPlugin(const char *pszPluginLibrary);
    5757
    5858private:
     
    129129                                               ULONG *aMaxInstances);
    130130
    131     HRESULT i_loadExtPackVDPluginCrypt();
    132     HRESULT i_unloadExtPackVDPluginCrypt();
    133 
    134131    HRESULT i_getUserHomeDirectory(Utf8Str &strPath);
    135132    HRESULT i_setDefaultMachineFolder(const Utf8Str &strPath);
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r52585 r52596  
    128128    void i_updateClientWatcher();
    129129
    130     void i_extPackInstallNotify(const char *pszExtPackName);
    131     void i_extPackUninstallNotify(const char *pszExtPackName);
     130    int i_loadVDPlugin(const char *pszPluginLibrary);
     131    int i_unloadVDPlugin(const char *pszPluginLibrary);
    132132
    133133    void i_onMachineStateChange(const Guid &aId, MachineState_T aState);
  • trunk/src/VBox/Main/src-all/ExtPackManagerImpl.cpp

    r52585 r52596  
    684684        /* pfnGetContext        = */ ExtPack::i_hlpGetContext,
    685685        /* pfnLoadHGCMService   = */ ExtPack::i_hlpLoadHGCMService,
     686        /* pfnLoadVDPlugin      = */ ExtPack::i_hlpLoadVDPlugin,
     687        /* pfnUnloadVDPlugin    = */ ExtPack::i_hlpUnloadVDPlugin,
    686688        /* pfnReserved1         = */ ExtPack::i_hlpReservedN,
    687689        /* pfnReserved2         = */ ExtPack::i_hlpReservedN,
     
    690692        /* pfnReserved5         = */ ExtPack::i_hlpReservedN,
    691693        /* pfnReserved6         = */ ExtPack::i_hlpReservedN,
    692         /* pfnReserved7         = */ ExtPack::i_hlpReservedN,
    693         /* pfnReserved8         = */ ExtPack::i_hlpReservedN,
    694694        /* u32EndMarker         = */ VBOXEXTPACKHLP_VERSION
    695695    };
     
    15601560#else
    15611561    NOREF(pHlp); NOREF(pConsole); NOREF(pszServiceLibrary); NOREF(pszServiceName);
     1562#endif
     1563    return VERR_INVALID_STATE;
     1564}
     1565
     1566/*static*/ DECLCALLBACK(int)
     1567ExtPack::i_hlpLoadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary)
     1568{
     1569#ifndef VBOX_COM_INPROC
     1570    /*
     1571     * Validate the input and get our bearings.
     1572     */
     1573    AssertPtrReturn(pszPluginLibrary, VERR_INVALID_POINTER);
     1574
     1575    AssertPtrReturn(pHlp, VERR_INVALID_POINTER);
     1576    AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VERR_INVALID_POINTER);
     1577    ExtPack::Data *m = RT_FROM_CPP_MEMBER(pHlp, Data, Hlp);
     1578    AssertPtrReturn(m, VERR_INVALID_POINTER);
     1579    ExtPack *pThis = m->pThis;
     1580    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
     1581    AssertPtrReturn(pVirtualBox, VERR_INVALID_POINTER);
     1582
     1583    VirtualBox *pVBox = (VirtualBox *)pVirtualBox;
     1584    return pVBox->i_loadVDPlugin(pszPluginLibrary);
     1585#else
     1586    NOREF(pHlp); NOREF(pVirtualBox);
     1587#endif
     1588    return VERR_INVALID_STATE;
     1589}
     1590
     1591/*static*/ DECLCALLBACK(int)
     1592ExtPack::i_hlpUnloadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary)
     1593{
     1594#ifndef VBOX_COM_INPROC
     1595    /*
     1596     * Validate the input and get our bearings.
     1597     */
     1598    AssertPtrReturn(pszPluginLibrary, VERR_INVALID_POINTER);
     1599
     1600    AssertPtrReturn(pHlp, VERR_INVALID_POINTER);
     1601    AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VERR_INVALID_POINTER);
     1602    ExtPack::Data *m = RT_FROM_CPP_MEMBER(pHlp, Data, Hlp);
     1603    AssertPtrReturn(m, VERR_INVALID_POINTER);
     1604    ExtPack *pThis = m->pThis;
     1605    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
     1606    AssertPtrReturn(pVirtualBox, VERR_INVALID_POINTER);
     1607
     1608    VirtualBox *pVBox = (VirtualBox *)pVirtualBox;
     1609    return pVBox->i_unloadVDPlugin(pszPluginLibrary);
     1610#else
     1611    NOREF(pHlp); NOREF(pVirtualBox);
    15621612#endif
    15631613    return VERR_INVALID_STATE;
     
    25302580        {
    25312581            if (pExtPack && a_fReplace)
    2532             {
    2533                 m->pVirtualBox->i_extPackUninstallNotify(pStrName->c_str());
    25342582                hrc = pExtPack->i_callUninstallHookAndClose(m->pVirtualBox, false /*a_ForcedRemoval*/);
    2535             }
    25362583            else if (pExtPack)
    25372584                hrc = setError(E_FAIL,
     
    25652612                    pExtPack->i_callInstalledHook(m->pVirtualBox, &autoLock, &ErrInfo.Core);
    25662613                    if (RT_SUCCESS(ErrInfo.Core.rc))
    2567                     {
    25682614                        LogRel(("ExtPackManager: Successfully installed extension pack '%s'.\n", pStrName->c_str()));
    2569                         m->pVirtualBox->i_extPackInstallNotify(pStrName->c_str());
    2570                     }
    25712615                    else
    25722616                    {
     
    26712715                 * Call the uninstall hook and unload the main dll.
    26722716                 */
    2673                 m->pVirtualBox->i_extPackUninstallNotify(a_pstrName->c_str());
    26742717                hrc = pExtPack->i_callUninstallHookAndClose(m->pVirtualBox, a_fForcedRemoval);
    26752718                if (SUCCEEDED(hrc))
  • trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp

    r52585 r52596  
    4444/////////////////////////////////////////////////////////////////////////////
    4545
    46 // globals
    47 /////////////////////////////////////////////////////////////////////////////
    48 static const Utf8Str g_strExtPackPuel("Oracle VM VirtualBox Extension Pack");
    49 static const char *g_pszVDPluginCrypt = "VDPluginCrypt";
    50 
    5146// constructor / destructor
    5247/////////////////////////////////////////////////////////////////////////////
     
    117112
    118113    HRESULT rc = S_OK;
    119 
    120     /* Load all VD plugins from all extension packs first. */
    121     /** @todo: Make generic for 4.4 (requires interface changes). */
    122     rc = i_loadExtPackVDPluginCrypt();
    123114
    124115    /* Fetch info of all available hd backends. */
     
    11191110
    11201111/**
    1121  * Extension pack install notification
     1112 * VD plugin load
    11221113 */
    1123 void SystemProperties::i_extPackInstallNotify(const char *pszExtPackName)
    1124 {
    1125     if (g_strExtPackPuel.equals(pszExtPackName))
    1126     {
    1127         i_loadExtPackVDPluginCrypt();
    1128     }
     1114int SystemProperties::i_loadVDPlugin(const char *pszPluginLibrary)
     1115{
     1116    return VDPluginLoadFromFilename(pszPluginLibrary);
    11291117}
    11301118
    11311119/**
    1132  * Extension pack uninstall notification
     1120 * VD plugin unload
    11331121 */
    1134 void SystemProperties::i_extPackUninstallNotify(const char *pszExtPackName)
    1135 {
    1136     if (g_strExtPackPuel.equals(pszExtPackName))
    1137     {
    1138         i_unloadExtPackVDPluginCrypt();
    1139     }
    1140 }
    1141 
    1142 HRESULT SystemProperties::i_loadExtPackVDPluginCrypt()
    1143 {
    1144     HRESULT rc = S_OK;
    1145 #ifdef VBOX_WITH_EXTPACK
    1146     if (mParent->i_getExtPackManager()->i_isExtPackUsable(g_strExtPackPuel.c_str()))
    1147     {
    1148         Utf8Str strPlugin;
    1149         rc = mParent->i_getExtPackManager()->i_getLibraryPathForExtPack(g_pszVDPluginCrypt, &g_strExtPackPuel, &strPlugin);
    1150         if (SUCCEEDED(rc))
    1151         {
    1152             int vrc = VDPluginLoadFromFilename(strPlugin.c_str());
    1153             NOREF(vrc); /** @todo: don't ignore errors. */
    1154         }
    1155         else
    1156             rc = S_OK; /* ignore errors */
    1157     }
    1158 # endif
    1159     return rc;
    1160 }
    1161 
    1162 HRESULT SystemProperties::i_unloadExtPackVDPluginCrypt()
    1163 {
    1164     HRESULT rc = S_OK;
    1165 #ifdef VBOX_WITH_EXTPACK
    1166     Utf8Str strPlugin;
    1167     rc = mParent->i_getExtPackManager()->i_getLibraryPathForExtPack(g_pszVDPluginCrypt, &g_strExtPackPuel, &strPlugin);
    1168     if (SUCCEEDED(rc))
    1169     {
    1170         int vrc = VDPluginUnloadFromFilename(strPlugin.c_str());
    1171         NOREF(vrc); /** @todo: don't ignore errors. */
    1172     }
    1173     else
    1174         rc = S_OK; /* ignore errors */
    1175 # endif
    1176     return rc;
     1122int SystemProperties::i_unloadVDPlugin(const char *pszPluginLibrary)
     1123{
     1124    return VDPluginUnloadFromFilename(pszPluginLibrary);
    11771125}
    11781126
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r52585 r52596  
    13711371          0xa0, 0xd7af, '\0' };
    13721372    char *pszName = strName.mutableRaw();
    1373     int cReplacements = RTStrPurgeComplementSet(pszName, aCpSet, '_');
     1373    ssize_t cReplacements = RTStrPurgeComplementSet(pszName, aCpSet, '_');
    13741374    Assert(cReplacements >= 0);
    13751375    NOREF(cReplacements);
     
    26372637
    26382638/**
    2639  * Extpack install notification
    2640  */
    2641 void VirtualBox::i_extPackInstallNotify(const char *pszExtPackName)
    2642 {
    2643     m->pSystemProperties->i_extPackInstallNotify(pszExtPackName);
    2644 }
    2645 
    2646 /**
    2647  * Extpack uninstall notification
    2648  */
    2649 void VirtualBox::i_extPackUninstallNotify(const char *pszExtPackName)
    2650 {
    2651     m->pSystemProperties->i_extPackUninstallNotify(pszExtPackName);
     2639 * VD plugin load
     2640 */
     2641int VirtualBox::i_loadVDPlugin(const char *pszPluginLibrary)
     2642{
     2643    return m->pSystemProperties->i_loadVDPlugin(pszPluginLibrary);
     2644}
     2645
     2646/**
     2647 * VD plugin unload
     2648 */
     2649int VirtualBox::i_unloadVDPlugin(const char *pszPluginLibrary)
     2650{
     2651    return m->pSystemProperties->i_unloadVDPlugin(pszPluginLibrary);
    26522652}
    26532653
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