1#ifndef SYSEMU_REPLAY_H
2#define SYSEMU_REPLAY_H
3
4
5
6
7
8
9
10
11
12
13
14
15#include "exec/replay-core.h"
16#include "qapi/qapi-types-misc.h"
17#include "qapi/qapi-types-run-state.h"
18#include "qapi/qapi-types-ui.h"
19#include "block/aio.h"
20
21
22enum ReplayClockKind {
23
24 REPLAY_CLOCK_HOST,
25
26 REPLAY_CLOCK_VIRTUAL_RT,
27 REPLAY_CLOCK_COUNT
28};
29typedef enum ReplayClockKind ReplayClockKind;
30
31
32enum ReplayCheckpoint {
33 CHECKPOINT_CLOCK_WARP_START,
34 CHECKPOINT_CLOCK_WARP_ACCOUNT,
35 CHECKPOINT_RESET_REQUESTED,
36 CHECKPOINT_SUSPEND_REQUESTED,
37 CHECKPOINT_CLOCK_VIRTUAL,
38 CHECKPOINT_CLOCK_HOST,
39 CHECKPOINT_CLOCK_VIRTUAL_RT,
40 CHECKPOINT_INIT,
41 CHECKPOINT_RESET,
42 CHECKPOINT_COUNT
43};
44typedef enum ReplayCheckpoint ReplayCheckpoint;
45
46typedef struct ReplayNetState ReplayNetState;
47
48
49extern char *replay_snapshot;
50
51
52
53
54
55
56
57
58
59
60
61void replay_mutex_lock(void);
62void replay_mutex_unlock(void);
63
64
65
66
67uint64_t replay_get_current_icount(void);
68
69int replay_get_instructions(void);
70
71void replay_account_executed_instructions(void);
72
73
74
75
76int64_t replay_save_clock(ReplayClockKind kind, int64_t clock,
77 int64_t raw_icount);
78
79int64_t replay_read_clock(ReplayClockKind kind, int64_t raw_icount);
80
81#define REPLAY_CLOCK(clock, value) \
82 (replay_mode == REPLAY_MODE_PLAY \
83 ? replay_read_clock((clock), icount_get_raw()) \
84 : replay_mode == REPLAY_MODE_RECORD \
85 ? replay_save_clock((clock), (value), icount_get_raw()) \
86 : (value))
87#define REPLAY_CLOCK_LOCKED(clock, value) \
88 (replay_mode == REPLAY_MODE_PLAY \
89 ? replay_read_clock((clock), icount_get_raw_locked()) \
90 : replay_mode == REPLAY_MODE_RECORD \
91 ? replay_save_clock((clock), (value), icount_get_raw_locked()) \
92 : (value))
93
94
95
96
97void replay_shutdown_request(ShutdownCause cause);
98
99
100
101
102
103bool replay_checkpoint(ReplayCheckpoint checkpoint);
104
105
106bool replay_has_event(void);
107
108
109
110
111void replay_async_events(void);
112
113
114
115
116void replay_disable_events(void);
117
118void replay_enable_events(void);
119
120bool replay_events_enabled(void);
121
122void replay_flush_events(void);
123
124void replay_bh_schedule_event(QEMUBH *bh);
125
126void replay_bh_schedule_oneshot_event(AioContext *ctx,
127 QEMUBHFunc *cb, void *opaque);
128
129void replay_input_event(QemuConsole *src, InputEvent *evt);
130
131void replay_input_sync_event(void);
132
133void replay_block_event(QEMUBH *bh, uint64_t id);
134
135uint64_t blkreplay_next_id(void);
136
137
138
139
140void replay_register_char_driver(struct Chardev *chr);
141
142void replay_chr_be_write(struct Chardev *s, const uint8_t *buf, int len);
143
144void replay_char_write_event_save(int res, int offset);
145
146void replay_char_write_event_load(int *res, int *offset);
147
148int replay_char_read_all_load(uint8_t *buf);
149
150void replay_char_read_all_save_error(int res);
151
152void replay_char_read_all_save_buf(uint8_t *buf, int offset);
153
154
155
156
157ReplayNetState *replay_register_net(NetFilterState *nfs);
158
159void replay_unregister_net(ReplayNetState *rns);
160
161void replay_net_packet_event(ReplayNetState *rns, unsigned flags,
162 const struct iovec *iov, int iovcnt);
163
164
165
166
167void replay_audio_out(size_t *played);
168
169void replay_audio_in(size_t *recorded, void *samples, size_t *wpos, size_t size);
170
171
172
173
174
175void replay_vmstate_init(void);
176
177
178bool replay_can_snapshot(void);
179
180#endif
181