Changeset 28967 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- May 3, 2010 11:44:28 AM (15 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/Makefile.kmk
r28800 r28967 55 55 VBoxServiceTimeSync.cpp \ 56 56 VBoxServiceUtils.cpp \ 57 VBoxServiceStats.cpp 57 VBoxServiceStats.cpp \ 58 VBoxServicePropCache.cpp 58 59 ifdef VBOX_WITH_GUEST_CONTROL 59 60 VBoxService_SOURCES += \ -
trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp
r28887 r28967 590 590 if (iMain == ~0U) 591 591 return VBoxServiceSyntax("At least one service must be enabled.\n"); 592 593 592 #ifndef RT_OS_WINDOWS 594 593 /* … … 652 651 } 653 652 #endif 654 655 653 #ifdef RT_OS_WINDOWS 656 654 /* -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp
r28887 r28967 339 339 340 340 if (pNext && RTListNodeIsLast(&g_GuestControlExecThreads, &pNext->Node)) 341 341 break; 342 342 343 343 pNode = pNext; -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h
r28943 r28967 213 213 /** Pointer to a standard input buffer. */ 214 214 typedef VBOXSERVICECTRLSTDINBUF *PVBOXSERVICECTRLSTDINBUF; 215 #endif 215 #endif /* VBOX_WITH_GUEST_CONTROL */ 216 217 #ifdef VBOX_WITH_GUEST_PROPS 218 /** 219 * A guest propertiy cache. 220 */ 221 typedef struct 222 { 223 /** The client ID for HGCM communication. */ 224 uint32_t uClientID; 225 RTLISTNODE Node; 226 } VBOXSERVICEVEPROPCACHE; 227 /** Pointer to a guest property cache. */ 228 typedef VBOXSERVICEVEPROPCACHE *PVBOXSERVICEVEPROPCACHE; 229 230 /** 231 * Handling guest properties used by the VM information service. 232 */ 233 typedef struct 234 { 235 /** Node. */ 236 RTLISTNODE Node; 237 /** Name (and full path) of guest property. */ 238 char *pszName; 239 /** The last value stored (for reference). */ 240 char *pszValue; 241 /** Reset value to write if property is temporary. */ 242 char *pszValueReset; 243 /** Flags. */ 244 uint32_t uFlags; 245 } VBOXSERVICEVEPROPCACHEENTRY; 246 /** Pointer to a cached guest property. */ 247 typedef VBOXSERVICEVEPROPCACHEENTRY *PVBOXSERVICEVEPROPCACHEENTRY; 248 #endif /* VBOX_WITH_GUEST_PROPS */ 216 249 217 250 RT_C_DECLS_BEGIN -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceUtils.cpp
r28800 r28967 183 183 return rc; 184 184 } 185 186 185 #endif /* VBOX_WITH_GUEST_PROPS */ 187 186 #ifdef RT_OS_WINDOWS -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp
r28800 r28967 54 54 #include "VBoxServiceInternal.h" 55 55 #include "VBoxServiceUtils.h" 56 #include "VBoxServicePropCache.h" 56 57 57 58 … … 60 61 *******************************************************************************/ 61 62 /** The vminfo interval (millseconds). */ 62 uint32_t g_VMInfoInterval = 0;63 uint32_t g_VMInfoInterval = 0; 63 64 /** The semaphore we're blocking on. */ 64 static RTSEMEVENTMULTI g_VMInfoEvent = NIL_RTSEMEVENTMULTI;65 static RTSEMEVENTMULTI g_VMInfoEvent = NIL_RTSEMEVENTMULTI; 65 66 /** The guest property service client ID. */ 66 static uint32_t g_VMInfoGuestPropSvcClientID = 0;67 static uint32_t g_VMInfoGuestPropSvcClientID = 0; 67 68 /** Number of logged in users in OS. */ 68 static uint32_t g_cVMInfoLoggedInUsers = UINT32_MAX; 69 static uint32_t g_cVMInfoLoggedInUsers = UINT32_MAX; 70 /** The guest property cache. */ 71 static VBOXSERVICEVEPROPCACHE g_VMInfoPropCache; 69 72 70 73 … … 124 127 } 125 128 129 if (RT_SUCCESS(rc)) 130 { 131 VBoxServicePropCacheInit(&g_VMInfoPropCache, g_VMInfoGuestPropSvcClientID); 132 133 VBoxServicePropCacheUpdateEx(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/Net/Count", 134 VBOXSERVICEPROPCACHEFLAG_TEMPORARY | VBOXSERVICEPROPCACHEFLAG_ALWAYS_UPDATE, "0", "0"); 135 VBoxServicePropCacheUpdateEx(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/LoggedInUsersList", 136 VBOXSERVICEPROPCACHEFLAG_TEMPORARY, NULL, NULL); 137 VBoxServicePropCacheUpdateEx(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/LoggedInUsers", 138 VBOXSERVICEPROPCACHEFLAG_TEMPORARY, "0", "0"); 139 VBoxServicePropCacheUpdateEx(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/NoLoggedInUsers", 140 VBOXSERVICEPROPCACHEFLAG_TEMPORARY, "true", "true"); 141 } 126 142 return rc; 127 143 } … … 306 322 307 323 if (cUsersInList > 0) 308 VBoxService WritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/LoggedInUsersList", "%s", szUserList);324 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/LoggedInUsersList", "%s", szUserList); 309 325 else 310 VBoxService WritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/LoggedInUsersList", NULL);311 VBoxService WritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/LoggedInUsers", "%u", cUsersInList);326 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/LoggedInUsersList", NULL); 327 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/LoggedInUsers", "%u", cUsersInList); 312 328 if ( g_cVMInfoLoggedInUsers != cUsersInList 313 329 || g_cVMInfoLoggedInUsers == UINT32_MAX) 314 330 { 315 /* Update this property ONLY if there is a real change from no users to 331 /* 332 * Update this property ONLY if there is a real change from no users to 316 333 * users or vice versa. The only exception is that the initialization 317 334 * forces an update, but only once. This ensures consistent property 318 * settings even if the VM aborted previously. */ 335 * settings even if the VM aborted previously. 336 */ 319 337 if (cUsersInList == 0) 320 VBoxService WritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/NoLoggedInUsers", "true");338 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/NoLoggedInUsers", "true"); 321 339 else if (g_cVMInfoLoggedInUsers == 0) 322 VBoxService WritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/NoLoggedInUsers", "false");340 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/NoLoggedInUsers", "false"); 323 341 } 324 342 g_cVMInfoLoggedInUsers = cUsersInList; … … 383 401 * properties are no longer valid. 384 402 */ 385 VBoxService WritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/Net/Count", "%d",386 nNumInterfaces > 1 ? nNumInterfaces-1 : 0);403 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/Net/Count", "%d", 404 nNumInterfaces > 1 ? nNumInterfaces-1 : 0); 387 405 388 406 /** @todo Use GetAdaptersInfo() and GetAdapterAddresses (IPv4 + IPv6) for more information. */ … … 409 427 Assert(pAddress); 410 428 RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%d/V4/IP", iCurIface); 411 VBoxService WritePropF(g_VMInfoGuestPropSvcClientID, szPropPath, "%s", inet_ntoa(pAddress->sin_addr));429 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", inet_ntoa(pAddress->sin_addr)); 412 430 413 431 #ifdef RT_OS_WINDOWS … … 422 440 #endif 423 441 RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%d/V4/Broadcast", iCurIface); 424 VBoxService WritePropF(g_VMInfoGuestPropSvcClientID, szPropPath, "%s", inet_ntoa(pAddress->sin_addr));442 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", inet_ntoa(pAddress->sin_addr)); 425 443 426 444 #ifdef RT_OS_WINDOWS … … 440 458 #endif 441 459 RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%d/V4/Netmask", iCurIface); 442 VBoxService WritePropF(g_VMInfoGuestPropSvcClientID, szPropPath, "%s", inet_ntoa(pAddress->sin_addr));460 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", inet_ntoa(pAddress->sin_addr)); 443 461 444 462 RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%d/Status", iCurIface); 445 VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, szPropPath, 446 nFlags & IFF_UP ? "Up" : "Down"); 447 463 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, 464 nFlags & IFF_UP ? "Up" : "Down"); 448 465 iCurIface++; 449 466 } … … 496 513 if (g_VMInfoEvent != NIL_RTSEMEVENTMULTI) 497 514 { 498 /** @todo temporary solution: Zap all values which are not valid 499 * anymore when VM goes down (reboot/shutdown ). Needs to 500 * be replaced with "temporary properties" later. 501 * 502 * One idea is to introduce a (HGCM-)session guest property 503 * flag meaning that a guest property is only valid as long 504 * as the HGCM session isn't closed (e.g. guest application 505 * terminates). 506 */ 507 rc = VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/LoggedInUsersList", NULL); 508 rc = VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/LoggedInUsers", "%d", 0); 509 if (g_cVMInfoLoggedInUsers > 0) 510 VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/NoLoggedInUsers", "true"); 511 515 /* Delete the "../Net" branch. */ 512 516 const char *apszPat[1] = { "/VirtualBox/GuestInfo/Net/*" }; 513 517 rc = VbglR3GuestPropDelSet(g_VMInfoGuestPropSvcClientID, &apszPat[0], RT_ELEMENTS(apszPat)); 514 rc = VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/Net/Count", "%d", 0); 518 519 /* Destroy property cache. */ 520 VBoxServicePropCacheDestroy(&g_VMInfoPropCache); 515 521 516 522 /* Disconnect from guest properties service. */ … … 519 525 VBoxServiceError("Failed to disconnect from guest property service! Error: %Rrc\n", rc); 520 526 g_VMInfoGuestPropSvcClientID = 0; 521 522 527 523 528 RTSemEventMultiDestroy(g_VMInfoEvent);
Note:
See TracChangeset
for help on using the changeset viewer.