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 int64_t raw_getlength(BlockDriverState
*bs
)
30 return bdrv_getlength(bs
->file
);
33 static int raw_truncate(BlockDriverState
*bs
, int64_t offset
)
35 return bdrv_truncate(bs
->file
, offset
);
38 static int raw_probe(const uint8_t *buf
, int buf_size
, const char *filename
)
40 return 1; /* everything can be opened as raw image */
43 static int coroutine_fn
raw_co_discard(BlockDriverState
*bs
,
44 int64_t sector_num
, int nb_sectors
)
46 return bdrv_co_discard(bs
->file
, sector_num
, nb_sectors
);
49 static int raw_is_inserted(BlockDriverState
*bs
)
51 return bdrv_is_inserted(bs
->file
);
54 static int raw_media_changed(BlockDriverState
*bs
)
56 return bdrv_media_changed(bs
->file
);
59 static void raw_eject(BlockDriverState
*bs
, bool eject_flag
)
61 bdrv_eject(bs
->file
, eject_flag
);
64 static void raw_lock_medium(BlockDriverState
*bs
, bool locked
)
66 bdrv_lock_medium(bs
->file
, locked
);
69 static int raw_ioctl(BlockDriverState
*bs
, unsigned long int req
, void *buf
)
71 return bdrv_ioctl(bs
->file
, req
, buf
);
74 static BlockDriverAIOCB
*raw_aio_ioctl(BlockDriverState
*bs
,
75 unsigned long int req
, void *buf
,
76 BlockDriverCompletionFunc
*cb
, void *opaque
)
78 return bdrv_aio_ioctl(bs
->file
, req
, buf
, cb
, opaque
);
81 static int raw_create(const char *filename
, QEMUOptionParameter
*options
)
83 return bdrv_create_file(filename
, options
);
86 static QEMUOptionParameter raw_create_options
[] = {
88 .name
= BLOCK_OPT_SIZE
,
90 .help
= "Virtual disk size"
95 static int raw_has_zero_init(BlockDriverState
*bs
)
97 return bdrv_has_zero_init(bs
->file
);
100 static BlockDriver bdrv_raw
= {
101 .format_name
= "raw",
103 /* It's really 0, but we need to make g_malloc() happy */
106 .bdrv_open
= raw_open
,
107 .bdrv_close
= raw_close
,
109 .bdrv_co_readv
= raw_co_readv
,
110 .bdrv_co_writev
= raw_co_writev
,
111 .bdrv_co_discard
= raw_co_discard
,
113 .bdrv_probe
= raw_probe
,
114 .bdrv_getlength
= raw_getlength
,
115 .bdrv_truncate
= raw_truncate
,
117 .bdrv_is_inserted
= raw_is_inserted
,
118 .bdrv_media_changed
= raw_media_changed
,
119 .bdrv_eject
= raw_eject
,
120 .bdrv_lock_medium
= raw_lock_medium
,
122 .bdrv_ioctl
= raw_ioctl
,
123 .bdrv_aio_ioctl
= raw_aio_ioctl
,
125 .bdrv_create
= raw_create
,
126 .create_options
= raw_create_options
,
127 .bdrv_has_zero_init
= raw_has_zero_init
,
130 static void bdrv_raw_init(void)
132 bdrv_register(&bdrv_raw
);
135 block_init(bdrv_raw_init
);