qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>,
	Markus Armbruster <armbru@redhat.com>
Subject: [Qemu-devel] [RFC 5/7] block: Add blk_new_open_string_opts()
Date: Wed,  2 May 2018 23:32:17 +0200	[thread overview]
Message-ID: <20180502213219.7842-6-mreitz@redhat.com> (raw)
In-Reply-To: <20180502213219.7842-1-mreitz@redhat.com>

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

  parent reply	other threads:[~2018-05-02 21:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-02 21:32 [Qemu-devel] [RFC 0/7] block: Try to use correctly typed blockdev options Max Reitz
2018-05-02 21:32 ` [Qemu-devel] [RFC 1/7] qdict: Add qdict_set_default_bool() Max Reitz
2018-05-02 21:32 ` [Qemu-devel] [RFC 2/7] block: Let change-medium add detect-zeroes as bool Max Reitz
2018-05-02 21:32 ` [Qemu-devel] [RFC 3/7] block: Make use of qdict_set_default_bool() Max Reitz
2018-05-02 21:32 ` [Qemu-devel] [RFC 4/7] block: Add bdrv_open_string_opts() Max Reitz
2018-05-02 21:32 ` Max Reitz [this message]
2018-05-02 21:32 ` [Qemu-devel] [RFC 6/7] block: Use {blk_new, bdrv}_open_string_opts() Max Reitz
2018-05-02 21:32 ` [Qemu-devel] [RFC 7/7] iotests: Test internal option typing Max Reitz
2018-05-02 21:36 ` [Qemu-devel] [Qemu-block] [RFC 0/7] block: Try to use correctly typed blockdev options Max Reitz
2018-05-03  8:16 ` [Qemu-devel] " Markus Armbruster
2018-05-04 15:53   ` Max Reitz
2018-05-04 16:11     ` Max Reitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180502213219.7842-6-mreitz@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).