block/raw: Fix to forward method bdrv_media_changed()
[qemu/cris-port.git] / block / raw.c
blobf197479645506301d11472fe6fa793bb756a392e
2 #include "qemu-common.h"
3 #include "block_int.h"
4 #include "module.h"
6 static int raw_open(BlockDriverState *bs, int flags)
8 bs->sg = bs->file->sg;
9 return 0;
12 static int raw_read(BlockDriverState *bs, int64_t sector_num,
13 uint8_t *buf, int nb_sectors)
15 return bdrv_read(bs->file, sector_num, buf, nb_sectors);
18 static int raw_write(BlockDriverState *bs, int64_t sector_num,
19 const uint8_t *buf, int nb_sectors)
21 return bdrv_write(bs->file, sector_num, buf, nb_sectors);
24 static BlockDriverAIOCB *raw_aio_readv(BlockDriverState *bs,
25 int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
26 BlockDriverCompletionFunc *cb, void *opaque)
28 return bdrv_aio_readv(bs->file, sector_num, qiov, nb_sectors, cb, opaque);
31 static BlockDriverAIOCB *raw_aio_writev(BlockDriverState *bs,
32 int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
33 BlockDriverCompletionFunc *cb, void *opaque)
35 return bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, cb, opaque);
38 static void raw_close(BlockDriverState *bs)
42 static int raw_flush(BlockDriverState *bs)
44 return bdrv_flush(bs->file);
47 static BlockDriverAIOCB *raw_aio_flush(BlockDriverState *bs,
48 BlockDriverCompletionFunc *cb, void *opaque)
50 return bdrv_aio_flush(bs->file, cb, opaque);
53 static int64_t raw_getlength(BlockDriverState *bs)
55 return bdrv_getlength(bs->file);
58 static int raw_truncate(BlockDriverState *bs, int64_t offset)
60 return bdrv_truncate(bs->file, offset);
63 static int raw_probe(const uint8_t *buf, int buf_size, const char *filename)
65 return 1; /* everything can be opened as raw image */
68 static int raw_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors)
70 return bdrv_discard(bs->file, sector_num, nb_sectors);
73 static int raw_is_inserted(BlockDriverState *bs)
75 return bdrv_is_inserted(bs->file);
78 static int raw_media_changed(BlockDriverState *bs)
80 return bdrv_media_changed(bs->file);
83 static void raw_eject(BlockDriverState *bs, int eject_flag)
85 bdrv_eject(bs->file, eject_flag);
88 static void raw_set_locked(BlockDriverState *bs, int locked)
90 bdrv_set_locked(bs->file, locked);
93 static int raw_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
95 return bdrv_ioctl(bs->file, req, buf);
98 static BlockDriverAIOCB *raw_aio_ioctl(BlockDriverState *bs,
99 unsigned long int req, void *buf,
100 BlockDriverCompletionFunc *cb, void *opaque)
102 return bdrv_aio_ioctl(bs->file, req, buf, cb, opaque);
105 static int raw_create(const char *filename, QEMUOptionParameter *options)
107 return bdrv_create_file(filename, options);
110 static QEMUOptionParameter raw_create_options[] = {
112 .name = BLOCK_OPT_SIZE,
113 .type = OPT_SIZE,
114 .help = "Virtual disk size"
116 { NULL }
119 static int raw_has_zero_init(BlockDriverState *bs)
121 return bdrv_has_zero_init(bs->file);
124 static BlockDriver bdrv_raw = {
125 .format_name = "raw",
127 /* It's really 0, but we need to make g_malloc() happy */
128 .instance_size = 1,
130 .bdrv_open = raw_open,
131 .bdrv_close = raw_close,
132 .bdrv_read = raw_read,
133 .bdrv_write = raw_write,
134 .bdrv_flush = raw_flush,
135 .bdrv_probe = raw_probe,
136 .bdrv_getlength = raw_getlength,
137 .bdrv_truncate = raw_truncate,
139 .bdrv_aio_readv = raw_aio_readv,
140 .bdrv_aio_writev = raw_aio_writev,
141 .bdrv_aio_flush = raw_aio_flush,
142 .bdrv_discard = raw_discard,
144 .bdrv_is_inserted = raw_is_inserted,
145 .bdrv_media_changed = raw_media_changed,
146 .bdrv_eject = raw_eject,
147 .bdrv_set_locked = raw_set_locked,
149 .bdrv_ioctl = raw_ioctl,
150 .bdrv_aio_ioctl = raw_aio_ioctl,
152 .bdrv_create = raw_create,
153 .create_options = raw_create_options,
154 .bdrv_has_zero_init = raw_has_zero_init,
157 static void bdrv_raw_init(void)
159 bdrv_register(&bdrv_raw);
162 block_init(bdrv_raw_init);