From 8f94a6e40e46cbc8e8014da825d25824b1803b34 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Thu, 10 Oct 2013 11:45:55 +0200 Subject: block: Improve driver whitelist checks The main intent of this patch is to consolidate the whitelist checks to a single point in the code instead of spreading it everywhere. This adds a nicer error message for read-only whitelisting, too, in places where it was still missing. The patch also contains a bonus bug fix: By finding the format first in bdrv_open() and then independently checking against the whitelist only later, we avoid the case that use of a non-whitelisted format results in probing rather than an error message. Previously, this could happen when using the driver=... option. Signed-off-by: Kevin Wolf Reviewed-by: Fam Zheng --- blockdev.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'blockdev.c') diff --git a/blockdev.c b/blockdev.c index a91d5a87df..ab79df7bff 100644 --- a/blockdev.c +++ b/blockdev.c @@ -468,13 +468,9 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts, return NULL; } - drv = bdrv_find_whitelisted_format(buf, ro); + drv = bdrv_find_format(buf); if (!drv) { - if (!ro && bdrv_find_whitelisted_format(buf, !ro)) { - error_report("'%s' can be only used as read-only device.", buf); - } else { - error_report("'%s' invalid format", buf); - } + error_report("'%s' invalid format", buf); return NULL; } } -- cgit v1.2.1