root / block.h @ 489251fa
History | View | Annotate | Download (6.7 kB)
1 | faf07963 | pbrook | #ifndef BLOCK_H
|
---|---|---|---|
2 | faf07963 | pbrook | #define BLOCK_H
|
3 | faf07963 | pbrook | |
4 | faf07963 | pbrook | /* block.c */
|
5 | faf07963 | pbrook | typedef struct BlockDriver BlockDriver; |
6 | faf07963 | pbrook | |
7 | faf07963 | pbrook | extern BlockDriver bdrv_raw;
|
8 | faf07963 | pbrook | extern BlockDriver bdrv_host_device;
|
9 | faf07963 | pbrook | extern BlockDriver bdrv_cow;
|
10 | faf07963 | pbrook | extern BlockDriver bdrv_qcow;
|
11 | faf07963 | pbrook | extern BlockDriver bdrv_vmdk;
|
12 | faf07963 | pbrook | extern BlockDriver bdrv_cloop;
|
13 | faf07963 | pbrook | extern BlockDriver bdrv_dmg;
|
14 | faf07963 | pbrook | extern BlockDriver bdrv_bochs;
|
15 | faf07963 | pbrook | extern BlockDriver bdrv_vpc;
|
16 | faf07963 | pbrook | extern BlockDriver bdrv_vvfat;
|
17 | faf07963 | pbrook | extern BlockDriver bdrv_qcow2;
|
18 | faf07963 | pbrook | extern BlockDriver bdrv_parallels;
|
19 | 75818250 | ths | extern BlockDriver bdrv_nbd;
|
20 | faf07963 | pbrook | |
21 | faf07963 | pbrook | typedef struct BlockDriverInfo { |
22 | faf07963 | pbrook | /* in bytes, 0 if irrelevant */
|
23 | faf07963 | pbrook | int cluster_size;
|
24 | faf07963 | pbrook | /* offset at which the VM state can be saved (0 if not possible) */
|
25 | faf07963 | pbrook | int64_t vm_state_offset; |
26 | faf07963 | pbrook | } BlockDriverInfo; |
27 | faf07963 | pbrook | |
28 | faf07963 | pbrook | typedef struct QEMUSnapshotInfo { |
29 | faf07963 | pbrook | char id_str[128]; /* unique snapshot id */ |
30 | faf07963 | pbrook | /* the following fields are informative. They are not needed for
|
31 | faf07963 | pbrook | the consistency of the snapshot */
|
32 | faf07963 | pbrook | char name[256]; /* user choosen name */ |
33 | faf07963 | pbrook | uint32_t vm_state_size; /* VM state info size */
|
34 | faf07963 | pbrook | uint32_t date_sec; /* UTC date of the snapshot */
|
35 | faf07963 | pbrook | uint32_t date_nsec; |
36 | faf07963 | pbrook | uint64_t vm_clock_nsec; /* VM clock relative to boot */
|
37 | faf07963 | pbrook | } QEMUSnapshotInfo; |
38 | faf07963 | pbrook | |
39 | faf07963 | pbrook | #define BDRV_O_RDONLY 0x0000 |
40 | faf07963 | pbrook | #define BDRV_O_RDWR 0x0002 |
41 | faf07963 | pbrook | #define BDRV_O_ACCESS 0x0003 |
42 | faf07963 | pbrook | #define BDRV_O_CREAT 0x0004 /* create an empty file */ |
43 | faf07963 | pbrook | #define BDRV_O_SNAPSHOT 0x0008 /* open the file read only and save writes in a snapshot */ |
44 | faf07963 | pbrook | #define BDRV_O_FILE 0x0010 /* open as a raw file (do not try to |
45 | faf07963 | pbrook | use a disk image format on top of
|
46 | faf07963 | pbrook | it (default for
|
47 | faf07963 | pbrook | bdrv_file_open()) */
|
48 | 33f00271 | balrog | #define BDRV_O_DIRECT 0x0020 |
49 | faf07963 | pbrook | |
50 | faf07963 | pbrook | #ifndef QEMU_IMG
|
51 | faf07963 | pbrook | void bdrv_info(void); |
52 | a36e69dd | ths | void bdrv_info_stats(void); |
53 | faf07963 | pbrook | #endif
|
54 | faf07963 | pbrook | |
55 | faf07963 | pbrook | void bdrv_init(void); |
56 | faf07963 | pbrook | BlockDriver *bdrv_find_format(const char *format_name); |
57 | faf07963 | pbrook | int bdrv_create(BlockDriver *drv,
|
58 | faf07963 | pbrook | const char *filename, int64_t size_in_sectors, |
59 | faf07963 | pbrook | const char *backing_file, int flags); |
60 | faf07963 | pbrook | BlockDriverState *bdrv_new(const char *device_name); |
61 | faf07963 | pbrook | void bdrv_delete(BlockDriverState *bs);
|
62 | faf07963 | pbrook | int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags); |
63 | faf07963 | pbrook | int bdrv_open(BlockDriverState *bs, const char *filename, int flags); |
64 | faf07963 | pbrook | int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, |
65 | faf07963 | pbrook | BlockDriver *drv); |
66 | faf07963 | pbrook | void bdrv_close(BlockDriverState *bs);
|
67 | faf07963 | pbrook | int bdrv_read(BlockDriverState *bs, int64_t sector_num,
|
68 | faf07963 | pbrook | uint8_t *buf, int nb_sectors);
|
69 | faf07963 | pbrook | int bdrv_write(BlockDriverState *bs, int64_t sector_num,
|
70 | faf07963 | pbrook | const uint8_t *buf, int nb_sectors); |
71 | faf07963 | pbrook | int bdrv_pread(BlockDriverState *bs, int64_t offset,
|
72 | faf07963 | pbrook | void *buf, int count); |
73 | faf07963 | pbrook | int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
|
74 | faf07963 | pbrook | const void *buf, int count); |
75 | faf07963 | pbrook | int bdrv_truncate(BlockDriverState *bs, int64_t offset);
|
76 | faf07963 | pbrook | int64_t bdrv_getlength(BlockDriverState *bs); |
77 | 96b8f136 | ths | void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
|
78 | faf07963 | pbrook | int bdrv_commit(BlockDriverState *bs);
|
79 | faf07963 | pbrook | void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size); |
80 | faf07963 | pbrook | /* async block I/O */
|
81 | faf07963 | pbrook | typedef struct BlockDriverAIOCB BlockDriverAIOCB; |
82 | faf07963 | pbrook | typedef void BlockDriverCompletionFunc(void *opaque, int ret); |
83 | faf07963 | pbrook | |
84 | faf07963 | pbrook | BlockDriverAIOCB *bdrv_aio_read(BlockDriverState *bs, int64_t sector_num, |
85 | faf07963 | pbrook | uint8_t *buf, int nb_sectors,
|
86 | faf07963 | pbrook | BlockDriverCompletionFunc *cb, void *opaque);
|
87 | faf07963 | pbrook | BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num, |
88 | faf07963 | pbrook | const uint8_t *buf, int nb_sectors, |
89 | faf07963 | pbrook | BlockDriverCompletionFunc *cb, void *opaque);
|
90 | faf07963 | pbrook | void bdrv_aio_cancel(BlockDriverAIOCB *acb);
|
91 | faf07963 | pbrook | |
92 | faf07963 | pbrook | void qemu_aio_init(void); |
93 | faf07963 | pbrook | void qemu_aio_poll(void); |
94 | faf07963 | pbrook | void qemu_aio_flush(void); |
95 | faf07963 | pbrook | void qemu_aio_wait_start(void); |
96 | faf07963 | pbrook | void qemu_aio_wait(void); |
97 | faf07963 | pbrook | void qemu_aio_wait_end(void); |
98 | faf07963 | pbrook | |
99 | faf07963 | pbrook | int qemu_key_check(BlockDriverState *bs, const char *name); |
100 | faf07963 | pbrook | |
101 | faf07963 | pbrook | /* Ensure contents are flushed to disk. */
|
102 | faf07963 | pbrook | void bdrv_flush(BlockDriverState *bs);
|
103 | f58c7b35 | ths | int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, |
104 | f58c7b35 | ths | int *pnum);
|
105 | faf07963 | pbrook | |
106 | faf07963 | pbrook | #define BDRV_TYPE_HD 0 |
107 | faf07963 | pbrook | #define BDRV_TYPE_CDROM 1 |
108 | faf07963 | pbrook | #define BDRV_TYPE_FLOPPY 2 |
109 | faf07963 | pbrook | #define BIOS_ATA_TRANSLATION_AUTO 0 |
110 | faf07963 | pbrook | #define BIOS_ATA_TRANSLATION_NONE 1 |
111 | faf07963 | pbrook | #define BIOS_ATA_TRANSLATION_LBA 2 |
112 | faf07963 | pbrook | #define BIOS_ATA_TRANSLATION_LARGE 3 |
113 | faf07963 | pbrook | #define BIOS_ATA_TRANSLATION_RECHS 4 |
114 | faf07963 | pbrook | |
115 | faf07963 | pbrook | void bdrv_set_geometry_hint(BlockDriverState *bs,
|
116 | faf07963 | pbrook | int cyls, int heads, int secs); |
117 | faf07963 | pbrook | void bdrv_set_type_hint(BlockDriverState *bs, int type); |
118 | faf07963 | pbrook | void bdrv_set_translation_hint(BlockDriverState *bs, int translation); |
119 | faf07963 | pbrook | void bdrv_get_geometry_hint(BlockDriverState *bs,
|
120 | faf07963 | pbrook | int *pcyls, int *pheads, int *psecs); |
121 | faf07963 | pbrook | int bdrv_get_type_hint(BlockDriverState *bs);
|
122 | faf07963 | pbrook | int bdrv_get_translation_hint(BlockDriverState *bs);
|
123 | faf07963 | pbrook | int bdrv_is_removable(BlockDriverState *bs);
|
124 | faf07963 | pbrook | int bdrv_is_read_only(BlockDriverState *bs);
|
125 | 985a03b0 | ths | int bdrv_is_sg(BlockDriverState *bs);
|
126 | faf07963 | pbrook | int bdrv_is_inserted(BlockDriverState *bs);
|
127 | faf07963 | pbrook | int bdrv_media_changed(BlockDriverState *bs);
|
128 | faf07963 | pbrook | int bdrv_is_locked(BlockDriverState *bs);
|
129 | faf07963 | pbrook | void bdrv_set_locked(BlockDriverState *bs, int locked); |
130 | faf07963 | pbrook | void bdrv_eject(BlockDriverState *bs, int eject_flag); |
131 | faf07963 | pbrook | void bdrv_set_change_cb(BlockDriverState *bs,
|
132 | faf07963 | pbrook | void (*change_cb)(void *opaque), void *opaque); |
133 | faf07963 | pbrook | void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size); |
134 | faf07963 | pbrook | BlockDriverState *bdrv_find(const char *name); |
135 | faf07963 | pbrook | void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque); |
136 | faf07963 | pbrook | int bdrv_is_encrypted(BlockDriverState *bs);
|
137 | faf07963 | pbrook | int bdrv_set_key(BlockDriverState *bs, const char *key); |
138 | faf07963 | pbrook | void bdrv_iterate_format(void (*it)(void *opaque, const char *name), |
139 | faf07963 | pbrook | void *opaque);
|
140 | faf07963 | pbrook | const char *bdrv_get_device_name(BlockDriverState *bs); |
141 | faf07963 | pbrook | int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
|
142 | faf07963 | pbrook | const uint8_t *buf, int nb_sectors); |
143 | faf07963 | pbrook | int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi);
|
144 | faf07963 | pbrook | |
145 | faf07963 | pbrook | void bdrv_get_backing_filename(BlockDriverState *bs,
|
146 | faf07963 | pbrook | char *filename, int filename_size); |
147 | faf07963 | pbrook | int bdrv_snapshot_create(BlockDriverState *bs,
|
148 | faf07963 | pbrook | QEMUSnapshotInfo *sn_info); |
149 | faf07963 | pbrook | int bdrv_snapshot_goto(BlockDriverState *bs,
|
150 | faf07963 | pbrook | const char *snapshot_id); |
151 | faf07963 | pbrook | int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id); |
152 | faf07963 | pbrook | int bdrv_snapshot_list(BlockDriverState *bs,
|
153 | faf07963 | pbrook | QEMUSnapshotInfo **psn_info); |
154 | faf07963 | pbrook | char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn); |
155 | 985a03b0 | ths | int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf); |
156 | faf07963 | pbrook | |
157 | faf07963 | pbrook | char *get_human_readable_size(char *buf, int buf_size, int64_t size); |
158 | faf07963 | pbrook | int path_is_absolute(const char *path); |
159 | faf07963 | pbrook | void path_combine(char *dest, int dest_size, |
160 | faf07963 | pbrook | const char *base_path, |
161 | faf07963 | pbrook | const char *filename); |
162 | faf07963 | pbrook | |
163 | faf07963 | pbrook | #endif |