VBoxServiceControl.cpp revision de210ca38246009981a22de928a52566c8c53970
/* $Id$ */
/** @file
* VBoxServiceControl - Host-driven Guest Control.
*/
/*
* Copyright (C) 2010 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/semaphore.h>
#include <VBox/VBoxGuestLib.h>
#include "VBoxServiceInternal.h"
#include "VBoxServiceUtils.h"
using namespace guestControl;
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** The control interval (millseconds). */
/** The semaphore we're blocking on. */
/** The guest property service client ID. */
static uint32_t g_GuestControlSvcClientID = 0;
/** @copydoc VBOXSERVICE::pfnPreInit */
static DECLCALLBACK(int) VBoxServiceControlPreInit(void)
{
return VINF_SUCCESS;
}
/** @copydoc VBOXSERVICE::pfnOption */
static DECLCALLBACK(int) VBoxServiceControlOption(const char **ppszShort, int argc, char **argv, int *pi)
{
int rc = -1;
if (ppszShort)
/* no short options */;
return rc;
}
/** @copydoc VBOXSERVICE::pfnInit */
static DECLCALLBACK(int) VBoxServiceControlInit(void)
{
/*
* If not specified, find the right interval default.
* Then create the event sem to block on.
*/
if (!g_ControlInterval)
g_ControlInterval = 1000;
if (RT_SUCCESS(rc))
else
{
}
return rc;
}
{
char szUser[128];
char szPassword[128];
/* Command */
/* Flags */
&uFlags,
/* Arguments */
/* Environment */
/* Pipes */
/* Credentials */
szPassword, sizeof(szPassword),
/* Timelimit */
&uTimeLimitMS);
if (RT_FAILURE(rc))
{
}
else
{
}
return rc;
}
/** @copydoc VBOXSERVICE::pfnWorker */
{
/*
* Tell the control thread that it can continue
* spawning services.
*/
int rc = VINF_SUCCESS;
/*
* Execution loop.
*
* @todo
*/
for (;;)
{
if (rc == VERR_TOO_MUCH_DATA)
{
VBoxServiceVerbose(3, "Control: Message requires %ld parameters, but only 2 supplied.\n", uNumParms);
rc = VINF_SUCCESS;
}
if (RT_SUCCESS(rc))
{
switch(uMsg)
{
case GETHOSTMSG_EXEC_CMD:
break;
default:
/* Don't terminate here; just wait for the next message. */
break;
}
}
/*
* Block for a while.
*
* The event semaphore takes care of ignoring interruptions and it
* allows us to implement service wakeup later.
*/
if (*pfShutdown)
break;
if (*pfShutdown)
break;
{
break;
}
}
return rc;
}
/** @copydoc VBOXSERVICE::pfnStop */
static DECLCALLBACK(void) VBoxServiceControlStop(void)
{
/** @todo Later, figure what to do if we're in RTProcWait(). it's a very
* annoying call since doesn't support timeouts in the posix world. */
}
/** @copydoc VBOXSERVICE::pfnTerm */
static DECLCALLBACK(void) VBoxServiceControlTerm(void)
{
/* Nothing here yet. */
if (g_hControlEvent != NIL_RTSEMEVENTMULTI)
{
}
}
/**
* The 'vminfo' service description.
*/
{
/* pszName. */
"control",
/* pszDescription. */
"Host-driven Guest Control",
/* pszUsage. */
"[--control-interval <ms>]"
,
/* pszOptions. */
" --control-interval Specifies the interval at which to check for\n"
" new ocntrol commands. The default is 1000 ms.\n"
,
/* methods */
};