Skip to content

Commit cdeb85c

Browse files
XanClicmdroth
authored andcommitted
block: Make essential BlockDriver objects public
There are some block drivers which are essential to QEMU and may not be removed: These are raw, file and qcow2 (as the default non-raw format). Make their BlockDriver objects public so they can be directly referenced throughout the block layer without needing to call bdrv_find_format() and having to deal with an error at runtime, while the real problem occurred during linking (where raw, file or qcow2 were not linked into qemu). Cc: [email protected] Signed-off-by: Max Reitz <[email protected]> Signed-off-by: Kevin Wolf <[email protected]> (cherry picked from commit 5f535a9) Signed-off-by: Michael Roth <[email protected]>
1 parent b28d7b5 commit cdeb85c

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

block/qcow2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2404,7 +2404,7 @@ static QemuOptsList qcow2_create_opts = {
24042404
}
24052405
};
24062406

2407-
static BlockDriver bdrv_qcow2 = {
2407+
BlockDriver bdrv_qcow2 = {
24082408
.format_name = "qcow2",
24092409
.instance_size = sizeof(BDRVQcowState),
24102410
.bdrv_probe = qcow2_probe,

block/raw-posix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,7 @@ static QemuOptsList raw_create_opts = {
15851585
}
15861586
};
15871587

1588-
static BlockDriver bdrv_file = {
1588+
BlockDriver bdrv_file = {
15891589
.format_name = "file",
15901590
.protocol_name = "file",
15911591
.instance_size = sizeof(BDRVRawState),

block/raw-win32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ static QemuOptsList raw_create_opts = {
540540
}
541541
};
542542

543-
static BlockDriver bdrv_file = {
543+
BlockDriver bdrv_file = {
544544
.format_name = "file",
545545
.protocol_name = "file",
546546
.instance_size = sizeof(BDRVRawState),

block/raw_bsd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static int raw_probe(const uint8_t *buf, int buf_size, const char *filename)
173173
return 1;
174174
}
175175

176-
static BlockDriver bdrv_raw = {
176+
BlockDriver bdrv_raw = {
177177
.format_name = "raw",
178178
.bdrv_probe = &raw_probe,
179179
.bdrv_reopen_prepare = &raw_reopen_prepare,

include/block/block_int.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,14 @@ struct BlockDriverState {
395395
Error *backing_blocker;
396396
};
397397

398+
399+
/* Essential block drivers which must always be statically linked into qemu, and
400+
* which therefore can be accessed without using bdrv_find_format() */
401+
extern BlockDriver bdrv_file;
402+
extern BlockDriver bdrv_raw;
403+
extern BlockDriver bdrv_qcow2;
404+
405+
398406
int get_tmp_filename(char *filename, int size);
399407

400408
void bdrv_set_io_limits(BlockDriverState *bs,

0 commit comments

Comments
 (0)