summaryrefslogtreecommitdiff
path: root/src/VBox/VMM/include/FTMInternal.h
blob: 6b442f16a6edc06f8d456b86a49e6fa88b7d3249 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* $Id: FTMInternal.h $ */
/** @file
 * FTM - Internal header file.
 */

/*
 * Copyright (C) 2010 Oracle Corporation
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * 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 ___FTMInternal_h
#define ___FTMInternal_h

#include <VBox/cdefs.h>
#include <VBox/types.h>
#include <VBox/vmm/ftm.h>
#include <VBox/vmm/stam.h>
#include <VBox/vmm/pdmcritsect.h>
#include <iprt/avl.h>

/** @defgroup grp_ftm_int Internals.
 * @ingroup grp_ftm
 * @{
 */

/** Physical page tree node. */
typedef struct FTMPHYSPAGETREENODE
{
    AVLGCPHYSNODECORE   Core;
    void               *pPage;
} FTMPHYSPAGETREENODE;
/** Pointer to FTMPHYSPAGETREENODE */
typedef FTMPHYSPAGETREENODE *PFTMPHYSPAGETREENODE;

/**
 * FTM VM Instance data.
 * Changes to this must checked against the padding of the ftm union in VM!
 */
typedef struct FTM
{
    /** Address of the standby VM. */
    R3PTRTYPE(char *)   pszAddress;
    /** Password to access the syncing server of the standby VM. */
    R3PTRTYPE(char *)   pszPassword;
    /** Port of the standby VM. */
    unsigned            uPort;
    /** Syncing interval in ms. */
    unsigned            uInterval;

    /** Set when this VM is the standby FT node. */
    bool                fIsStandbyNode;
    /** Set when this master VM is busy with checkpointing. */
    bool                fCheckpointingActive;
    /** Set when VM save/restore should only include changed pages. */
    bool                fDeltaLoadSaveActive;
    /** Fallover to the standby VM. */
    bool                fActivateStandby;
    bool                fAlignment[4];

    /** Current active socket. */
    RTSOCKET            hSocket;

    /* Shutdown event semaphore. */
    RTSEMEVENT          hShutdownEvent;

    /** State sync. */
    struct
    {
        unsigned            uOffStream;
        unsigned            cbReadBlock;
        bool                fStopReading;
        bool                fIOError;
        bool                fEndOfStream;
        bool                fAlignment[5];
    } syncstate;

    struct
    {
        R3PTRTYPE(PRTTCPSERVER)    hServer;
        R3PTRTYPE(AVLGCPHYSTREE)   pPhysPageTree;
        uint64_t                   u64LastHeartbeat;
    } standby;

    /*
    struct
    {
    } master;
    */

    /** FTM critical section.
     * This makes sure only the checkpoint or sync is active
     */
    PDMCRITSECT         CritSect;

    STAMCOUNTER         StatReceivedMem;
    STAMCOUNTER         StatReceivedState;
    STAMCOUNTER         StatSentMem;
    STAMCOUNTER         StatSentState;
    STAMCOUNTER         StatDeltaMem;
    STAMCOUNTER         StatDeltaVM;
    STAMCOUNTER         StatFullSync;
    STAMCOUNTER         StatCheckpointNetwork;
    STAMCOUNTER         StatCheckpointStorage;
#ifdef VBOX_WITH_STATISTICS
    STAMPROFILE         StatCheckpoint;
    STAMPROFILE         StatCheckpointResume;
    STAMPROFILE         StatCheckpointPause;
    STAMCOUNTER         StatSentMemRAM;
    STAMCOUNTER         StatSentMemMMIO2;
    STAMCOUNTER         StatSentMemShwROM;
    STAMCOUNTER         StatSentStateWrite;
#endif
} FTM;
AssertCompileMemberAlignment(FTM, CritSect, 8);

/** @} */

#endif