This is an interface to bdrv_open_string_opts().
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
include/sysemu/block-backend.h | 2 ++
block/block-backend.c | 30 +++++++++++++++++++++++++++++-
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 92ab624fac..1ad002fa7e 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -79,6 +79,8 @@ typedef struct BlockBackendPublic {
BlockBackend *blk_new(uint64_t perm, uint64_t shared_perm);
BlockBackend *blk_new_open(const char *filename, const char *reference,
QDict *options, int flags, Error **errp);
+BlockBackend *blk_new_open_string_opts(const char *filename, QDict *options,
+ int flags, Error **errp);
int blk_get_refcnt(BlockBackend *blk);
void blk_ref(BlockBackend *blk);
void blk_unref(BlockBackend *blk);
diff --git a/block/block-backend.c b/block/block-backend.c
index 89f47b00ea..fd3024602a 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -105,6 +105,11 @@ static const AIOCBInfo block_backend_aiocb_info = {
static void drive_info_del(DriveInfo *dinfo);
static BlockBackend *bdrv_first_blk(BlockDriverState *bs);
+static BlockBackend *blk_do_new_open(const char *filename,
+ const char *reference, QDict *options,
+ int flags, bool string_opts,
+ Error **errp);
+
/* All BlockBackends */
static QTAILQ_HEAD(, BlockBackend) block_backends =
QTAILQ_HEAD_INITIALIZER(block_backends);
@@ -348,6 +353,24 @@ BlockBackend *blk_new(uint64_t perm, uint64_t shared_perm)
*/
BlockBackend *blk_new_open(const char *filename, const char *reference,
QDict *options, int flags, Error **errp)
+{
+ return blk_do_new_open(filename, reference, options, flags, false, errp);
+}
+
+/*
+ * Like blk_new_open(), but accepts an @options QDict where some (or
+ * all) values are strings instead of their correct type.
+ */
+BlockBackend *blk_new_open_string_opts(const char *filename, QDict *options,
+ int flags, Error **errp)
+{
+ return blk_do_new_open(filename, NULL, options, flags, true, errp);
+}
+
+static BlockBackend *blk_do_new_open(const char *filename,
+ const char *reference, QDict *options,
+ int flags, bool string_opts,
+ Error **errp)
{
BlockBackend *blk;
BlockDriverState *bs;
@@ -372,7 +395,12 @@ BlockBackend *blk_new_open(const char *filename, const char *reference,
}
blk = blk_new(perm, BLK_PERM_ALL);
- bs = bdrv_open(filename, reference, options, flags, errp);
+ if (string_opts) {
+ assert(!reference);
+ bs = bdrv_open_string_opts(filename, options, flags, errp);
+ } else {
+ bs = bdrv_open(filename, reference, options, flags, errp);
+ }
if (!bs) {
blk_unref(blk);
return NULL;
--
2.14.3