VMAll.cpp revision 65bee08da2ae66d098423e06e27ad06f69e4aa63
/* $Id$ */
/** @file
* VM - Virtual Machine All Contexts.
*/
/*
* Copyright (C) 2006-2007 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 *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_VM
#include "VMInternal.h"
#ifndef IN_RC
#endif
/**
* Sets the error message.
*
* @returns rc. Meaning you can do:
* @code
* return VM_SET_ERROR(pVM, VERR_OF_YOUR_CHOICE, "descriptive message");
* @endcode
* @param pVM VM handle. Must be non-NULL.
* @param rc VBox status code.
* @param RT_SRC_POS_DECL Use RT_SRC_POS.
* @param pszFormat Error message format string.
* @param ... Error message arguments.
* @thread Any
*/
{
return rc;
}
/**
* Sets the error message.
*
* @returns rc. Meaning you can do:
* @code
* return VM_SET_ERROR(pVM, VERR_OF_YOUR_CHOICE, "descriptive message");
* @endcode
* @param pVM VM handle. Must be non-NULL.
* @param rc VBox status code.
* @param RT_SRC_POS_DECL Use RT_SRC_POS.
* @param pszFormat Error message format string.
* @param args Error message arguments.
* @thread Any
*/
{
#ifdef IN_RING3
/*
* Switch to EMT.
*/
VMR3ReqCall(pVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, (PFNRT)vmR3SetErrorUV, 7, /* ASSUMES 3 source pos args! */
#else
/*
* We're already on the EMT thread and can safely create a VMERROR chunk.
*/
#endif
return rc;
}
/**
* Copies the error to a VMERROR structure.
*
* This is mainly intended for Ring-0 and GC where the error must be copied to
* memory accessible from ring-3. But it's just possible that we might add
* APIs for retrieving the VMERROR copy later.
*
* @param pVM VM handle. Must be non-NULL.
* @param rc VBox status code.
* @param RT_SRC_POS_DECL Use RT_SRC_POS.
* @param pszFormat Error message format string.
* @param args Error message arguments.
* @thread EMT
*/
{
#if 0 /// @todo implement Ring-0 and GC VMSetError
/*
* Create the untranslated message copy.
*/
/* free any old message. */
/* calc reasonable start size. */
+ cchFile + 1
+ cchFunction + 1
+ cchFormat + 32;
/* allocate it */
void *pv;
if (RT_SUCCESS(rc2))
{
/* initialize it. */
if (cchFile)
{
}
if (cchFunction)
{
}
/* format the message (pErr might be reallocated) */
/* done. */
}
#endif
}
/**
* Sets the runtime error message.
*
* As opposed VMSetError(), this method is intended to inform the VM user about
* errors and error-like conditions that happen at an arbitrary point during VM
* execution (like "host memory low" or "out of host disk space").
*
* @returns VBox status code. For some flags the status code <b>must</b> be
* propagated up the stack.
*
* @param pVM The VM handle.
*
* @param fFlags Flags indicating which actions to take.
* See VMSETRTERR_FLAGS_* for details on each flag.
*
* @param pszErrorId Unique error identificator string. This is used by
* the frontends and maybe other devices or drivers, so
* once an ID has been selected it's essentially
* unchangable. Employ camelcase when constructing the
* string, leave out spaces.
*
* The registered runtime error callbacks should string
* switch on this and handle the ones it knows
* specifically and the unknown ones generically.
*
* @param pszFormat Error message format string.
* @param ... Error message arguments.
*
* @thread Any
*/
VMMDECL(int) VMSetRuntimeError(PVM pVM, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
{
return rc;
}
/**
* va_list version of VMSetRuntimeError.
*
* @returns VBox status code. For some flags the status code <b>must</b> be
* propagated up the stack.
*
* @param pVM The VM handle.
* @param fFlags Flags indicating which actions to take. See
* VMSETRTERR_FLAGS_*.
* @param pszErrorId Error ID string.
* @param pszFormat Error message format string.
* @param va Error message arguments.
*
* @thread Any
*/
VMMDECL(int) VMSetRuntimeErrorV(PVM pVM, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
{
/*
* Relaxed parameter validation.
*/
AssertMsg(!(fFlags & ~(VMSETRTERR_FLAGS_NO_WAIT | VMSETRTERR_FLAGS_SUSPEND | VMSETRTERR_FLAGS_FATAL)), ("%#x\n", fFlags));
Assert(*pszErrorId);
#ifdef IN_RING3
/*
* Switch to EMT.
*
* If it's a no-wait request, we have to format the message into a buffer
* here since the variable arguments list will become invalid once we call
* va_end and return.
*/
int rc;
if ( !(fFlags & VMSETRTERR_FLAGS_NO_WAIT)
{
if (RT_SUCCESS(rc))
}
else
{
if (RT_FAILURE(rc))
}
#else
/*
* We're already on the EMT and can safely create a VMRUNTIMEERROR chunk.
*/
AssertReleaseMsgFailed(("Congratulations! You will have the pleasure of debugging the RC/R0 path.\n"));
#endif
return rc;
}
/**
* Copies the error to a VMRUNTIMEERROR structure.
*
* This is mainly intended for Ring-0 and RC where the error must be copied to
* memory accessible from ring-3. But it's just possible that we might add
* APIs for retrieving the VMRUNTIMEERROR copy later.
*
* @param pVM VM handle. Must be non-NULL.
* @param fFlags The error flags.
* @param pszErrorId Error ID string.
* @param pszFormat Error message format string.
* @param va Error message arguments. This is of course spoiled
* by this call.
* @thread EMT
*/
void vmSetRuntimeErrorCopy(PVM pVM, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
{
#if 0 /// @todo implement Ring-0 and GC VMSetError
/*
* Create the untranslated message copy.
*/
/* free any old message. */
/* calc reasonable start size. */
+ cchErrorID + 1
+ cchFormat + 32;
/* allocate it */
void *pv;
if (RT_SUCCESS(rc2))
{
/* initialize it. */
pErr->offErrorID = 0;
if (cchErrorID)
{
}
/* format the message (pErr might be reallocated) */
/* done. */
}
#endif
}
/**
* Gets the name of VM state.
*
* @returns Pointer to a read-only string with the state name.
* @param enmState The state.
*/
{
switch (enmState)
{
default:
return "Unknown";
}
}