Changeset 29026 in vbox for trunk/src/VBox/Additions/common/VBoxService
- Timestamp:
- May 4, 2010 2:18:27 PM (15 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/Makefile.kmk
r29011 r29026 55 55 VBoxServiceTimeSync.cpp \ 56 56 VBoxServiceUtils.cpp \ 57 VBoxServiceStats.cpp \ 58 VBoxServicePropCache.cpp 57 VBoxServiceStats.cpp 59 58 ifdef VBOX_WITH_GUEST_CONTROL 60 59 VBoxService_SOURCES += \ 61 VBoxServiceControl.cpp \62 VBoxServiceControlExec.cpp60 VBoxServiceControl.cpp \ 61 VBoxServiceControlExec.cpp 63 62 endif 64 63 ifdef VBOX_WITH_MEMBALLOON 65 64 VBoxService_SOURCES += \ 66 VBoxServiceBalloon.cpp65 VBoxServiceBalloon.cpp 67 66 endif 68 67 ifdef VBOX_WITH_PAGE_SHARING 69 68 VBoxService_SOURCES += \ 70 VBoxServicePageSharing.cpp69 VBoxServicePageSharing.cpp 71 70 endif 72 71 ifdef VBOX_WITH_GUEST_PROPS … … 74 73 VBoxServiceVMInfo-win.cpp 75 74 VBoxService_SOURCES += \ 76 VBoxServiceVMInfo.cpp 75 VBoxServiceVMInfo.cpp \ 76 VBoxServicePropCache.cpp 77 77 if1of ($(KBUILD_TARGET), win) 78 78 VBoxService_SOURCES += \ -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h
r28983 r29026 93 93 94 94 #ifdef RT_OS_WINDOWS 95 95 96 /** The service name (needed for mutex creation on Windows). */ 96 97 # define VBOXSERVICE_NAME "VBoxService" … … 122 123 /** Function prototypes for dynamic loading. */ 123 124 typedef DWORD (WINAPI *PFNWTSGETACTIVECONSOLESESSIONID)(void); 125 124 126 #endif /* RT_OS_WINDOWS */ 125 126 127 #ifdef VBOX_WITH_GUEST_CONTROL 128 127 129 enum VBOXSERVICECTRLTHREADDATATYPE 128 130 { … … 194 196 * For buffering process input supplied by the client. 195 197 */ 196 typedef struct 198 typedef struct VBOXSERVICECTRLSTDINBUF 197 199 { 198 200 /** The mount of buffered data. */ … … 211 213 /** Pointer to a standard input buffer. */ 212 214 typedef VBOXSERVICECTRLSTDINBUF *PVBOXSERVICECTRLSTDINBUF; 215 213 216 #endif /* VBOX_WITH_GUEST_CONTROL */ 214 215 217 #ifdef VBOX_WITH_GUEST_PROPS 218 216 219 /** 217 220 * A guest property cache. 218 221 */ 219 typedef struct 220 { 222 typedef struct VBOXSERVICEVEPROPCACHE 223 { 221 224 /** The client ID for HGCM communication. */ 222 uint32_t uClientID; 223 RTLISTNODE Node; 224 RTSEMMUTEX Mutex; 225 uint32_t uClientID; 226 /** List of VBOXSERVICEVEPROPCACHEENTRY nodes. 227 * @todo r=bird: Node -> ListSomething, please. "Node" is very nondescript and 228 * makes the list-head vs. list-node confusion greater. */ 229 RTLISTNODE Node; 230 /** @todo Use a RTCRITSECT. RTSEMMUTEXes are deprecated in ring-3. */ 231 RTSEMMUTEX Mutex; 225 232 } VBOXSERVICEVEPROPCACHE; 226 233 /** Pointer to a guest property cache. */ … … 228 235 229 236 /** 230 * Handling guest properties used by the VM information service.231 */ 232 typedef struct 233 { 237 * An entry in the property cache (VBOXSERVICEVEPROPCACHE). 238 */ 239 typedef struct VBOXSERVICEVEPROPCACHEENTRY 240 { 234 241 /** Node. */ 235 RTLISTNODE Node;242 RTLISTNODE Node; 236 243 /** Name (and full path) of guest property. */ 237 char *pszName;244 char *pszName; 238 245 /** The last value stored (for reference). */ 239 char *pszValue; 240 /** Reset value to write if property is temporary. */ 241 char *pszValueReset; 246 char *pszValue; 247 /** Reset value to write if property is temporary. If NULL, it will be 248 * deleted. */ 249 char *pszValueReset; 242 250 /** Flags. */ 243 uint32_t uFlags;251 uint32_t fFlags; 244 252 } VBOXSERVICEVEPROPCACHEENTRY; 245 253 /** Pointer to a cached guest property. */ 246 254 typedef VBOXSERVICEVEPROPCACHEENTRY *PVBOXSERVICEVEPROPCACHEENTRY; 255 247 256 #endif /* VBOX_WITH_GUEST_PROPS */ 248 257 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServicePropCache.cpp
r28983 r29026 30 30 #include "VBoxServicePropCache.h" 31 31 32 #ifdef VBOX_WITH_GUEST_PROPS 33 34 /** @todo Docs */ 35 int VBoxServicePropCacheInit(PVBOXSERVICEVEPROPCACHE pCache, uint32_t u32ClientId) 36 { 37 AssertPtr(pCache); 38 /** @todo Prevent init the cache twice! */ 32 33 /** 34 * Initializes the property cache. 35 * 36 * @returns IPRT status code. 37 * @param pCache Pointer to the cache. 38 * @param uClientId The HGCM handle of to the guest property service. 39 */ 40 int VBoxServicePropCacheInit(PVBOXSERVICEVEPROPCACHE pCache, uint32_t uClientId) 41 { 42 AssertPtr(pCache); 43 /** @todo Prevent init the cache twice! 44 * r=bird: Use a magic, or/and abstract the whole cache by rename this function 45 * VBoxServicePropCacheCreate(). */ 39 46 RTListInit(&pCache->Node); 40 pCache->uClientID = u 32ClientId;47 pCache->uClientID = uClientId; 41 48 return RTSemMutexCreate(&pCache->Mutex); 42 49 } 43 50 44 51 45 /** @todo Docs */ 52 /** @todo Docs 53 * @todo this looks internal to me, nobody should need to access the 54 * structures directly here. */ 46 55 PVBOXSERVICEVEPROPCACHEENTRY VBoxServicePropCacheFind(PVBOXSERVICEVEPROPCACHE pCache, const char *pszName, uint32_t uFlags) 47 56 { 48 57 AssertPtr(pCache); 49 58 AssertPtr(pszName); 50 /* This is a O(n) lookup, maybe improve this later to O(1) using a map. */ 59 /** @todo This is a O(n) lookup, maybe improve this later to O(1) using a 60 * map. 61 * r=bird: Use a string space (RTstrSpace*). That is O(log n) in its current 62 * implementation (AVL tree). However, this is not important at the 63 * moment. */ 51 64 PVBOXSERVICEVEPROPCACHEENTRY pNodeIt, pNode = NULL; 52 65 if (RT_SUCCESS(RTSemMutexRequest(pCache->Mutex, RT_INDEFINITE_WAIT))) 53 { 66 { 54 67 RTListForEach(&pCache->Node, pNodeIt, VBOXSERVICEVEPROPCACHEENTRY, Node) 55 68 { … … 67 80 68 81 /** @todo Docs */ 69 int VBoxServicePropCacheUpdateEntry(PVBOXSERVICEVEPROPCACHE pCache, 70 const char *pszName, uint32_t u32Flags, const char *pszValueReset)82 int VBoxServicePropCacheUpdateEntry(PVBOXSERVICEVEPROPCACHE pCache, 83 const char *pszName, uint32_t fFlags, const char *pszValueReset) 71 84 { 72 85 AssertPtr(pCache); … … 79 92 if (RT_SUCCESS(rc)) 80 93 { 81 pNode-> uFlags = u32Flags;94 pNode->fFlags = fFlags; 82 95 if (pszValueReset) 83 96 { … … 100 113 * @returns VBox status code. Errors will be logged. 101 114 * 102 * @param u32ClientId The HGCM client ID for the guest property session.115 * @param pCache The property cache. 103 116 * @param pszName The property name. 104 117 * @param pszValueFormat The property format string. If this is NULL then … … 129 142 * @returns VBox status code. Errors will be logged. 130 143 * 131 * @param u32ClientId The HGCM client ID for the guest property session.144 * @param pCache The property cache. 132 145 * @param pszName The property name. 133 146 * @param pszValueFormat The property format string. If this is NULL then … … 135 148 * @param ... Format arguments. 136 149 */ 137 int VBoxServicePropCacheUpdateEx(PVBOXSERVICEVEPROPCACHE pCache, const char *pszName, uint32_t u32Flags, const char *pszValueReset, const char *pszValueFormat, ...) 150 int VBoxServicePropCacheUpdateEx(PVBOXSERVICEVEPROPCACHE pCache, const char *pszName, uint32_t fFlags, 151 const char *pszValueReset, const char *pszValueFormat, ...) 138 152 { 139 153 AssertPtr(pCache); … … 141 155 AssertPtr(pszName); 142 156 157 /* 158 * Format the value first. 159 */ 143 160 char *pszValue = NULL; 144 161 if (pszValueFormat) … … 148 165 RTStrAPrintfV(&pszValue, pszValueFormat, va); 149 166 va_end(va); 167 if (!pszValue) 168 return VERR_NO_STR_MEMORY; 150 169 } 151 170 … … 156 175 if (RT_SUCCESS(rc)) 157 176 { 158 177 159 178 if (pNode == NULL) 160 { 179 { 161 180 pNode = (PVBOXSERVICEVEPROPCACHEENTRY)RTMemAlloc(sizeof(VBOXSERVICEVEPROPCACHEENTRY)); 162 AssertPtrReturn(pNode, VERR_NO_MEMORY); 163 181 if (RT_UNLIKELY(!pNode)) 182 { 183 RTSemMutexRelease(pCache->Mutex); 184 return VERR_NO_MEMORY; 185 } 186 164 187 pNode->pszName = RTStrDup(pszName); 165 pNode->pszValue = NULL; 166 pNode-> uFlags = 0;188 pNode->pszValue = NULL; 189 pNode->fFlags = 0; 167 190 pNode->pszValueReset = NULL; 168 191 169 192 /*rc =*/ RTListAppend(&pCache->Node, &pNode->Node); 170 193 } 171 194 172 195 AssertPtr(pNode); 173 196 if (pszValue) /* Do we have a value to check for? */ … … 175 198 bool fUpdate = false; 176 199 /* Always update this property, no matter what? */ 177 if (pNode-> uFlags & VBOXSERVICEPROPCACHEFLAG_ALWAYS_UPDATE)200 if (pNode->fFlags & VBOXSERVICEPROPCACHEFLAG_ALWAYS_UPDATE) 178 201 fUpdate = true; 179 202 /* Did the value change so we have to update? */ … … 181 204 fUpdate = true; 182 205 /* No value stored at the moment but we have a value now? */ 183 else if (pNode->pszValue == NULL) 206 else if (pNode->pszValue == NULL) 184 207 fUpdate = true; 185 208 186 209 if (fUpdate) 187 210 { 188 211 /* Write the update. */ 189 212 rc = VBoxServiceWritePropF(pCache->uClientID, pNode->pszName, pszValue); 190 if (pNode->pszValue) 191 RTStrFree(pNode->pszValue); 213 RTStrFree(pNode->pszValue); 192 214 pNode->pszValue = RTStrDup(pszValue); 193 215 } 194 216 else 217 /** @todo r=bird: Add a VINF_NO_CHANGE status code to iprt/err.h and use it. */ 195 218 rc = VINF_ALREADY_INITIALIZED; /* No update needed. */ 196 219 } 197 else 220 else 198 221 { 199 222 /* No value specified. Deletion (or no action required). */ … … 201 224 { 202 225 /* Delete property (but do not remove from cache) if not deleted yet. */ 203 rc = VBoxServiceWritePropF(pCache->uClientID, pNode->pszName, NULL);204 226 RTStrFree(pNode->pszValue); 205 227 pNode->pszValue = NULL; 228 rc = VBoxServiceWritePropF(pCache->uClientID, pNode->pszName, NULL); 206 229 } 207 230 else 231 /** @todo r=bird: Use VINF_NO_CHANGE. */ 208 232 rc = VINF_ALREADY_INITIALIZED; /* No update needed. */ 209 233 } 210 234 211 235 /* Update rest of the fields. */ 212 236 if (pszValueReset) … … 216 240 pNode->pszValueReset = RTStrDup(pszValueReset); 217 241 } 218 if (u32Flags) 219 pNode->uFlags = u32Flags; 220 221 /* Delete temp stuff. */ 222 if (pszValue) 223 RTStrFree(pszValue); 224 242 if (fFlags) 243 pNode->fFlags = fFlags; 244 225 245 /* Release cache. */ 226 246 int rc2 = RTSemMutexRelease(pCache->Mutex); … … 228 248 rc2 = rc; 229 249 } 250 251 /* Delete temp stuff. */ 252 RTStrFree(pszValue); 253 230 254 return rc; 231 255 } 232 256 233 257 234 /** @todo Docs */ 258 /** 259 * Reset all temporary properties and destroy the cache. 260 * 261 * @param pCache The property cache. 262 */ 235 263 void VBoxServicePropCacheDestroy(PVBOXSERVICEVEPROPCACHE pCache) 236 264 { … … 240 268 RTListForEach(&pCache->Node, pNode, VBOXSERVICEVEPROPCACHEENTRY, Node) 241 269 { 242 if ((pNode->uFlags & VBOXSERVICEPROPCACHEFLAG_TEMPORARY) == 0) 243 { 244 if (pNode->pszValueReset) /* Write reset value? */ 245 { 246 /* rc = */VBoxServiceWritePropF(pCache->uClientID, pNode->pszName, pNode->pszValueReset); 247 } 248 else /* Delete value. */ 249 /* rc = */VBoxServiceWritePropF(pCache->uClientID, pNode->pszName, NULL); 250 } 270 if ((pNode->fFlags & VBOXSERVICEPROPCACHEFLAG_TEMPORARY) == 0) 271 VBoxServiceWritePropF(pCache->uClientID, pNode->pszName, pNode->pszValueReset); 251 272 252 273 AssertPtr(pNode->pszName); 253 274 RTStrFree(pNode->pszName); 254 if (pNode->pszValue) 255 RTStrFree(pNode->pszValue); 256 if (pNode->pszValueReset) 257 RTStrFree(pNode->pszValueReset); 258 pNode->uFlags = 0; 275 RTStrFree(pNode->pszValue); 276 RTStrFree(pNode->pszValueReset); 277 pNode->fFlags = 0; 259 278 } 260 279 … … 264 283 PVBOXSERVICEVEPROPCACHEENTRY pNext = RTListNodeGetNext(&pNode->Node, VBOXSERVICEVEPROPCACHEENTRY, Node); 265 284 RTListNodeRemove(&pNode->Node); 285 /** @todo r=bird: hrm. missing RTMemFree(pNode)? Why don't you just combine the 286 * two loops? */ 287 266 288 if (pNext && RTListNodeIsLast(&pCache->Node, &pNext->Node)) 267 289 break; 268 290 pNode = pNext; 269 291 } 292 270 293 /* Destroy mutex. */ 271 294 RTSemMutexDestroy(pCache->Mutex); 272 295 } 273 #endif /* VBOX_WITH_GUEST_PROPS */ 296 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServicePropCache.h
r28967 r29026 26 26 #define VBOXSERVICEPROPCACHEFLAG_ALWAYS_UPDATE RT_BIT(2) 27 27 28 int VBoxServicePropCacheInit(PVBOXSERVICEVEPROPCACHE pCache, uint32_t u 32ClientId);28 int VBoxServicePropCacheInit(PVBOXSERVICEVEPROPCACHE pCache, uint32_t uClientId); 29 29 PVBOXSERVICEVEPROPCACHEENTRY VBoxServicePropCacheFind(PVBOXSERVICEVEPROPCACHE pCache, const char *pszName, uint32_t uFlags); 30 int VBoxServicePropCacheUpdateEntry(PVBOXSERVICEVEPROPCACHE pCache, const char *pszName, uint32_t uFlags, const char *pszValueReset);30 int VBoxServicePropCacheUpdateEntry(PVBOXSERVICEVEPROPCACHE pCache, const char *pszName, uint32_t fFlags, const char *pszValueReset); 31 31 int VBoxServicePropCacheUpdate(PVBOXSERVICEVEPROPCACHE pCache, const char *pszName, const char *pszValueFormat, ...); 32 int VBoxServicePropCacheUpdateEx(PVBOXSERVICEVEPROPCACHE pCache, const char *pszName, uint32_t u32Flags, const char *pszValueReset, const char *pszValueFormat, ...);32 int VBoxServicePropCacheUpdateEx(PVBOXSERVICEVEPROPCACHE pCache, const char *pszName, uint32_t fFlags, const char *pszValueReset, const char *pszValueFormat, ...); 33 33 void VBoxServicePropCacheDestroy(PVBOXSERVICEVEPROPCACHE pCache); 34 34 #endif -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp
r28978 r29026 61 61 *******************************************************************************/ 62 62 /** The vminfo interval (millseconds). */ 63 uint32_t g_VMInfoInterval = 0;63 static uint32_t g_cMsVMInfoInterval = 0; 64 64 /** The semaphore we're blocking on. */ 65 static RTSEMEVENTMULTI g_ VMInfoEvent = NIL_RTSEMEVENTMULTI;65 static RTSEMEVENTMULTI g_hVMInfoEvent = NIL_RTSEMEVENTMULTI; 66 66 /** The guest property service client ID. */ 67 static uint32_t g_ VMInfoGuestPropSvcClientID = 0;67 static uint32_t g_uVMInfoGuestPropSvcClientID = 0; 68 68 /** Number of logged in users in OS. */ 69 69 static uint32_t g_cVMInfoLoggedInUsers = UINT32_MAX; … … 87 87 else if (!strcmp(argv[*pi], "--vminfo-interval")) 88 88 rc = VBoxServiceArgUInt32(argc, argv, "", pi, 89 &g_ VMInfoInterval, 1, UINT32_MAX - 1);89 &g_cMsVMInfoInterval, 1, UINT32_MAX - 1); 90 90 return rc; 91 91 } … … 99 99 * Then create the event sem to block on. 100 100 */ 101 if (!g_ VMInfoInterval)102 g_ VMInfoInterval = g_DefaultInterval * 1000;103 if (!g_ VMInfoInterval)104 g_ VMInfoInterval = 10 * 1000;105 106 int rc = RTSemEventMultiCreate(&g_ VMInfoEvent);101 if (!g_cMsVMInfoInterval) 102 g_cMsVMInfoInterval = g_DefaultInterval * 1000; 103 if (!g_cMsVMInfoInterval) 104 g_cMsVMInfoInterval = 10 * 1000; 105 106 int rc = RTSemEventMultiCreate(&g_hVMInfoEvent); 107 107 AssertRCReturn(rc, rc); 108 108 … … 117 117 #endif 118 118 119 rc = VbglR3GuestPropConnect(&g_ VMInfoGuestPropSvcClientID);119 rc = VbglR3GuestPropConnect(&g_uVMInfoGuestPropSvcClientID); 120 120 if (RT_SUCCESS(rc)) 121 VBoxServiceVerbose(3, "Property Service Client ID: %#x\n", g_ VMInfoGuestPropSvcClientID);121 VBoxServiceVerbose(3, "Property Service Client ID: %#x\n", g_uVMInfoGuestPropSvcClientID); 122 122 else 123 123 { 124 124 VBoxServiceError("Failed to connect to the guest property service! Error: %Rrc\n", rc); 125 RTSemEventMultiDestroy(g_ VMInfoEvent);126 g_ VMInfoEvent = NIL_RTSEMEVENTMULTI;125 RTSemEventMultiDestroy(g_hVMInfoEvent); 126 g_hVMInfoEvent = NIL_RTSEMEVENTMULTI; 127 127 } 128 128 129 129 if (RT_SUCCESS(rc)) 130 130 { 131 VBoxServicePropCacheInit(&g_VMInfoPropCache, g_VMInfoGuestPropSvcClientID); 131 VBoxServicePropCacheInit(&g_VMInfoPropCache, g_uVMInfoGuestPropSvcClientID); 132 133 /** @todo r=bird: Setting Net/Count to 0 here is wrong and will confuse users. 134 * Besides, because it is the beacon updating it implies that all the 135 * other values are up to date too, but they aren't 136 * (VBoxServiceVMInfoWriteFixedProperties hasn't been called yet for 137 * instance). I would suggest changing these statements to 138 * "declarations" or moving them. */ 132 139 133 140 /* … … 135 142 * Passing NULL as an actual value does not write the properties yet. 136 143 */ 137 VBoxServicePropCacheUpdateEx(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/LoggedInUsersList", 144 VBoxServicePropCacheUpdateEx(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/LoggedInUsersList", 138 145 VBOXSERVICEPROPCACHEFLAG_TEMPORARY, NULL /* Delete on exit */, NULL); 139 VBoxServicePropCacheUpdateEx(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/LoggedInUsers", 146 VBoxServicePropCacheUpdateEx(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/LoggedInUsers", 140 147 VBOXSERVICEPROPCACHEFLAG_TEMPORARY, "0", NULL); 141 VBoxServicePropCacheUpdateEx(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/NoLoggedInUsers", 148 VBoxServicePropCacheUpdateEx(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/NoLoggedInUsers", 142 149 VBOXSERVICEPROPCACHEFLAG_TEMPORARY, "true", NULL); 143 150 /* … … 146 153 * properties are no longer valid. 147 154 */ 148 VBoxServicePropCacheUpdateEx(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/Net/Count", 155 VBoxServicePropCacheUpdateEx(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/Net/Count", 149 156 VBOXSERVICEPROPCACHEFLAG_TEMPORARY | VBOXSERVICEPROPCACHEFLAG_ALWAYS_UPDATE, "0", NULL); 150 157 } … … 165 172 char szInfo[256]; 166 173 int rc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szInfo, sizeof(szInfo)); 167 VBoxServiceWritePropF(g_ VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Product",174 VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Product", 168 175 "%s", RT_FAILURE(rc) ? "" : szInfo); 169 176 170 177 rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szInfo, sizeof(szInfo)); 171 VBoxServiceWritePropF(g_ VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Release",178 VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Release", 172 179 "%s", RT_FAILURE(rc) ? "" : szInfo); 173 180 174 181 rc = RTSystemQueryOSInfo(RTSYSOSINFO_VERSION, szInfo, sizeof(szInfo)); 175 VBoxServiceWritePropF(g_ VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Version",182 VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Version", 176 183 "%s", RT_FAILURE(rc) ? "" : szInfo); 177 184 178 185 rc = RTSystemQueryOSInfo(RTSYSOSINFO_SERVICE_PACK, szInfo, sizeof(szInfo)); 179 VBoxServiceWritePropF(g_ VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/ServicePack",186 VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/ServicePack", 180 187 "%s", RT_FAILURE(rc) ? "" : szInfo); 181 188 … … 186 193 char *pszAddRev; 187 194 rc = VbglR3GetAdditionsVersion(&pszAddVer, &pszAddRev); 188 VBoxServiceWritePropF(g_ VMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Version",195 VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Version", 189 196 "%s", RT_FAILURE(rc) ? "" : pszAddVer); 190 VBoxServiceWritePropF(g_ VMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Revision",197 VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Revision", 191 198 "%s", RT_FAILURE(rc) ? "" : pszAddRev); 192 199 if (RT_SUCCESS(rc)) … … 202 209 char *pszInstDir; 203 210 rc = VbglR3GetAdditionsInstallationPath(&pszInstDir); 204 VBoxServiceWritePropF(g_ VMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/InstallDir",211 VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/InstallDir", 205 212 "%s", RT_FAILURE(rc) ? "" : pszInstDir); 206 213 if (RT_SUCCESS(rc)) 207 214 RTStrFree(pszInstDir); 208 215 209 VBoxServiceWinGetComponentVersions(g_ VMInfoGuestPropSvcClientID);216 VBoxServiceWinGetComponentVersions(g_uVMInfoGuestPropSvcClientID); 210 217 #endif 211 218 } … … 338 345 || g_cVMInfoLoggedInUsers == UINT32_MAX) 339 346 { 340 /* 347 /* 341 348 * Update this property ONLY if there is a real change from no users to 342 349 * users or vice versa. The only exception is that the initialization 343 350 * forces an update, but only once. This ensures consistent property 344 * settings even if the VM aborted previously. 351 * settings even if the VM aborted previously. 345 352 */ 346 353 if (cUsersInList == 0) … … 355 362 */ 356 363 /** @todo Throw this code into a separate function/module? */ 357 int nNumInterfaces = 0;364 int cInterfaces = 0; 358 365 #ifdef RT_OS_WINDOWS 359 366 SOCKET sd = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0); … … 379 386 return -1; 380 387 } 381 nNumInterfaces = nBytesReturned / sizeof(INTERFACE_INFO);388 cInterfaces = nBytesReturned / sizeof(INTERFACE_INFO); 382 389 #else 383 390 int sd = socket(AF_INET, SOCK_DGRAM, 0); … … 400 407 ifreq* ifrequest = ifcfg.ifc_req; 401 408 ifreq *ifreqitem = NULL; 402 nNumInterfaces = ifcfg.ifc_len / sizeof(ifreq);409 cInterfaces = ifcfg.ifc_len / sizeof(ifreq); 403 410 #endif 404 411 char szPropPath [FILENAME_MAX]; 405 412 int iCurIface = 0; 406 413 414 /** @todo r=bird: As mentioned in the defect, this must be written after ALL 415 * the other values since it indicates that they are up-to-date by its 416 * timestamp. */ 407 417 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/Net/Count", "%d", 408 nNumInterfaces > 1 ? nNumInterfaces-1 : 0);418 cInterfaces > 1 ? cInterfaces-1 : 0); 409 419 410 420 /** @todo Use GetAdaptersInfo() and GetAdapterAddresses (IPv4 + IPv6) for more information. */ 411 for (int i = 0; i < nNumInterfaces; ++i)421 for (int i = 0; i < cInterfaces; ++i) 412 422 { 413 423 sockaddr_in *pAddress; … … 475 485 close(sd); 476 486 #endif 487 /** @todo r=bird: if cInterfaces decreased compared to the previous run, zap 488 * the stale data. */ 489 477 490 478 491 /* … … 484 497 if (*pfShutdown) 485 498 break; 486 int rc2 = RTSemEventMultiWait(g_ VMInfoEvent, g_VMInfoInterval);499 int rc2 = RTSemEventMultiWait(g_hVMInfoEvent, g_cMsVMInfoInterval); 487 500 if (*pfShutdown) 488 501 break; … … 506 519 static DECLCALLBACK(void) VBoxServiceVMInfoStop(void) 507 520 { 508 RTSemEventMultiSignal(g_ VMInfoEvent);521 RTSemEventMultiSignal(g_hVMInfoEvent); 509 522 } 510 523 … … 515 528 int rc; 516 529 517 if (g_ VMInfoEvent != NIL_RTSEMEVENTMULTI)530 if (g_hVMInfoEvent != NIL_RTSEMEVENTMULTI) 518 531 { 532 /** @todo temporary solution: Zap all values which are not valid 533 * anymore when VM goes down (reboot/shutdown ). Needs to 534 * be replaced with "temporary properties" later. 535 * 536 * One idea is to introduce a (HGCM-)session guest property 537 * flag meaning that a guest property is only valid as long 538 * as the HGCM session isn't closed (e.g. guest application 539 * terminates). [don't remove till implemented] 540 */ 541 /** @todo r=bird: Drop the VbglR3GuestPropDelSet call here and make the cache 542 * remember what we've written. */ 519 543 /* Delete the "../Net" branch. */ 520 544 const char *apszPat[1] = { "/VirtualBox/GuestInfo/Net/*" }; 521 rc = VbglR3GuestPropDelSet(g_ VMInfoGuestPropSvcClientID, &apszPat[0], RT_ELEMENTS(apszPat));545 rc = VbglR3GuestPropDelSet(g_uVMInfoGuestPropSvcClientID, &apszPat[0], RT_ELEMENTS(apszPat)); 522 546 523 547 /* Destroy property cache. */ … … 525 549 526 550 /* Disconnect from guest properties service. */ 527 rc = VbglR3GuestPropDisconnect(g_ VMInfoGuestPropSvcClientID);551 rc = VbglR3GuestPropDisconnect(g_uVMInfoGuestPropSvcClientID); 528 552 if (RT_FAILURE(rc)) 529 553 VBoxServiceError("Failed to disconnect from guest property service! Error: %Rrc\n", rc); 530 g_ VMInfoGuestPropSvcClientID = 0;531 532 RTSemEventMultiDestroy(g_ VMInfoEvent);533 g_ VMInfoEvent = NIL_RTSEMEVENTMULTI;554 g_uVMInfoGuestPropSvcClientID = 0; 555 556 RTSemEventMultiDestroy(g_hVMInfoEvent); 557 g_hVMInfoEvent = NIL_RTSEMEVENTMULTI; 534 558 } 535 559 }
Note:
See TracChangeset
for help on using the changeset viewer.