root / include / block / block.h @ 8d3b1a2d
History | View | Annotate | Download (18.5 kB)
1 | faf07963 | pbrook | #ifndef BLOCK_H
|
---|---|---|---|
2 | faf07963 | pbrook | #define BLOCK_H
|
3 | faf07963 | pbrook | |
4 | 737e150e | Paolo Bonzini | #include "block/aio.h" |
5 | 3b69e4b9 | aliguori | #include "qemu-common.h" |
6 | 1de7afc9 | Paolo Bonzini | #include "qemu/option.h" |
7 | 737e150e | Paolo Bonzini | #include "block/coroutine.h" |
8 | 7b1b5d19 | Paolo Bonzini | #include "qapi/qmp/qobject.h" |
9 | 2f0c9fe6 | Paolo Bonzini | #include "qapi-types.h" |
10 | a76bab49 | aliguori | |
11 | faf07963 | pbrook | /* block.c */
|
12 | faf07963 | pbrook | typedef struct BlockDriver BlockDriver; |
13 | 2f0c9fe6 | Paolo Bonzini | typedef struct BlockJob BlockJob; |
14 | faf07963 | pbrook | |
15 | faf07963 | pbrook | typedef struct BlockDriverInfo { |
16 | faf07963 | pbrook | /* in bytes, 0 if irrelevant */
|
17 | faf07963 | pbrook | int cluster_size;
|
18 | faf07963 | pbrook | /* offset at which the VM state can be saved (0 if not possible) */
|
19 | faf07963 | pbrook | int64_t vm_state_offset; |
20 | 64c79160 | Dong Xu Wang | bool is_dirty;
|
21 | faf07963 | pbrook | } BlockDriverInfo; |
22 | faf07963 | pbrook | |
23 | f8111c24 | Dong Xu Wang | typedef struct BlockFragInfo { |
24 | f8111c24 | Dong Xu Wang | uint64_t allocated_clusters; |
25 | f8111c24 | Dong Xu Wang | uint64_t total_clusters; |
26 | f8111c24 | Dong Xu Wang | uint64_t fragmented_clusters; |
27 | e6439d78 | Stefan Hajnoczi | uint64_t compressed_clusters; |
28 | f8111c24 | Dong Xu Wang | } BlockFragInfo; |
29 | f8111c24 | Dong Xu Wang | |
30 | faf07963 | pbrook | typedef struct QEMUSnapshotInfo { |
31 | faf07963 | pbrook | char id_str[128]; /* unique snapshot id */ |
32 | faf07963 | pbrook | /* the following fields are informative. They are not needed for
|
33 | faf07963 | pbrook | the consistency of the snapshot */
|
34 | e7d81004 | Stefan Weil | char name[256]; /* user chosen name */ |
35 | c2c9a466 | Kevin Wolf | uint64_t vm_state_size; /* VM state info size */
|
36 | faf07963 | pbrook | uint32_t date_sec; /* UTC date of the snapshot */
|
37 | faf07963 | pbrook | uint32_t date_nsec; |
38 | faf07963 | pbrook | uint64_t vm_clock_nsec; /* VM clock relative to boot */
|
39 | faf07963 | pbrook | } QEMUSnapshotInfo; |
40 | faf07963 | pbrook | |
41 | 145feb17 | Markus Armbruster | /* Callbacks for block device models */
|
42 | 0e49de52 | Markus Armbruster | typedef struct BlockDevOps { |
43 | 145feb17 | Markus Armbruster | /*
|
44 | 145feb17 | Markus Armbruster | * Runs when virtual media changed (monitor commands eject, change)
|
45 | 7d4b4ba5 | Markus Armbruster | * Argument load is true on load and false on eject.
|
46 | 145feb17 | Markus Armbruster | * Beware: doesn't run when a host device's physical media
|
47 | 145feb17 | Markus Armbruster | * changes. Sure would be useful if it did.
|
48 | 2c6942fa | Markus Armbruster | * Device models with removable media must implement this callback.
|
49 | 145feb17 | Markus Armbruster | */
|
50 | 7d4b4ba5 | Markus Armbruster | void (*change_media_cb)(void *opaque, bool load); |
51 | 145feb17 | Markus Armbruster | /*
|
52 | 025ccaa7 | Paolo Bonzini | * Runs when an eject request is issued from the monitor, the tray
|
53 | 025ccaa7 | Paolo Bonzini | * is closed, and the medium is locked.
|
54 | 025ccaa7 | Paolo Bonzini | * Device models that do not implement is_medium_locked will not need
|
55 | 025ccaa7 | Paolo Bonzini | * this callback. Device models that can lock the medium or tray might
|
56 | 025ccaa7 | Paolo Bonzini | * want to implement the callback and unlock the tray when "force" is
|
57 | 025ccaa7 | Paolo Bonzini | * true, even if they do not support eject requests.
|
58 | 025ccaa7 | Paolo Bonzini | */
|
59 | 025ccaa7 | Paolo Bonzini | void (*eject_request_cb)(void *opaque, bool force); |
60 | 025ccaa7 | Paolo Bonzini | /*
|
61 | e4def80b | Markus Armbruster | * Is the virtual tray open?
|
62 | e4def80b | Markus Armbruster | * Device models implement this only when the device has a tray.
|
63 | e4def80b | Markus Armbruster | */
|
64 | e4def80b | Markus Armbruster | bool (*is_tray_open)(void *opaque); |
65 | e4def80b | Markus Armbruster | /*
|
66 | f107639a | Markus Armbruster | * Is the virtual medium locked into the device?
|
67 | f107639a | Markus Armbruster | * Device models implement this only when device has such a lock.
|
68 | f107639a | Markus Armbruster | */
|
69 | f107639a | Markus Armbruster | bool (*is_medium_locked)(void *opaque); |
70 | f107639a | Markus Armbruster | /*
|
71 | 145feb17 | Markus Armbruster | * Runs when the size changed (e.g. monitor command block_resize)
|
72 | 145feb17 | Markus Armbruster | */
|
73 | 145feb17 | Markus Armbruster | void (*resize_cb)(void *opaque); |
74 | 0e49de52 | Markus Armbruster | } BlockDevOps; |
75 | 0e49de52 | Markus Armbruster | |
76 | faf07963 | pbrook | #define BDRV_O_RDWR 0x0002 |
77 | faf07963 | pbrook | #define BDRV_O_SNAPSHOT 0x0008 /* open the file read only and save writes in a snapshot */ |
78 | 9f7965c7 | aliguori | #define BDRV_O_NOCACHE 0x0020 /* do not use the host page cache */ |
79 | 9f7965c7 | aliguori | #define BDRV_O_CACHE_WB 0x0040 /* use write-back caching */ |
80 | 5c6c3a6c | Christoph Hellwig | #define BDRV_O_NATIVE_AIO 0x0080 /* use native AIO instead of the thread pool */ |
81 | b783e409 | Kevin Wolf | #define BDRV_O_NO_BACKING 0x0100 /* don't open the backing file */ |
82 | 016f5cf6 | Alexander Graf | #define BDRV_O_NO_FLUSH 0x0200 /* disable flushing on this disk */ |
83 | 53fec9d3 | Stefan Hajnoczi | #define BDRV_O_COPY_ON_READ 0x0400 /* copy read backing sectors into image */ |
84 | ccb1f4a7 | Benoît Canet | #define BDRV_O_INCOMING 0x0800 /* consistency hint for incoming migration */ |
85 | 058f8f16 | Stefan Hajnoczi | #define BDRV_O_CHECK 0x1000 /* open solely for consistency check */ |
86 | be028adc | Jeff Cody | #define BDRV_O_ALLOW_RDWR 0x2000 /* allow reopen to change from r/o to r/w */ |
87 | 9e8f1835 | Paolo Bonzini | #define BDRV_O_UNMAP 0x4000 /* execute guest UNMAP/TRIM operations */ |
88 | 9f7965c7 | aliguori | |
89 | ceb25e5c | Kevin Wolf | #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH)
|
90 | faf07963 | pbrook | |
91 | 6ea44308 | Jan Kiszka | #define BDRV_SECTOR_BITS 9 |
92 | c63782cb | Jes Sorensen | #define BDRV_SECTOR_SIZE (1ULL << BDRV_SECTOR_BITS) |
93 | 3abbc4d9 | Stefan Hajnoczi | #define BDRV_SECTOR_MASK ~(BDRV_SECTOR_SIZE - 1) |
94 | 6ea44308 | Jan Kiszka | |
95 | 2582bfed | Luiz Capitulino | typedef enum { |
96 | 2582bfed | Luiz Capitulino | BDRV_ACTION_REPORT, BDRV_ACTION_IGNORE, BDRV_ACTION_STOP |
97 | ff06f5f3 | Paolo Bonzini | } BlockErrorAction; |
98 | 2582bfed | Luiz Capitulino | |
99 | e971aa12 | Jeff Cody | typedef QSIMPLEQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue;
|
100 | e971aa12 | Jeff Cody | |
101 | e971aa12 | Jeff Cody | typedef struct BDRVReopenState { |
102 | e971aa12 | Jeff Cody | BlockDriverState *bs; |
103 | e971aa12 | Jeff Cody | int flags;
|
104 | e971aa12 | Jeff Cody | void *opaque;
|
105 | e971aa12 | Jeff Cody | } BDRVReopenState; |
106 | e971aa12 | Jeff Cody | |
107 | e971aa12 | Jeff Cody | |
108 | 28a7282a | Luiz Capitulino | void bdrv_iostatus_enable(BlockDriverState *bs);
|
109 | 28a7282a | Luiz Capitulino | void bdrv_iostatus_reset(BlockDriverState *bs);
|
110 | 28a7282a | Luiz Capitulino | void bdrv_iostatus_disable(BlockDriverState *bs);
|
111 | 28a7282a | Luiz Capitulino | bool bdrv_iostatus_is_enabled(const BlockDriverState *bs); |
112 | 28a7282a | Luiz Capitulino | void bdrv_iostatus_set_err(BlockDriverState *bs, int error); |
113 | d15e5465 | Luiz Capitulino | void bdrv_info_print(Monitor *mon, const QObject *data); |
114 | d15e5465 | Luiz Capitulino | void bdrv_info(Monitor *mon, QObject **ret_data);
|
115 | 218a536a | Luiz Capitulino | void bdrv_stats_print(Monitor *mon, const QObject *data); |
116 | 218a536a | Luiz Capitulino | void bdrv_info_stats(Monitor *mon, QObject **ret_data);
|
117 | faf07963 | pbrook | |
118 | 0563e191 | Zhi Yong Wu | /* disk I/O throttling */
|
119 | 0563e191 | Zhi Yong Wu | void bdrv_io_limits_enable(BlockDriverState *bs);
|
120 | 98f90dba | Zhi Yong Wu | void bdrv_io_limits_disable(BlockDriverState *bs);
|
121 | 0563e191 | Zhi Yong Wu | bool bdrv_io_limits_enabled(BlockDriverState *bs);
|
122 | 0563e191 | Zhi Yong Wu | |
123 | faf07963 | pbrook | void bdrv_init(void); |
124 | eb852011 | Markus Armbruster | void bdrv_init_with_whitelist(void); |
125 | b50cbabc | MORITA Kazutaka | BlockDriver *bdrv_find_protocol(const char *filename); |
126 | faf07963 | pbrook | BlockDriver *bdrv_find_format(const char *format_name); |
127 | eb852011 | Markus Armbruster | BlockDriver *bdrv_find_whitelisted_format(const char *format_name); |
128 | 0e7e1989 | Kevin Wolf | int bdrv_create(BlockDriver *drv, const char* filename, |
129 | 0e7e1989 | Kevin Wolf | QEMUOptionParameter *options); |
130 | 84a12e66 | Christoph Hellwig | int bdrv_create_file(const char* filename, QEMUOptionParameter *options); |
131 | faf07963 | pbrook | BlockDriverState *bdrv_new(const char *device_name); |
132 | d22b2f41 | Ryan Harper | void bdrv_make_anon(BlockDriverState *bs);
|
133 | 4ddc07ca | Paolo Bonzini | void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old);
|
134 | 8802d1fd | Jeff Cody | void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top);
|
135 | faf07963 | pbrook | void bdrv_delete(BlockDriverState *bs);
|
136 | c3993cdc | Stefan Hajnoczi | int bdrv_parse_cache_flags(const char *mode, int *flags); |
137 | 9e8f1835 | Paolo Bonzini | int bdrv_parse_discard_flags(const char *mode, int *flags); |
138 | 787e4a85 | Kevin Wolf | int bdrv_file_open(BlockDriverState **pbs, const char *filename, |
139 | 787e4a85 | Kevin Wolf | QDict *options, int flags);
|
140 | 9156df12 | Paolo Bonzini | int bdrv_open_backing_file(BlockDriverState *bs);
|
141 | de9c0cec | Kevin Wolf | int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, |
142 | de9c0cec | Kevin Wolf | int flags, BlockDriver *drv);
|
143 | e971aa12 | Jeff Cody | BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, |
144 | e971aa12 | Jeff Cody | BlockDriverState *bs, int flags);
|
145 | e971aa12 | Jeff Cody | int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp);
|
146 | e971aa12 | Jeff Cody | int bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp); |
147 | e971aa12 | Jeff Cody | int bdrv_reopen_prepare(BDRVReopenState *reopen_state,
|
148 | e971aa12 | Jeff Cody | BlockReopenQueue *queue, Error **errp); |
149 | e971aa12 | Jeff Cody | void bdrv_reopen_commit(BDRVReopenState *reopen_state);
|
150 | e971aa12 | Jeff Cody | void bdrv_reopen_abort(BDRVReopenState *reopen_state);
|
151 | faf07963 | pbrook | void bdrv_close(BlockDriverState *bs);
|
152 | d7d512f6 | Paolo Bonzini | void bdrv_add_close_notifier(BlockDriverState *bs, Notifier *notify);
|
153 | fa879d62 | Markus Armbruster | int bdrv_attach_dev(BlockDriverState *bs, void *dev); |
154 | fa879d62 | Markus Armbruster | void bdrv_attach_dev_nofail(BlockDriverState *bs, void *dev); |
155 | fa879d62 | Markus Armbruster | void bdrv_detach_dev(BlockDriverState *bs, void *dev); |
156 | fa879d62 | Markus Armbruster | void *bdrv_get_attached_dev(BlockDriverState *bs);
|
157 | 0e49de52 | Markus Armbruster | void bdrv_set_dev_ops(BlockDriverState *bs, const BlockDevOps *ops, |
158 | 0e49de52 | Markus Armbruster | void *opaque);
|
159 | 025ccaa7 | Paolo Bonzini | void bdrv_dev_eject_request(BlockDriverState *bs, bool force); |
160 | 2c6942fa | Markus Armbruster | bool bdrv_dev_has_removable_media(BlockDriverState *bs);
|
161 | e4def80b | Markus Armbruster | bool bdrv_dev_is_tray_open(BlockDriverState *bs);
|
162 | f107639a | Markus Armbruster | bool bdrv_dev_is_medium_locked(BlockDriverState *bs);
|
163 | faf07963 | pbrook | int bdrv_read(BlockDriverState *bs, int64_t sector_num,
|
164 | faf07963 | pbrook | uint8_t *buf, int nb_sectors);
|
165 | 07d27a44 | Markus Armbruster | int bdrv_read_unthrottled(BlockDriverState *bs, int64_t sector_num,
|
166 | 07d27a44 | Markus Armbruster | uint8_t *buf, int nb_sectors);
|
167 | faf07963 | pbrook | int bdrv_write(BlockDriverState *bs, int64_t sector_num,
|
168 | faf07963 | pbrook | const uint8_t *buf, int nb_sectors); |
169 | 8d3b1a2d | Kevin Wolf | int bdrv_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov);
|
170 | faf07963 | pbrook | int bdrv_pread(BlockDriverState *bs, int64_t offset,
|
171 | faf07963 | pbrook | void *buf, int count); |
172 | faf07963 | pbrook | int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
|
173 | faf07963 | pbrook | const void *buf, int count); |
174 | 8d3b1a2d | Kevin Wolf | int bdrv_pwritev(BlockDriverState *bs, int64_t offset, QEMUIOVector *qiov);
|
175 | f08145fe | Kevin Wolf | int bdrv_pwrite_sync(BlockDriverState *bs, int64_t offset,
|
176 | f08145fe | Kevin Wolf | const void *buf, int count); |
177 | da1fa91d | Kevin Wolf | int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num,
|
178 | da1fa91d | Kevin Wolf | int nb_sectors, QEMUIOVector *qiov);
|
179 | 470c0504 | Stefan Hajnoczi | int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs,
|
180 | 470c0504 | Stefan Hajnoczi | int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
|
181 | da1fa91d | Kevin Wolf | int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num,
|
182 | da1fa91d | Kevin Wolf | int nb_sectors, QEMUIOVector *qiov);
|
183 | f08f2dda | Stefan Hajnoczi | /*
|
184 | f08f2dda | Stefan Hajnoczi | * Efficiently zero a region of the disk image. Note that this is a regular
|
185 | f08f2dda | Stefan Hajnoczi | * I/O request like read or write and should have a reasonable size. This
|
186 | f08f2dda | Stefan Hajnoczi | * function is not suitable for zeroing the entire image in a single request
|
187 | f08f2dda | Stefan Hajnoczi | * because it may allocate memory for the entire region.
|
188 | f08f2dda | Stefan Hajnoczi | */
|
189 | f08f2dda | Stefan Hajnoczi | int coroutine_fn bdrv_co_write_zeroes(BlockDriverState *bs, int64_t sector_num,
|
190 | f08f2dda | Stefan Hajnoczi | int nb_sectors);
|
191 | 060f51c9 | Stefan Hajnoczi | int coroutine_fn bdrv_co_is_allocated(BlockDriverState *bs, int64_t sector_num,
|
192 | 060f51c9 | Stefan Hajnoczi | int nb_sectors, int *pnum); |
193 | 188a7bbf | Paolo Bonzini | int coroutine_fn bdrv_co_is_allocated_above(BlockDriverState *top,
|
194 | 188a7bbf | Paolo Bonzini | BlockDriverState *base, |
195 | 188a7bbf | Paolo Bonzini | int64_t sector_num, |
196 | 188a7bbf | Paolo Bonzini | int nb_sectors, int *pnum); |
197 | e8a6bb9c | Marcelo Tosatti | BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, |
198 | e8a6bb9c | Marcelo Tosatti | const char *backing_file); |
199 | f198fd1c | Benoît Canet | int bdrv_get_backing_file_depth(BlockDriverState *bs);
|
200 | faf07963 | pbrook | int bdrv_truncate(BlockDriverState *bs, int64_t offset);
|
201 | faf07963 | pbrook | int64_t bdrv_getlength(BlockDriverState *bs); |
202 | 4a1d5e1f | Fam Zheng | int64_t bdrv_get_allocated_file_size(BlockDriverState *bs); |
203 | 96b8f136 | ths | void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
|
204 | faf07963 | pbrook | int bdrv_commit(BlockDriverState *bs);
|
205 | e8877497 | Stefan Hajnoczi | int bdrv_commit_all(void); |
206 | 756e6736 | Kevin Wolf | int bdrv_change_backing_file(BlockDriverState *bs,
|
207 | 756e6736 | Kevin Wolf | const char *backing_file, const char *backing_fmt); |
208 | 5efa9d5a | Anthony Liguori | void bdrv_register(BlockDriver *bdrv);
|
209 | 6ebdcee2 | Jeff Cody | int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top,
|
210 | 6ebdcee2 | Jeff Cody | BlockDriverState *base); |
211 | 6ebdcee2 | Jeff Cody | BlockDriverState *bdrv_find_overlay(BlockDriverState *active, |
212 | 6ebdcee2 | Jeff Cody | BlockDriverState *bs); |
213 | 79fac568 | Jeff Cody | BlockDriverState *bdrv_find_base(BlockDriverState *bs); |
214 | 5efa9d5a | Anthony Liguori | |
215 | e076f338 | Kevin Wolf | |
216 | e076f338 | Kevin Wolf | typedef struct BdrvCheckResult { |
217 | e076f338 | Kevin Wolf | int corruptions;
|
218 | e076f338 | Kevin Wolf | int leaks;
|
219 | e076f338 | Kevin Wolf | int check_errors;
|
220 | ccf34716 | Kevin Wolf | int corruptions_fixed;
|
221 | ccf34716 | Kevin Wolf | int leaks_fixed;
|
222 | c6bb9ad1 | Federico Simoncelli | int64_t image_end_offset; |
223 | f8111c24 | Dong Xu Wang | BlockFragInfo bfi; |
224 | e076f338 | Kevin Wolf | } BdrvCheckResult; |
225 | e076f338 | Kevin Wolf | |
226 | 4534ff54 | Kevin Wolf | typedef enum { |
227 | 4534ff54 | Kevin Wolf | BDRV_FIX_LEAKS = 1,
|
228 | 4534ff54 | Kevin Wolf | BDRV_FIX_ERRORS = 2,
|
229 | 4534ff54 | Kevin Wolf | } BdrvCheckMode; |
230 | 4534ff54 | Kevin Wolf | |
231 | 4534ff54 | Kevin Wolf | int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix);
|
232 | e076f338 | Kevin Wolf | |
233 | faf07963 | pbrook | /* async block I/O */
|
234 | 7cd1e32a | lirans@il.ibm.com | typedef void BlockDriverDirtyHandler(BlockDriverState *bs, int64_t sector, |
235 | 39aa9a12 | Devin Nakamura | int sector_num);
|
236 | 3b69e4b9 | aliguori | BlockDriverAIOCB *bdrv_aio_readv(BlockDriverState *bs, int64_t sector_num, |
237 | 3b69e4b9 | aliguori | QEMUIOVector *iov, int nb_sectors,
|
238 | 3b69e4b9 | aliguori | BlockDriverCompletionFunc *cb, void *opaque);
|
239 | 3b69e4b9 | aliguori | BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num, |
240 | 3b69e4b9 | aliguori | QEMUIOVector *iov, int nb_sectors,
|
241 | 3b69e4b9 | aliguori | BlockDriverCompletionFunc *cb, void *opaque);
|
242 | b2e12bc6 | Christoph Hellwig | BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs, |
243 | 39aa9a12 | Devin Nakamura | BlockDriverCompletionFunc *cb, void *opaque);
|
244 | 4265d620 | Paolo Bonzini | BlockDriverAIOCB *bdrv_aio_discard(BlockDriverState *bs, |
245 | 4265d620 | Paolo Bonzini | int64_t sector_num, int nb_sectors,
|
246 | 4265d620 | Paolo Bonzini | BlockDriverCompletionFunc *cb, void *opaque);
|
247 | faf07963 | pbrook | void bdrv_aio_cancel(BlockDriverAIOCB *acb);
|
248 | faf07963 | pbrook | |
249 | 40b4f539 | Kevin Wolf | typedef struct BlockRequest { |
250 | 40b4f539 | Kevin Wolf | /* Fields to be filled by multiwrite caller */
|
251 | 40b4f539 | Kevin Wolf | int64_t sector; |
252 | 40b4f539 | Kevin Wolf | int nb_sectors;
|
253 | 40b4f539 | Kevin Wolf | QEMUIOVector *qiov; |
254 | 40b4f539 | Kevin Wolf | BlockDriverCompletionFunc *cb; |
255 | 40b4f539 | Kevin Wolf | void *opaque;
|
256 | 40b4f539 | Kevin Wolf | |
257 | 40b4f539 | Kevin Wolf | /* Filled by multiwrite implementation */
|
258 | 40b4f539 | Kevin Wolf | int error;
|
259 | 40b4f539 | Kevin Wolf | } BlockRequest; |
260 | 40b4f539 | Kevin Wolf | |
261 | 40b4f539 | Kevin Wolf | int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs,
|
262 | 40b4f539 | Kevin Wolf | int num_reqs);
|
263 | 40b4f539 | Kevin Wolf | |
264 | 7d780669 | aliguori | /* sg packet commands */
|
265 | 221f715d | aliguori | int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf); |
266 | 221f715d | aliguori | BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs, |
267 | 221f715d | aliguori | unsigned long int req, void *buf, |
268 | 221f715d | aliguori | BlockDriverCompletionFunc *cb, void *opaque);
|
269 | 7d780669 | aliguori | |
270 | 0f15423c | Anthony Liguori | /* Invalidate any cached metadata used by image formats */
|
271 | 0f15423c | Anthony Liguori | void bdrv_invalidate_cache(BlockDriverState *bs);
|
272 | 0f15423c | Anthony Liguori | void bdrv_invalidate_cache_all(void); |
273 | 0f15423c | Anthony Liguori | |
274 | 07789269 | Benoît Canet | void bdrv_clear_incoming_migration_all(void); |
275 | 07789269 | Benoît Canet | |
276 | faf07963 | pbrook | /* Ensure contents are flushed to disk. */
|
277 | 205ef796 | Kevin Wolf | int bdrv_flush(BlockDriverState *bs);
|
278 | 07f07615 | Paolo Bonzini | int coroutine_fn bdrv_co_flush(BlockDriverState *bs);
|
279 | c6ca28d6 | aliguori | void bdrv_flush_all(void); |
280 | 2bc93fed | MORITA Kazutaka | void bdrv_close_all(void); |
281 | 922453bc | Stefan Hajnoczi | void bdrv_drain_all(void); |
282 | c6ca28d6 | aliguori | |
283 | bb8bf76f | Christoph Hellwig | int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors); |
284 | 4265d620 | Paolo Bonzini | int bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors); |
285 | f2feebbd | Kevin Wolf | int bdrv_has_zero_init(BlockDriverState *bs);
|
286 | f58c7b35 | ths | int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, |
287 | 39aa9a12 | Devin Nakamura | int *pnum);
|
288 | b35b2bba | Miroslav Rezanina | int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
|
289 | b35b2bba | Miroslav Rezanina | int64_t sector_num, int nb_sectors, int *pnum); |
290 | faf07963 | pbrook | |
291 | ff06f5f3 | Paolo Bonzini | void bdrv_set_on_error(BlockDriverState *bs, BlockdevOnError on_read_error,
|
292 | ff06f5f3 | Paolo Bonzini | BlockdevOnError on_write_error); |
293 | 1ceee0d5 | Paolo Bonzini | BlockdevOnError bdrv_get_on_error(BlockDriverState *bs, bool is_read);
|
294 | 3e1caa5f | Paolo Bonzini | BlockErrorAction bdrv_get_error_action(BlockDriverState *bs, bool is_read, int error); |
295 | 3e1caa5f | Paolo Bonzini | void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action,
|
296 | 3e1caa5f | Paolo Bonzini | bool is_read, int error); |
297 | faf07963 | pbrook | int bdrv_is_read_only(BlockDriverState *bs);
|
298 | 985a03b0 | ths | int bdrv_is_sg(BlockDriverState *bs);
|
299 | e900a7b7 | Christoph Hellwig | int bdrv_enable_write_cache(BlockDriverState *bs);
|
300 | 425b0148 | Paolo Bonzini | void bdrv_set_enable_write_cache(BlockDriverState *bs, bool wce); |
301 | faf07963 | pbrook | int bdrv_is_inserted(BlockDriverState *bs);
|
302 | faf07963 | pbrook | int bdrv_media_changed(BlockDriverState *bs);
|
303 | 025e849a | Markus Armbruster | void bdrv_lock_medium(BlockDriverState *bs, bool locked); |
304 | f36f3949 | Luiz Capitulino | void bdrv_eject(BlockDriverState *bs, bool eject_flag); |
305 | f8d6bba1 | Markus Armbruster | const char *bdrv_get_format_name(BlockDriverState *bs); |
306 | faf07963 | pbrook | BlockDriverState *bdrv_find(const char *name); |
307 | 2f399b0a | Markus Armbruster | BlockDriverState *bdrv_next(BlockDriverState *bs); |
308 | 51de9760 | aliguori | void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs), |
309 | 51de9760 | aliguori | void *opaque);
|
310 | faf07963 | pbrook | int bdrv_is_encrypted(BlockDriverState *bs);
|
311 | c0f4ce77 | aliguori | int bdrv_key_required(BlockDriverState *bs);
|
312 | faf07963 | pbrook | int bdrv_set_key(BlockDriverState *bs, const char *key); |
313 | c0f4ce77 | aliguori | int bdrv_query_missing_keys(void); |
314 | faf07963 | pbrook | void bdrv_iterate_format(void (*it)(void *opaque, const char *name), |
315 | faf07963 | pbrook | void *opaque);
|
316 | faf07963 | pbrook | const char *bdrv_get_device_name(BlockDriverState *bs); |
317 | c8433287 | Markus Armbruster | int bdrv_get_flags(BlockDriverState *bs);
|
318 | faf07963 | pbrook | int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
|
319 | faf07963 | pbrook | const uint8_t *buf, int nb_sectors); |
320 | faf07963 | pbrook | int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi);
|
321 | 343bded4 | Paolo Bonzini | void bdrv_round_to_clusters(BlockDriverState *bs,
|
322 | 343bded4 | Paolo Bonzini | int64_t sector_num, int nb_sectors,
|
323 | 343bded4 | Paolo Bonzini | int64_t *cluster_sector_num, |
324 | 343bded4 | Paolo Bonzini | int *cluster_nb_sectors);
|
325 | faf07963 | pbrook | |
326 | 045df330 | aliguori | const char *bdrv_get_encrypted_filename(BlockDriverState *bs); |
327 | faf07963 | pbrook | void bdrv_get_backing_filename(BlockDriverState *bs,
|
328 | faf07963 | pbrook | char *filename, int filename_size); |
329 | dc5a1371 | Paolo Bonzini | void bdrv_get_full_backing_filename(BlockDriverState *bs,
|
330 | dc5a1371 | Paolo Bonzini | char *dest, size_t sz);
|
331 | ac84adac | Paolo Bonzini | BlockInfo *bdrv_query_info(BlockDriverState *s); |
332 | 9887b616 | Paolo Bonzini | BlockStats *bdrv_query_stats(const BlockDriverState *bs);
|
333 | feeee5ac | Miguel Di Ciurcio Filho | int bdrv_can_snapshot(BlockDriverState *bs);
|
334 | 199630b6 | Blue Swirl | int bdrv_is_snapshot(BlockDriverState *bs);
|
335 | f9092b10 | Markus Armbruster | BlockDriverState *bdrv_snapshots(void);
|
336 | faf07963 | pbrook | int bdrv_snapshot_create(BlockDriverState *bs,
|
337 | faf07963 | pbrook | QEMUSnapshotInfo *sn_info); |
338 | faf07963 | pbrook | int bdrv_snapshot_goto(BlockDriverState *bs,
|
339 | faf07963 | pbrook | const char *snapshot_id); |
340 | faf07963 | pbrook | int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id); |
341 | faf07963 | pbrook | int bdrv_snapshot_list(BlockDriverState *bs,
|
342 | faf07963 | pbrook | QEMUSnapshotInfo **psn_info); |
343 | 51ef6727 | edison | int bdrv_snapshot_load_tmp(BlockDriverState *bs,
|
344 | 51ef6727 | edison | const char *snapshot_name); |
345 | faf07963 | pbrook | char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn); |
346 | faf07963 | pbrook | |
347 | faf07963 | pbrook | char *get_human_readable_size(char *buf, int buf_size, int64_t size); |
348 | faf07963 | pbrook | int path_is_absolute(const char *path); |
349 | faf07963 | pbrook | void path_combine(char *dest, int dest_size, |
350 | faf07963 | pbrook | const char *base_path, |
351 | faf07963 | pbrook | const char *filename); |
352 | faf07963 | pbrook | |
353 | cf8074b3 | Kevin Wolf | int bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
|
354 | 45566e9c | Christoph Hellwig | int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf, |
355 | 45566e9c | Christoph Hellwig | int64_t pos, int size);
|
356 | 178e08a5 | aliguori | |
357 | 45566e9c | Christoph Hellwig | int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf,
|
358 | 45566e9c | Christoph Hellwig | int64_t pos, int size);
|
359 | 178e08a5 | aliguori | |
360 | d92ada22 | Luiz Capitulino | void bdrv_img_create(const char *filename, const char *fmt, |
361 | d92ada22 | Luiz Capitulino | const char *base_filename, const char *base_fmt, |
362 | f382d43a | Miroslav Rezanina | char *options, uint64_t img_size, int flags, |
363 | f382d43a | Miroslav Rezanina | Error **errp, bool quiet);
|
364 | f88e1a42 | Jes Sorensen | |
365 | 7b6f9300 | Markus Armbruster | void bdrv_set_buffer_alignment(BlockDriverState *bs, int align); |
366 | ba5b7ad4 | Markus Armbruster | void *qemu_blockalign(BlockDriverState *bs, size_t size);
|
367 | c53b1c51 | Stefan Hajnoczi | bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov);
|
368 | ba5b7ad4 | Markus Armbruster | |
369 | 8f0720ec | Paolo Bonzini | struct HBitmapIter;
|
370 | 50717e94 | Paolo Bonzini | void bdrv_set_dirty_tracking(BlockDriverState *bs, int granularity); |
371 | 7cd1e32a | lirans@il.ibm.com | int bdrv_get_dirty(BlockDriverState *bs, int64_t sector);
|
372 | 1755da16 | Paolo Bonzini | void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors); |
373 | 1755da16 | Paolo Bonzini | void bdrv_reset_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors); |
374 | 8f0720ec | Paolo Bonzini | void bdrv_dirty_iter_init(BlockDriverState *bs, struct HBitmapIter *hbi); |
375 | aaa0eb75 | Liran Schour | int64_t bdrv_get_dirty_count(BlockDriverState *bs); |
376 | 8b9b0cc2 | Kevin Wolf | |
377 | 53fec9d3 | Stefan Hajnoczi | void bdrv_enable_copy_on_read(BlockDriverState *bs);
|
378 | 53fec9d3 | Stefan Hajnoczi | void bdrv_disable_copy_on_read(BlockDriverState *bs);
|
379 | 53fec9d3 | Stefan Hajnoczi | |
380 | db593f25 | Marcelo Tosatti | void bdrv_set_in_use(BlockDriverState *bs, int in_use); |
381 | db593f25 | Marcelo Tosatti | int bdrv_in_use(BlockDriverState *bs);
|
382 | 8b9b0cc2 | Kevin Wolf | |
383 | 4065742a | Stefan Hajnoczi | #ifdef CONFIG_LINUX_AIO
|
384 | 4065742a | Stefan Hajnoczi | int raw_get_aio_fd(BlockDriverState *bs);
|
385 | 4065742a | Stefan Hajnoczi | #else
|
386 | 4065742a | Stefan Hajnoczi | static inline int raw_get_aio_fd(BlockDriverState *bs) |
387 | 4065742a | Stefan Hajnoczi | { |
388 | 4065742a | Stefan Hajnoczi | return -ENOTSUP;
|
389 | 4065742a | Stefan Hajnoczi | } |
390 | 4065742a | Stefan Hajnoczi | #endif
|
391 | 4065742a | Stefan Hajnoczi | |
392 | a597e79c | Christoph Hellwig | enum BlockAcctType {
|
393 | a597e79c | Christoph Hellwig | BDRV_ACCT_READ, |
394 | a597e79c | Christoph Hellwig | BDRV_ACCT_WRITE, |
395 | a597e79c | Christoph Hellwig | BDRV_ACCT_FLUSH, |
396 | a597e79c | Christoph Hellwig | BDRV_MAX_IOTYPE, |
397 | a597e79c | Christoph Hellwig | }; |
398 | a597e79c | Christoph Hellwig | |
399 | a597e79c | Christoph Hellwig | typedef struct BlockAcctCookie { |
400 | a597e79c | Christoph Hellwig | int64_t bytes; |
401 | c488c7f6 | Christoph Hellwig | int64_t start_time_ns; |
402 | a597e79c | Christoph Hellwig | enum BlockAcctType type;
|
403 | a597e79c | Christoph Hellwig | } BlockAcctCookie; |
404 | a597e79c | Christoph Hellwig | |
405 | a597e79c | Christoph Hellwig | void bdrv_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie,
|
406 | a597e79c | Christoph Hellwig | int64_t bytes, enum BlockAcctType type);
|
407 | a597e79c | Christoph Hellwig | void bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie *cookie);
|
408 | a597e79c | Christoph Hellwig | |
409 | 8b9b0cc2 | Kevin Wolf | typedef enum { |
410 | 8252278a | Kevin Wolf | BLKDBG_L1_UPDATE, |
411 | 8252278a | Kevin Wolf | |
412 | 8252278a | Kevin Wolf | BLKDBG_L1_GROW_ALLOC_TABLE, |
413 | 8252278a | Kevin Wolf | BLKDBG_L1_GROW_WRITE_TABLE, |
414 | 8252278a | Kevin Wolf | BLKDBG_L1_GROW_ACTIVATE_TABLE, |
415 | 8252278a | Kevin Wolf | |
416 | 8252278a | Kevin Wolf | BLKDBG_L2_LOAD, |
417 | 8252278a | Kevin Wolf | BLKDBG_L2_UPDATE, |
418 | 8252278a | Kevin Wolf | BLKDBG_L2_UPDATE_COMPRESSED, |
419 | 8252278a | Kevin Wolf | BLKDBG_L2_ALLOC_COW_READ, |
420 | 8252278a | Kevin Wolf | BLKDBG_L2_ALLOC_WRITE, |
421 | 8252278a | Kevin Wolf | |
422 | 8252278a | Kevin Wolf | BLKDBG_READ_AIO, |
423 | 8252278a | Kevin Wolf | BLKDBG_READ_BACKING_AIO, |
424 | 8252278a | Kevin Wolf | BLKDBG_READ_COMPRESSED, |
425 | 8252278a | Kevin Wolf | |
426 | 8252278a | Kevin Wolf | BLKDBG_WRITE_AIO, |
427 | 8252278a | Kevin Wolf | BLKDBG_WRITE_COMPRESSED, |
428 | 8252278a | Kevin Wolf | |
429 | 8252278a | Kevin Wolf | BLKDBG_VMSTATE_LOAD, |
430 | 8252278a | Kevin Wolf | BLKDBG_VMSTATE_SAVE, |
431 | 8252278a | Kevin Wolf | |
432 | 8252278a | Kevin Wolf | BLKDBG_COW_READ, |
433 | 8252278a | Kevin Wolf | BLKDBG_COW_WRITE, |
434 | 8252278a | Kevin Wolf | |
435 | 8252278a | Kevin Wolf | BLKDBG_REFTABLE_LOAD, |
436 | 8252278a | Kevin Wolf | BLKDBG_REFTABLE_GROW, |
437 | 8252278a | Kevin Wolf | |
438 | 8252278a | Kevin Wolf | BLKDBG_REFBLOCK_LOAD, |
439 | 8252278a | Kevin Wolf | BLKDBG_REFBLOCK_UPDATE, |
440 | 8252278a | Kevin Wolf | BLKDBG_REFBLOCK_UPDATE_PART, |
441 | 8252278a | Kevin Wolf | BLKDBG_REFBLOCK_ALLOC, |
442 | 8252278a | Kevin Wolf | BLKDBG_REFBLOCK_ALLOC_HOOKUP, |
443 | 8252278a | Kevin Wolf | BLKDBG_REFBLOCK_ALLOC_WRITE, |
444 | 8252278a | Kevin Wolf | BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS, |
445 | 8252278a | Kevin Wolf | BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE, |
446 | 8252278a | Kevin Wolf | BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE, |
447 | 8252278a | Kevin Wolf | |
448 | 8252278a | Kevin Wolf | BLKDBG_CLUSTER_ALLOC, |
449 | 8252278a | Kevin Wolf | BLKDBG_CLUSTER_ALLOC_BYTES, |
450 | 8252278a | Kevin Wolf | BLKDBG_CLUSTER_FREE, |
451 | 8252278a | Kevin Wolf | |
452 | 8b9b0cc2 | Kevin Wolf | BLKDBG_EVENT_MAX, |
453 | 8b9b0cc2 | Kevin Wolf | } BlkDebugEvent; |
454 | 8b9b0cc2 | Kevin Wolf | |
455 | 8b9b0cc2 | Kevin Wolf | #define BLKDBG_EVENT(bs, evt) bdrv_debug_event(bs, evt)
|
456 | 8b9b0cc2 | Kevin Wolf | void bdrv_debug_event(BlockDriverState *bs, BlkDebugEvent event);
|
457 | 8b9b0cc2 | Kevin Wolf | |
458 | 41c695c7 | Kevin Wolf | int bdrv_debug_breakpoint(BlockDriverState *bs, const char *event, |
459 | 41c695c7 | Kevin Wolf | const char *tag); |
460 | 41c695c7 | Kevin Wolf | int bdrv_debug_resume(BlockDriverState *bs, const char *tag); |
461 | 41c695c7 | Kevin Wolf | bool bdrv_debug_is_suspended(BlockDriverState *bs, const char *tag); |
462 | 41c695c7 | Kevin Wolf | |
463 | 8a4bc5aa | Markus Armbruster | #endif |