198
* If not in a VM then there's no point in trying to run the loop, just exit
199
* with a '0' return status (see bug 297528 for why '0'). If we ever want
200
* to run vmtoolsd on physical hardware (or another hypervisor), we'll have
201
* to revisit this code.
203
if (!state->ctx.isVMware) {
207
ToolsCore_RegisterPlugins(state);
210
* Listen for the I/O freeze signal. We have to disable the config file
211
* check when I/O is frozen or the (Win32) sync driver may cause the service
212
* to hang (and make the VM unusable until it times out).
214
if (g_signal_lookup(TOOLS_CORE_SIG_IO_FREEZE,
215
G_OBJECT_TYPE(state->ctx.serviceObj)) != 0) {
216
g_signal_connect(state->ctx.serviceObj,
217
TOOLS_CORE_SIG_IO_FREEZE,
218
G_CALLBACK(ToolsCoreIOFreezeCb),
222
state->configCheckTask = g_timeout_add(CONF_POLL_TIME * 10,
200
* The following criteria needs to hold for the main loop to be run:
202
* . no plugin has requested the service to shut down during initialization.
203
* . we're either on a VMware hypervisor, or running an unknown service name.
204
* . we're running in debug mode.
206
* In the non-VMware hypervisor case, just exit with a '0' return status (see
207
* bug 297528 for why '0').
209
if (state->ctx.errorCode == 0 &&
210
(state->ctx.isVMware ||
211
ToolsCore_GetTcloName(state) == NULL ||
212
state->debugPlugin != NULL)) {
213
ToolsCore_RegisterPlugins(state);
216
* Listen for the I/O freeze signal. We have to disable the config file
217
* check when I/O is frozen or the (Win32) sync driver may cause the service
218
* to hang (and make the VM unusable until it times out).
220
if (g_signal_lookup(TOOLS_CORE_SIG_IO_FREEZE,
221
G_OBJECT_TYPE(state->ctx.serviceObj)) != 0) {
222
g_signal_connect(state->ctx.serviceObj,
223
TOOLS_CORE_SIG_IO_FREEZE,
224
G_CALLBACK(ToolsCoreIOFreezeCb),
228
state->configCheckTask = g_timeout_add(CONF_POLL_TIME * 10,
226
232
#if defined(__APPLE__)
227
ToolsCore_CFRunLoop(state);
233
ToolsCore_CFRunLoop(state);
229
g_main_loop_run(state->ctx.mainLoop);
235
g_main_loop_run(state->ctx.mainLoop);
232
239
ToolsCoreCleanup(state);
233
240
return state->ctx.errorCode;
255
262
ASSERT_ON_COMPILE(ARRAYSIZE(providerStates) == TOOLS_PROVIDER_MAX);
257
g_message("VM Tools Service '%s':\n", state->name);
258
g_message(" Plugin path: %s\n", state->pluginPath);
264
ToolsCore_LogState(TOOLS_STATE_LOG_ROOT,
265
"VM Tools Service '%s':\n",
267
ToolsCore_LogState(TOOLS_STATE_LOG_CONTAINER,
260
271
for (i = 0; i < state->providers->len; i++) {
261
272
ToolsAppProviderReg *prov = &g_array_index(state->providers,
262
273
ToolsAppProviderReg,
264
g_message(" App provider: %s (%s)\n",
266
providerStates[prov->state]);
275
ToolsCore_LogState(TOOLS_STATE_LOG_CONTAINER,
276
"App provider: %s (%s)\n",
278
providerStates[prov->state]);
267
279
if (prov->prov->dumpState != NULL) {
268
280
prov->prov->dumpState(&state->ctx, prov->prov, NULL);
368
381
state->ctx.errorCode = EXIT_SUCCESS;
369
382
state->ctx.mainLoop = g_main_loop_new(gctx, TRUE);
370
383
state->ctx.isVMware = VmCheck_IsVirtualWorld();
384
g_main_context_unref(gctx);
373
387
state->ctx.serviceObj = g_object_new(TOOLSCORE_TYPE_SERVICE, NULL);
389
/* Register the core properties. */
390
ToolsCoreService_RegisterProperty(state->ctx.serviceObj,
392
g_object_set(state->ctx.serviceObj, TOOLS_CORE_PROP_CTX, &state->ctx, NULL);
393
ToolsCorePool_Init(&state->ctx);
375
395
/* Initializes the debug library if needed. */
376
396
if (state->debugPlugin != NULL) {
377
397
ToolsCoreInitializeDebug(state);