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#ifndef MIGRATION_QEMU_FILE_H
26#define MIGRATION_QEMU_FILE_H
27
28#include <zlib.h>
29#include "exec/cpu-common.h"
30#include "io/channel.h"
31
32
33
34
35
36
37typedef int (QEMURamHookFunc)(QEMUFile *f, uint64_t flags, void *data);
38
39
40
41
42#define RAM_CONTROL_SETUP 0
43#define RAM_CONTROL_ROUND 1
44#define RAM_CONTROL_HOOK 2
45#define RAM_CONTROL_FINISH 3
46#define RAM_CONTROL_BLOCK_REG 4
47
48
49
50
51
52typedef size_t (QEMURamSaveFunc)(QEMUFile *f,
53 ram_addr_t block_offset,
54 ram_addr_t offset,
55 size_t size,
56 uint64_t *bytes_sent);
57
58typedef struct QEMUFileHooks {
59 QEMURamHookFunc *before_ram_iterate;
60 QEMURamHookFunc *after_ram_iterate;
61 QEMURamHookFunc *hook_ram_load;
62 QEMURamSaveFunc *save_page;
63} QEMUFileHooks;
64
65QEMUFile *qemu_file_new_input(QIOChannel *ioc);
66QEMUFile *qemu_file_new_output(QIOChannel *ioc);
67void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks);
68int qemu_fclose(QEMUFile *f);
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86int64_t qemu_file_total_transferred(QEMUFile *f);
87
88
89
90
91
92
93
94
95
96
97
98int64_t qemu_file_total_transferred_fast(QEMUFile *f);
99
100
101
102
103
104void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, size_t size,
105 bool may_free);
106bool qemu_file_mode_is_not_valid(const char *mode);
107bool qemu_file_is_writable(QEMUFile *f);
108
109#include "migration/qemu-file-types.h"
110
111size_t qemu_peek_buffer(QEMUFile *f, uint8_t **buf, size_t size, size_t offset);
112size_t qemu_get_buffer_in_place(QEMUFile *f, uint8_t **buf, size_t size);
113ssize_t qemu_put_compression_data(QEMUFile *f, z_stream *stream,
114 const uint8_t *p, size_t size);
115int qemu_put_qemu_file(QEMUFile *f_des, QEMUFile *f_src);
116
117
118
119
120
121
122int qemu_peek_byte(QEMUFile *f, int offset);
123void qemu_file_skip(QEMUFile *f, int size);
124
125
126
127
128
129
130
131void qemu_file_credit_transfer(QEMUFile *f, size_t size);
132void qemu_file_reset_rate_limit(QEMUFile *f);
133
134
135
136
137
138
139
140void qemu_file_acct_rate_limit(QEMUFile *f, int64_t len);
141void qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate);
142int64_t qemu_file_get_rate_limit(QEMUFile *f);
143int qemu_file_get_error_obj(QEMUFile *f, Error **errp);
144int qemu_file_get_error_obj_any(QEMUFile *f1, QEMUFile *f2, Error **errp);
145void qemu_file_set_error_obj(QEMUFile *f, int ret, Error *err);
146void qemu_file_set_error(QEMUFile *f, int ret);
147int qemu_file_shutdown(QEMUFile *f);
148QEMUFile *qemu_file_get_return_path(QEMUFile *f);
149void qemu_fflush(QEMUFile *f);
150void qemu_file_set_blocking(QEMUFile *f, bool block);
151
152void ram_control_before_iterate(QEMUFile *f, uint64_t flags);
153void ram_control_after_iterate(QEMUFile *f, uint64_t flags);
154void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data);
155
156
157
158
159
160
161#define RAM_SAVE_FLAG_HOOK 0x80
162
163#define RAM_SAVE_CONTROL_NOT_SUPP -1000
164#define RAM_SAVE_CONTROL_DELAYED -2000
165
166size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
167 ram_addr_t offset, size_t size,
168 uint64_t *bytes_sent);
169QIOChannel *qemu_file_get_ioc(QEMUFile *file);
170
171#endif
172