aboutsummaryrefslogtreecommitdiffstats
path: root/tools/python/xen/lowlevel/checkpoint/checkpoint.h
blob: 187d9d768c234a8da50b8ed02cf4e64f53dcbe45 (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
/* API for checkpointing */

#ifndef _CHECKPOINT_H_
#define _CHECKPOINT_H_ 1

#include <pthread.h>
#include <semaphore.h>
#include <time.h>

#include <xenguest.h>
#include <xenstore.h>

typedef enum {
    dt_unknown,
    dt_pv,
    dt_hvm,
    dt_pvhvm /* HVM with PV drivers */
} checkpoint_domtype;

typedef struct {
    xc_interface *xch;
    xc_evtchn *xce;        /* event channel handle */
    struct xs_handle* xsh; /* xenstore handle */
    int watching_shutdown; /* state of watch on @releaseDomain */

    unsigned int domid;
    checkpoint_domtype domtype;
    int fd;

    int suspend_evtchn;

    char* errstr;

    /* suspend deadline thread support */
    volatile int suspended;
    volatile int done;
    pthread_t suspend_thr;
    sem_t suspended_sem;
    sem_t resumed_sem;
    timer_t timer;
} checkpoint_state;

#define CHECKPOINT_FLAGS_COMPRESSION 1
char* checkpoint_error(checkpoint_state* s);

void checkpoint_init(checkpoint_state* s);
int checkpoint_open(checkpoint_state* s, unsigned int domid);
void checkpoint_close(checkpoint_state* s);
int checkpoint_start(checkpoint_state* s, int fd,
		     struct save_callbacks* callbacks,
		     unsigned int remus_flags);
int checkpoint_suspend(checkpoint_state* s);
int checkpoint_resume(checkpoint_state* s);
int checkpoint_postflush(checkpoint_state* s);

int checkpoint_settimer(checkpoint_state* s, int millis);
int checkpoint_wait(checkpoint_state* s);
void block_timer(void);
void unblock_timer(void);

#endif