VirtualBox

Changeset 35184 in vbox


Ignore:
Timestamp:
Dec 16, 2010 2:00:55 PM (14 years ago)
Author:
vboxsync
Message:

ExtPack: Changed the installed callback so that it can report back error info and trigger an immediate uninstall ifhoost incompatibilities are found.

Location:
trunk
Files:
4 edited

Legend:

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

    r34287 r35184  
    185185     * This is called in the context of the per-user service (VBoxSVC).
    186186     *
     187     * @returns VBox status code.
     188     * @retval  VERR_EXTPACK_UNSUPPORTED_HOST_UNINSTALL if the extension pack
     189     *          requires some different host version or a prerequisite is
     190     *          missing from the host.  Automatic uninstall will be attempted.
     191     *          Must set error info.
     192     *
    187193     * @param   pThis       Pointer to this structure.
    188194     * @param   pVirtualBox The VirtualBox interface.
    189      */
    190     DECLCALLBACKMEMBER(void, pfnInstalled)(PCVBOXEXTPACKREG pThis, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox);
     195     * @param   pErrInfo    Where to return extended error information.
     196     */
     197    DECLCALLBACKMEMBER(int, pfnInstalled)(PCVBOXEXTPACKREG pThis, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox,
     198                                          PRTERRINFO pErrInfo);
    191199
    192200    /**
     
    198206     * @param   pThis       Pointer to this structure.
    199207     * @param   pVirtualBox The VirtualBox interface.
     208     *
    200209     * @todo    This is currently called holding locks making pVirtualBox
    201210     *          relatively unusable.
     
    319328 *                          be valid and unchanged until the module is unloaded
    320329 *                          (i.e. use some static const data for it).
    321  * @param   pszErr          Error message buffer for explaining any failure.
    322  * @param   cbErr           The size of the error message buffer.
    323  */
    324 typedef DECLCALLBACK(int) FNVBOXEXTPACKREGISTER(PCVBOXEXTPACKHLP pHlp, PCVBOXEXTPACKREG *ppReg, char *pszErr, size_t cbErr);
     330 * @param   pErrInfo        Where to return extended error information.
     331 */
     332typedef DECLCALLBACK(int) FNVBOXEXTPACKREGISTER(PCVBOXEXTPACKHLP pHlp, PCVBOXEXTPACKREG *ppReg, PRTERRINFO pErrInfo);
    325333/** Pointer to a FNVBOXEXTPACKREGISTER. */
    326334typedef FNVBOXEXTPACKREGISTER *PFNVBOXEXTPACKREGISTER;
     
    339347#define VBOXEXTPACK_IS_VER_COMPAT(u32Provider, u32User) \
    340348    (    VBOXEXTPACK_IS_MAJOR_VER_EQUAL(u32Provider, u32User) \
    341       && RT_LOWORD(u32Provider) >= RT_LOWORD(u32User) )
     349      && (int32_t)RT_LOWORD(u32Provider) >= (int32_t)RT_LOWORD(u32User) ) /* stupid casts to shut up gcc */
    342350
    343351/**
  • trunk/include/VBox/err.h

    r33806 r35184  
    16111611 * @{
    16121612 */
    1613 /** CPU hotplug events from VMMDev are not monitored by the guest */
     1613/** CPU hotplug events from VMMDev are not monitored by the guest. */
    16141614#define VERR_CPU_HOTPLUG_NOT_MONITORED_BY_GUEST    (-4700)
    16151615/** @} */
     
    16251625 * @{
    16261626 */
    1627 /** LUN type is not supported */
     1627/** LUN type is not supported. */
    16281628#define VERR_VSCSI_LUN_TYPE_NOT_SUPPORTED           (-4900)
    1629 /** LUN is already/still attached to a device */
     1629/** LUN is already/still attached to a device. */
    16301630#define VERR_VSCSI_LUN_ATTACHED_TO_DEVICE           (-4901)
    1631 /** The specified LUN is invalid */
     1631/** The specified LUN is invalid. */
    16321632#define VERR_VSCSI_LUN_INVALID                      (-4902)
    1633 /** The LUN is not attached to the device */
     1633/** The LUN is not attached to the device. */
    16341634#define VERR_VSCSI_LUN_NOT_ATTACHED                 (-4903)
    16351635/** The LUN is still busy. */
     
    16371637/** @} */
    16381638
    1639 /** @name VBox FAM error codes
    1640  * @{
    1641  */
    1642 /** FAM failed to open a connection */
     1639/** @name VBox FAM Status Codes
     1640 * @{
     1641 */
     1642/** FAM failed to open a connection. */
    16431643#define VERR_FAM_OPEN_FAILED                        (-5000)
    1644 /** FAM failed to add a file to the list to be monitored */
     1644/** FAM failed to add a file to the list to be monitored. */
    16451645#define VERR_FAM_MONITOR_FILE_FAILED                (-5001)
    1646 /** FAM failed to add a directory to the list to be monitored */
     1646/** FAM failed to add a directory to the list to be monitored. */
    16471647#define VERR_FAM_MONITOR_DIRECTORY_FAILED           (-5002)
    1648 /** The connection to the FAM daemon was lost */
     1648/** The connection to the FAM daemon was lost. */
    16491649#define VERR_FAM_CONNECTION_LOST                    (-5003)
    16501650/** @} */
    16511651
     1652/** @name VBox Extension Pack Status Codes
     1653 * @{
     1654 */
     1655/** The host is not supported. Uninstall the extension pack.
     1656 * Returned by the VBOXEXTPACKREG::pfnInstalled. */
     1657#define VERR_EXTPACK_UNSUPPORTED_HOST_UNINSTALL     (-5000)
     1658/** @} */
     1659
    16521660/* SED-END */
    16531661
  • trunk/src/VBox/Main/ExtPackManagerImpl.cpp

    r35152 r35184  
    3838#include <VBox/com/array.h>
    3939#include <VBox/com/ErrorInfo.h>
     40#include <VBox/err.h>
    4041#include <VBox/log.h>
    4142#include <VBox/sup.h>
     
    726727 * @param   a_pVirtualBox       The VirtualBox interface.
    727728 * @param   a_pLock             The write lock held by the caller.
    728  */
    729 bool    ExtPack::callInstalledHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock)
     729 * @param   pErrInfo            Where to return error information.
     730 */
     731bool    ExtPack::callInstalledHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock, PRTERRINFO pErrInfo)
    730732{
    731733    if (   m != NULL
     
    736738            ComPtr<ExtPack> ptrSelfRef = this;
    737739            a_pLock->release();
    738             m->pReg->pfnInstalled(m->pReg, a_pVirtualBox);
     740            pErrInfo->rc = m->pReg->pfnInstalled(m->pReg, a_pVirtualBox, pErrInfo);
    739741            a_pLock->acquire();
    740742            return true;
    741743        }
    742744    }
     745    pErrInfo->rc = VINF_SUCCESS;
    743746    return false;
    744747}
     
    11721175    }
    11731176
     1177    RTERRINFOSTATIC ErrInfo;
     1178    RTErrInfoInitStatic(&ErrInfo);
    11741179    if (fIsNative)
    11751180    {
    1176         char szError[8192];
    1177         vrc = RTLdrLoadEx(m->strMainModPath.c_str(), &m->hMainMod, 0 /*=fFlags*/, szError, sizeof(szError));
     1181        vrc = RTLdrLoadEx(m->strMainModPath.c_str(), &m->hMainMod, 0 /*fFlags*/, &ErrInfo.Core);
    11781182        if (RT_FAILURE(vrc))
    11791183        {
    11801184            m->hMainMod = NIL_RTLDRMOD;
    11811185            m->strWhyUnusable.printf(tr("Failed to locate load the main module ('%s'): %Rrc - %s"),
    1182                                            m->strMainModPath.c_str(), vrc, szError);
     1186                                     m->strMainModPath.c_str(), vrc, ErrInfo.Core.pszMsg);
    11831187            return;
    11841188        }
     
    11971201    if (RT_SUCCESS(vrc))
    11981202    {
    1199         RT_ZERO(szErr);
    1200         vrc = pfnRegistration(&m->Hlp, &m->pReg, szErr, sizeof(szErr) - 16);
     1203        RTErrInfoClear(&ErrInfo.Core);
     1204        vrc = pfnRegistration(&m->Hlp, &m->pReg, &ErrInfo.Core);
    12011205        if (   RT_SUCCESS(vrc)
    1202             && szErr[0] == '\0'
     1206            && !RTErrInfoIsSet(&ErrInfo.Core)
    12031207            && VALID_PTR(m->pReg))
    12041208        {
     
    12331237        }
    12341238        else
    1235         {
    1236             szErr[sizeof(szErr) - 1] = '\0';
    1237             m->strWhyUnusable.printf(tr("%s returned %Rrc, pReg=%p szErr='%s'"),
    1238                                      VBOX_EXTPACK_MAIN_MOD_ENTRY_POINT, vrc, m->pReg, szErr);
    1239         }
     1239            m->strWhyUnusable.printf(tr("%s returned %Rrc, pReg=%p ErrInfo='%s'"),
     1240                                     VBOX_EXTPACK_MAIN_MOD_ENTRY_POINT, vrc, m->pReg, ErrInfo.Core.pszMsg);
    12401241        m->pReg = NULL;
    12411242    }
     
    24882489                if (SUCCEEDED(hrc))
    24892490                {
    2490                     LogRel(("ExtPackManager: Successfully installed extension pack '%s'.\n", pStrName->c_str()));
    2491                     pExtPack->callInstalledHook(m->pVirtualBox, &autoLock);
     2491                    RTERRINFOSTATIC ErrInfo;
     2492                    RTErrInfoInitStatic(&ErrInfo);
     2493                    pExtPack->callInstalledHook(m->pVirtualBox, &autoLock, &ErrInfo.Core);
     2494                    if (RT_SUCCESS(ErrInfo.Core.rc))
     2495                        LogRel(("ExtPackManager: Successfully installed extension pack '%s'.\n", pStrName->c_str()));
     2496                    else
     2497                    {
     2498                        LogRel(("ExtPackManager: Installated hook for '%s' failed: %Rrc - %s\n",
     2499                                pStrName->c_str(), ErrInfo.Core.rc, ErrInfo.Core.pszMsg));
     2500
     2501                        /*
     2502                         * Uninstall the extpack if the error indicates that.
     2503                         */
     2504                        if (ErrInfo.Core.rc == VERR_EXTPACK_UNSUPPORTED_HOST_UNINSTALL)
     2505                            runSetUidToRootHelper("uninstall",
     2506                                                  "--base-dir", m->strBaseDir.c_str(),
     2507                                                  "--name",     pStrName->c_str(),
     2508                                                  "--forced",
     2509                                                  (const char *)NULL);
     2510                        hrc = setError(E_FAIL, tr("The installation hook failed: %Rrc - %s"),
     2511                                       ErrInfo.Core.rc, ErrInfo.Core.pszMsg);
     2512                    }
    24922513                }
    24932514            }
  • trunk/src/VBox/Main/include/ExtPackManagerImpl.h

    r35100 r35184  
    139139    /** @name Internal interfaces used by ExtPackManager.
    140140     * @{ */
    141     bool        callInstalledHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock);
     141    bool        callInstalledHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock, PRTERRINFO pErrInfo);
    142142    HRESULT     callUninstallHookAndClose(IVirtualBox *a_pVirtualBox, bool a_fForcedRemoval);
    143143    bool        callVirtualBoxReadyHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock);
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