vmapi.h revision 5ae996009ba3ee269b8639ab90a1009b872887b6
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/** @file
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * VM - The Virtual Machine, API. (VMM)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/*
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * available from http://www.virtualbox.org. This file is free software;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * General Public License (GPL) as published by the Free Software
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * The contents of this file may alternatively be used under the terms
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * of the Common Development and Distribution License Version 1.0
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * VirtualBox OSE distribution, in which case the provisions of the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * CDDL are applicable instead of those of the GPL.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * You may elect to license modified versions of this file under the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * terms and conditions of either the GPL or the CDDL or both.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * additional information or have any questions.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
8302394f164acb4adb187954f6ac8ef7a9efa629vboxsync#ifndef ___VBox_vmapi_h
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#define ___VBox_vmapi_h
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#include <VBox/cdefs.h>
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#include <VBox/types.h>
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#include <VBox/stam.h>
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#include <VBox/cfgm.h>
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync#include <iprt/stdarg.h>
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncRT_C_DECLS_BEGIN
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/** @defgroup grp_vmm_apis VM All Contexts API
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @ingroup grp_vm
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @{ */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/** @def VM_RC_ADDR
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Converts a current context address of data within the VM structure to the equivalent
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * raw-mode address.
8302394f164acb4adb187954f6ac8ef7a9efa629vboxsync *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @returns raw-mode virtual address.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @param pVM Pointer to the VM.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @param pvInVM CC Pointer within the VM.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#ifdef IN_RING3
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# define VM_RC_ADDR(pVM, pvInVM) ( (RTRCPTR)((RTRCUINTPTR)pVM->pVMRC + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR3)) )
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#elif defined(IN_RING0)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# define VM_RC_ADDR(pVM, pvInVM) ( (RTRCPTR)((RTRCUINTPTR)pVM->pVMRC + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR0)) )
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#else
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# define VM_RC_ADDR(pVM, pvInVM) ( (RTRCPTR)(pvInVM) )
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#endif
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/** @def VM_R3_ADDR
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Converts a current context address of data within the VM structure to the equivalent
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * ring-3 host address.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @returns host virtual address.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @param pVM Pointer to the VM.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @param pvInVM CC pointer within the VM.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#ifdef IN_RC
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# define VM_R3_ADDR(pVM, pvInVM) ( (RTR3PTR)((RTR3UINTPTR)pVM->pVMR3 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMRC)) )
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#elif defined(IN_RING0)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# define VM_R3_ADDR(pVM, pvInVM) ( (RTR3PTR)((RTR3UINTPTR)pVM->pVMR3 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR0)) )
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#else
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# define VM_R3_ADDR(pVM, pvInVM) ( (RTR3PTR)(pvInVM) )
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#endif
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/** @def VM_R0_ADDR
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Converts a current context address of data within the VM structure to the equivalent
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * ring-0 host address.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync *
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @returns host virtual address.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param pVM Pointer to the VM.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param pvInVM CC pointer within the VM.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync */
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync#ifdef IN_RC
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync# define VM_R0_ADDR(pVM, pvInVM) ( (RTR0PTR)((RTR0UINTPTR)pVM->pVMR0 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMRC)) )
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync#elif defined(IN_RING3)
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync# define VM_R0_ADDR(pVM, pvInVM) ( (RTR0PTR)((RTR0UINTPTR)pVM->pVMR0 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR3)) )
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync#else
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync# define VM_R0_ADDR(pVM, pvInVM) ( (RTR0PTR)(pvInVM) )
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync#endif
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync/**
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * VM error callback function.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync *
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param pVM The VM handle. Can be NULL if an error occurred before
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * successfully creating a VM.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param pvUser The user argument.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param rc VBox status code.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param RT_SRC_POS_DECL The source position arguments. See RT_SRC_POS and RT_SRC_POS_ARGS.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param pszFormat Error message format string.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param args Error message arguments.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync */
0c2ffca957882f38c677fc23f324cfd695b96947vboxsynctypedef DECLCALLBACK(void) FNVMATERROR(PVM pVM, void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszError, va_list args);
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync/** Pointer to a VM error callback. */
0c2ffca957882f38c677fc23f324cfd695b96947vboxsynctypedef FNVMATERROR *PFNVMATERROR;
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync
0c2ffca957882f38c677fc23f324cfd695b96947vboxsyncVMMDECL(int) VMSetError(PVM pVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...);
0c2ffca957882f38c677fc23f324cfd695b96947vboxsyncVMMDECL(int) VMSetErrorV(PVM pVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list args);
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync/** @def VM_SET_ERROR
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * Macro for setting a simple VM error message.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * Don't use '%' in the message!
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync *
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @returns rc. Meaning you can do:
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @code
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * return VM_SET_ERROR(pVM, VERR_OF_YOUR_CHOICE, "descriptive message");
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @endcode
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param pVM VM handle.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param rc VBox status code.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param pszMessage Error message string.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @thread Any
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync */
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync#define VM_SET_ERROR(pVM, rc, pszMessage) (VMSetError(pVM, rc, RT_SRC_POS, pszMessage))
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync/**
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * VM runtime error callback function.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync *
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * See VMSetRuntimeError for the detailed description of parameters.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync *
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param pVM The VM handle.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param pvUser The user argument.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param fFlags The error flags.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param pszErrorId Error ID string.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param pszFormat Error message format string.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync * @param va Error message arguments.
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync */
0c2ffca957882f38c677fc23f324cfd695b96947vboxsynctypedef DECLCALLBACK(void) FNVMATRUNTIMEERROR(PVM pVM, void *pvUser, uint32_t fFlags, const char *pszErrorId,
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync const char *pszFormat, va_list va);
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync/** Pointer to a VM runtime error callback. */
0c2ffca957882f38c677fc23f324cfd695b96947vboxsynctypedef FNVMATRUNTIMEERROR *PFNVMATRUNTIMEERROR;
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync
0c2ffca957882f38c677fc23f324cfd695b96947vboxsyncVMMDECL(int) VMSetRuntimeError(PVM pVM, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...);
0c2ffca957882f38c677fc23f324cfd695b96947vboxsyncVMMDECL(int) VMSetRuntimeErrorV(PVM pVM, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list args);
0c2ffca957882f38c677fc23f324cfd695b96947vboxsync
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync/** @name VMSetRuntimeError fFlags
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * When no flags are given the VM will continue running and it's up to the front
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * end to take action on the error condition.
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync *
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * @{ */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync/** The error is fatal.
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * The VM is not in a state where it can be saved and will enter a state
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * where it can no longer execute code. The caller <b>must</b> propagate status
d6774203fd1e13a9d1787611e48adfdd4a2d6834vboxsync * codes. */
d6774203fd1e13a9d1787611e48adfdd4a2d6834vboxsync#define VMSETRTERR_FLAGS_FATAL RT_BIT_32(0)
d6774203fd1e13a9d1787611e48adfdd4a2d6834vboxsync/** Suspend the VM after, or if possible before, raising the error on EMT. The
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * caller <b>must</b> propagate status codes. */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync#define VMSETRTERR_FLAGS_SUSPEND RT_BIT_32(1)
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync/** Don't wait for the EMT to handle the request.
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * Only valid when on a worker thread and there is a high risk of a dead
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * lock. Be careful not to flood the user with errors. */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync#define VMSETRTERR_FLAGS_NO_WAIT RT_BIT_32(2)
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync/** @} */
30f07af559efcbd967e801903746fc21f81ee533vboxsync
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync/**
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * VM state callback function.
30f07af559efcbd967e801903746fc21f81ee533vboxsync *
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * You are not allowed to call any function which changes the VM state from a
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * state callback, except VMR3Destroy().
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync *
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * @param pVM The VM handle.
74f7805911fff84c2dec0fb3b727ef9ddc4df8b0vboxsync * @param enmState The new state.
74f7805911fff84c2dec0fb3b727ef9ddc4df8b0vboxsync * @param enmOldState The old state.
74f7805911fff84c2dec0fb3b727ef9ddc4df8b0vboxsync * @param pvUser The user argument.
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsynctypedef DECLCALLBACK(void) FNVMATSTATE(PVM pVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
74f7805911fff84c2dec0fb3b727ef9ddc4df8b0vboxsync/** Pointer to a VM state callback. */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsynctypedef FNVMATSTATE *PFNVMATSTATE;
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsyncVMMDECL(const char *) VMGetStateName(VMSTATE enmState);
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync/**
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * Request type.
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsynctypedef enum VMREQTYPE
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync{
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync /** Invalid request. */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync VMREQTYPE_INVALID = 0,
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync /** VM: Internal. */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync VMREQTYPE_INTERNAL,
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync /** Maximum request type (exclusive). Used for validation. */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync VMREQTYPE_MAX
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync} VMREQTYPE;
8302394f164acb4adb187954f6ac8ef7a9efa629vboxsync
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync/**
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * Request state.
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsynctypedef enum VMREQSTATE
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync{
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync /** The state is invalid. */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync VMREQSTATE_INVALID = 0,
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync /** The request have been allocated and is in the process of being filed. */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync VMREQSTATE_ALLOCATED,
0b8ed19cf8df49d6fcd144b43ae4af5c21316ce9vboxsync /** The request is queued by the requester. */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync VMREQSTATE_QUEUED,
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync /** The request is begin processed. */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync VMREQSTATE_PROCESSING,
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync /** The request is completed, the requester is begin notified. */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync VMREQSTATE_COMPLETED,
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync /** The request packet is in the free chain. (The requester */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync VMREQSTATE_FREE
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync} VMREQSTATE;
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync/**
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * Request flags.
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync */
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsynctypedef enum VMREQFLAGS
30f07af559efcbd967e801903746fc21f81ee533vboxsync{
30f07af559efcbd967e801903746fc21f81ee533vboxsync /** The request returns a VBox status code. */
d6774203fd1e13a9d1787611e48adfdd4a2d6834vboxsync VMREQFLAGS_VBOX_STATUS = 0,
d6774203fd1e13a9d1787611e48adfdd4a2d6834vboxsync /** The request is a void request and have no status code. */
30f07af559efcbd967e801903746fc21f81ee533vboxsync VMREQFLAGS_VOID = 1,
30f07af559efcbd967e801903746fc21f81ee533vboxsync /** Return type mask. */
30f07af559efcbd967e801903746fc21f81ee533vboxsync VMREQFLAGS_RETURN_MASK = 1,
30f07af559efcbd967e801903746fc21f81ee533vboxsync /** Caller does not wait on the packet, EMT will free it. */
30f07af559efcbd967e801903746fc21f81ee533vboxsync VMREQFLAGS_NO_WAIT = 2,
30f07af559efcbd967e801903746fc21f81ee533vboxsync /** Poke the destination EMT(s) if executing guest code. Use with care. */
30f07af559efcbd967e801903746fc21f81ee533vboxsync VMREQFLAGS_POKE = 4
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync} VMREQFLAGS;
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync
30f07af559efcbd967e801903746fc21f81ee533vboxsync/**
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync * VM Request packet.
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync *
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync * This is used to request an action in the EMT. Usually the requester is
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * another thread, but EMT can also end up being the requester in which case
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync * it's carried out synchronously.
d1e6154d21dcc739e31ac7d8b139ee0fdfe60d45vboxsync */
a60be2c64ea23bb7ce4c9998bcd541c4db879fbavboxsynctypedef struct VMREQ
a60be2c64ea23bb7ce4c9998bcd541c4db879fbavboxsync{
a60be2c64ea23bb7ce4c9998bcd541c4db879fbavboxsync /** Pointer to the next request in the chain. */
a60be2c64ea23bb7ce4c9998bcd541c4db879fbavboxsync struct VMREQ * volatile pNext;
a60be2c64ea23bb7ce4c9998bcd541c4db879fbavboxsync /** Pointer to ring-3 VM structure which this request belongs to. */
a60be2c64ea23bb7ce4c9998bcd541c4db879fbavboxsync PUVM pUVM;
a60be2c64ea23bb7ce4c9998bcd541c4db879fbavboxsync /** Request state. */
a60be2c64ea23bb7ce4c9998bcd541c4db879fbavboxsync volatile VMREQSTATE enmState;
a60be2c64ea23bb7ce4c9998bcd541c4db879fbavboxsync /** VBox status code for the completed request. */
volatile int iStatus;
/** Requester event sem.
* The request can use this event semaphore to wait/poll for completion
* of the request.
*/
RTSEMEVENT EventSem;
/** Set if the event semaphore is clear. */
volatile bool fEventSemClear;
/** Flags, VMR3REQ_FLAGS_*. */
unsigned fFlags;
/** Request type. */
VMREQTYPE enmType;
/** Request destination. */
VMCPUID idDstCpu;
/** Request specific data. */
union VMREQ_U
{
/** VMREQTYPE_INTERNAL. */
struct
{
/** Pointer to the function to be called. */
PFNRT pfn;
/** Number of arguments. */
unsigned cArgs;
/** Array of arguments. */
uintptr_t aArgs[64];
} Internal;
} u;
} VMREQ;
/** Pointer to a VM request packet. */
typedef VMREQ *PVMREQ;
/** @} */
#ifndef IN_RC
/** @defgroup grp_vmm_apis_hc VM Host Context API
* @ingroup grp_vm
* @{ */
/** @} */
#endif
#ifdef IN_RING3
/** @defgroup grp_vmm_apis_r3 VM Host Context Ring 3 API
* This interface is a _draft_!
* @ingroup grp_vm
* @{ */
/**
* Completion notification codes.
*/
typedef enum VMINITCOMPLETED
{
/** The Ring3 init is completed. */
VMINITCOMPLETED_RING3 = 1,
/** The Ring0 init is completed. */
VMINITCOMPLETED_RING0,
/** The GC init is completed. */
VMINITCOMPLETED_GC
} VMINITCOMPLETED;
VMMR3DECL(int) VMR3Create(uint32_t cCpus, PFNVMATERROR pfnVMAtError, void *pvUserVM, PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUserCFGM, PVM *ppVM);
VMMR3DECL(int) VMR3PowerOn(PVM pVM);
VMMR3DECL(int) VMR3Suspend(PVM pVM);
VMMR3DECL(int) VMR3Resume(PVM pVM);
VMMR3DECL(int) VMR3Reset(PVM pVM);
/**
* Progress callback.
* This will report the completion percentage of an operation.
*
* @returns VINF_SUCCESS.
* @returns Error code to cancel the operation with.
* @param pVM The VM handle.
* @param uPercent Completetion precentage (0-100).
* @param pvUser User specified argument.
*/
typedef DECLCALLBACK(int) FNVMPROGRESS(PVM pVM, unsigned uPercent, void *pvUser);
/** Pointer to a FNVMPROGRESS function. */
typedef FNVMPROGRESS *PFNVMPROGRESS;
VMMR3DECL(int) VMR3Save(PVM pVM, const char *pszFilename, bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended);
VMMR3DECL(int) VMR3Teleport(PVM pVM, uint32_t cMsDowntime, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, PFNVMPROGRESS pfnProgress, void *pvProgressUser, bool *pfSuspended);
VMMR3DECL(int) VMR3LoadFromFile(PVM pVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser);
VMMR3DECL(int) VMR3LoadFromStream(PVM pVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
PFNVMPROGRESS pfnProgress, void *pvProgressUser);
VMMR3DECL(int) VMR3PowerOff(PVM pVM);
VMMR3DECL(int) VMR3Destroy(PVM pVM);
VMMR3DECL(void) VMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
VMMR3DECL(PVM) VMR3EnumVMs(PVM pVMPrev);
/**
* VM destruction callback.
* @param pVM The VM which is about to be destroyed.
* @param pvUser The user parameter specified at registration.
*/
typedef DECLCALLBACK(void) FNVMATDTOR(PVM pVM, void *pvUser);
/** Pointer to a VM destruction callback. */
typedef FNVMATDTOR *PFNVMATDTOR;
VMMR3DECL(int) VMR3AtDtorRegister(PFNVMATDTOR pfnAtDtor, void *pvUser);
VMMR3DECL(int) VMR3AtDtorDeregister(PFNVMATDTOR pfnAtDtor);
VMMR3DECL(int) VMR3AtStateRegister(PVM pVM, PFNVMATSTATE pfnAtState, void *pvUser);
VMMR3DECL(int) VMR3AtStateDeregister(PVM pVM, PFNVMATSTATE pfnAtState, void *pvUser);
VMMR3DECL(VMSTATE) VMR3GetState(PVM pVM);
VMMR3DECL(const char *) VMR3GetStateName(VMSTATE enmState);
VMMR3DECL(bool) VMR3TeleportedAndNotFullyResumedYet(PVM pVM);
VMMR3DECL(int) VMR3AtErrorRegister(PVM pVM, PFNVMATERROR pfnAtError, void *pvUser);
VMMR3DECL(int) VMR3AtErrorRegisterU(PUVM pVM, PFNVMATERROR pfnAtError, void *pvUser);
VMMR3DECL(int) VMR3AtErrorDeregister(PVM pVM, PFNVMATERROR pfnAtError, void *pvUser);
VMMR3DECL(void) VMR3SetErrorWorker(PVM pVM);
VMMR3DECL(uint32_t) VMR3GetErrorCount(PVM pVM);
VMMR3DECL(int) VMR3AtRuntimeErrorRegister(PVM pVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
VMMR3DECL(int) VMR3AtRuntimeErrorDeregister(PVM pVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
VMMR3DECL(int) VMR3SetRuntimeErrorWorker(PVM pVM);
VMMR3DECL(uint32_t) VMR3GetRuntimeErrorCount(PVM pVM);
VMMR3DECL(int) VMR3ReqCall(PVM pVM, VMCPUID idDstCpu, PVMREQ *ppReq, RTMSINTERVAL cMillies, uint32_t fFlags, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallU(PUVM pUVM, VMCPUID idDstCpu, PVMREQ *ppReq, RTMSINTERVAL cMillies, uint32_t fFlags, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallVU(PUVM pUVM, VMCPUID idDstCpu, PVMREQ *ppReq, RTMSINTERVAL cMillies, uint32_t fFlags, PFNRT pfnFunction, unsigned cArgs, va_list Args);
VMMR3DECL(int) VMR3ReqCallWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallNoWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallVoidWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallVoidWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallVoidNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallVoidNoWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqAlloc(PVM pVM, PVMREQ *ppReq, VMREQTYPE enmType, VMCPUID idDstCpu);
VMMR3DECL(int) VMR3ReqAllocU(PUVM pUVM, PVMREQ *ppReq, VMREQTYPE enmType, VMCPUID idDstCpu);
VMMR3DECL(int) VMR3ReqFree(PVMREQ pReq);
VMMR3DECL(int) VMR3ReqQueue(PVMREQ pReq, RTMSINTERVAL cMillies);
VMMR3DECL(int) VMR3ReqWait(PVMREQ pReq, RTMSINTERVAL cMillies);
VMMR3DECL(int) VMR3ReqProcessU(PUVM pUVM, VMCPUID idDstCpu);
VMMR3DECL(void) VMR3NotifyGlobalFFU(PUVM pUVM, uint32_t fFlags);
VMMR3DECL(void) VMR3NotifyCpuFFU(PUVMCPU pUVMCpu, uint32_t fFlags);
/** @name Flags for VMR3NotifyCpuFFU and VMR3NotifyGlobalFFU.
* @{ */
/** Whether we've done REM or not. */
#define VMNOTIFYFF_FLAGS_DONE_REM RT_BIT_32(0)
/** Whether we should poke the CPU if it's executing guest code. */
#define VMNOTIFYFF_FLAGS_POKE RT_BIT_32(1)
/** @} */
VMMR3DECL(int) VMR3WaitHalted(PVM pVM, PVMCPU pVCpu, bool fIgnoreInterrupts);
VMMR3DECL(int) VMR3WaitU(PUVMCPU pUVMCpu);
VMMR3_INT_DECL(int) VMR3AsyncPdmNotificationWaitU(PUVMCPU pUVCpu);
VMMR3_INT_DECL(void) VMR3AsyncPdmNotificationWakeupU(PUVM pUVM);
VMMR3DECL(RTCPUID) VMR3GetVMCPUId(PVM pVM);
VMMR3DECL(RTTHREAD) VMR3GetVMCPUThread(PVM pVM);
VMMR3DECL(RTTHREAD) VMR3GetVMCPUThreadU(PUVM pUVM);
VMMR3DECL(RTNATIVETHREAD) VMR3GetVMCPUNativeThread(PVM pVM);
VMMR3DECL(RTNATIVETHREAD) VMR3GetVMCPUNativeThreadU(PUVM pUVM);
VMMR3DECL(int) VMR3GetCPUCoreAndPackageIdFromCPUId(PVM pVM, VMCPUID idCpu, uint32_t *pidCpuCore, uint32_t *pidCpuPackage);
VMMR3DECL(int) VMR3HotunplugCPU(PVM pVM, VMCPUID idCpu);
VMMR3DECL(int) VMR3HotplugCPU(PVM pVM, VMCPUID idCpu);
/** @} */
#endif /* IN_RING3 */
#ifdef IN_RC
/** @defgroup grp_vmm_apis_gc VM Guest Context APIs
* @ingroup grp_vm
* @{ */
/** @} */
#endif
RT_C_DECLS_END
/** @} */
#endif