VirtualBox

Changeset 75955 in vbox


Ignore:
Timestamp:
Dec 4, 2018 9:08:55 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
127171
Message:

Main: Load VBoxGuestPropSvc from the VMMDev driver.

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

Legend:

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

    r75853 r75955  
    291291     *
    292292     * @returns COM status code.
    293      * @þaram   strCfg    The config for the disks.
    294      *
    295      * @note: One line in the config string contains all required data for one disk.
     293     * @param   strCfg    The config for the disks.
     294     *
     295     * @note  One line in the config string contains all required data for one disk.
    296296     *        The format for one disk is some sort of comma separated value using
    297297     *        key=value pairs.
     
    302302     */
    303303    HRESULT i_setDiskEncryptionKeys(const Utf8Str &strCfg);
     304
     305
     306#ifdef VBOX_WITH_GUEST_PROPS
     307    // VMMDev needs:
     308    HRESULT                     i_pullGuestProperties(ComSafeArrayOut(BSTR, names), ComSafeArrayOut(BSTR, values),
     309                                                      ComSafeArrayOut(LONG64, timestamps), ComSafeArrayOut(BSTR, flags));
     310    static DECLCALLBACK(int)    i_doGuestPropNotification(void *pvExtension, uint32_t, void *pvParms, uint32_t cbParms);
     311#endif
    304312
    305313private:
     
    739747                        bool fAttachDetach, bool fIgnoreConnectFailure);
    740748    int i_configSerialPort(PCFGMNODE pInst, PortMode_T ePortMode, const char *pszPath, bool fServer);
    741     static DECLCALLBACK(int) i_configGuestProperties(void *pvConsole);
    742749    static DECLCALLBACK(void) i_vmstateChangeCallback(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
    743750    static DECLCALLBACK(int) i_unplugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu);
     
    836843
    837844#ifdef VBOX_WITH_GUEST_PROPS
    838     static DECLCALLBACK(int)    i_doGuestPropNotification(void *pvExtension, uint32_t, void *pvParms, uint32_t cbParms);
    839845    HRESULT                     i_doEnumerateGuestProperties(const Utf8Str &aPatterns,
    840846                                                             std::vector<Utf8Str> &aNames,
  • trunk/src/VBox/Main/include/VMMDev.h

    r75574 r75955  
    5959    int hgcmLoadService (const char *pszServiceLibrary, const char *pszServiceName);
    6060    int hgcmHostCall (const char *pszServiceName, uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms);
    61 #ifdef VBOX_WITH_CRHGSMI
     61# ifdef VBOX_WITH_CRHGSMI
    6262    int hgcmHostSvcHandleCreate (const char *pszServiceName, HGCMCVSHANDLE * phSvc);
    6363    int hgcmHostSvcHandleDestroy (HGCMCVSHANDLE hSvc);
    6464    int hgcmHostFastCallAsync (HGCMCVSHANDLE hSvc, uint32_t function, PVBOXHGCMSVCPARM pParm, PHGCMHOSTFASTCALLCB pfnCompletion, void *pvCompletion);
    65 #endif
     65# endif
    6666    void hgcmShutdown(bool fUvmIsInvalid = false);
    6767
     
    7070
    7171private:
     72#ifdef VBOX_WITH_HGCM
     73# ifdef VBOX_WITH_GUEST_PROPS
     74    void i_guestPropSetMultiple(void *names, void *values, void *timestamps, void *flags);
     75    void i_guestPropSet(const char *pszName, const char *pszValue, const char *pszFlags);
     76    int  i_guestPropSetGlobalPropertyFlags(uint32_t fFlags);
     77    int  i_guestPropLoadAndConfigure();
     78# endif
     79#endif
     80
    7281    static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
    7382    static DECLCALLBACK(int)    drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r75926 r75955  
    835835
    836836#ifdef VBOX_WITH_GUEST_PROPS
     837
     838/**
     839 * Wrapper for VMMDev::i_guestPropertiesHandleVMReset
     840 */
     841HRESULT Console::i_pullGuestProperties(ComSafeArrayOut(BSTR, names), ComSafeArrayOut(BSTR, values),
     842                                       ComSafeArrayOut(LONG64, timestamps), ComSafeArrayOut(BSTR, flags))
     843{
     844    AssertReturn(mControl.isNotNull(), VERR_INVALID_POINTER);
     845    return mControl->PullGuestProperties(ComSafeArrayOutArg(names), ComSafeArrayOutArg(values),
     846                                         ComSafeArrayOutArg(timestamps), ComSafeArrayOutArg(flags));
     847}
    837848
    838849/**
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r75853 r75955  
    31853185            }
    31863186        }
    3187 #endif
    3188 
    3189 #ifdef VBOX_WITH_GUEST_PROPS
    3190         /*
    3191          * Guest property service.
    3192          */
    3193         rc = i_configGuestProperties(this);
    31943187#endif
    31953188
     
    60005993}
    60015994
    6002 
    6003 #ifdef VBOX_WITH_GUEST_PROPS
    6004 
    6005 /**
    6006  * Set an array of guest properties
    6007  */
    6008 static void configSetProperties(VMMDev * const pVMMDev,
    6009                                 void *names,
    6010                                 void *values,
    6011                                 void *timestamps,
    6012                                 void *flags)
    6013 {
    6014     VBOXHGCMSVCPARM parms[4];
    6015 
    6016     parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
    6017     parms[0].u.pointer.addr = names;
    6018     parms[0].u.pointer.size = 0;  /* We don't actually care. */
    6019     parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
    6020     parms[1].u.pointer.addr = values;
    6021     parms[1].u.pointer.size = 0;  /* We don't actually care. */
    6022     parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
    6023     parms[2].u.pointer.addr = timestamps;
    6024     parms[2].u.pointer.size = 0;  /* We don't actually care. */
    6025     parms[3].type = VBOX_HGCM_SVC_PARM_PTR;
    6026     parms[3].u.pointer.addr = flags;
    6027     parms[3].u.pointer.size = 0;  /* We don't actually care. */
    6028 
    6029     pVMMDev->hgcmHostCall("VBoxGuestPropSvc", GUEST_PROP_FN_HOST_SET_PROPS, 4, &parms[0]);
    6030 }
    6031 
    6032 /**
    6033  * Set a single guest property
    6034  */
    6035 static void configSetProperty(VMMDev * const pVMMDev,
    6036                               const char *pszName,
    6037                               const char *pszValue,
    6038                               const char *pszFlags)
    6039 {
    6040     VBOXHGCMSVCPARM parms[4];
    6041 
    6042     AssertPtrReturnVoid(pszName);
    6043     AssertPtrReturnVoid(pszValue);
    6044     AssertPtrReturnVoid(pszFlags);
    6045     parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
    6046     parms[0].u.pointer.addr = (void *)pszName;
    6047     parms[0].u.pointer.size = (uint32_t)strlen(pszName) + 1;
    6048     parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
    6049     parms[1].u.pointer.addr = (void *)pszValue;
    6050     parms[1].u.pointer.size = (uint32_t)strlen(pszValue) + 1;
    6051     parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
    6052     parms[2].u.pointer.addr = (void *)pszFlags;
    6053     parms[2].u.pointer.size = (uint32_t)strlen(pszFlags) + 1;
    6054     pVMMDev->hgcmHostCall("VBoxGuestPropSvc", GUEST_PROP_FN_HOST_SET_PROP, 3, &parms[0]);
    6055 }
    6056 
    6057 /**
    6058  * Set the global flags value by calling the service
    6059  * @returns the status returned by the call to the service
    6060  *
    6061  * @param   pTable  the service instance handle
    6062  * @param   eFlags  the flags to set
    6063  */
    6064 int configSetGlobalPropertyFlags(VMMDev * const pVMMDev, uint32_t fFlags)
    6065 {
    6066     VBOXHGCMSVCPARM parm;
    6067     HGCMSvcSetU32(&parm, fFlags);
    6068     int rc = pVMMDev->hgcmHostCall("VBoxGuestPropSvc", GUEST_PROP_FN_HOST_SET_GLOBAL_FLAGS, 1, &parm);
    6069     if (RT_FAILURE(rc))
    6070     {
    6071         char szFlags[GUEST_PROP_MAX_FLAGS_LEN];
    6072         if (RT_FAILURE(GuestPropWriteFlags(fFlags, szFlags)))
    6073             Log(("Failed to set the global flags.\n"));
    6074         else
    6075             Log(("Failed to set the global flags \"%s\".\n", szFlags));
    6076     }
    6077     return rc;
    6078 }
    6079 
    6080 #endif /* VBOX_WITH_GUEST_PROPS */
    6081 
    6082 /**
    6083  * Set up the Guest Property service, populate it with properties read from
    6084  * the machine XML and set a couple of initial properties.
    6085  */
    6086 /* static */ int Console::i_configGuestProperties(void *pvConsole)
    6087 {
    6088 #ifdef VBOX_WITH_GUEST_PROPS
    6089     AssertReturn(pvConsole, VERR_INVALID_POINTER);
    6090     ComObjPtr<Console> pConsole = static_cast<Console *>(pvConsole);
    6091     AssertReturn(pConsole->m_pVMMDev, VERR_INVALID_POINTER);
    6092 
    6093     /* Load the service */
    6094     int rc = pConsole->m_pVMMDev->hgcmLoadService("VBoxGuestPropSvc", "VBoxGuestPropSvc");
    6095 
    6096     if (RT_FAILURE(rc))
    6097     {
    6098         LogRel(("VBoxGuestPropSvc is not available. rc = %Rrc\n", rc));
    6099         /* That is not a fatal failure. */
    6100         rc = VINF_SUCCESS;
    6101     }
    6102     else
    6103     {
    6104         /*
    6105          * Initialize built-in properties that can be changed and saved.
    6106          *
    6107          * These are typically transient properties that the guest cannot
    6108          * change.
    6109          */
    6110 
    6111         /* Sysprep execution by VBoxService. */
    6112         configSetProperty(pConsole->m_pVMMDev,
    6113                           "/VirtualBox/HostGuest/SysprepExec", "",
    6114                           "TRANSIENT, RDONLYGUEST");
    6115         configSetProperty(pConsole->m_pVMMDev,
    6116                           "/VirtualBox/HostGuest/SysprepArgs", "",
    6117                           "TRANSIENT, RDONLYGUEST");
    6118 
    6119         /*
    6120          * Pull over the properties from the server.
    6121          */
    6122         SafeArray<BSTR> namesOut;
    6123         SafeArray<BSTR> valuesOut;
    6124         SafeArray<LONG64> timestampsOut;
    6125         SafeArray<BSTR> flagsOut;
    6126         HRESULT hrc;
    6127         hrc = pConsole->mControl->PullGuestProperties(ComSafeArrayAsOutParam(namesOut),
    6128                                                       ComSafeArrayAsOutParam(valuesOut),
    6129                                                       ComSafeArrayAsOutParam(timestampsOut),
    6130                                                       ComSafeArrayAsOutParam(flagsOut));
    6131         AssertLogRelMsgReturn(SUCCEEDED(hrc), ("hrc=%Rhrc\n", hrc), VERR_MAIN_CONFIG_CONSTRUCTOR_COM_ERROR);
    6132         size_t cProps = namesOut.size();
    6133         size_t cAlloc = cProps + 1;
    6134         if (   valuesOut.size() != cProps
    6135             || timestampsOut.size() != cProps
    6136             || flagsOut.size() != cProps
    6137            )
    6138             AssertFailedReturn(VERR_INVALID_PARAMETER);
    6139 
    6140         char **papszNames, **papszValues, **papszFlags;
    6141         char szEmpty[] = "";
    6142         LONG64 *pai64Timestamps;
    6143         papszNames = (char **)RTMemTmpAllocZ(sizeof(void *) * cAlloc);
    6144         papszValues = (char **)RTMemTmpAllocZ(sizeof(void *) * cAlloc);
    6145         pai64Timestamps = (LONG64 *)RTMemTmpAllocZ(sizeof(LONG64) * cAlloc);
    6146         papszFlags = (char **)RTMemTmpAllocZ(sizeof(void *) * cAlloc);
    6147         if (papszNames && papszValues && pai64Timestamps && papszFlags)
    6148         {
    6149             for (unsigned i = 0; RT_SUCCESS(rc) && i < cProps; ++i)
    6150             {
    6151                 AssertPtrBreakStmt(namesOut[i], rc = VERR_INVALID_PARAMETER);
    6152                 rc = RTUtf16ToUtf8(namesOut[i], &papszNames[i]);
    6153                 if (RT_FAILURE(rc))
    6154                     break;
    6155                 if (valuesOut[i])
    6156                     rc = RTUtf16ToUtf8(valuesOut[i], &papszValues[i]);
    6157                 else
    6158                     papszValues[i] = szEmpty;
    6159                 if (RT_FAILURE(rc))
    6160                     break;
    6161                 pai64Timestamps[i] = timestampsOut[i];
    6162                 if (flagsOut[i])
    6163                     rc = RTUtf16ToUtf8(flagsOut[i], &papszFlags[i]);
    6164                 else
    6165                     papszFlags[i] = szEmpty;
    6166             }
    6167             if (RT_SUCCESS(rc))
    6168                 configSetProperties(pConsole->m_pVMMDev,
    6169                                     (void *)papszNames,
    6170                                     (void *)papszValues,
    6171                                     (void *)pai64Timestamps,
    6172                                     (void *)papszFlags);
    6173             for (unsigned i = 0; i < cProps; ++i)
    6174             {
    6175                 RTStrFree(papszNames[i]);
    6176                 if (valuesOut[i])
    6177                     RTStrFree(papszValues[i]);
    6178                 if (flagsOut[i])
    6179                     RTStrFree(papszFlags[i]);
    6180             }
    6181         }
    6182         else
    6183             rc = VERR_NO_MEMORY;
    6184         RTMemTmpFree(papszNames);
    6185         RTMemTmpFree(papszValues);
    6186         RTMemTmpFree(pai64Timestamps);
    6187         RTMemTmpFree(papszFlags);
    6188         AssertRCReturn(rc, rc);
    6189 
    6190         /*
    6191          * These properties have to be set before pulling over the properties
    6192          * from the machine XML, to ensure that properties saved in the XML
    6193          * will override them.
    6194          */
    6195         /* Set the raw VBox version string as a guest property. Used for host/guest
    6196          * version comparison. */
    6197         configSetProperty(pConsole->m_pVMMDev, "/VirtualBox/HostInfo/VBoxVer",
    6198                           VBOX_VERSION_STRING_RAW, "TRANSIENT, RDONLYGUEST");
    6199         /* Set the full VBox version string as a guest property. Can contain vendor-specific
    6200          * information/branding and/or pre-release tags. */
    6201         configSetProperty(pConsole->m_pVMMDev, "/VirtualBox/HostInfo/VBoxVerExt",
    6202                           VBOX_VERSION_STRING, "TRANSIENT, RDONLYGUEST");
    6203         /* Set the VBox SVN revision as a guest property */
    6204         configSetProperty(pConsole->m_pVMMDev, "/VirtualBox/HostInfo/VBoxRev",
    6205                           RTBldCfgRevisionStr(), "TRANSIENT, RDONLYGUEST");
    6206 
    6207         /*
    6208          * Register the host notification callback
    6209          */
    6210         HGCMSVCEXTHANDLE hDummy;
    6211         HGCMHostRegisterServiceExtension(&hDummy, "VBoxGuestPropSvc",
    6212                                          Console::i_doGuestPropNotification,
    6213                                          pvConsole);
    6214 
    6215 #ifdef VBOX_WITH_GUEST_PROPS_RDONLY_GUEST
    6216         rc = configSetGlobalPropertyFlags(pConsole->m_pVMMDev, GUEST_PROP_F_RDONLYGUEST);
    6217         AssertRCReturn(rc, rc);
    6218 #endif
    6219 
    6220         Log(("Set VBoxGuestPropSvc property store\n"));
    6221     }
    6222     return VINF_SUCCESS;
    6223 #else /* !VBOX_WITH_GUEST_PROPS */
    6224     return VERR_NOT_SUPPORTED;
    6225 #endif /* !VBOX_WITH_GUEST_PROPS */
    6226 }
    6227 
  • trunk/src/VBox/Main/src-client/VMMDevInterface.cpp

    r75853 r75955  
    2929#include <VBox/shflsvc.h>
    3030#include <iprt/asm.h>
     31#include <iprt/buildconfig.h>
    3132
    3233#ifdef VBOX_WITH_HGCM
     
    3536# if defined(RT_OS_DARWIN) && defined(VBOX_WITH_CROGL)
    3637#  include <VBox/HostServices/VBoxCrOpenGLSvc.h>
     38# endif
     39# ifdef VBOX_WITH_GUEST_PROPS
     40#  include <VBox/version.h>
    3741# endif
    3842#endif
     
    7983//
    8084VMMDev::VMMDev(Console *console)
    81     : mpDrv(NULL),
    82       mParent(console)
     85    : mpDrv(NULL)
     86    , mParent(console)
    8387{
    8488    int rc = RTSemEventCreate(&mCredentialsEvent);
     
    797801    }
    798802}
     803
     804#ifdef VBOX_WITH_GUEST_PROPS
     805
     806/**
     807 * Set an array of guest properties
     808 */
     809void VMMDev::i_guestPropSetMultiple(void *names, void *values, void *timestamps, void *flags)
     810{
     811    VBOXHGCMSVCPARM parms[4];
     812
     813    parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
     814    parms[0].u.pointer.addr = names;
     815    parms[0].u.pointer.size = 0;  /* We don't actually care. */
     816    parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
     817    parms[1].u.pointer.addr = values;
     818    parms[1].u.pointer.size = 0;  /* We don't actually care. */
     819    parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
     820    parms[2].u.pointer.addr = timestamps;
     821    parms[2].u.pointer.size = 0;  /* We don't actually care. */
     822    parms[3].type = VBOX_HGCM_SVC_PARM_PTR;
     823    parms[3].u.pointer.addr = flags;
     824    parms[3].u.pointer.size = 0;  /* We don't actually care. */
     825
     826    hgcmHostCall("VBoxGuestPropSvc", GUEST_PROP_FN_HOST_SET_PROPS, 4, &parms[0]);
     827}
     828
     829/**
     830 * Set a single guest property
     831 */
     832void VMMDev::i_guestPropSet(const char *pszName, const char *pszValue, const char *pszFlags)
     833{
     834    VBOXHGCMSVCPARM parms[4];
     835
     836    AssertPtrReturnVoid(pszName);
     837    AssertPtrReturnVoid(pszValue);
     838    AssertPtrReturnVoid(pszFlags);
     839    parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
     840    parms[0].u.pointer.addr = (void *)pszName;
     841    parms[0].u.pointer.size = (uint32_t)strlen(pszName) + 1;
     842    parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
     843    parms[1].u.pointer.addr = (void *)pszValue;
     844    parms[1].u.pointer.size = (uint32_t)strlen(pszValue) + 1;
     845    parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
     846    parms[2].u.pointer.addr = (void *)pszFlags;
     847    parms[2].u.pointer.size = (uint32_t)strlen(pszFlags) + 1;
     848    hgcmHostCall("VBoxGuestPropSvc", GUEST_PROP_FN_HOST_SET_PROP, 3, &parms[0]);
     849}
     850
     851/**
     852 * Set the global flags value by calling the service
     853 * @returns the status returned by the call to the service
     854 *
     855 * @param   pTable  the service instance handle
     856 * @param   eFlags  the flags to set
     857 */
     858int VMMDev::i_guestPropSetGlobalPropertyFlags(uint32_t fFlags)
     859{
     860    VBOXHGCMSVCPARM parm;
     861    HGCMSvcSetU32(&parm, fFlags);
     862    int rc = hgcmHostCall("VBoxGuestPropSvc", GUEST_PROP_FN_HOST_SET_GLOBAL_FLAGS, 1, &parm);
     863    if (RT_FAILURE(rc))
     864    {
     865        char szFlags[GUEST_PROP_MAX_FLAGS_LEN];
     866        if (RT_FAILURE(GuestPropWriteFlags(fFlags, szFlags)))
     867            Log(("Failed to set the global flags.\n"));
     868        else
     869            Log(("Failed to set the global flags \"%s\".\n", szFlags));
     870    }
     871    return rc;
     872}
     873
     874
     875/**
     876 * Set up the Guest Property service, populate it with properties read from
     877 * the machine XML and set a couple of initial properties.
     878 */
     879int VMMDev::i_guestPropLoadAndConfigure()
     880{
     881    Assert(mpDrv);
     882    ComObjPtr<Console> ptrConsole = this->mParent;
     883    AssertReturn(ptrConsole.isNotNull(), VERR_INVALID_POINTER);
     884
     885    /* Load the service */
     886    int rc = hgcmLoadService("VBoxGuestPropSvc", "VBoxGuestPropSvc");
     887    if (RT_FAILURE(rc))
     888    {
     889        LogRel(("VBoxGuestPropSvc is not available. rc = %Rrc\n", rc));
     890        return VINF_SUCCESS; /* That is not a fatal failure. */
     891    }
     892    /*
     893     * Initialize built-in properties that can be changed and saved.
     894     *
     895     * These are typically transient properties that the guest cannot
     896     * change.
     897     */
     898
     899    /* Sysprep execution by VBoxService. */
     900    i_guestPropSet("/VirtualBox/HostGuest/SysprepExec", "", "TRANSIENT, RDONLYGUEST");
     901    i_guestPropSet("/VirtualBox/HostGuest/SysprepArgs", "", "TRANSIENT, RDONLYGUEST");
     902
     903    /*
     904     * Pull over the properties from the server.
     905     */
     906    SafeArray<BSTR>     namesOut;
     907    SafeArray<BSTR>     valuesOut;
     908    SafeArray<LONG64>   timestampsOut;
     909    SafeArray<BSTR>     flagsOut;
     910    HRESULT hrc = ptrConsole->i_pullGuestProperties(ComSafeArrayAsOutParam(namesOut),
     911                                                    ComSafeArrayAsOutParam(valuesOut),
     912                                                    ComSafeArrayAsOutParam(timestampsOut),
     913                                                    ComSafeArrayAsOutParam(flagsOut));
     914    AssertLogRelMsgReturn(SUCCEEDED(hrc), ("hrc=%Rhrc\n", hrc), VERR_MAIN_CONFIG_CONSTRUCTOR_COM_ERROR);
     915    size_t const cProps = namesOut.size();
     916    size_t const cAlloc = cProps + 1;
     917    AssertLogRelReturn(valuesOut.size()     == cProps, VERR_INTERNAL_ERROR_2);
     918    AssertLogRelReturn(timestampsOut.size() == cProps, VERR_INTERNAL_ERROR_3);
     919    AssertLogRelReturn(flagsOut.size()      == cProps, VERR_INTERNAL_ERROR_4);
     920
     921    char    szEmpty[] = "";
     922    char  **papszNames      = (char  **)RTMemTmpAllocZ(sizeof(char *) * cAlloc);
     923    char  **papszValues     = (char  **)RTMemTmpAllocZ(sizeof(char *) * cAlloc);
     924    LONG64 *pai64Timestamps = (LONG64 *)RTMemTmpAllocZ(sizeof(LONG64) * cAlloc);
     925    char  **papszFlags      = (char  **)RTMemTmpAllocZ(sizeof(char *) * cAlloc);
     926    if (papszNames && papszValues && pai64Timestamps && papszFlags)
     927    {
     928        for (unsigned i = 0; RT_SUCCESS(rc) && i < cProps; ++i)
     929        {
     930            AssertPtrBreakStmt(namesOut[i], rc = VERR_INVALID_PARAMETER);
     931            rc = RTUtf16ToUtf8(namesOut[i], &papszNames[i]);
     932            if (RT_FAILURE(rc))
     933                break;
     934            if (valuesOut[i])
     935                rc = RTUtf16ToUtf8(valuesOut[i], &papszValues[i]);
     936            else
     937                papszValues[i] = szEmpty;
     938            if (RT_FAILURE(rc))
     939                break;
     940            pai64Timestamps[i] = timestampsOut[i];
     941            if (flagsOut[i])
     942                rc = RTUtf16ToUtf8(flagsOut[i], &papszFlags[i]);
     943            else
     944                papszFlags[i] = szEmpty;
     945        }
     946        if (RT_SUCCESS(rc))
     947            i_guestPropSetMultiple((void *)papszNames, (void *)papszValues, (void *)pai64Timestamps, (void *)papszFlags);
     948        for (unsigned i = 0; i < cProps; ++i)
     949        {
     950            RTStrFree(papszNames[i]);
     951            if (valuesOut[i])
     952                RTStrFree(papszValues[i]);
     953            if (flagsOut[i])
     954                RTStrFree(papszFlags[i]);
     955        }
     956    }
     957    else
     958        rc = VERR_NO_MEMORY;
     959    RTMemTmpFree(papszNames);
     960    RTMemTmpFree(papszValues);
     961    RTMemTmpFree(pai64Timestamps);
     962    RTMemTmpFree(papszFlags);
     963    AssertRCReturn(rc, rc);
     964
     965    /*
     966     * These properties have to be set before pulling over the properties
     967     * from the machine XML, to ensure that properties saved in the XML
     968     * will override them.
     969     */
     970    /* Set the raw VBox version string as a guest property. Used for host/guest
     971     * version comparison. */
     972    i_guestPropSet("/VirtualBox/HostInfo/VBoxVer", VBOX_VERSION_STRING_RAW, "TRANSIENT, RDONLYGUEST");
     973    /* Set the full VBox version string as a guest property. Can contain vendor-specific
     974     * information/branding and/or pre-release tags. */
     975    i_guestPropSet("/VirtualBox/HostInfo/VBoxVerExt", VBOX_VERSION_STRING, "TRANSIENT, RDONLYGUEST");
     976    /* Set the VBox SVN revision as a guest property */
     977    i_guestPropSet("/VirtualBox/HostInfo/VBoxRev", RTBldCfgRevisionStr(), "TRANSIENT, RDONLYGUEST");
     978
     979    /*
     980     * Register the host notification callback
     981     */
     982    HGCMSVCEXTHANDLE hDummy;
     983    HGCMHostRegisterServiceExtension(&hDummy, "VBoxGuestPropSvc", Console::i_doGuestPropNotification, ptrConsole.m_p);
     984
     985# ifdef VBOX_WITH_GUEST_PROPS_RDONLY_GUEST
     986    rc = i_guestPropSetGlobalPropertyFlags(GUEST_PROP_F_RDONLYGUEST);
     987    AssertRCReturn(rc, rc);
     988# endif
     989
     990    Log(("Set VBoxGuestPropSvc property store\n"));
     991    return VINF_SUCCESS;
     992}
     993
     994#endif /* VBOX_WITH_GUEST_PROPS */
    799995
    800996/**
     
    9051101
    9061102    /*
    907      * Load and configure guest control service.
     1103     * Load and configure the guest control service.
    9081104     */
    9091105# ifdef VBOX_WITH_GUEST_CONTROL
     
    9231119        LogRel(("Warning!: Failed to load the Guest Control Service! %Rrc\n", rc));
    9241120# endif /* VBOX_WITH_GUEST_CONTROL */
     1121
     1122
     1123    /*
     1124     * Load and configure the guest properties service.
     1125     */
     1126# ifdef VBOX_WITH_GUEST_PROPS
     1127    rc = pThis->pVMMDev->i_guestPropLoadAndConfigure();
     1128    AssertLogRelRCReturn(rc, rc);
     1129# endif
    9251130
    9261131
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