2 #include "qemu-common.h"
6 static int raw_open(BlockDriverState
*bs
, int flags
)
12 static int coroutine_fn
raw_co_readv(BlockDriverState
*bs
, int64_t sector_num
,
13 int nb_sectors
, QEMUIOVector
*qiov
)
15 return bdrv_co_readv(bs
->file
, sector_num
, nb_sectors
, qiov
);
18 static int coroutine_fn
raw_co_writev(BlockDriverState
*bs
, int64_t sector_num
,
19 int nb_sectors
, QEMUIOVector
*qiov
)
21 return bdrv_co_writev(bs
->file
, sector_num
, nb_sectors
, qiov
);
24 static void raw_close(BlockDriverState
*bs
)
28 static int raw_flush(BlockDriverState
*bs
)
30 return bdrv_flush(bs
->file
);
33 static BlockDriverAIOCB
*raw_aio_flush(BlockDriverState
*bs
,
34 BlockDriverCompletionFunc
*cb
, void *opaque
)
36 return bdrv_aio_flush(bs
->file
, cb
, opaque
);
39 static int64_t raw_getlength(BlockDriverState
*bs
)
41 return bdrv_getlength(bs
->file
);
44 static int raw_truncate(BlockDriverState
*bs
, int64_t offset
)
46 return bdrv_truncate(bs
->file
, offset
);
49 static int raw_probe(const uint8_t *buf
, int buf_size
, const char *filename
)
51 return 1; /* everything can be opened as raw image */
54 static int raw_discard(BlockDriverState
*bs
, int64_t sector_num
, int nb_sectors
)
56 return bdrv_discard(bs
->file
, sector_num
, nb_sectors
);
59 static int raw_is_inserted(BlockDriverState
*bs
)
61 return bdrv_is_inserted(bs
->file
);
64 static int raw_media_changed(BlockDriverState
*bs
)
66 return bdrv_media_changed(bs
->file
);
69 static void raw_eject(BlockDriverState
*bs
, int eject_flag
)
71 bdrv_eject(bs
->file
, eject_flag
);
74 static void raw_lock_medium(BlockDriverState
*bs
, bool locked
)
76 bdrv_lock_medium(bs
->file
, locked
);
79 static int raw_ioctl(BlockDriverState
*bs
, unsigned long int req
, void *buf
)
81 return bdrv_ioctl(bs
->file
, req
, buf
);
84 static BlockDriverAIOCB
*raw_aio_ioctl(BlockDriverState
*bs
,
85 unsigned long int req
, void *buf
,
86 BlockDriverCompletionFunc
*cb
, void *opaque
)
88 return bdrv_aio_ioctl(bs
->file
, req
, buf
, cb
, opaque
);
91 static int raw_create(const char *filename
, QEMUOptionParameter
*options
)
93 return bdrv_create_file(filename
, options
);
96 static QEMUOptionParameter raw_create_options
[] = {
98 .name
= BLOCK_OPT_SIZE
,
100 .help
= "Virtual disk size"
105 static int raw_has_zero_init(BlockDriverState
*bs
)
107 return bdrv_has_zero_init(bs
->file
);
110 static BlockDriver bdrv_raw
= {
111 .format_name
= "raw",
113 /* It's really 0, but we need to make g_malloc() happy */
116 .bdrv_open
= raw_open
,
117 .bdrv_close
= raw_close
,
118 .bdrv_co_readv
= raw_co_readv
,
119 .bdrv_co_writev
= raw_co_writev
,
120 .bdrv_flush
= raw_flush
,
121 .bdrv_probe
= raw_probe
,
122 .bdrv_getlength
= raw_getlength
,
123 .bdrv_truncate
= raw_truncate
,
125 .bdrv_aio_flush
= raw_aio_flush
,
126 .bdrv_discard
= raw_discard
,
128 .bdrv_is_inserted
= raw_is_inserted
,
129 .bdrv_media_changed
= raw_media_changed
,
130 .bdrv_eject
= raw_eject
,
131 .bdrv_lock_medium
= raw_lock_medium
,
133 .bdrv_ioctl
= raw_ioctl
,
134 .bdrv_aio_ioctl
= raw_aio_ioctl
,
136 .bdrv_create
= raw_create
,
137 .create_options
= raw_create_options
,
138 .bdrv_has_zero_init
= raw_has_zero_init
,
141 static void bdrv_raw_init(void)
143 bdrv_register(&bdrv_raw
);
146 block_init(bdrv_raw_init
);