]> git.proxmox.com Git - qemu.git/blame - block/raw.c
block: drop redundant bdrv_flush implementation
[qemu.git] / block / raw.c
CommitLineData
84a12e66
CH
1
2#include "qemu-common.h"
3#include "block_int.h"
4#include "module.h"
5
66f82cee 6static int raw_open(BlockDriverState *bs, int flags)
84a12e66 7{
66f82cee
KW
8 bs->sg = bs->file->sg;
9 return 0;
84a12e66
CH
10}
11
d8b7e0ad
SH
12static int coroutine_fn raw_co_readv(BlockDriverState *bs, int64_t sector_num,
13 int nb_sectors, QEMUIOVector *qiov)
84a12e66 14{
d8b7e0ad 15 return bdrv_co_readv(bs->file, sector_num, nb_sectors, qiov);
84a12e66
CH
16}
17
d8b7e0ad
SH
18static int coroutine_fn raw_co_writev(BlockDriverState *bs, int64_t sector_num,
19 int nb_sectors, QEMUIOVector *qiov)
84a12e66 20{
d8b7e0ad 21 return bdrv_co_writev(bs->file, sector_num, nb_sectors, qiov);
84a12e66
CH
22}
23
24static void raw_close(BlockDriverState *bs)
25{
84a12e66
CH
26}
27
6f6dc656 28static int coroutine_fn raw_co_flush(BlockDriverState *bs)
84a12e66 29{
6f6dc656 30 return bdrv_co_flush(bs->file);
84a12e66
CH
31}
32
33static int64_t raw_getlength(BlockDriverState *bs)
34{
66f82cee 35 return bdrv_getlength(bs->file);
84a12e66
CH
36}
37
38static int raw_truncate(BlockDriverState *bs, int64_t offset)
39{
66f82cee 40 return bdrv_truncate(bs->file, offset);
84a12e66
CH
41}
42
43static int raw_probe(const uint8_t *buf, int buf_size, const char *filename)
44{
45 return 1; /* everything can be opened as raw image */
46}
47
bb8bf76f
CH
48static int raw_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors)
49{
50 return bdrv_discard(bs->file, sector_num, nb_sectors);
51}
52
84a12e66
CH
53static int raw_is_inserted(BlockDriverState *bs)
54{
66f82cee 55 return bdrv_is_inserted(bs->file);
84a12e66
CH
56}
57
be32f75f
MA
58static int raw_media_changed(BlockDriverState *bs)
59{
60 return bdrv_media_changed(bs->file);
61}
62
822e1cd1 63static void raw_eject(BlockDriverState *bs, int eject_flag)
84a12e66 64{
822e1cd1 65 bdrv_eject(bs->file, eject_flag);
84a12e66
CH
66}
67
025e849a 68static void raw_lock_medium(BlockDriverState *bs, bool locked)
84a12e66 69{
025e849a 70 bdrv_lock_medium(bs->file, locked);
84a12e66
CH
71}
72
73static int raw_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
74{
66f82cee 75 return bdrv_ioctl(bs->file, req, buf);
84a12e66
CH
76}
77
78static BlockDriverAIOCB *raw_aio_ioctl(BlockDriverState *bs,
79 unsigned long int req, void *buf,
80 BlockDriverCompletionFunc *cb, void *opaque)
81{
66f82cee 82 return bdrv_aio_ioctl(bs->file, req, buf, cb, opaque);
84a12e66
CH
83}
84
85static int raw_create(const char *filename, QEMUOptionParameter *options)
86{
87 return bdrv_create_file(filename, options);
88}
89
90static QEMUOptionParameter raw_create_options[] = {
91 {
92 .name = BLOCK_OPT_SIZE,
93 .type = OPT_SIZE,
94 .help = "Virtual disk size"
95 },
96 { NULL }
97};
98
336c1c12
KW
99static int raw_has_zero_init(BlockDriverState *bs)
100{
101 return bdrv_has_zero_init(bs->file);
102}
103
84a12e66
CH
104static BlockDriver bdrv_raw = {
105 .format_name = "raw",
106
7267c094 107 /* It's really 0, but we need to make g_malloc() happy */
66f82cee 108 .instance_size = 1,
84a12e66
CH
109
110 .bdrv_open = raw_open,
111 .bdrv_close = raw_close,
d8b7e0ad
SH
112 .bdrv_co_readv = raw_co_readv,
113 .bdrv_co_writev = raw_co_writev,
6f6dc656 114 .bdrv_co_flush = raw_co_flush,
84a12e66
CH
115 .bdrv_probe = raw_probe,
116 .bdrv_getlength = raw_getlength,
117 .bdrv_truncate = raw_truncate,
118
bb8bf76f 119 .bdrv_discard = raw_discard,
84a12e66
CH
120
121 .bdrv_is_inserted = raw_is_inserted,
be32f75f 122 .bdrv_media_changed = raw_media_changed,
84a12e66 123 .bdrv_eject = raw_eject,
025e849a 124 .bdrv_lock_medium = raw_lock_medium,
be32f75f 125
84a12e66
CH
126 .bdrv_ioctl = raw_ioctl,
127 .bdrv_aio_ioctl = raw_aio_ioctl,
128
129 .bdrv_create = raw_create,
130 .create_options = raw_create_options,
336c1c12 131 .bdrv_has_zero_init = raw_has_zero_init,
84a12e66
CH
132};
133
134static void bdrv_raw_init(void)
135{
136 bdrv_register(&bdrv_raw);
137}
138
139block_init(bdrv_raw_init);