All of lore.kernel.org
 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>, Alberto Garcia <berto@igalia.com>,
	Eric Blake <eblake@redhat.com>
Subject: [Qemu-devel] [PATCH v3 18/25] block: Add sgfnt_runtime_opts to BlockDriver
Date: Wed, 30 Nov 2016 02:18:44 +0100	[thread overview]
Message-ID: <20161130011851.24696-19-mreitz@redhat.com> (raw)
In-Reply-To: <20161130011851.24696-1-mreitz@redhat.com>

This new field can be set by block drivers to list the runtime options
they accept that may influence the contents of the respective BDS. As of
a follow-up patch, this list will be used by the common
bdrv_refresh_filename() implementation to decide which options to put
into BDS.full_open_options (and consequently whether a JSON filename has
to be created), thus freeing the drivers of having to implement that
logic themselves.

Additionally, this patch adds the field to all of the block drivers that
need it and sets it accordingly.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/blkdebug.c          |  6 ++++++
 block/curl.c              | 20 ++++++++++++++++++++
 block/gluster.c           | 19 +++++++++++++++++++
 block/nbd.c               |  8 ++++++++
 block/nfs.c               |  3 +++
 block/null.c              |  9 +++++++++
 block/quorum.c            |  8 ++++++++
 block/rbd.c               |  2 ++
 block/vvfat.c             |  4 ++++
 include/block/block_int.h |  7 +++++++
 10 files changed, 86 insertions(+)

diff --git a/block/blkdebug.c b/block/blkdebug.c
index 4127571..5de6fad 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -762,6 +762,12 @@ static BlockDriver bdrv_blkdebug = {
                                 = blkdebug_debug_remove_breakpoint,
     .bdrv_debug_resume          = blkdebug_debug_resume,
     .bdrv_debug_is_suspended    = blkdebug_debug_is_suspended,
+
+    .sgfnt_runtime_opts         = (const char *const[]) { "config",
+                                                          "inject-error.",
+                                                          "set-state.",
+                                                          "suspend.",
+                                                          NULL },
 };
 
 static void bdrv_blkdebug_init(void)
diff --git a/block/curl.c b/block/curl.c
index 0404c1b..0777d5b 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -872,6 +872,18 @@ static int64_t curl_getlength(BlockDriverState *bs)
     return s->len;
 }
 
