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 coroutine_fn
raw_co_is_allocated(BlockDriverState
*bs
,
30 int nb_sectors
, int *pnum
)
32 return bdrv_co_is_allocated(bs
->file
, sector_num
, nb_sectors
, pnum
);
35 static int64_t raw_getlength(BlockDriverState
*bs
)
37 return bdrv_getlength(bs
->file
);
40 static int raw_truncate(BlockDriverState
*bs
, int64_t offset
)
42 return bdrv_truncate(bs
->file
, offset
);
45 static int raw_probe(const uint8_t *buf
, int buf_size
, const char *filename
)
47 return 1; /* everything can be opened as raw image */
50 static int coroutine_fn
raw_co_discard(BlockDriverState
*bs
,
51 int64_t sector_num
, int nb_sectors
)
53 return bdrv_co_discard(bs
->file
, sector_num
, nb_sectors
);
56 static int raw_is_inserted(BlockDriverState
*bs
)
58 return bdrv_is_inserted(bs
->file
);
61 static int raw_media_changed(BlockDriverState
*bs
)
63 return bdrv_media_changed(bs
->file
);
66 static void raw_eject(BlockDriverState
*bs
, bool eject_flag
)
68 bdrv_eject(bs
->file
, eject_flag
);
71 static void raw_lock_medium(BlockDriverState
*bs
, bool locked
)
73 bdrv_lock_medium(bs
->file
, locked
);
76 static int raw_ioctl(BlockDriverState
*bs
, unsigned long int req
, void *buf
)
78 return bdrv_ioctl(bs
->file
, req
, buf
);
81 static BlockDriverAIOCB
*raw_aio_ioctl(BlockDriverState
*bs
,
82 unsigned long int req
, void *buf
,
83 BlockDriverCompletionFunc
*cb
, void *opaque
)
85 return bdrv_aio_ioctl(bs
->file
, req
, buf
, cb
, opaque
);
88 static int raw_create(const char *filename
, QEMUOptionParameter
*options
)
90 return bdrv_create_file(filename
, options
);
93 static QEMUOptionParameter raw_create_options
[] = {
95 .name
= BLOCK_OPT_SIZE
,
97 .help
= "Virtual disk size"
102 static int raw_has_zero_init(BlockDriverState
*bs
)
104 return bdrv_has_zero_init(bs
->file
);
107 static BlockDriver bdrv_raw
= {
108 .format_name
= "raw",
110 /* It's really 0, but we need to make g_malloc() happy */
113 .bdrv_open
= raw_open
,
114 .bdrv_close
= raw_close
,
116 .bdrv_co_readv
= raw_co_readv
,
117 .bdrv_co_writev
= raw_co_writev
,
118 .bdrv_co_is_allocated
= raw_co_is_allocated
,
119 .bdrv_co_discard
= raw_co_discard
,
121 .bdrv_probe
= raw_probe
,
122 .bdrv_getlength
= raw_getlength
,
123 .bdrv_truncate
= raw_truncate
,
125 .bdrv_is_inserted
= raw_is_inserted
,
126 .bdrv_media_changed
= raw_media_changed
,
127 .bdrv_eject
= raw_eject
,
128 .bdrv_lock_medium
= raw_lock_medium
,
130 .bdrv_ioctl
= raw_ioctl
,
131 .bdrv_aio_ioctl
= raw_aio_ioctl
,
133 .bdrv_create
= raw_create
,
134 .create_options
= raw_create_options
,
135 .bdrv_has_zero_init
= raw_has_zero_init
,
138 static void bdrv_raw_init(void)
140 bdrv_register(&bdrv_raw
);
143 block_init(bdrv_raw_init
);