aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'block.c')
-rw-r--r--block.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/block.c b/block.c
index 22647b221a..0fb0165eb6 100644
--- a/block.c
+++ b/block.c
@@ -708,7 +708,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
bdrv_swap(file, bs);
ret = 0;
} else {
- ret = drv->bdrv_file_open(bs, filename, open_flags);
+ ret = drv->bdrv_file_open(bs, filename, options, open_flags);
}
} else {
assert(file != NULL);
@@ -742,13 +742,21 @@ free_and_fail:
/*
* Opens a file using a protocol (file, host_device, nbd, ...)
+ *
+ * options is a QDict of options to pass to the block drivers, or NULL for an
+ * empty set of options. The reference to the QDict belongs to the block layer
+ * 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, int flags)
+int bdrv_file_open(BlockDriverState **pbs, const char *filename,
+ QDict *options, int flags)
{
BlockDriverState *bs;
BlockDriver *drv;
int ret;
+ QDECREF(options);
+
drv = bdrv_find_protocol(filename);
if (!drv) {
return -ENOENT;
@@ -888,7 +896,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
flags |= BDRV_O_ALLOW_RDWR;
}
- ret = bdrv_file_open(&file, filename, bdrv_open_flags(bs, flags));
+ ret = bdrv_file_open(&file, filename, NULL, bdrv_open_flags(bs, flags));
if (ret < 0) {
goto fail;
}