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