root / block_int.h @ f8d3d128
History | View | Annotate | Download (12.2 kB)
1 | ea2384d3 | bellard | /*
|
---|---|---|---|
2 | ea2384d3 | bellard | * QEMU System Emulator block driver
|
3 | 5fafdf24 | ths | *
|
4 | ea2384d3 | bellard | * Copyright (c) 2003 Fabrice Bellard
|
5 | 5fafdf24 | ths | *
|
6 | ea2384d3 | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | ea2384d3 | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | ea2384d3 | bellard | * in the Software without restriction, including without limitation the rights
|
9 | ea2384d3 | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | ea2384d3 | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | ea2384d3 | bellard | * furnished to do so, subject to the following conditions:
|
12 | ea2384d3 | bellard | *
|
13 | ea2384d3 | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | ea2384d3 | bellard | * all copies or substantial portions of the Software.
|
15 | ea2384d3 | bellard | *
|
16 | ea2384d3 | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | ea2384d3 | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | ea2384d3 | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | ea2384d3 | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | ea2384d3 | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | ea2384d3 | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | ea2384d3 | bellard | * THE SOFTWARE.
|
23 | ea2384d3 | bellard | */
|
24 | ea2384d3 | bellard | #ifndef BLOCK_INT_H
|
25 | ea2384d3 | bellard | #define BLOCK_INT_H
|
26 | ea2384d3 | bellard | |
27 | faf07963 | pbrook | #include "block.h" |
28 | 0e7e1989 | Kevin Wolf | #include "qemu-option.h" |
29 | 1b7bdbc1 | Stefan Hajnoczi | #include "qemu-queue.h" |
30 | da1fa91d | Kevin Wolf | #include "qemu-coroutine.h" |
31 | c488c7f6 | Christoph Hellwig | #include "qemu-timer.h" |
32 | b2023818 | Luiz Capitulino | #include "qapi-types.h" |
33 | faf07963 | pbrook | |
34 | ec36ba14 | ths | #define BLOCK_FLAG_ENCRYPT 1 |
35 | ec36ba14 | ths | #define BLOCK_FLAG_COMPAT6 4 |
36 | ec36ba14 | ths | |
37 | 0563e191 | Zhi Yong Wu | #define BLOCK_IO_LIMIT_READ 0 |
38 | 0563e191 | Zhi Yong Wu | #define BLOCK_IO_LIMIT_WRITE 1 |
39 | 0563e191 | Zhi Yong Wu | #define BLOCK_IO_LIMIT_TOTAL 2 |
40 | 0563e191 | Zhi Yong Wu | |
41 | 0563e191 | Zhi Yong Wu | #define BLOCK_IO_SLICE_TIME 100000000 |
42 | 98f90dba | Zhi Yong Wu | #define NANOSECONDS_PER_SECOND 1000000000.0 |
43 | 0563e191 | Zhi Yong Wu | |
44 | 0e7e1989 | Kevin Wolf | #define BLOCK_OPT_SIZE "size" |
45 | 0e7e1989 | Kevin Wolf | #define BLOCK_OPT_ENCRYPT "encryption" |
46 | 0e7e1989 | Kevin Wolf | #define BLOCK_OPT_COMPAT6 "compat6" |
47 | 0e7e1989 | Kevin Wolf | #define BLOCK_OPT_BACKING_FILE "backing_file" |
48 | 0e7e1989 | Kevin Wolf | #define BLOCK_OPT_BACKING_FMT "backing_fmt" |
49 | 73c632ed | Kevin Wolf | #define BLOCK_OPT_CLUSTER_SIZE "cluster_size" |
50 | 75411d23 | Stefan Hajnoczi | #define BLOCK_OPT_TABLE_SIZE "table_size" |
51 | a35e1c17 | Kevin Wolf | #define BLOCK_OPT_PREALLOC "preallocation" |
52 | f66fd6c3 | Fam Zheng | #define BLOCK_OPT_SUBFMT "subformat" |
53 | 0e7e1989 | Kevin Wolf | |
54 | dbffbdcf | Stefan Hajnoczi | typedef struct BdrvTrackedRequest BdrvTrackedRequest; |
55 | dbffbdcf | Stefan Hajnoczi | |
56 | 6bbff9a0 | aliguori | typedef struct AIOPool { |
57 | 6bbff9a0 | aliguori | void (*cancel)(BlockDriverAIOCB *acb);
|
58 | 6bbff9a0 | aliguori | int aiocb_size;
|
59 | 6bbff9a0 | aliguori | BlockDriverAIOCB *free_aiocb; |
60 | 6bbff9a0 | aliguori | } AIOPool; |
61 | 6bbff9a0 | aliguori | |
62 | 0563e191 | Zhi Yong Wu | typedef struct BlockIOLimit { |
63 | 0563e191 | Zhi Yong Wu | int64_t bps[3];
|
64 | 0563e191 | Zhi Yong Wu | int64_t iops[3];
|
65 | 0563e191 | Zhi Yong Wu | } BlockIOLimit; |
66 | 0563e191 | Zhi Yong Wu | |
67 | 0563e191 | Zhi Yong Wu | typedef struct BlockIOBaseValue { |
68 | 0563e191 | Zhi Yong Wu | uint64_t bytes[2];
|
69 | 0563e191 | Zhi Yong Wu | uint64_t ios[2];
|
70 | 0563e191 | Zhi Yong Wu | } BlockIOBaseValue; |
71 | 0563e191 | Zhi Yong Wu | |
72 | eeec61f2 | Stefan Hajnoczi | typedef void BlockJobCancelFunc(void *opaque); |
73 | eeec61f2 | Stefan Hajnoczi | typedef struct BlockJob BlockJob; |
74 | eeec61f2 | Stefan Hajnoczi | typedef struct BlockJobType { |
75 | eeec61f2 | Stefan Hajnoczi | /** Derived BlockJob struct size */
|
76 | eeec61f2 | Stefan Hajnoczi | size_t instance_size; |
77 | eeec61f2 | Stefan Hajnoczi | |
78 | eeec61f2 | Stefan Hajnoczi | /** String describing the operation, part of query-block-jobs QMP API */
|
79 | eeec61f2 | Stefan Hajnoczi | const char *job_type; |
80 | eeec61f2 | Stefan Hajnoczi | |
81 | eeec61f2 | Stefan Hajnoczi | /** Optional callback for job types that support setting a speed limit */
|
82 | eeec61f2 | Stefan Hajnoczi | int (*set_speed)(BlockJob *job, int64_t value);
|
83 | eeec61f2 | Stefan Hajnoczi | } BlockJobType; |
84 | eeec61f2 | Stefan Hajnoczi | |
85 | eeec61f2 | Stefan Hajnoczi | /**
|
86 | eeec61f2 | Stefan Hajnoczi | * Long-running operation on a BlockDriverState
|
87 | eeec61f2 | Stefan Hajnoczi | */
|
88 | eeec61f2 | Stefan Hajnoczi | struct BlockJob {
|
89 | eeec61f2 | Stefan Hajnoczi | const BlockJobType *job_type;
|
90 | eeec61f2 | Stefan Hajnoczi | BlockDriverState *bs; |
91 | eeec61f2 | Stefan Hajnoczi | bool cancelled;
|
92 | eeec61f2 | Stefan Hajnoczi | |
93 | eeec61f2 | Stefan Hajnoczi | /* These fields are published by the query-block-jobs QMP API */
|
94 | eeec61f2 | Stefan Hajnoczi | int64_t offset; |
95 | eeec61f2 | Stefan Hajnoczi | int64_t len; |
96 | eeec61f2 | Stefan Hajnoczi | int64_t speed; |
97 | eeec61f2 | Stefan Hajnoczi | |
98 | eeec61f2 | Stefan Hajnoczi | BlockDriverCompletionFunc *cb; |
99 | eeec61f2 | Stefan Hajnoczi | void *opaque;
|
100 | eeec61f2 | Stefan Hajnoczi | }; |
101 | eeec61f2 | Stefan Hajnoczi | |
102 | ea2384d3 | bellard | struct BlockDriver {
|
103 | ea2384d3 | bellard | const char *format_name; |
104 | ea2384d3 | bellard | int instance_size;
|
105 | ea2384d3 | bellard | int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename); |
106 | 508c7cb3 | Christoph Hellwig | int (*bdrv_probe_device)(const char *filename); |
107 | 66f82cee | Kevin Wolf | int (*bdrv_open)(BlockDriverState *bs, int flags); |
108 | 66f82cee | Kevin Wolf | int (*bdrv_file_open)(BlockDriverState *bs, const char *filename, int flags); |
109 | 5fafdf24 | ths | int (*bdrv_read)(BlockDriverState *bs, int64_t sector_num,
|
110 | ea2384d3 | bellard | uint8_t *buf, int nb_sectors);
|
111 | 5fafdf24 | ths | int (*bdrv_write)(BlockDriverState *bs, int64_t sector_num,
|
112 | ea2384d3 | bellard | const uint8_t *buf, int nb_sectors); |
113 | e2731add | bellard | void (*bdrv_close)(BlockDriverState *bs);
|
114 | 0e7e1989 | Kevin Wolf | int (*bdrv_create)(const char *filename, QEMUOptionParameter *options); |
115 | ea2384d3 | bellard | int (*bdrv_set_key)(BlockDriverState *bs, const char *key); |
116 | 95389c86 | bellard | int (*bdrv_make_empty)(BlockDriverState *bs);
|
117 | 83f64091 | bellard | /* aio */
|
118 | f141eafe | aliguori | BlockDriverAIOCB *(*bdrv_aio_readv)(BlockDriverState *bs, |
119 | f141eafe | aliguori | int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
|
120 | ce1a14dc | pbrook | BlockDriverCompletionFunc *cb, void *opaque);
|
121 | f141eafe | aliguori | BlockDriverAIOCB *(*bdrv_aio_writev)(BlockDriverState *bs, |
122 | f141eafe | aliguori | int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
|
123 | ce1a14dc | pbrook | BlockDriverCompletionFunc *cb, void *opaque);
|
124 | b2e12bc6 | Christoph Hellwig | BlockDriverAIOCB *(*bdrv_aio_flush)(BlockDriverState *bs, |
125 | b2e12bc6 | Christoph Hellwig | BlockDriverCompletionFunc *cb, void *opaque);
|
126 | 4265d620 | Paolo Bonzini | BlockDriverAIOCB *(*bdrv_aio_discard)(BlockDriverState *bs, |
127 | 4265d620 | Paolo Bonzini | int64_t sector_num, int nb_sectors,
|
128 | 4265d620 | Paolo Bonzini | BlockDriverCompletionFunc *cb, void *opaque);
|
129 | 83f64091 | bellard | |
130 | da1fa91d | Kevin Wolf | int coroutine_fn (*bdrv_co_readv)(BlockDriverState *bs,
|
131 | da1fa91d | Kevin Wolf | int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
|
132 | da1fa91d | Kevin Wolf | int coroutine_fn (*bdrv_co_writev)(BlockDriverState *bs,
|
133 | da1fa91d | Kevin Wolf | int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
|
134 | f08f2dda | Stefan Hajnoczi | /*
|
135 | f08f2dda | Stefan Hajnoczi | * Efficiently zero a region of the disk image. Typically an image format
|
136 | f08f2dda | Stefan Hajnoczi | * would use a compact metadata representation to implement this. This
|
137 | f08f2dda | Stefan Hajnoczi | * function pointer may be NULL and .bdrv_co_writev() will be called
|
138 | f08f2dda | Stefan Hajnoczi | * instead.
|
139 | f08f2dda | Stefan Hajnoczi | */
|
140 | f08f2dda | Stefan Hajnoczi | int coroutine_fn (*bdrv_co_write_zeroes)(BlockDriverState *bs,
|
141 | f08f2dda | Stefan Hajnoczi | int64_t sector_num, int nb_sectors);
|
142 | 4265d620 | Paolo Bonzini | int coroutine_fn (*bdrv_co_discard)(BlockDriverState *bs,
|
143 | 4265d620 | Paolo Bonzini | int64_t sector_num, int nb_sectors);
|
144 | 376ae3f1 | Stefan Hajnoczi | int coroutine_fn (*bdrv_co_is_allocated)(BlockDriverState *bs,
|
145 | 376ae3f1 | Stefan Hajnoczi | int64_t sector_num, int nb_sectors, int *pnum); |
146 | da1fa91d | Kevin Wolf | |
147 | c68b89ac | Kevin Wolf | /*
|
148 | 0f15423c | Anthony Liguori | * Invalidate any cached meta-data.
|
149 | 0f15423c | Anthony Liguori | */
|
150 | 0f15423c | Anthony Liguori | void (*bdrv_invalidate_cache)(BlockDriverState *bs);
|
151 | 0f15423c | Anthony Liguori | |
152 | 0f15423c | Anthony Liguori | /*
|
153 | c68b89ac | Kevin Wolf | * Flushes all data that was already written to the OS all the way down to
|
154 | c68b89ac | Kevin Wolf | * the disk (for example raw-posix calls fsync()).
|
155 | c68b89ac | Kevin Wolf | */
|
156 | c68b89ac | Kevin Wolf | int coroutine_fn (*bdrv_co_flush_to_disk)(BlockDriverState *bs);
|
157 | c68b89ac | Kevin Wolf | |
158 | eb489bb1 | Kevin Wolf | /*
|
159 | eb489bb1 | Kevin Wolf | * Flushes all internal caches to the OS. The data may still sit in a
|
160 | eb489bb1 | Kevin Wolf | * writeback cache of the host OS, but it will survive a crash of the qemu
|
161 | eb489bb1 | Kevin Wolf | * process.
|
162 | eb489bb1 | Kevin Wolf | */
|
163 | eb489bb1 | Kevin Wolf | int coroutine_fn (*bdrv_co_flush_to_os)(BlockDriverState *bs);
|
164 | eb489bb1 | Kevin Wolf | |
165 | 40b4f539 | Kevin Wolf | int (*bdrv_aio_multiwrite)(BlockDriverState *bs, BlockRequest *reqs,
|
166 | 40b4f539 | Kevin Wolf | int num_reqs);
|
167 | 40b4f539 | Kevin Wolf | int (*bdrv_merge_requests)(BlockDriverState *bs, BlockRequest* a,
|
168 | 40b4f539 | Kevin Wolf | BlockRequest *b); |
169 | 40b4f539 | Kevin Wolf | |
170 | 40b4f539 | Kevin Wolf | |
171 | 83f64091 | bellard | const char *protocol_name; |
172 | 83f64091 | bellard | int (*bdrv_truncate)(BlockDriverState *bs, int64_t offset);
|
173 | 83f64091 | bellard | int64_t (*bdrv_getlength)(BlockDriverState *bs); |
174 | 4a1d5e1f | Fam Zheng | int64_t (*bdrv_get_allocated_file_size)(BlockDriverState *bs); |
175 | 5fafdf24 | ths | int (*bdrv_write_compressed)(BlockDriverState *bs, int64_t sector_num,
|
176 | faea38e7 | bellard | const uint8_t *buf, int nb_sectors); |
177 | faea38e7 | bellard | |
178 | 5fafdf24 | ths | int (*bdrv_snapshot_create)(BlockDriverState *bs,
|
179 | faea38e7 | bellard | QEMUSnapshotInfo *sn_info); |
180 | 5fafdf24 | ths | int (*bdrv_snapshot_goto)(BlockDriverState *bs,
|
181 | faea38e7 | bellard | const char *snapshot_id); |
182 | faea38e7 | bellard | int (*bdrv_snapshot_delete)(BlockDriverState *bs, const char *snapshot_id); |
183 | 5fafdf24 | ths | int (*bdrv_snapshot_list)(BlockDriverState *bs,
|
184 | faea38e7 | bellard | QEMUSnapshotInfo **psn_info); |
185 | 51ef6727 | edison | int (*bdrv_snapshot_load_tmp)(BlockDriverState *bs,
|
186 | 51ef6727 | edison | const char *snapshot_name); |
187 | faea38e7 | bellard | int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi);
|
188 | 83f64091 | bellard | |
189 | 45566e9c | Christoph Hellwig | int (*bdrv_save_vmstate)(BlockDriverState *bs, const uint8_t *buf, |
190 | 45566e9c | Christoph Hellwig | int64_t pos, int size);
|
191 | 45566e9c | Christoph Hellwig | int (*bdrv_load_vmstate)(BlockDriverState *bs, uint8_t *buf,
|
192 | 45566e9c | Christoph Hellwig | int64_t pos, int size);
|
193 | 178e08a5 | aliguori | |
194 | 756e6736 | Kevin Wolf | int (*bdrv_change_backing_file)(BlockDriverState *bs,
|
195 | 756e6736 | Kevin Wolf | const char *backing_file, const char *backing_fmt); |
196 | 756e6736 | Kevin Wolf | |
197 | 19cb3738 | bellard | /* removable device specific */
|
198 | 19cb3738 | bellard | int (*bdrv_is_inserted)(BlockDriverState *bs);
|
199 | 19cb3738 | bellard | int (*bdrv_media_changed)(BlockDriverState *bs);
|
200 | f36f3949 | Luiz Capitulino | void (*bdrv_eject)(BlockDriverState *bs, bool eject_flag); |
201 | 025e849a | Markus Armbruster | void (*bdrv_lock_medium)(BlockDriverState *bs, bool locked); |
202 | 3b46e624 | ths | |
203 | 985a03b0 | ths | /* to control generic scsi devices */
|
204 | 985a03b0 | ths | int (*bdrv_ioctl)(BlockDriverState *bs, unsigned long int req, void *buf); |
205 | 221f715d | aliguori | BlockDriverAIOCB *(*bdrv_aio_ioctl)(BlockDriverState *bs, |
206 | 221f715d | aliguori | unsigned long int req, void *buf, |
207 | 221f715d | aliguori | BlockDriverCompletionFunc *cb, void *opaque);
|
208 | 985a03b0 | ths | |
209 | 0e7e1989 | Kevin Wolf | /* List of options for creating images, terminated by name == NULL */
|
210 | 0e7e1989 | Kevin Wolf | QEMUOptionParameter *create_options; |
211 | 0e7e1989 | Kevin Wolf | |
212 | 5eb45639 | aliguori | |
213 | 9ac228e0 | Kevin Wolf | /*
|
214 | 9ac228e0 | Kevin Wolf | * Returns 0 for completed check, -errno for internal errors.
|
215 | 9ac228e0 | Kevin Wolf | * The check results are stored in result.
|
216 | 9ac228e0 | Kevin Wolf | */
|
217 | 9ac228e0 | Kevin Wolf | int (*bdrv_check)(BlockDriverState* bs, BdrvCheckResult *result);
|
218 | e97fc193 | aliguori | |
219 | 8b9b0cc2 | Kevin Wolf | void (*bdrv_debug_event)(BlockDriverState *bs, BlkDebugEvent event);
|
220 | 8b9b0cc2 | Kevin Wolf | |
221 | 336c1c12 | Kevin Wolf | /*
|
222 | 336c1c12 | Kevin Wolf | * Returns 1 if newly created images are guaranteed to contain only
|
223 | 336c1c12 | Kevin Wolf | * zeros, 0 otherwise.
|
224 | 336c1c12 | Kevin Wolf | */
|
225 | 336c1c12 | Kevin Wolf | int (*bdrv_has_zero_init)(BlockDriverState *bs);
|
226 | 12c09b8c | Kevin Wolf | |
227 | 8a22f02a | Stefan Hajnoczi | QLIST_ENTRY(BlockDriver) list; |
228 | ea2384d3 | bellard | }; |
229 | ea2384d3 | bellard | |
230 | ea2384d3 | bellard | struct BlockDriverState {
|
231 | d15a771d | bellard | int64_t total_sectors; /* if we are reading a disk image, give its
|
232 | d15a771d | bellard | size in sectors */
|
233 | ea2384d3 | bellard | int read_only; /* if true, the media is read only */ |
234 | 4dca4b63 | Naphtali Sprei | int keep_read_only; /* if true, the media was requested to stay read only */ |
235 | 4dca4b63 | Naphtali Sprei | int open_flags; /* flags used to open the file, re-used for re-open */ |
236 | ea2384d3 | bellard | int encrypted; /* if true, the media is encrypted */ |
237 | c0f4ce77 | aliguori | int valid_key; /* if true, a valid encryption key has been set */ |
238 | 985a03b0 | ths | int sg; /* if true, the device is a /dev/sg* */ |
239 | 53fec9d3 | Stefan Hajnoczi | int copy_on_read; /* if true, copy read backing sectors into image |
240 | 53fec9d3 | Stefan Hajnoczi | note this is a reference count */
|
241 | ea2384d3 | bellard | |
242 | 19cb3738 | bellard | BlockDriver *drv; /* NULL means no media */
|
243 | ea2384d3 | bellard | void *opaque;
|
244 | ea2384d3 | bellard | |
245 | fa879d62 | Markus Armbruster | void *dev; /* attached device model, if any */ |
246 | fa879d62 | Markus Armbruster | /* TODO change to DeviceState when all users are qdevified */
|
247 | 0e49de52 | Markus Armbruster | const BlockDevOps *dev_ops;
|
248 | 0e49de52 | Markus Armbruster | void *dev_opaque;
|
249 | 18846dee | Markus Armbruster | |
250 | ea2384d3 | bellard | char filename[1024]; |
251 | ea2384d3 | bellard | char backing_file[1024]; /* if non zero, the image is a diff of |
252 | ea2384d3 | bellard | this file image */
|
253 | 5eb45639 | aliguori | char backing_format[16]; /* if non-zero and backing_file exists */ |
254 | ea2384d3 | bellard | int is_temporary;
|
255 | 19cb3738 | bellard | |
256 | ea2384d3 | bellard | BlockDriverState *backing_hd; |
257 | 66f82cee | Kevin Wolf | BlockDriverState *file; |
258 | 66f82cee | Kevin Wolf | |
259 | 470c0504 | Stefan Hajnoczi | /* number of in-flight copy-on-read requests */
|
260 | 470c0504 | Stefan Hajnoczi | unsigned int copy_on_read_in_flight; |
261 | 470c0504 | Stefan Hajnoczi | |
262 | ce1a14dc | pbrook | /* async read/write emulation */
|
263 | 83f64091 | bellard | |
264 | ce1a14dc | pbrook | void *sync_aiocb;
|
265 | 3b46e624 | ths | |
266 | 0563e191 | Zhi Yong Wu | /* the time for latest disk I/O */
|
267 | 0563e191 | Zhi Yong Wu | int64_t slice_time; |
268 | 0563e191 | Zhi Yong Wu | int64_t slice_start; |
269 | 0563e191 | Zhi Yong Wu | int64_t slice_end; |
270 | 0563e191 | Zhi Yong Wu | BlockIOLimit io_limits; |
271 | 0563e191 | Zhi Yong Wu | BlockIOBaseValue io_base; |
272 | 0563e191 | Zhi Yong Wu | CoQueue throttled_reqs; |
273 | 0563e191 | Zhi Yong Wu | QEMUTimer *block_timer; |
274 | 0563e191 | Zhi Yong Wu | bool io_limits_enabled;
|
275 | 0563e191 | Zhi Yong Wu | |
276 | a36e69dd | ths | /* I/O stats (display with "info blockstats"). */
|
277 | a597e79c | Christoph Hellwig | uint64_t nr_bytes[BDRV_MAX_IOTYPE]; |
278 | a597e79c | Christoph Hellwig | uint64_t nr_ops[BDRV_MAX_IOTYPE]; |
279 | c488c7f6 | Christoph Hellwig | uint64_t total_time_ns[BDRV_MAX_IOTYPE]; |
280 | 294cc35f | Kevin Wolf | uint64_t wr_highest_sector; |
281 | a36e69dd | ths | |
282 | 71d0770c | aliguori | /* Whether the disk can expand beyond total_sectors */
|
283 | 71d0770c | aliguori | int growable;
|
284 | 71d0770c | aliguori | |
285 | e268ca52 | aliguori | /* the memory alignment required for the buffers handled by this driver */
|
286 | e268ca52 | aliguori | int buffer_alignment;
|
287 | e268ca52 | aliguori | |
288 | e900a7b7 | Christoph Hellwig | /* do we need to tell the quest if we have a volatile write cache? */
|
289 | e900a7b7 | Christoph Hellwig | int enable_write_cache;
|
290 | e900a7b7 | Christoph Hellwig | |
291 | ea2384d3 | bellard | /* NOTE: the following infos are only hints for real hardware
|
292 | ea2384d3 | bellard | drivers. They are not used by the block driver */
|
293 | 46d4767d | bellard | int cyls, heads, secs, translation;
|
294 | abd7f68d | Markus Armbruster | BlockErrorAction on_read_error, on_write_error; |
295 | d6bf279e | Luiz Capitulino | bool iostatus_enabled;
|
296 | b2023818 | Luiz Capitulino | BlockDeviceIoStatus iostatus; |
297 | ea2384d3 | bellard | char device_name[32]; |
298 | c6d22830 | Jan Kiszka | unsigned long *dirty_bitmap; |
299 | aaa0eb75 | Liran Schour | int64_t dirty_count; |
300 | db593f25 | Marcelo Tosatti | int in_use; /* users other than guest access, eg. block migration */ |
301 | 1b7bdbc1 | Stefan Hajnoczi | QTAILQ_ENTRY(BlockDriverState) list; |
302 | b0a7b120 | aliguori | void *private;
|
303 | dbffbdcf | Stefan Hajnoczi | |
304 | dbffbdcf | Stefan Hajnoczi | QLIST_HEAD(, BdrvTrackedRequest) tracked_requests; |
305 | eeec61f2 | Stefan Hajnoczi | |
306 | eeec61f2 | Stefan Hajnoczi | /* long-running background operation */
|
307 | eeec61f2 | Stefan Hajnoczi | BlockJob *job; |
308 | ea2384d3 | bellard | }; |
309 | ea2384d3 | bellard | |
310 | 83f64091 | bellard | struct BlockDriverAIOCB {
|
311 | 6bbff9a0 | aliguori | AIOPool *pool; |
312 | 83f64091 | bellard | BlockDriverState *bs; |
313 | 83f64091 | bellard | BlockDriverCompletionFunc *cb; |
314 | ce1a14dc | pbrook | void *opaque;
|
315 | ce1a14dc | pbrook | BlockDriverAIOCB *next; |
316 | 83f64091 | bellard | }; |
317 | 83f64091 | bellard | |
318 | 95389c86 | bellard | void get_tmp_filename(char *filename, int size); |
319 | 95389c86 | bellard | |
320 | c16b5a2c | Christoph Hellwig | void *qemu_aio_get(AIOPool *pool, BlockDriverState *bs,
|
321 | c16b5a2c | Christoph Hellwig | BlockDriverCompletionFunc *cb, void *opaque);
|
322 | ce1a14dc | pbrook | void qemu_aio_release(void *p); |
323 | ce1a14dc | pbrook | |
324 | 0563e191 | Zhi Yong Wu | void bdrv_set_io_limits(BlockDriverState *bs,
|
325 | 0563e191 | Zhi Yong Wu | BlockIOLimit *io_limits); |
326 | 0563e191 | Zhi Yong Wu | |
327 | 508c7cb3 | Christoph Hellwig | #ifdef _WIN32
|
328 | 508c7cb3 | Christoph Hellwig | int is_windows_drive(const char *filename); |
329 | 508c7cb3 | Christoph Hellwig | #endif
|
330 | 508c7cb3 | Christoph Hellwig | |
331 | eeec61f2 | Stefan Hajnoczi | void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs, |
332 | eeec61f2 | Stefan Hajnoczi | BlockDriverCompletionFunc *cb, void *opaque);
|
333 | eeec61f2 | Stefan Hajnoczi | void block_job_complete(BlockJob *job, int ret); |
334 | eeec61f2 | Stefan Hajnoczi | int block_job_set_speed(BlockJob *job, int64_t value);
|
335 | eeec61f2 | Stefan Hajnoczi | void block_job_cancel(BlockJob *job);
|
336 | eeec61f2 | Stefan Hajnoczi | bool block_job_is_cancelled(BlockJob *job);
|
337 | eeec61f2 | Stefan Hajnoczi | |
338 | 4f1043b4 | Stefan Hajnoczi | int stream_start(BlockDriverState *bs, BlockDriverState *base,
|
339 | c8c3080f | Marcelo Tosatti | const char *base_id, BlockDriverCompletionFunc *cb, |
340 | c8c3080f | Marcelo Tosatti | void *opaque);
|
341 | 4f1043b4 | Stefan Hajnoczi | |
342 | ea2384d3 | bellard | #endif /* BLOCK_INT_H */ |