service.cpp revision 3c3a5ab35783f4d31cb5d3a15db9daadeb804daa
/** @file
*
* Guest Property Service:
* Host service entry points.
*/
/*
* Copyright (C) 2008 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.
*/
/**
* This HGCM service allows the guest to set and query values in a property
* store on the host. The service proxies the guest requests to the service
* owner on the host using a request callback provided by the owner, and is
* notified of changes to properties made by the host. It forwards these
* notifications to clients in the guest which have expressed interest and
* are waiting for notification.
*
* The service currently consists of two threads. One of these is the main
* HGCM service thread which waits for requests from the guest and schedules
* these to the second thread. The second thread deals with the requests
* sequentially by calling the callback provided by the service owner,
* notifying the guest clients when it has finished dealing with a given
* request.
*
* Guest requests to wait for notification are dealt with differently. They
* are added to a list of open notification requests but do not schedule
* anything in the request thread except for a possible timeout.
*/
#define LOG_GROUP LOG_GROUP_HGCM
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <memory> /* for auto_ptr */
#include "noncopyable.h"
/*******************************************************************************
* Internal functions *
*******************************************************************************/
/** Extract a pointer value from an HGCM parameter structure */
{
{
return VINF_SUCCESS;
}
return VERR_INVALID_PARAMETER;
}
/** Set a uint32_t value to an HGCM parameter structure */
{
}
/** Set a uint64_t value to an HGCM parameter structure */
{
}
namespace guestProp {
/**
* Class containing the shared information service functionality.
*/
class Service : public noncopyable
{
private:
/** Type definition for use in callback functions */
/** HGCM helper functions. */
/** Pointer to our configuration node. */
public:
/**
* @copydoc VBOXHGCMSVCHELPERS::pfnUnload
* Simply deletes the service object
*/
{
delete pSelf;
return VINF_SUCCESS;
}
/**
* @copydoc VBOXHGCMSVCHELPERS::pfnConnect
* Stub implementation of pfnConnect and pfnDisconnect.
*/
uint32_t /* u32ClientID */,
void * /* pvClient */)
{
return VINF_SUCCESS;
}
/**
* @copydoc VBOXHGCMSVCHELPERS::pfnCall
* Wraps to the call member function
*/
void *pvClient,
{
}
/**
* @copydoc VBOXHGCMSVCHELPERS::pfnHostCall
* Wraps to the hostCall member function
*/
{
}
private:
};
/**
* Checking that the key passed by the guest fits our criteria for a
* configuration key
*
* @returns IPRT status code
* @param pszKey the key passed by the guest
* @param cbKey the number of bytes pszKey points to, including the
* terminating '\0'
* @thread HGCM
*/
{
int rc = VINF_SUCCESS;
/* Validate the format of the key. */
/* Only accept names in valid Utf8. */
if (RT_SUCCESS(rc))
/* We want the byte length, not the Utf8 length */
return rc;
}
/**
* Check that the data passed by the guest fits our criteria for the value of
* a configuration key
*
* @returns IPRT status code
* @param pszValue the value to store in the key
* @param cbValue the number of bytes in the buffer pszValue points to
* @thread HGCM
*/
{
int rc = VINF_SUCCESS;
/* Validate the format of the value. */
/* Only accept values in valid Utf8 */
if (RT_SUCCESS(rc))
/* We want the byte length, not the Utf8 length */
if (RT_SUCCESS(rc))
return rc;
}
/**
* Retrieve a value from the guest registry by key, checking the validity
* of the arguments passed. If the guest has not allocated enough buffer
* space for the value then we return VERR_OVERFLOW and set the size of the
* buffer needed in the "size" HGCM parameter. If the key was not found at
* all, we return VERR_NOT_FOUND.
*
* @returns iprt status value
* @param cParms the number of HGCM parameters supplied
* @param paParms the array of HGCM parameters
* @thread HGCM
*/
{
int rc = VINF_SUCCESS;
LogFlowThisFunc(("\n"));
)
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
else if (VERR_CFGM_VALUE_NOT_FOUND == rc)
rc = VERR_NOT_FOUND;
return rc;
}
/**
* Retrieve a value from the guest registry by key, checking the validity
* of the arguments passed. If the guest has not allocated enough buffer
* space for the value then we return VERR_OVERFLOW and set the size of the
* buffer needed in the "size" HGCM parameter. If the key was not found at
* all, we return VERR_NOT_FOUND.
*
* @returns iprt status value
* @param cParms the number of HGCM parameters supplied
* @param paParms the array of HGCM parameters
* @thread HGCM
*/
{
int rc = VINF_SUCCESS;
LogFlowThisFunc(("\n"));
)
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
{
/* Temporary hack for an empty flags string */
cbValueActual += 1;
}
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
{
/* No timestamp */
/* No flags */
}
if (RT_SUCCESS(rc))
else if (VERR_CFGM_VALUE_NOT_FOUND == rc)
rc = VERR_NOT_FOUND;
return rc;
}
/**
* Set a value in the guest registry by key, checking the validity
* of the arguments passed.
*
* @returns iprt status value
* @param cParms the number of HGCM parameters supplied
* @param paParms the array of HGCM parameters
* @thread HGCM
*/
{
int rc = VINF_SUCCESS;
LogFlowThisFunc(("\n"));
)
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
{
/* Limit the number of keys that we can set. */
unsigned cChildren = 0;
for (PCFGMNODE pChild = CFGMR3GetFirstChild(mpNode); pChild != 0; pChild = CFGMR3GetNextChild(pChild))
++cChildren;
}
if (RT_SUCCESS(rc))
{
if (pszValue > 0)
}
if (RT_SUCCESS(rc))
return rc;
}
/**
* Remove a value in the guest registry by key, checking the validity
* of the arguments passed.
*
* @returns iprt status value
* @param cParms the number of HGCM parameters supplied
* @param paParms the array of HGCM parameters
* @thread HGCM
*/
{
int rc = VINF_SUCCESS;
char *pszKey;
LogFlowThisFunc(("\n"));
)
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
return rc;
}
/**
* Handle an HGCM service call.
* @copydoc VBOXHGCMSVCFNTABLE::pfnCall
* @note All functions which do not involve an unreasonable delay will be
* handled synchronously. If needed, we will add a request handler
* thread in future for those which do.
*
* @thread HGCM
*/
{
int rc = VINF_SUCCESS;
bool fCallSync = true;
LogFlowFunc(("u32ClientID = %d, fn = %d, cParms = %d, pparms = %d\n",
switch (eFunction)
{
/* The guest wishes to read a property */
case GET_PROP:
LogFlowFunc(("GET_PROP\n"));
break;
/* The guest wishes to set a property */
case SET_PROP:
LogFlowFunc(("SET_PROP\n"));
break;
/* The guest wishes to set a property value */
case SET_PROP_VALUE:
LogFlowFunc(("SET_PROP_VALUE\n"));
break;
/* The guest wishes to remove a configuration value */
case DEL_PROP:
LogFlowFunc(("DEL_PROP\n"));
break;
default:
}
if (fCallSync)
{
}
}
/**
* Service call handler for the host.
* @copydoc VBOXHGCMSVCFNTABLE::pfnHostCall
* @thread hgcm
*/
{
int rc = VINF_SUCCESS;
LogFlowFunc(("fn = %d, cParms = %d, pparms = %d\n",
switch (eFunction)
{
/* Set the root CFGM node used. This should be called when instantiating
* the service. */
case SET_CFGM_NODE:
{
LogFlowFunc(("SET_CFGM_NODE\n"));
if (cParms != 1)
{
}
)
{
}
else
{
}
} break;
/* The host wishes to read a configuration value */
case GET_CONFIG_KEY_HOST:
LogFlowFunc(("GET_CONFIG_KEY_HOST\n"));
break;
/* The host wishes to set a configuration value */
case SET_CONFIG_KEY_HOST:
LogFlowFunc(("SET_CONFIG_KEY_HOST\n"));
break;
/* The host wishes to remove a configuration value */
case DEL_CONFIG_KEY_HOST:
LogFlowFunc(("DEL_CONFIG_KEY_HOST\n"));
break;
default:
break;
}
return rc;
}
} /* namespace guestProp */
/**
* @copydoc VBOXHGCMSVCLOAD
*/
{
int rc = VINF_SUCCESS;
{
}
else
{
LogFlowFunc(("ptable->cbSize = %d, ptable->u32Version = 0x%08X\n", ptable->cbSize, ptable->u32Version));
{
}
else
{
try {
} catch (...) {
/* No exceptions may propogate outside. */
}
if (RT_SUCCESS(rc))
{
/* We do not maintain connections, so no client data is needed. */
/* Service specific initialization. */
}
}
}
return rc;
}