From 2e40134bfdbb073512f9f264cb96162787ec62b1 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Tue, 18 Feb 2014 18:33:07 +0100 Subject: block: Make bdrv_file_open() static Add the bdrv_open() option BDRV_O_PROTOCOL which results in passing the call to bdrv_file_open(). Additionally, make bdrv_file_open() static and therefore bdrv_open() the only way to call it. Consequently, all existing calls to bdrv_file_open() have to be adjusted to use bdrv_open() with the BDRV_O_PROTOCOL flag instead. Signed-off-by: Max Reitz Reviewed-by: Kevin Wolf Reviewed-by: Benoit Canet Signed-off-by: Kevin Wolf --- block.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'block.c') diff --git a/block.c b/block.c index 86a32e7192..8abbbefbd5 100644 --- a/block.c +++ b/block.c @@ -960,9 +960,9 @@ free_and_fail: * after the call (even on failure), so if the caller intends to reuse the * dictionary, it needs to use QINCREF() before calling bdrv_file_open. */ -int bdrv_file_open(BlockDriverState **pbs, const char *filename, - const char *reference, QDict *options, int flags, - Error **errp) +static int bdrv_file_open(BlockDriverState **pbs, const char *filename, + const char *reference, QDict *options, int flags, + Error **errp) { BlockDriverState *bs = NULL; BlockDriver *drv; @@ -1208,8 +1208,8 @@ int bdrv_open_image(BlockDriverState **pbs, const char *filename, ret = bdrv_open(pbs, filename, NULL, image_options, flags, NULL, errp); } else { - ret = bdrv_file_open(pbs, filename, reference, image_options, flags, - errp); + ret = bdrv_open(pbs, filename, reference, image_options, + flags | BDRV_O_PROTOCOL, NULL, errp); } done: @@ -1245,6 +1245,12 @@ int bdrv_open(BlockDriverState **pbs, const char *filename, assert(pbs); + if (flags & BDRV_O_PROTOCOL) { + assert(!drv); + return bdrv_file_open(pbs, filename, reference, options, + flags & ~BDRV_O_PROTOCOL, errp); + } + if (reference) { bool options_non_empty = options ? qdict_size(options) : false; QDECREF(options); -- cgit v1.2.1