ssm.h revision 6dea6d87ed79bc0994d314fed1c90431091e8820
9daf20fb31dda50072a73c0302e704c1d0d619a8vboxsync * SSM - The Save State Manager. (VMM)
9daf20fb31dda50072a73c0302e704c1d0d619a8vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
9daf20fb31dda50072a73c0302e704c1d0d619a8vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
9daf20fb31dda50072a73c0302e704c1d0d619a8vboxsync * available from http://www.virtualbox.org. This file is free software;
9daf20fb31dda50072a73c0302e704c1d0d619a8vboxsync * you can redistribute it and/or modify it under the terms of the GNU
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * General Public License (GPL) as published by the Free Software
9daf20fb31dda50072a73c0302e704c1d0d619a8vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a74782eac5771b0de57834e8c8c0247c55e8dd57vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a74782eac5771b0de57834e8c8c0247c55e8dd57vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a74782eac5771b0de57834e8c8c0247c55e8dd57vboxsync * The contents of this file may alternatively be used under the terms
a74782eac5771b0de57834e8c8c0247c55e8dd57vboxsync * of the Common Development and Distribution License Version 1.0
a74782eac5771b0de57834e8c8c0247c55e8dd57vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
a74782eac5771b0de57834e8c8c0247c55e8dd57vboxsync * VirtualBox OSE distribution, in which case the provisions of the
9daf20fb31dda50072a73c0302e704c1d0d619a8vboxsync * CDDL are applicable instead of those of the GPL.
9daf20fb31dda50072a73c0302e704c1d0d619a8vboxsync * You may elect to license modified versions of this file under the
9daf20fb31dda50072a73c0302e704c1d0d619a8vboxsync * terms and conditions of either the GPL or the CDDL or both.
9daf20fb31dda50072a73c0302e704c1d0d619a8vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
9daf20fb31dda50072a73c0302e704c1d0d619a8vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
9daf20fb31dda50072a73c0302e704c1d0d619a8vboxsync * additional information or have any questions.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync/** @defgroup grp_ssm The Saved State Manager API
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * Determine the major version of the SSM version. If the major SSM version of two snapshots is
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * different, the snapshots are incompatible.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * Determine the minor version of the SSM version. If the major SSM version of two snapshots is
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * the same, the code must handle incompatibilies between minor version changes (e.g. use dummy
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * values for non-existent fields).
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * Determine if the major version changed between two SSM versions.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync#define SSM_VERSION_MAJOR_CHANGED(ver1,ver2) (SSM_VERSION_MAJOR(ver1) != SSM_VERSION_MAJOR(ver2))
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync/** The special value for the final pass. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync/** @defgroup grp_ssm_r3 The SSM Host Context Ring-3 API
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * What to do after the save/load operation.
c95a2e1555b5e57471b8a87b5c61a373d074285bvboxsync /** Invalid. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync /** Will resume the loaded state. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync /** Will destroy the VM after saving. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync /** Will continue execution after saving the VM. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync /** Will migrate the VM.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * The source VM will be destroyed (then one saving), the destination VM
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * will continue execution. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync /** Will debug the saved state.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * This is used to drop some of the stricter consitentcy checks so it'll
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * load fine in the debugger or animator. */
c95a2e1555b5e57471b8a87b5c61a373d074285bvboxsync /** The file was opened using SSMR3Open() and we have no idea what the plan is. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * A structure field description.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * @todo Add an type field here for recording what's a GCPtr, GCPhys or anything
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * else that may change and is expected to continue to work.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * @todo Later we need to add load transformations to this structure. I think a
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * callback with a number of default transformations in SIG_DEF style
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * would be good enough. The callback would take a user context from a new
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * SSMR3GetStruct parameter or something.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsynctypedef struct SSMFIELD
c95a2e1555b5e57471b8a87b5c61a373d074285bvboxsync /** Field offset into the structure. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync /** The size of the field. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync/** Pointer to a structure field description. */
c95a2e1555b5e57471b8a87b5c61a373d074285bvboxsync/** Pointer to a const structure field description. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync/** Emit a SSMFIELD array entry. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync#define SSMFIELD_ENTRY(Type, Field) { RT_OFFSETOF(Type, Field), RT_SIZEOFMEMB(Type, Field) }
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync/** Emit a SSMFIELD array entry for a RTGCPTR type. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync#define SSMFIELD_ENTRY_GCPTR(Type, Field) SSMFIELD_ENTRY(Type, Field)
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync/** Emit a SSMFIELD array entry for a RTGCPHYS type. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync#define SSMFIELD_ENTRY_GCPHYS(Type, Field) SSMFIELD_ENTRY(Type, Field)
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync/** Emit the terminating entry of a SSMFIELD array. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync#define SSMFIELD_ENTRY_TERM() { UINT32_MAX, UINT32_MAX }
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync/** The PDM Device callback variants.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * Prepare state live save operation.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * @returns VBox status code.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * @param pDevIns Device instance of the device which registered the data unit.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * @param pSSM SSM operation handle.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * @thread Any.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsynctypedef DECLCALLBACK(int) FNSSMDEVLIVEPREP(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync/** Pointer to a FNSSMDEVLIVEPREP() function. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * Execute state live save operation.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * This will be called repeatedly until all units vote that the live phase has
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * been concluded.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * @returns VBox status code.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * @param pDevIns Device instance of the device which registered the data unit.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * @param pSSM SSM operation handle.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * @param uPass The pass.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * @thread Any.
20606357beeba9ef9025b662f5e3d178dd37d559vboxsynctypedef DECLCALLBACK(int) FNSSMDEVLIVEEXEC(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass);
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync/** Pointer to a FNSSMDEVLIVEEXEC() function. */
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * Vote on whether the live part of the saving has been concluded.
165fadeb66c752c3bcc6792f789247b41092d1a1vboxsync * The vote stops once a unit has vetoed the decision, so don't rely upon this
20606357beeba9ef9025b662f5e3d178dd37d559vboxsync * being called every time.
typedef DECLCALLBACK(int) FNSSMDEVLOADEXEC(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
typedef DECLCALLBACK(int) FNSSMDRVLOADEXEC(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
typedef DECLCALLBACK(int) FNSSMINTLOADEXEC(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
typedef DECLCALLBACK(int) FNSSMEXTLOADEXEC(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
VMMR3DECL(int) SSMR3RegisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
VMMR3DECL(int) SSMR3RegisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
VMMR3DECL(int) SSMR3RegisterInternal(PVM pVM, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
VMMR3DECL(int) SSMR3RegisterExternal(PVM pVM, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
PFNSSMEXTLOADPREP pfnLoadPrep, PFNSSMEXTLOADEXEC pfnLoadExec, PFNSSMEXTLOADDONE pfnLoadDone, void *pvUser);
VMMR3DECL(int) SSMR3DeregisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t uInstance);
VMMR3DECL(int) SSMR3DeregisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance);
VMMR3DECL(int) SSMR3Save(PVM pVM, const char *pszFilename, SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser);
VMMR3DECL(int) SSMR3Load(PVM pVM, const char *pszFilename, SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser);