GuestCtrlImplPrivate.h revision 234b7b45e964034cabd288cd60a28a020855cad4
/** @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. */
/**
* Simple structure mantaining guest credentials.
*/
struct GuestCredentials
{
};
{
void Clear(void);
static void FreeEnvironmentBlock(void *pvEnv);
};
/**
* Structure for keeping all the relevant guest directory
* information around.
*/
struct GuestDirectoryOpenInfo
{
/** The directory path. */
/** Then open filter. */
/** Opening flags. */
};
/**
* Structure for keeping all the relevant guest file
* information around.
*/
struct GuestFileOpenInfo
{
/** The filename. */
/** Then file's opening mode. */
/** The file's disposition mode. */
/** The file's sharing mode.
**@todo Not implemented yet.*/
/** 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. */
};
{
GuestWaitEventPayload(void)
: uType(0),
cbData(0),
{
if (cbPayload)
{
if (pvData)
{
}
else /* Throw IPRT error. */
}
else
{
cbData = 0;
}
}
virtual ~GuestWaitEventPayload(void)
{
Clear();
}
{
return *this;
}
void Clear(void)
{
if (pvData)
{
cbData = 0;
}
uType = 0;
}
{
Clear();
int rc = VINF_SUCCESS;
{
if (pvData)
{
}
else
rc = VERR_NO_MEMORY;
}
return rc;
}
void* MutableRaw(void) { return pvData; }
/** Type of payload. */
/** Size (in bytes) of payload. */
/** Pointer to actual payload data. */
void *pvData;
};
{
GuestWaitEventBase(void);
virtual ~GuestWaitEventBase(void);
int GuestResult(void) { return mGuestRc; }
/* Shutdown indicator. */
bool mfAborted;
/* Associated context ID (CID). */
/** The event semaphore for triggering
* the actual event. */
/** The event's overall result. If
* set to VERR_GSTCTL_GUEST_ERROR,
* mGuestRc will contain the actual
* error code from the guest side. */
int mRc;
/** The event'S overall result from the
* guest side. If used, mRc must be
* set to VERR_GSTCTL_GUEST_ERROR. */
int mGuestRc;
/** The event's payload data. Optional. */
};
/** List of public guest event types. */
{
virtual ~GuestWaitEvent(void);
int Cancel(void);
/** List of public event types this event should
* be signalled on. Optional. */
/** Pointer to the actual public event, if any. */
};
/** Map of pointers to guest events. The primary key
* contains the context ID. */
/** Map of wait events per public guest event. Nice for
* faster lookups when signalling a whole event group. */
{
GuestBase(void);
/** Signals a wait event using a public guest event; also used for
* for external event listeners. */
/** Signals a wait event using a guest rc. */
int signalWaitEventInternal(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, int guestRc, const GuestWaitEventPayload *pPayload);
/** Signals a wait event without letting public guest events know,
* extended director's cut version. */
int signalWaitEventInternalEx(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, int rc, int guestRc, const GuestWaitEventPayload *pPayload);
int baseInit(void);
void baseUninit(void);
int cancelWaitEvents(void);
int registerWaitEvent(uint32_t uSessionID, uint32_t uObjectID, const GuestEventTypes &lstEvents, GuestWaitEvent **ppEvent);
int waitForEvent(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, VBoxEventType_T *pType, IEvent **ppEvent);
/** Pointer to the console object. Needed
* for HGCM (VMMDev) communication. */
/** The next upcoming context ID for this object. */
/** Local listener for handling the waiting events
* internally. */
/** Critical section for wait events access. */
/** Map of registered wait events per event group. */
/** Map of registered wait events. */
};
/**
* Virtual class (interface) for guest objects (processes, files, ...) --
* contains all per-object callback management.
*/
{
GuestObject(void);
virtual ~GuestObject(void);
/** Callback dispatcher -- must be implemented by the actual object. */
virtual int callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb) = 0;
/**
* Commom parameters for all derived objects, when then have
* an own mData structure to keep their specific data around.
*/
/** Pointer to parent session. Per definition
* this objects *always* lives shorter than the
* parent. */
/** The object ID -- must be unique for each guest
* object 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. */
};
#endif // ____H_GUESTIMPLPRIVATE