From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, kwolf@redhat.com, mreitz@redhat.com,
jcody@redhat.com, eblake@redhat.com
Subject: [Qemu-devel] [PATCH 17/18] rbd: New parameter auth-client-required
Date: Tue, 12 Jun 2018 14:58:20 +0200 [thread overview]
Message-ID: <20180612125821.4229-18-armbru@redhat.com> (raw)
In-Reply-To: <20180612125821.4229-1-armbru@redhat.com>
Parameter auth-client-required lets you configure authentication
methods. We tried to provide that in v2.9.0, but backed out due to
interface design doubts (commit 464444fcc16).
This commit is similar to what we backed out, but simpler: we use a
list of enumeration values instead of a list of objects with a member
of enumeration type.
Let's review our reasons for backing out the first try, as stated in
the commit message:
* The implementation uses deprecated rados_conf_set() key
"auth_supported". No biggie.
Fixed: we use "auth-client-required".
* The implementation makes -drive silently ignore invalid parameters
"auth" and "auth-supported.*.X" where X isn't "auth". Fixable (in
fact I'm going to fix similar bugs around parameter server), so
again no biggie.
That fix is commit 2836284db60. This commit doesn't bring the bugs
back.
* BlockdevOptionsRbd member @password-secret applies only to
authentication method cephx. Should it be a variant member of
RbdAuthMethod?
We've had time to ponder, and we decided to stick to the way Ceph
configuration works: the key configured separately, and silently
ignored if the authentication method doesn't use it.
* BlockdevOptionsRbd member @user could apply to both methods cephx
and none, but I'm not sure it's actually used with none. If it
isn't, should it be a variant member of RbdAuthMethod?
Likewise.
* The client offers a *set* of authentication methods, not a list.
Should the methods be optional members of BlockdevOptionsRbd instead
of members of list @auth-supported? The latter begs the question
what multiple entries for the same method mean. Trivial question
now that RbdAuthMethod contains nothing but @type, but less so when
RbdAuthMethod acquires other members, such the ones discussed above.
Again, we decided to stick to the way Ceph configuration works, except
we make auth-client-required a list of enumeration values instead of a
string containing keywords separated by delimiters.
* How BlockdevOptionsRbd member @auth-supported interacts with
settings from a configuration file specified with @conf is
undocumented. I suspect it's untested, too.
Not actually true, the documentation for @conf says "Values in the
configuration file will be overridden by options specified via QAPI",
and we've tested this.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
block/rbd.c | 42 ++++++++++++++++++++++++++++++++----------
qapi/block-core.json | 13 +++++++++++++
2 files changed, 45 insertions(+), 10 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
index 82346a2a5e..ea0575d068 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -240,20 +240,42 @@ static void qemu_rbd_refresh_limits(BlockDriverState *bs, Error **errp)
static int qemu_rbd_set_auth(rados_t cluster, const char *secretid,
+ BlockdevOptionsRbd *opts,
Error **errp)
{
- if (secretid == 0) {
- return 0;
- }
+ char *acr;
+ int r;
+ GString *accu;
+ RbdAuthModeList *auth;
+
+ if (secretid) {
+ gchar *secret = qcrypto_secret_lookup_as_base64(secretid,
+ errp);
+ if (!secret) {
+ return -1;
+ }
- gchar *secret = qcrypto_secret_lookup_as_base64(secretid,
- errp);
- if (!secret) {
- return -1;
+ rados_conf_set(cluster, "key", secret);
+ g_free(secret);
}
- rados_conf_set(cluster, "key", secret);
- g_free(secret);
+ if (opts->has_auth_client_required) {
+ accu = g_string_new("");
+ for (auth = opts->auth_client_required; auth; auth = auth->next) {
+ if (accu->str[0]) {
+ g_string_append_c(accu, ';');
+ }
+ g_string_append(accu, RbdAuthMode_str(auth->value));
+ }
+ acr = g_string_free(accu, FALSE);
+ r = rados_conf_set(cluster, "auth_client_required", acr);
+ g_free(acr);
+ if (r < 0) {
+ error_setg_errno(errp, -r,
+ "Could not set 'auth_client_required'");
+ return r;
+ }
+ }
return 0;
}
@@ -585,7 +607,7 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
}
}
- if (qemu_rbd_set_auth(*cluster, secretid, errp) < 0) {
+ if (qemu_rbd_set_auth(*cluster, secretid, opts, errp) < 0) {
r = -EIO;
goto failed_shutdown;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 4b1de474a9..841d196a21 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3093,6 +3093,14 @@
'*timeout': 'int' } }
+##
+# @RbdAuthMode:
+#
+# Since: 3.0
+##
+{ 'enum': 'RbdAuthMode',
+ 'data': [ 'cephx', 'none' ] }
+
##
# @BlockdevOptionsRbd:
#
@@ -3108,6 +3116,10 @@
#
# @user: Ceph id name.
#
+# @auth-client-required: Acceptable authentication modes.
+# This maps to Ceph configuration option
+# "auth_client_required". (Since 3.0)
+#
# @server: Monitor host address and port. This maps
# to the "mon_host" Ceph option.
#
@@ -3119,6 +3131,7 @@
'*conf': 'str',
'*snapshot': 'str',
'*user': 'str',
+ '*auth-client-required': ['RbdAuthMode'],
'*server': ['InetSocketAddressBase'] } }
##
--
2.17.1
next prev parent reply other threads:[~2018-06-12 12:58 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-12 12:58 [Qemu-devel] [PATCH 00/18] block: Configuration fixes and rbd authentication Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 01/18] rbd: Drop deprecated -drive parameter "filename" Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 02/18] iscsi: " Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 03/18] block: Add block-specific QDict header Markus Armbruster
2018-06-12 15:02 ` Kevin Wolf
2018-06-12 16:40 ` Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 04/18] qobject: Move block-specific qdict code to block-qdict.c Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 05/18] block: Fix -blockdev for certain non-string scalars Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 06/18] block: Fix -drive " Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 07/18] block: Clean up a misuse of qobject_to() in .bdrv_co_create_opts() Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 08/18] block: Factor out qobject_input_visitor_new_flat_confused() Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 09/18] block: Make remaining uses of qobject input visitor more robust Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 10/18] block-qdict: Simplify qdict_flatten_qdict() Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 11/18] block-qdict: Tweak qdict_flatten_qdict(), qdict_flatten_qlist() Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 12/18] block-qdict: Clean up qdict_crumple() a bit Markus Armbruster
2018-06-12 15:39 ` Kevin Wolf
2018-06-13 15:23 ` Markus Armbruster
2018-06-14 8:40 ` Kevin Wolf
2018-06-14 8:46 ` Daniel P. Berrangé
2018-06-14 13:11 ` Markus Armbruster
2018-06-14 11:52 ` Markus Armbruster
2018-06-14 13:26 ` Kevin Wolf
2018-06-12 12:58 ` [Qemu-devel] [PATCH 13/18] block-qdict: Simplify qdict_is_list() some Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 14/18] check-block-qdict: Rename qdict_flatten()'s variables for clarity Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 15/18] check-block-qdict: Cover flattening of empty lists and dictionaries Markus Armbruster
2018-06-12 12:58 ` [Qemu-devel] [PATCH 16/18] block: Fix -blockdev / blockdev-add for empty objects and arrays Markus Armbruster
2018-06-12 12:58 ` Markus Armbruster [this message]
2018-06-12 12:58 ` [Qemu-devel] [PATCH 18/18] rbd: New parameter key-secret Markus Armbruster
2018-06-12 13:20 ` Daniel P. Berrangé
2018-06-12 16:42 ` Markus Armbruster
2018-06-12 15:04 ` [Qemu-devel] [PATCH 00/18] block: Configuration fixes and rbd authentication Kevin Wolf
2018-06-12 16:41 ` Kevin Wolf
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=20180612125821.4229-18-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@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).