VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxBalloonCtrl/VBoxModAPIMonitor.cpp@ 39986

Last change on this file since 39986 was 39986, checked in by vboxsync, 13 years ago

VBoxBalloonCtrl: Update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1
2/* $Id: VBoxModAPIMonitor.cpp 39986 2012-02-03 14:21:28Z vboxsync $ */
3/** @file
4 * VBoxModAPIMonitor - API monitor module for detecting host isolation.
5 */
6
7/*
8 * Copyright (C) 2012 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19
20/*******************************************************************************
21* Header Files *
22*******************************************************************************/
23#ifndef VBOX_ONLY_DOCS
24# include <VBox/com/com.h>
25# include <VBox/com/string.h>
26# include <VBox/com/Guid.h>
27# include <VBox/com/array.h>
28# include <VBox/com/ErrorInfo.h>
29# include <VBox/com/errorprint.h>
30
31# include <VBox/com/EventQueue.h>
32# include <VBox/com/listeners.h>
33# include <VBox/com/VirtualBox.h>
34#endif /* !VBOX_ONLY_DOCS */
35
36#include <VBox/err.h>
37#include <VBox/log.h>
38#include <VBox/version.h>
39
40#include <package-generated.h>
41
42#include <iprt/asm.h>
43#include <iprt/buildconfig.h>
44#include <iprt/critsect.h>
45#include <iprt/getopt.h>
46#include <iprt/initterm.h>
47#include <iprt/path.h>
48#include <iprt/process.h>
49#include <iprt/semaphore.h>
50#include <iprt/stream.h>
51#include <iprt/string.h>
52#include <iprt/system.h>
53
54#include <map>
55#include <string>
56#include <signal.h>
57
58#include "VBoxWatchdogInternal.h"
59
60using namespace com;
61
62#define VBOX_MOD_APIMONITOR_NAME "apimonitor"
63
64/**
65 * The module's RTGetOpt-IDs for the command line.
66 */
67enum GETOPTDEF_APIMONITOR
68{
69 GETOPTDEF_APIMONITOR_GROUPS = 1000,
70};
71
72/**
73 * The module's command line arguments.
74 */
75static const RTGETOPTDEF g_aAPIMonitorOpts[] = {
76 { "--apimonitor-groups", GETOPTDEF_APIMONITOR_GROUPS, RTGETOPT_REQ_STRING }
77};
78
79/* Callbacks. */
80static DECLCALLBACK(int) VBoxModAPIMonitorPreInit(void)
81{
82 return VINF_SUCCESS;
83}
84
85static DECLCALLBACK(int) VBoxModAPIMonitorOption(int argc, char **argv)
86{
87 if (!argc) /* Take a shortcut. */
88 return -1;
89
90 AssertPtrReturn(argv, VERR_INVALID_PARAMETER);
91
92 RTGETOPTSTATE GetState;
93 int rc = RTGetOptInit(&GetState, argc, argv,
94 g_aAPIMonitorOpts, RT_ELEMENTS(g_aAPIMonitorOpts),
95 0 /* First */, 0 /*fFlags*/);
96 if (RT_FAILURE(rc))
97 return rc;
98
99 rc = 0; /* Set default parsing result to valid. */
100
101 int c;
102 RTGETOPTUNION ValueUnion;
103 while ((c = RTGetOpt(&GetState, &ValueUnion)))
104 {
105 switch (c)
106 {
107 case GETOPTDEF_APIMONITOR_GROUPS:
108 break;
109
110 default:
111 rc = -1; /* We don't handle this option, skip. */
112 break;
113 }
114 }
115
116 return rc;
117}
118
119static DECLCALLBACK(int) VBoxModAPIMonitorInit(void)
120{
121 return VINF_SUCCESS; /* Nothing to do here right now. */
122}
123
124static DECLCALLBACK(int) VBoxModAPIMonitorMain(void)
125{
126 return VINF_SUCCESS; /* Nothing to do here right now. */
127}
128
129static DECLCALLBACK(int) VBoxModAPIMonitorStop(void)
130{
131 return VINF_SUCCESS;
132}
133
134static DECLCALLBACK(void) VBoxModAPIMonitorTerm(void)
135{
136}
137
138static DECLCALLBACK(int) VBoxModAPIMonitorOnMachineRegistered(const Bstr &strUuid)
139{
140 return VINF_SUCCESS;
141}
142
143static DECLCALLBACK(int) VBoxModAPIMonitorOnMachineUnregistered(const Bstr &strUuid)
144{
145 return VINF_SUCCESS;
146}
147
148static DECLCALLBACK(int) VBoxModAPIMonitorOnMachineStateChanged(const Bstr &strUuid,
149 MachineState_T enmState)
150{
151 return VINF_SUCCESS;
152}
153
154static DECLCALLBACK(int) VBoxModAPIMonitorOnServiceStateChanged(bool fAvailable)
155{
156 return VINF_SUCCESS;
157}
158
159/**
160 * The 'apimonitor' module description.
161 */
162VBOXMODULE g_ModAPIMonitor =
163{
164 /* pszName. */
165 VBOX_MOD_APIMONITOR_NAME,
166 /* pszDescription. */
167 "API monitor for host isolation detection",
168 /* pszDepends. */
169 NULL,
170 /* uPriority. */
171 0 /* Not used */,
172 /* pszUsage. */
173 " [--apimonitor-groups <string>]\n"
174 ,
175 /* pszOptions. */
176 "--apimonitor-groups Sets the VM groups for monitoring (none).\n",
177 /* methods. */
178 VBoxModAPIMonitorPreInit,
179 VBoxModAPIMonitorOption,
180 VBoxModAPIMonitorInit,
181 VBoxModAPIMonitorMain,
182 VBoxModAPIMonitorStop,
183 VBoxModAPIMonitorTerm,
184 /* callbacks. */
185 VBoxModAPIMonitorOnMachineRegistered,
186 VBoxModAPIMonitorOnMachineUnregistered,
187 VBoxModAPIMonitorOnMachineStateChanged,
188 VBoxModAPIMonitorOnServiceStateChanged
189};
190
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