+static const char *const curl_sgfnt_runtime_opts[] = {
+    CURL_BLOCK_OPT_URL,
+    CURL_BLOCK_OPT_SSLVERIFY,
+    CURL_BLOCK_OPT_COOKIE,
+    CURL_BLOCK_OPT_USERNAME,
+    CURL_BLOCK_OPT_PASSWORD_SECRET,
+    CURL_BLOCK_OPT_PROXY_USERNAME,
+    CURL_BLOCK_OPT_PROXY_PASSWORD_SECRET,
+
+    NULL
+};
+
 static BlockDriver bdrv_http = {
     .format_name                = "http",
     .protocol_name              = "http",
@@ -886,6 +898,8 @@ static BlockDriver bdrv_http = {
 
     .bdrv_detach_aio_context    = curl_detach_aio_context,
     .bdrv_attach_aio_context    = curl_attach_aio_context,
+
+    .sgfnt_runtime_opts         = curl_sgfnt_runtime_opts,
 };
 
 static BlockDriver bdrv_https = {
@@ -902,6 +916,8 @@ static BlockDriver bdrv_https = {
 
     .bdrv_detach_aio_context    = curl_detach_aio_context,
     .bdrv_attach_aio_context    = curl_attach_aio_context,
+
+    .sgfnt_runtime_opts         = curl_sgfnt_runtime_opts,
 };
 
 static BlockDriver bdrv_ftp = {
@@ -918,6 +934,8 @@ static BlockDriver bdrv_ftp = {
 
     .bdrv_detach_aio_context    = curl_detach_aio_context,
     .bdrv_attach_aio_context    = curl_attach_aio_context,
+
+    .sgfnt_runtime_opts         = curl_sgfnt_runtime_opts,
 };
 
 static BlockDriver bdrv_ftps = {
@@ -934,6 +952,8 @@ static BlockDriver bdrv_ftps = {
 
     .bdrv_detach_aio_context    = curl_detach_aio_context,
     .bdrv_attach_aio_context    = curl_attach_aio_context,
+
+    .sgfnt_runtime_opts         = curl_sgfnt_runtime_opts,
 };
 
 static void curl_block_init(void)
diff --git a/block/gluster.c b/block/gluster.c
index 891c13b..3b286c7 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -1402,6 +1402,21 @@ static int64_t coroutine_fn qemu_gluster_co_get_block_status(
 }
 
 
+static const char *const gluster_sgfnt_open_opts[] = {
+    GLUSTER_OPT_VOLUME,
+    GLUSTER_OPT_PATH,
+    GLUSTER_OPT_TYPE,
+    GLUSTER_OPT_SERVER_PATTERN,
+    GLUSTER_OPT_HOST,
+    GLUSTER_OPT_PORT,
+    GLUSTER_OPT_TO,
+    GLUSTER_OPT_IPV4,
+    GLUSTER_OPT_IPV6,
+    GLUSTER_OPT_SOCKET,
+
+    NULL
+};
+
 static BlockDriver bdrv_gluster = {
     .format_name                  = "gluster",
     .protocol_name                = "gluster",
@@ -1428,6 +1443,7 @@ static BlockDriver bdrv_gluster = {
 #endif
     .bdrv_co_get_block_status     = qemu_gluster_co_get_block_status,
     .create_opts                  = &qemu_gluster_create_opts,
+    .sgfnt_runtime_opts           = gluster_sgfnt_open_opts,
 };
 
 static BlockDriver bdrv_gluster_tcp = {
@@ -1456,6 +1472,7 @@ static BlockDriver bdrv_gluster_tcp = {
 #endif
     .bdrv_co_get_block_status     = qemu_gluster_co_get_block_status,
     .create_opts                  = &qemu_gluster_create_opts,
+    .sgfnt_runtime_opts           = gluster_sgfnt_open_opts,
 };
 
 static BlockDriver bdrv_gluster_unix = {
@@ -1484,6 +1501,7 @@ static BlockDriver bdrv_gluster_unix = {
 #endif
     .bdrv_co_get_block_status     = qemu_gluster_co_get_block_status,
     .create_opts                  = &qemu_gluster_create_opts,
+    .sgfnt_runtime_opts           = gluster_sgfnt_open_opts,
 };
 
 /* rdma is deprecated (actually never supported for volfile fetch).
@@ -1518,6 +1536,7 @@ static BlockDriver bdrv_gluster_rdma = {
 #endif
     .bdrv_co_get_block_status     = qemu_gluster_co_get_block_status,
     .create_opts                  = &qemu_gluster_create_opts,
+    .sgfnt_runtime_opts           = gluster_sgfnt_open_opts,
 };
 
 static void bdrv_gluster_init(void)
diff --git a/block/nbd.c b/block/nbd.c
index 42f0cd6..1307989 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -580,6 +580,11 @@ static char *nbd_dirname(BlockDriverState *bs, Error **errp)
     return NULL;
 }
 
+static const char *const nbd_sgfnt_runtime_opts[] = {
+    "path", "host", "port", "export", "tls-creds", "server.",
+    NULL
+};
+
 static BlockDriver bdrv_nbd = {
     .format_name                = "nbd",
     .protocol_name              = "nbd",
@@ -598,6 +603,7 @@ static BlockDriver bdrv_nbd = {
     .bdrv_attach_aio_context    = nbd_attach_aio_context,
     .bdrv_refresh_filename      = nbd_refresh_filename,
     .bdrv_dirname               = nbd_dirname,
+    .sgfnt_runtime_opts         = nbd_sgfnt_runtime_opts,
 };
 
 static BlockDriver bdrv_nbd_tcp = {
@@ -618,6 +624,7 @@ static BlockDriver bdrv_nbd_tcp = {
     .bdrv_attach_aio_context    = nbd_attach_aio_context,
     .bdrv_refresh_filename      = nbd_refresh_filename,
     .bdrv_dirname               = nbd_dirname,
+    .sgfnt_runtime_opts         = nbd_sgfnt_runtime_opts,
 };
 
 static BlockDriver bdrv_nbd_unix = {
@@ -638,6 +645,7 @@ static BlockDriver bdrv_nbd_unix = {
     .bdrv_attach_aio_context    = nbd_attach_aio_context,
     .bdrv_refresh_filename      = nbd_refresh_filename,
     .bdrv_dirname               = nbd_dirname,
+    .sgfnt_runtime_opts         = nbd_sgfnt_runtime_opts,
 };
 
 static void bdrv_nbd_init(void)
diff --git a/block/nfs.c b/block/nfs.c
index 81ce98a..6ffdede 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -876,6 +876,9 @@ static BlockDriver bdrv_nfs = {
     .bdrv_refresh_filename          = nfs_refresh_filename,
     .bdrv_dirname                   = nfs_dirname,
 
+    .sgfnt_runtime_opts             = (const char *const[]) { "path", "uid",
+                                                              "gid", NULL },
+
 #ifdef LIBNFS_FEATURE_PAGECACHE
     .bdrv_invalidate_cache          = nfs_invalidate_cache,
 #endif
diff --git a/block/null.c b/block/null.c
index b300390..16ef8b2 100644
--- a/block/null.c
+++ b/block/null.c
@@ -236,6 +236,13 @@ static void null_refresh_filename(BlockDriverState *bs, QDict *opts)
     bs->full_open_options = opts;
 }
 
+static const char *const null_sgfnt_runtime_opts[] = {
+    BLOCK_OPT_SIZE,
+    NULL_OPT_ZEROES,
+
+    NULL
+};
+
 static BlockDriver bdrv_null_co = {
     .format_name            = "null-co",
     .protocol_name          = "null-co",
@@ -253,6 +260,7 @@ static BlockDriver bdrv_null_co = {
     .bdrv_co_get_block_status   = null_co_get_block_status,
 
     .bdrv_refresh_filename  = null_refresh_filename,
+    .sgfnt_runtime_opts     = null_sgfnt_runtime_opts,
 };
 
 static BlockDriver bdrv_null_aio = {
@@ -272,6 +280,7 @@ static BlockDriver bdrv_null_aio = {
     .bdrv_co_get_block_status   = null_co_get_block_status,
 
     .bdrv_refresh_filename  = null_refresh_filename,
+    .sgfnt_runtime_opts     = null_sgfnt_runtime_opts,
 };
 
 static void bdrv_null_init(void)
diff --git a/block/quorum.c b/block/quorum.c
index 07c943c..0fa803b 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -1116,6 +1116,14 @@ static BlockDriver bdrv_quorum = {
 
     .is_filter                          = true,
     .bdrv_recurse_is_first_non_filter   = quorum_recurse_is_first_non_filter,
+
+    .sgfnt_runtime_opts                 = (const char *const[]) {
+                                              QUORUM_OPT_VOTE_THRESHOLD,
+                                              QUORUM_OPT_BLKVERIFY,
+                                              QUORUM_OPT_REWRITE,
+                                              QUORUM_OPT_READ_PATTERN,
+                                              NULL
+                                          },
 };
 
 static void bdrv_quorum_init(void)
diff --git a/block/rbd.c b/block/rbd.c
index a57b3e3..b09a18f 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -1005,6 +1005,8 @@ static BlockDriver bdrv_rbd = {
 #ifdef LIBRBD_SUPPORTS_INVALIDATE
     .bdrv_invalidate_cache  = qemu_rbd_invalidate_cache,
 #endif
+
+    .sgfnt_runtime_opts     = (const char *const[]) { "password-secret", NULL },
 };
 
 static void bdrv_rbd_init(void)
diff --git a/block/vvfat.c b/block/vvfat.c
index ded2109..94f2860 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -3077,6 +3077,10 @@ static BlockDriver bdrv_vvfat = {
     .bdrv_co_preadv         = vvfat_co_preadv,
     .bdrv_co_pwritev        = vvfat_co_pwritev,
     .bdrv_co_get_block_status = vvfat_co_get_block_status,
+
+    .sgfnt_runtime_opts     = (const char *const[]) { "dir", "fat-type",
+                                                      "floppy", "label", "rw",
+                                                      NULL },
 };
 
 static void bdrv_vvfat_init(void)
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 7143737..5885d9f 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -322,6 +322,13 @@ struct BlockDriver {
                            Error **errp);
 
     QLIST_ENTRY(BlockDriver) list;
+
+    /* Pointer to a NULL-terminated array of names of significant options that
+     * can be specified for bdrv_open(). A significant option is one that
+     * changes the data of a BDS.
+     * If this pointer is NULL, the array is considered empty.
+     * "filename" and "driver" are always considered significant. */
+    const char *const *sgfnt_runtime_opts;
 };
 
 typedef struct BlockLimits {
-- 
2.10.2

  parent reply	other threads:[~2016-11-30  1:19 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30  1:18 [Qemu-devel] [PATCH v3 00/25] block: Fix some filename generation issues Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 01/25] block/mirror: Small absolute-paths simplification Max Reitz
2016-12-15 16:14   ` Alberto Garcia
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 02/25] block: Use children list in bdrv_refresh_filename Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 03/25] block: Add BDS.backing_overridden Max Reitz
2017-01-11 19:00   ` Eric Blake
2017-01-11 19:06     ` Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 04/25] block: Respect backing bs in bdrv_refresh_filename Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 05/25] block: Make path_combine() return the path Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 06/25] block: bdrv_get_full_backing_filename_from_...'s ret. val Max Reitz
2016-12-15 16:28   ` Alberto Garcia
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 07/25] block: bdrv_get_full_backing_filename's " Max Reitz
2016-12-15 16:39   ` Alberto Garcia
2016-12-16 13:26     ` Max Reitz
2016-12-16 13:51       ` Alberto Garcia
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 08/25] block: Add bdrv_make_absolute_filename() Max Reitz
2016-12-16 10:23   ` Alberto Garcia
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 09/25] block: Fix bdrv_find_backing_image() Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 10/25] block: Add bdrv_dirname() Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 11/25] blkverify: Make bdrv_dirname() return NULL Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 12/25] quorum: " Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 13/25] block/nbd: Implement bdrv_dirname() Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 14/25] block/nfs: " Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 15/25] block: Use bdrv_dirname() for relative filenames Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 16/25] block: Add 'base-directory' BDS option Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 17/25] iotests: Add quorum case to test 110 Max Reitz
2016-11-30  1:18 ` Max Reitz [this message]
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 19/25] block: Add BlockDriver.bdrv_gather_child_options Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 20/25] block: Generically refresh runtime options Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 21/25] block: Purify .bdrv_refresh_filename() Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 22/25] block: Do not copy exact_filename from format file Max Reitz
2017-01-11 16:29   ` Max Reitz
2017-01-11 17:13     ` Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 23/25] block: Fix FIXME from "Add BDS.backing_overridden" Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 24/25] block/curl: Implement bdrv_refresh_filename() Max Reitz
2016-11-30  1:18 ` [Qemu-devel] [PATCH v3 25/25] block/null: Generate filename even with latency-ns 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=20161130011851.24696-19-mreitz@redhat.com \
    --to=mreitz@redhat.com \
    --cc=berto@igalia.com \
    --cc=eblake@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.