From 74fe54f2a1b5c4f4498a8fe521e1dfc936656cd4 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 9 Jul 2013 11:09:02 +0200 Subject: block: Allow "driver" option on the top level This is traditionally -drive format=..., which is now translated into the new driver option. This gives us a more consistent way to select the driver of BlockDriverStates that can be used in QMP context, too. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'block.c') diff --git a/block.c b/block.c index 6cd39fa146..c77cfd16c7 100644 --- a/block.c +++ b/block.c @@ -970,6 +970,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, char tmp_filename[PATH_MAX + 1]; BlockDriverState *file = NULL; QDict *file_options = NULL; + const char *drvname; /* NULL means an empty set of options */ if (options == NULL) { @@ -1059,6 +1060,12 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, } /* Find the right image format driver */ + drvname = qdict_get_try_str(options, "driver"); + if (drvname) { + drv = bdrv_find_whitelisted_format(drvname, !(flags & BDRV_O_RDWR)); + qdict_del(options, "driver"); + } + if (!drv) { ret = find_image_format(file, filename, &drv); } -- cgit v1.2.1