VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp@ 29345

Last change on this file since 29345 was 29345, checked in by vboxsync, 15 years ago

VBoxService,VBox/err.h: Use a dedicated status code for this, VERR_NOT_IMPLEMENTED and VERR_NOT_SUPPORTED are not suitable. Disable ballooning if either VbglR3MemBalloonRefresh or VBoxServiceBalloonSetUser fails instead of just checking the first. Don't display an error message on non-Windows hosts when ballooning is unavailbe (status code mixup).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.2 KB
Line 
1/* $Id: VBoxServiceVMInfo.cpp 29345 2010-05-11 12:22:48Z vboxsync $ */
2/** @file
3 * VBoxService - Virtual Machine Information for the Host.
4 */
5
6/*
7 * Copyright (C) 2009-2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19
20/*******************************************************************************
21* Header Files *
22*******************************************************************************/
23#ifdef RT_OS_WINDOWS
24#include <winsock2.h>
25#include <ws2tcpip.h>
26#include <windows.h>
27#include <Ntsecapi.h>
28#else
29# define __STDC_LIMIT_MACROS
30# include <arpa/inet.h>
31# include <errno.h>
32# include <netinet/in.h>
33# include <sys/ioctl.h>
34# include <sys/socket.h>
35# include <net/if.h>
36# include <unistd.h>
37# ifndef RT_OS_FREEBSD /* The header does not exist anymore since FreeBSD 9-current */
38# include <utmp.h>
39# endif
40# ifdef RT_OS_SOLARIS
41# include <sys/sockio.h>
42# endif
43#endif
44
45#include <iprt/mem.h>
46#include <iprt/thread.h>
47#include <iprt/string.h>
48#include <iprt/semaphore.h>
49#include <iprt/system.h>
50#include <iprt/time.h>
51#include <iprt/assert.h>
52#include <VBox/version.h>
53#include <VBox/VBoxGuestLib.h>
54#include "VBoxServiceInternal.h"
55#include "VBoxServiceUtils.h"
56#include "VBoxServicePropCache.h"
57
58
59/*******************************************************************************
60* Global Variables *
61*******************************************************************************/
62/** The vminfo interval (millseconds). */
63static uint32_t g_cMsVMInfoInterval = 0;
64/** The semaphore we're blocking on. */
65static RTSEMEVENTMULTI g_hVMInfoEvent = NIL_RTSEMEVENTMULTI;
66/** The guest property service client ID. */
67static uint32_t g_uVMInfoGuestPropSvcClientID = 0;
68/** Number of logged in users in OS. */
69static uint32_t g_cVMInfoLoggedInUsers = UINT32_MAX;
70/** The guest property cache. */
71static VBOXSERVICEVEPROPCACHE g_VMInfoPropCache;
72
73
74/** @copydoc VBOXSERVICE::pfnPreInit */
75static DECLCALLBACK(int) VBoxServiceVMInfoPreInit(void)
76{
77 return VINF_SUCCESS;
78}
79
80
81/** @copydoc VBOXSERVICE::pfnOption */
82static DECLCALLBACK(int) VBoxServiceVMInfoOption(const char **ppszShort, int argc, char **argv, int *pi)
83{
84 int rc = -1;
85 if (ppszShort)
86 /* no short options */;
87 else if (!strcmp(argv[*pi], "--vminfo-interval"))
88 rc = VBoxServiceArgUInt32(argc, argv, "", pi,
89 &g_cMsVMInfoInterval, 1, UINT32_MAX - 1);
90 return rc;
91}
92
93
94/** @copydoc VBOXSERVICE::pfnInit */
95static DECLCALLBACK(int) VBoxServiceVMInfoInit(void)
96{
97 /*
98 * If not specified, find the right interval default.
99 * Then create the event sem to block on.
100 */
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 AssertRCReturn(rc, rc);
108
109#ifdef RT_OS_WINDOWS
110 /** @todo r=bird: call a windows specific init function and move
111 * g_pfnWTSGetActiveConsoleSessionId out of the global scope. */
112 /* Get function pointers. */
113 HMODULE hKernel32 = LoadLibrary("kernel32");
114 if (hKernel32 != NULL)
115 {
116 g_pfnWTSGetActiveConsoleSessionId = (PFNWTSGETACTIVECONSOLESESSIONID)GetProcAddress(hKernel32, "WTSGetActiveConsoleSessionId");
117 FreeLibrary(hKernel32);
118 }
119#endif
120
121 rc = VbglR3GuestPropConnect(&g_uVMInfoGuestPropSvcClientID);
122 if (RT_SUCCESS(rc))
123 VBoxServiceVerbose(3, "VMInfo: Property Service Client ID: %#x\n", g_uVMInfoGuestPropSvcClientID);
124 else
125 {
126 /* If the service was not found, we disable this service without
127 causing VBoxService to fail. */
128 if (rc == VERR_HGCM_SERVICE_NOT_FOUND) /* Host service is not available. */
129 {
130 VBoxServiceVerbose(0, "VMInfo: Guest property service is not available, disabling the service\n");
131 rc = VERR_SERVICE_DISABLED;
132 }
133 else
134 VBoxServiceError("VMInfo: Failed to connect to the guest property service! Error: %Rrc\n", rc);
135 RTSemEventMultiDestroy(g_hVMInfoEvent);
136 g_hVMInfoEvent = NIL_RTSEMEVENTMULTI;
137 }
138
139 if (RT_SUCCESS(rc))
140 {
141 VBoxServicePropCacheCreate(&g_VMInfoPropCache, g_uVMInfoGuestPropSvcClientID);
142
143 /*
144 * Declare some guest properties with flags and reset values.
145 */
146 VBoxServicePropCacheUpdateEntry(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/LoggedInUsersList",
147 VBOXSERVICEPROPCACHEFLAG_TEMPORARY, NULL /* Delete on exit */);
148 VBoxServicePropCacheUpdateEntry(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/LoggedInUsers",
149 VBOXSERVICEPROPCACHEFLAG_TEMPORARY, "0");
150 VBoxServicePropCacheUpdateEntry(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/NoLoggedInUsers",
151 VBOXSERVICEPROPCACHEFLAG_TEMPORARY, "true");
152 VBoxServicePropCacheUpdateEntry(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/Net/Count",
153 VBOXSERVICEPROPCACHEFLAG_TEMPORARY | VBOXSERVICEPROPCACHEFLAG_ALWAYS_UPDATE, NULL /* Delete on exit */);
154 }
155 return rc;
156}
157
158
159/**
160 * Writes the properties that won't change while the service is running.
161 *
162 * Errors are ignored.
163 */
164static void VBoxServiceVMInfoWriteFixedProperties(void)
165{
166 /*
167 * First get OS information that won't change.
168 */
169 char szInfo[256];
170 int rc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szInfo, sizeof(szInfo));
171 VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Product",
172 "%s", RT_FAILURE(rc) ? "" : szInfo);
173
174 rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szInfo, sizeof(szInfo));
175 VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Release",
176 "%s", RT_FAILURE(rc) ? "" : szInfo);
177
178 rc = RTSystemQueryOSInfo(RTSYSOSINFO_VERSION, szInfo, sizeof(szInfo));
179 VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Version",
180 "%s", RT_FAILURE(rc) ? "" : szInfo);
181
182 rc = RTSystemQueryOSInfo(RTSYSOSINFO_SERVICE_PACK, szInfo, sizeof(szInfo));
183 VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/ServicePack",
184 "%s", RT_FAILURE(rc) ? "" : szInfo);
185
186 /*
187 * Retrieve version information about Guest Additions and installed files (components).
188 */
189 char *pszAddVer;
190 char *pszAddRev;
191 rc = VbglR3GetAdditionsVersion(&pszAddVer, &pszAddRev);
192 VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Version",
193 "%s", RT_FAILURE(rc) ? "" : pszAddVer);
194 VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Revision",
195 "%s", RT_FAILURE(rc) ? "" : pszAddRev);
196 if (RT_SUCCESS(rc))
197 {
198 RTStrFree(pszAddVer);
199 RTStrFree(pszAddRev);
200 }
201
202#ifdef RT_OS_WINDOWS
203 /*
204 * Do windows specific properties.
205 */
206 char *pszInstDir;
207 rc = VbglR3GetAdditionsInstallationPath(&pszInstDir);
208 VBoxServiceWritePropF(g_uVMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/InstallDir",
209 "%s", RT_FAILURE(rc) ? "" : pszInstDir);
210 if (RT_SUCCESS(rc))
211 RTStrFree(pszInstDir);
212
213 VBoxServiceWinGetComponentVersions(g_uVMInfoGuestPropSvcClientID);
214#endif
215}
216
217
218/** @copydoc VBOXSERVICE::pfnWorker */
219DECLCALLBACK(int) VBoxServiceVMInfoWorker(bool volatile *pfShutdown)
220{
221 int rc = VINF_SUCCESS;
222
223 /*
224 * Tell the control thread that it can continue
225 * spawning services.
226 */
227 RTThreadUserSignal(RTThreadSelf());
228
229#ifdef RT_OS_WINDOWS
230 /* Required for network information (must be called per thread). */
231 WSADATA wsaData;
232 if (WSAStartup(MAKEWORD(2, 2), &wsaData))
233 VBoxServiceError("WSAStartup failed! Error: %Rrc\n", RTErrConvertFromWin32(WSAGetLastError()));
234#endif /* RT_OS_WINDOWS */
235
236 /*
237 * Write the fixed properties first.
238 */
239 VBoxServiceVMInfoWriteFixedProperties();
240
241 /*
242 * Now enter the loop retrieving runtime data continuously.
243 */
244 unsigned cErrors = 0;
245 for (;;)
246 {
247/** @todo r=bird: split this code up into functions!! */
248 /* Enumerate logged in users. */
249 uint32_t cUsersInList = 0;
250 char szUserList[4096] = {0};
251
252#ifdef RT_OS_WINDOWS
253# ifndef TARGET_NT4
254 PLUID paSessions = NULL;
255 ULONG cSession = 0;
256 NTSTATUS r = 0;
257
258 /* This function can report stale or orphaned interactive logon sessions
259 of already logged off users (especially in Windows 2000). */
260 r = ::LsaEnumerateLogonSessions(&cSession, &paSessions);
261 VBoxServiceVerbose(3, "Users: Found %ld users.\n", cSession);
262 if (r != STATUS_SUCCESS)
263 {
264 VBoxServiceError("LsaEnumerate failed %lu\n", LsaNtStatusToWinError(r));
265 return 1;
266 }
267
268 PVBOXSERVICEVMINFOPROC paProcs;
269 DWORD cProcs;
270 rc = VBoxServiceVMInfoWinProcessesEnumerate(&paProcs, &cProcs);
271 if (RT_SUCCESS(rc))
272 {
273 for (ULONG i = 0; i < cSession; i++)
274 {
275 VBOXSERVICEVMINFOUSER UserInfo;
276 if ( VBoxServiceVMInfoWinIsLoggedIn(&UserInfo, &paSessions[i])
277 && VBoxServiceVMInfoWinSessionHasProcesses(&paSessions[i], paProcs, cProcs))
278 {
279 if (cUsersInList > 0)
280 strcat(szUserList, ",");
281
282 cUsersInList++;
283
284 char *pszTemp;
285 int rc2 = RTUtf16ToUtf8(UserInfo.wszUser, &pszTemp);
286 if (RT_SUCCESS(rc2))
287 {
288 strcat(szUserList, pszTemp);
289 RTMemFree(pszTemp);
290 }
291 else
292 strcat(szUserList, "<string-convertion-error>");
293 }
294 }
295 VBoxServiceVMInfoWinProcessesFree(paProcs);
296 }
297
298 ::LsaFreeReturnBuffer(paSessions);
299# endif /* TARGET_NT4 */
300#elif defined(RT_OS_FREEBSD)
301 /** @todo FreeBSD: Port logged on user info retrival. */
302#elif defined(RT_OS_OS2)
303 /** @todo OS/2: Port logged on (LAN/local/whatever) user info retrival. */
304#else
305 rc = utmpname(UTMP_FILE);
306# ifdef RT_OS_SOLARIS
307 if (rc != 1)
308# else
309 if (rc != 0)
310# endif
311 {
312 VBoxServiceError("Could not set UTMP file! Error: %ld\n", errno);
313 }
314 setutent();
315 utmp *ut_user;
316 while ((ut_user = getutent()))
317 {
318 /* Make sure we don't add user names which are not
319 * part of type USER_PROCESS and don't add same users twice. */
320 if ( ut_user->ut_type == USER_PROCESS
321 && strstr(szUserList, ut_user->ut_user) == NULL)
322 {
323 /** @todo Do we really want to filter out double user names? (Same user logged in twice)
324 * bird: If we do, then we must add checks for buffer overflows here! */
325 /** @todo r=bird: strstr will filtering out users with similar names. For
326 * example: smith, smithson, joesmith and bobsmith */
327 if (cUsersInList > 0)
328 strcat(szUserList, ",");
329 strcat(szUserList, ut_user->ut_user);
330 cUsersInList++;
331 }
332 }
333 endutent();
334#endif /* !RT_OS_WINDOWS */
335
336 if (cUsersInList > 0)
337 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/LoggedInUsersList", "%s", szUserList);
338 else
339 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/LoggedInUsersList", NULL);
340 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/LoggedInUsers", "%u", cUsersInList);
341 if ( g_cVMInfoLoggedInUsers != cUsersInList
342 || g_cVMInfoLoggedInUsers == UINT32_MAX)
343 {
344 /*
345 * Update this property ONLY if there is a real change from no users to
346 * users or vice versa. The only exception is that the initialization
347 * forces an update, but only once. This ensures consistent property
348 * settings even if the VM aborted previously.
349 */
350 if (cUsersInList == 0)
351 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/NoLoggedInUsers", "true");
352 else if (g_cVMInfoLoggedInUsers == 0)
353 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/OS/NoLoggedInUsers", "false");
354 }
355 g_cVMInfoLoggedInUsers = cUsersInList;
356
357 /*
358 * Get network configuration.
359 */
360 /** @todo Throw this code into a separate function/module? */
361 int cInterfaces = 0;
362#ifdef RT_OS_WINDOWS
363 SOCKET sd = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0);
364 if (sd == SOCKET_ERROR) /* Socket invalid. */
365 {
366 VBoxServiceError("Failed to get a socket: Error %d\n", WSAGetLastError());
367 return -1;
368 }
369
370 INTERFACE_INFO InterfaceList[20] = {0};
371 unsigned long nBytesReturned = 0;
372 if (WSAIoctl(sd,
373 SIO_GET_INTERFACE_LIST,
374 0,
375 0,
376 &InterfaceList,
377 sizeof(InterfaceList),
378 &nBytesReturned,
379 0,
380 0) == SOCKET_ERROR)
381 {
382 VBoxServiceError("Failed to WSAIoctl() on socket: Error: %d\n", WSAGetLastError());
383 return -1;
384 }
385 cInterfaces = nBytesReturned / sizeof(INTERFACE_INFO);
386#else
387 int sd = socket(AF_INET, SOCK_DGRAM, 0);
388 if (sd < 0) /* Socket invalid. */
389 {
390 VBoxServiceError("Failed to get a socket: Error %d\n", errno);
391 return -1;
392 }
393
394 ifconf ifcfg;
395 char buffer[1024] = {0};
396 ifcfg.ifc_len = sizeof(buffer);
397 ifcfg.ifc_buf = buffer;
398 if (ioctl(sd, SIOCGIFCONF, &ifcfg) < 0)
399 {
400 VBoxServiceError("Failed to ioctl(SIOCGIFCONF) on socket: Error %d\n", errno);
401 return -1;
402 }
403
404 ifreq* ifrequest = ifcfg.ifc_req;
405 ifreq *ifreqitem = NULL;
406 cInterfaces = ifcfg.ifc_len / sizeof(ifreq);
407#endif
408 char szPropPath [FILENAME_MAX];
409 int iCurIface = 0;
410
411 /** @todo Use GetAdaptersInfo() and GetAdapterAddresses (IPv4 + IPv6) for more information. */
412 for (int i = 0; i < cInterfaces; ++i)
413 {
414 sockaddr_in *pAddress;
415 u_long nFlags = 0;
416#ifdef RT_OS_WINDOWS
417 if (InterfaceList[i].iiFlags & IFF_LOOPBACK) /* Skip loopback device. */
418 continue;
419 nFlags = InterfaceList[i].iiFlags;
420 pAddress = (sockaddr_in *)&(InterfaceList[i].iiAddress);
421#else
422 if (ioctl(sd, SIOCGIFFLAGS, &ifrequest[i]) < 0)
423 {
424 VBoxServiceError("Failed to ioctl(SIOCGIFFLAGS) on socket: Error %d\n", errno);
425 return -1;
426 }
427 if (ifrequest[i].ifr_flags & IFF_LOOPBACK) /* Skip loopback device. */
428 continue;
429 nFlags = ifrequest[i].ifr_flags;
430 pAddress = ((sockaddr_in *)&ifrequest[i].ifr_addr);
431#endif
432 Assert(pAddress);
433 RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%d/V4/IP", iCurIface);
434 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", inet_ntoa(pAddress->sin_addr));
435
436#ifdef RT_OS_WINDOWS
437 pAddress = (sockaddr_in *) & (InterfaceList[i].iiBroadcastAddress);
438#else
439 if (ioctl(sd, SIOCGIFBRDADDR, &ifrequest[i]) < 0)
440 {
441 VBoxServiceError("Failed to ioctl(SIOCGIFBRDADDR) on socket: Error %d\n", errno);
442 return -1;
443 }
444 pAddress = (sockaddr_in *)&ifrequest[i].ifr_broadaddr;
445#endif
446 RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%d/V4/Broadcast", iCurIface);
447 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", inet_ntoa(pAddress->sin_addr));
448
449#ifdef RT_OS_WINDOWS
450 pAddress = (sockaddr_in *)&(InterfaceList[i].iiNetmask);
451#else
452 if (ioctl(sd, SIOCGIFNETMASK, &ifrequest[i]) < 0)
453 {
454 VBoxServiceError("Failed to ioctl(SIOCGIFBRDADDR) on socket: Error %d\n", errno);
455 return -1;
456 }
457 #if defined(RT_OS_FREEBSD) || defined(RT_OS_OS2) || defined(RT_OS_SOLARIS)
458 pAddress = (sockaddr_in *)&ifrequest[i].ifr_addr;
459 #else
460 pAddress = (sockaddr_in *)&ifrequest[i].ifr_netmask;
461 #endif
462
463#endif
464 RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%d/V4/Netmask", iCurIface);
465 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", inet_ntoa(pAddress->sin_addr));
466
467 RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%d/Status", iCurIface);
468 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath,
469 nFlags & IFF_UP ? "Up" : "Down");
470 iCurIface++;
471 }
472 if (sd >= 0)
473#ifdef RT_OS_WINDOWS
474 closesocket(sd);
475#else
476 close(sd);
477#endif
478
479 /*
480 * This property is a beacon which is _always_ written, even if the network configuration
481 * does not change. If this property is missing, the host assumes that all other GuestInfo
482 * properties are no longer valid.
483 *
484 * cInterfaces also counts in local loopback, but we don't want to report that.
485 */
486 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/Net/Count", "%d",
487 cInterfaces > 1 ? cInterfaces-1 : 0);
488
489 /** @todo r=bird: if cInterfaces decreased compared to the previous run, zap
490 * the stale data. This can probably be encorporated into the cache. */
491
492
493 /*
494 * Block for a while.
495 *
496 * The event semaphore takes care of ignoring interruptions and it
497 * allows us to implement service wakeup later.
498 */
499 if (*pfShutdown)
500 break;
501 int rc2 = RTSemEventMultiWait(g_hVMInfoEvent, g_cMsVMInfoInterval);
502 if (*pfShutdown)
503 break;
504 if (rc2 != VERR_TIMEOUT && RT_FAILURE(rc2))
505 {
506 VBoxServiceError("RTSemEventMultiWait failed; rc2=%Rrc\n", rc2);
507 rc = rc2;
508 break;
509 }
510 }
511
512#ifdef RT_OS_WINDOWS
513 WSACleanup();
514#endif
515
516 return rc;
517}
518
519
520/** @copydoc VBOXSERVICE::pfnStop */
521static DECLCALLBACK(void) VBoxServiceVMInfoStop(void)
522{
523 RTSemEventMultiSignal(g_hVMInfoEvent);
524}
525
526
527/** @copydoc VBOXSERVICE::pfnTerm */
528static DECLCALLBACK(void) VBoxServiceVMInfoTerm(void)
529{
530 int rc;
531
532 if (g_hVMInfoEvent != NIL_RTSEMEVENTMULTI)
533 {
534 /** @todo temporary solution: Zap all values which are not valid
535 * anymore when VM goes down (reboot/shutdown ). Needs to
536 * be replaced with "temporary properties" later.
537 *
538 * One idea is to introduce a (HGCM-)session guest property
539 * flag meaning that a guest property is only valid as long
540 * as the HGCM session isn't closed (e.g. guest application
541 * terminates). [don't remove till implemented]
542 */
543 /** @todo r=bird: Drop the VbglR3GuestPropDelSet call here and use the cache
544 * since it remembers what we've written. */
545 /* Delete the "../Net" branch. */
546 const char *apszPat[1] = { "/VirtualBox/GuestInfo/Net/*" };
547 rc = VbglR3GuestPropDelSet(g_uVMInfoGuestPropSvcClientID, &apszPat[0], RT_ELEMENTS(apszPat));
548
549 /* Destroy property cache. */
550 VBoxServicePropCacheDestroy(&g_VMInfoPropCache);
551
552 /* Disconnect from guest properties service. */
553 rc = VbglR3GuestPropDisconnect(g_uVMInfoGuestPropSvcClientID);
554 if (RT_FAILURE(rc))
555 VBoxServiceError("Failed to disconnect from guest property service! Error: %Rrc\n", rc);
556 g_uVMInfoGuestPropSvcClientID = 0;
557
558 RTSemEventMultiDestroy(g_hVMInfoEvent);
559 g_hVMInfoEvent = NIL_RTSEMEVENTMULTI;
560 }
561}
562
563
564/**
565 * The 'vminfo' service description.
566 */
567VBOXSERVICE g_VMInfo =
568{
569 /* pszName. */
570 "vminfo",
571 /* pszDescription. */
572 "Virtual Machine Information",
573 /* pszUsage. */
574 "[--vminfo-interval <ms>]"
575 ,
576 /* pszOptions. */
577 " --vminfo-interval Specifies the interval at which to retrieve the\n"
578 " VM information. The default is 10000 ms.\n"
579 ,
580 /* methods */
581 VBoxServiceVMInfoPreInit,
582 VBoxServiceVMInfoOption,
583 VBoxServiceVMInfoInit,
584 VBoxServiceVMInfoWorker,
585 VBoxServiceVMInfoStop,
586 VBoxServiceVMInfoTerm
587};
588
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette