~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201210021442

« back to all changes in this revision

Viewing changes to services/vmtoolsd/mainLoop.c

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2011-03-31 14:20:05 UTC
  • mfrom: (1.4.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110331142005-3n9red91p7ogkweo
Tags: 2011.03.28-387002-0ubuntu1
* Merge latest upstream git tag.  This has the unlocked_ioctl change
  needed to fix dkms build failures (LP: #727342)
* Changes in debian/rules:
  - work around a bug in toolbox/Makefile, where install-exec-hook is
    not happening.  This needs to get fixed the right way.
  - don't install 'vmware-user' which seems to no longer exist
  - move /etc/xdg into open-vm-toolbox (which should be done using .install)
* debian/open-vm-tools.init: add 'modprobe [-r] vmblock'. (LP: #332323)
* debian/rules and debian/open-vm-toolbox.lintian-overrides:
  - Make vmware-user-suid-wrapper suid-root (LP: #332323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
static void
56
56
ToolsCoreCleanup(ToolsServiceState *state)
57
57
{
 
58
   ToolsCorePool_Shutdown(&state->ctx);
58
59
   ToolsCore_UnloadPlugins(state);
59
60
   if (state->ctx.rpc != NULL) {
60
61
      RpcChannel_Destroy(state->ctx.rpc);
77
78
   }
78
79
#endif
79
80
 
 
81
   g_object_set(state->ctx.serviceObj, TOOLS_CORE_PROP_CTX, NULL, NULL);
80
82
   g_object_unref(state->ctx.serviceObj);
81
83
   state->ctx.serviceObj = NULL;
82
84
   state->ctx.config = NULL;
195
197
   }
196
198
 
197
199
   /*
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.
202
 
    */
203
 
   if (!state->ctx.isVMware) {
204
 
      return 0;
205
 
   }
206
 
 
207
 
   ToolsCore_RegisterPlugins(state);
208
 
 
209
 
   /*
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).
213
 
    */
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),
219
 
                       state);
220
 
   }
221
 
 
222
 
   state->configCheckTask = g_timeout_add(CONF_POLL_TIME * 10,
223
 
                                          ToolsCoreConfFileCb,
224
 
                                          state);
 
200
    * The following criteria needs to hold for the main loop to be run:
 
201
    *
 
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.
 
205
    *
 
206
    * In the non-VMware hypervisor case, just exit with a '0' return status (see
 
207
    * bug 297528 for why '0').
 
208
    */
 
209
   if (state->ctx.errorCode == 0 &&
 
210
       (state->ctx.isVMware ||
 
211
        ToolsCore_GetTcloName(state) == NULL ||
 
212
        state->debugPlugin != NULL)) {
 
213
      ToolsCore_RegisterPlugins(state);
 
214
 
 
215
      /*
 
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).
 
219
       */
 
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),
 
225
                          state);
 
226
      }
 
227
 
 
228
      state->configCheckTask = g_timeout_add(CONF_POLL_TIME * 10,
 
229
                                             ToolsCoreConfFileCb,
 
230
                                             state);
225
231
 
226
232
#if defined(__APPLE__)
227
 
   ToolsCore_CFRunLoop(state);
 
233
      ToolsCore_CFRunLoop(state);
228
234
#else
229
 
   g_main_loop_run(state->ctx.mainLoop);
 
235
      g_main_loop_run(state->ctx.mainLoop);
230
236
#endif
 
237
   }
231
238
 
232
239
   ToolsCoreCleanup(state);
233
240
   return state->ctx.errorCode;
254
261
 
255
262
   ASSERT_ON_COMPILE(ARRAYSIZE(providerStates) == TOOLS_PROVIDER_MAX);
256
263
 
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",
 
266
                      state->name);
 
267
   ToolsCore_LogState(TOOLS_STATE_LOG_CONTAINER,
 
268
                      "Plugin path: %s\n",
 
269
                      state->pluginPath);
259
270
 
260
271
   for (i = 0; i < state->providers->len; i++) {
261
272
      ToolsAppProviderReg *prov = &g_array_index(state->providers,
262
273
                                                 ToolsAppProviderReg,
263
274
                                                 i);
264
 
      g_message("   App provider: %s (%s)\n",
265
 
                prov->prov->name,
266
 
                providerStates[prov->state]);
 
275
      ToolsCore_LogState(TOOLS_STATE_LOG_CONTAINER,
 
276
                         "App provider: %s (%s)\n",
 
277
                         prov->prov->name,
 
278
                         providerStates[prov->state]);
267
279
      if (prov->prov->dumpState != NULL) {
268
280
         prov->prov->dumpState(&state->ctx, prov->prov, NULL);
269
281
      }
354
366
ToolsCore_Setup(ToolsServiceState *state)
355
367
{
356
368
   GMainContext *gctx;
 
369
   ToolsServiceProperty ctxProp = { TOOLS_CORE_PROP_CTX };
357
370
 
358
371
   if (!g_thread_supported()) {
359
372
      g_thread_init(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);
371
385
 
372
386
   g_type_init();
373
387
   state->ctx.serviceObj = g_object_new(TOOLSCORE_TYPE_SERVICE, NULL);
374
388
 
 
389
   /* Register the core properties. */
 
390
   ToolsCoreService_RegisterProperty(state->ctx.serviceObj,
 
391
                                     &ctxProp);
 
392
   g_object_set(state->ctx.serviceObj, TOOLS_CORE_PROP_CTX, &state->ctx, NULL);
 
393
   ToolsCorePool_Init(&state->ctx);
 
394
 
375
395
   /* Initializes the debug library if needed. */
376
396
   if (state->debugPlugin != NULL) {
377
397
      ToolsCoreInitializeDebug(state);