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_shutdown_request(ShutdownCause cause);
124
125
126
127
128
129bool replay_checkpoint(ReplayCheckpoint checkpoint);
130
131
132bool replay_has_checkpoint(void);
133
134
135
136
137void replay_disable_events(void);
138
139void replay_enable_events(void);
140
141bool replay_events_enabled(void);
142
143void replay_bh_schedule_event(QEMUBH *bh);
144
145void replay_bh_schedule_oneshot_event(AioContext *ctx,
146 QEMUBHFunc *cb, void *opaque);
147
148void replay_input_event(QemuConsole *src, InputEvent *evt);
149
150void replay_input_sync_event(void);
151
152void replay_block_event(QEMUBH *bh, uint64_t id);
153
154uint64_t blkreplay_next_id(void);
155
156
157
158
159void replay_register_char_driver(struct Chardev *chr);
160
161void replay_chr_be_write(struct Chardev *s, uint8_t *buf, int len);
162
163void replay_char_write_event_save(int res, int offset);
164
165void replay_char_write_event_load(int *res, int *offset);
166
167int replay_char_read_all_load(uint8_t *buf);
168
169void replay_char_read_all_save_error(int res);
170
171void replay_char_read_all_save_buf(uint8_t *buf, int offset);
172
173
174
175
176ReplayNetState *replay_register_net(NetFilterState *nfs);
177
178void replay_unregister_net(ReplayNetState *rns);
179
180void replay_net_packet_event(ReplayNetState *rns, unsigned flags,
181 const struct iovec *iov, int iovcnt);
182
183
184
185
186void replay_audio_out(size_t *played);
187
188void replay_audio_in(size_t *recorded, void *samples, size_t *wpos, size_t size);
189
190
191
192
193
194void replay_vmstate_init(void);
195
196
197bool replay_can_snapshot(void);
198
199#endif
200