GuestCtrlImplPrivate.h revision 9bff17fe6983cfda2ddd98f1979841bcb48e78e7
/** @file
*
* Internal helpers/structures for guest control functionality.
*/
/*
* Copyright (C) 2011-2013 Oracle Corporation
*
* 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.
*/
#ifndef ____H_GUESTIMPLPRIVATE
#define ____H_GUESTIMPLPRIVATE
#include "ConsoleImpl.h"
#include <iprt/semaphore.h>
#include <map>
#include <vector>
#ifdef VBOX_WITH_GUEST_CONTROL
#endif
/** Vector holding a process' CPU affinity. */
/** Vector holding process startup arguments. */
/**
*/
{
GuestCtrlEvent(void);
virtual ~GuestCtrlEvent(void);
/** @todo Copy/comparison operator? */
int Cancel(void);
bool Canceled(void);
int Init(void);
int GetResultCode(void) { return mRC; }
/** Was the callback canceled? */
bool fCanceled;
/** Did the callback complete? */
bool fCompleted;
/** The event semaphore for triggering
* the actual event. */
/** The waiting mutex. */
/** Overall result code. */
int mRC;
};
/*
* Enumeration holding the host callback types.
*/
enum CALLBACKTYPE
{
CALLBACKTYPE_UNKNOWN = 0,
/** Guest session status. */
/** Guest process status. */
CALLBACKTYPE_PROC_STATUS = 100,
/** Guest process output notification. */
CALLBACKTYPE_PROC_OUTPUT = 105,
/** Guest process input notification. */
CALLBACKTYPE_PROC_INPUT = 106,
/** @todo Docs! */
CALLBACKTYPE_FILE_OPEN = 210,
CALLBACKTYPE_FILE_CLOSE = 215,
CALLBACKTYPE_FILE_READ = 230,
CALLBACKTYPE_FILE_WRITE = 240,
CALLBACKTYPE_FILE_SEEK = 250,
CALLBACKTYPE_FILE_TELL = 260
};
/*
* Class representing a guest control callback.
*/
{
GuestCtrlCallback(void);
virtual ~GuestCtrlCallback(void);
void Destroy(void);
const void* GetDataRaw(void) const { return pvData; }
const void* GetPayloadRaw(void) const { return pvPayload; }
/** Pointer to actual callback data. */
void *pvData;
/** Size of user-supplied data. */
/** The callback type. */
/** Callback flags. */
/** Payload which will be available on successful
* waiting (optional). */
void *pvPayload;
/** Size of the payload (optional). */
};
/*
* Class representing a guest control process waiting
* event.
*/
{
GuestProcessWaitEvent(void);
virtual ~GuestProcessWaitEvent(void);
void Destroy(void);
/** The waiting flag(s). The specifies what to
* wait for. See ProcessWaitFlag_T. */
/** Structure containing the overall result. */
};
/*
* Class representing a guest control session waiting
* event.
*/
{
GuestSessionWaitEvent(void);
virtual ~GuestSessionWaitEvent(void);
void Destroy(void);
/** The waiting flag(s). The specifies what to
* wait for. See GuestSessionWaitFlag_T. */
/** Structure containing the overall result. */
};
/**
* Simple structure mantaining guest credentials.
*/
struct GuestCredentials
{
};
{
void Clear(void);
static void FreeEnvironmentBlock(void *pvEnv);
};
/**
* Structure for keeping all the relevant guest file
* information around.
*/
struct GuestFileOpenInfo
{
/** The filename. */
/** Then file's opening mode. */
/** The file's disposition mode. */
/** Octal creation mode. */
/** The initial offset on open. */
};
/**
* Structure representing information of a
* file system object.
*/
struct GuestFsObjData
{
/** Helper function to extract the data from
* a certin VBoxService tool's guest stream block. */
};
/**
* Structure for keeping all the relevant guest session
* startup parameters around.
*/
{
GuestSessionStartupInfo(void)
: mIsInternal(false /* Non-internal session */),
mOpenFlags(0 /* No opening flags set */) { }
/** The session's friendly name. Optional. */
/** The session's unique ID. Used to encode
* a context ID. */
/** Flag indicating if this is an internal session
* or not. Internal session are not accessible by
* public API clients. */
bool mIsInternal;
/** Timeout (in ms) used for opening the session. */
/** Session opening flags. */
};
/**
* Structure for keeping all the relevant guest process
* startup parameters around.
*/
{
GuestProcessStartupInfo(void)
/** The process' friendly name. */
/** The actual command to execute. */
/** Process creation flags. */
/** Process priority. */
/** Process affinity. At the moment we
* only support 64 VCPUs. API and
* guest can do more already! */
};
/**
* Class representing the "value" side of a "key=value" pair.
*/
{
GuestProcessStreamValue(void) { }
GuestProcessStreamValue(const char *pszValue)
};
/** Map containing "key=value" pairs of a guest process stream. */
typedef std::map < Utf8Str, GuestProcessStreamValue >::const_iterator GuestCtrlStreamPairMapIterConst;
/**
* Class representing a block of stream pairs (key=value). Each block in a raw guest
* output stream is separated by "\0\0", each pair is separated by "\0". The overall
* end of a guest stream is marked by "\0\0\0\0".
*/
{
GuestProcessStreamBlock(void);
virtual ~GuestProcessStreamBlock(void);
void Clear(void);
#ifdef DEBUG
void DumpToLog(void) const;
#endif
};
/** Vector containing multiple allocated stream pair objects. */
/**
* Class for parsing machine-readable guest process output by VBoxService'
* toolbox commands ("vbox_ls", "vbox_stat" etc), aka "guest stream".
*/
{
void Destroy();
#ifdef DEBUG
#endif
/** Currently allocated size of internal stream buffer. */
/** Currently used size of allocated internal stream buffer. */
/** Current offset within the internal stream buffer. */
/** Internal stream buffer. */
};
{
enum TaskType
{
/** Copies a file from host to the guest. */
TaskType_CopyFileToGuest = 50,
/** Copies a file from guest to the host. */
/** Update Guest Additions by directly copying the required installer
* off the .ISO file, transfer it to the guest and execute the installer
* with system privileges. */
};
int startThread();
/* Task data. */
};
/**
* Pure virtual class (interface) for guest objects (processes, files, ...) --
* contains all per-object callback management.
*/
{
/** Callback dispatcher -- must be implemented by the actual object. */
virtual int callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb) = 0;
int callbackRemoveAll(void);
/**
* Commom structure for all derived objects, when then have
* an own mData structure to keep their specific data around.
*/
struct Object
{
/** Pointer to parent session. Per definition
* this objects *always* lives shorter than the
* parent. */
/** Pointer to the console object. Needed
* for HGCM (VMMDev) communication. */
/** All related callbacks to this object. */
/** The next upcoming context ID for this object. */
/** The object ID -- must be unique for each guest
* session and is encoded into the context ID. Must
* be set manually when initializing the object.
*
* For guest processes this is the internal PID,
* for guest files this is the internal file ID. */
} mObject;
};
#if 0
/*
* Guest (HGCM) callbacks. All classes will throw
* an exception on misuse.
*/
/** Callback class for guest process status. */
{
{
if (RT_FAILURE(rc))
return rc;
if ( uFunction != GUEST_EXEC_SEND_STATUS
return VERR_INVALID_PARAMETER;
/* pSvcCb->mpaParms[0] always contains the context ID. */
return VINF_SUCCESS;
}
void Destroy(void) { }
void *mData;
};
/** Callback class for guest process input. */
{
{
if (RT_FAILURE(rc))
return rc;
return VERR_INVALID_PARAMETER;
/* pSvcCb->mpaParms[0] always contains the context ID. */
/* Associated file handle. */
return VINF_SUCCESS;
}
void Destroy(void) { }
{
return *this;
}
};
/** Callback class for guest process output. */
{
{
if (RT_FAILURE(rc))
return rc;
if ( uFunction != GUEST_EXEC_SEND_OUTPUT
return VERR_INVALID_PARAMETER;
/* pSvcCb->mpaParms[0] always contains the context ID. */
/* Associated file handle. */
if (RT_SUCCESS(rc))
{
}
return rc;
}
void Destroy(void)
{
if (mData)
{
mcbData = 0;
}
}
{
Destroy();
{
if (pvData)
{
}
}
return *this;
}
void *mData;
};
/** Callback class for guest process IO notifications. */
{
{
if (RT_FAILURE(rc))
return rc;
return VERR_NOT_IMPLEMENTED;
}
{
return *this;
}
};
#endif
#endif // ____H_GUESTIMPLPRIVATE