VMAll.cpp revision fd2b656969be7e126ef37a47e5bbf4c8f87f3afb
/* $Id$ */
/** @file
* VM - Virtual Machine All Contexts.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_VM
#include "VMInternal.h"
/**
* 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, &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.
*/
# ifdef IN_GC
# else
# endif
#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 (VBOX_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").
*
* The @a fFatal parameter defines whether the error is fatal or not. If it is
* true, then it is expected that the caller has already paused the VM execution
* before calling this method. The VM user is supposed to power off the VM
* immediately after it has received the runtime error notification via the
* FNVMATRUNTIMEERROR callback.
*
* If @a fFatal is false, then the paused state of the VM defines the kind of
* the error. If the VM is paused before calling this method, it means that
* the VM user may try to fix the error condition (i.e. free more host memory)
* and then resume the VM execution. If the VM is not paused before calling
* this method, it means that the given error is a warning about an error
* condition that may happen soon but that doesn't directly affect the
* VM execution by the time of the call.
*
* The @a pszErrorID parameter defines an unique error identificator.
* It is used by the front-ends to show a proper message to the end user
* an error ID assigned once to some particular error condition should not
* change in the future. The format of this parameter is "someErrorCondition".
*
* @param pVM VM handle. Must be non-NULL.
* @param fFatal Whether it is a fatal error or not.
* @param pszErrorID Error ID string.
* @param pszFormat Error message format string.
* @param ... Error message arguments.
*
* @return VBox status code (whether the error has been successfully set
* and delivered to callbacks or not).
*
* @thread Any
* @todo r=bird: The pausing/suspending of the VM should be done here, we'll just end
* up duplicating code all over the place otherwise. In the case of
* vm even. Change fFatal to fFlags and define action flags and a fatal flag.
*
* Also, why a string ID and not an enum?
*/
const char *pszFormat, ...)
{
return rc;
}
/**
* va_list version of VMSetRuntimeError.
*
* @param pVM VM handle. Must be non-NULL.
* @param fFatal Whether it is a fatal error or not.
* @param pszErrorID Error ID string.
* @param pszFormat Error message format string.
* @param args Error message arguments.
*
* @return VBox status code (whether the error has been successfully set
* and delivered to callbacks or not).
*
* @thread Any
*/
{
#ifdef IN_RING3
/*
* Switch to EMT.
*/
#else
/*
* We're already on the EMT thread and can safely create a VMRUNTIMEERROR chunk.
*/
# ifdef IN_GC
# else
# endif
#endif
return VINF_SUCCESS;
}
/**
* Copies the error to a VMRUNTIMEERROR 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 VMRUNTIMEERROR copy later.
*
* @param pVM VM handle. Must be non-NULL.
* @param fFatal Whether it is a fatal error or not.
* @param pszErrorID Error ID string.
* @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. */
+ cchErrorID + 1
+ cchFormat + 32;
/* allocate it */
void *pv;
if (VBOX_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";
}
}