From: Josh Durgin <jdurgin@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Jeff Cody <jcody@redhat.com>,
qemu-block@nongnu.org
Subject: [Qemu-devel] [PATCH 4/4] rbd: fix ceph settings precedence
Date: Wed, 10 Jun 2015 20:28:46 -0700 [thread overview]
Message-ID: <1433993326-26294-5-git-send-email-jdurgin@redhat.com> (raw)
In-Reply-To: <1433993326-26294-1-git-send-email-jdurgin@redhat.com>
Apply the ceph settings from a config file before any ceph settings
from the command line. Since the ceph config file location may be
specified on the command line, parse it once to read the config file,
and do a second pass to apply the rest of the command line ceph
options.
Signed-off-by: Josh Durgin <jdurgin@redhat.com>
---
block/rbd.c | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
index 00d027d..a60a19d 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -228,7 +228,9 @@ static char *qemu_rbd_parse_clientname(const char *conf, char *clientname)
return NULL;
}
-static int qemu_rbd_set_conf(rados_t cluster, const char *conf, Error **errp)
+static int qemu_rbd_set_conf(rados_t cluster, const char *conf,
+ bool only_read_conf_file,
+ Error **errp)
{
char *p, *buf;
char name[RBD_MAX_CONF_NAME_SIZE];
@@ -260,14 +262,18 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf, Error **errp)
qemu_rbd_unescape(value);
if (strcmp(name, "conf") == 0) {
- ret = rados_conf_read_file(cluster, value);
- if (ret < 0) {
- error_setg(errp, "error reading conf file %s", value);
- break;
+ /* read the conf file alone, so it doesn't override more
+ specific settings for a particular device */
+ if (only_read_conf_file) {
+ ret = rados_conf_read_file(cluster, value);
+ if (ret < 0) {
+ error_setg(errp, "error reading conf file %s", value);
+ break;
+ }
}
} else if (strcmp(name, "id") == 0) {
/* ignore, this is parsed by qemu_rbd_parse_clientname() */
- } else {
+ } else if (!only_read_conf_file) {
ret = rados_conf_set(cluster, name, value);
if (ret < 0) {
error_setg(errp, "invalid conf option %s", name);
@@ -330,10 +336,15 @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
if (strstr(conf, "conf=") == NULL) {
/* try default location, but ignore failure */
rados_conf_read_file(cluster, NULL);
+ } else if (conf[0] != '\0' &&
+ qemu_rbd_set_conf(cluster, conf, true, &local_err) < 0) {
+ rados_shutdown(cluster);
+ error_propagate(errp, local_err);
+ return -EIO;
}
if (conf[0] != '\0' &&
- qemu_rbd_set_conf(cluster, conf, &local_err) < 0) {
+ qemu_rbd_set_conf(cluster, conf, false, &local_err) < 0) {
rados_shutdown(cluster);
error_propagate(errp, local_err);
return -EIO;
@@ -463,10 +474,15 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
if (strstr(conf, "conf=") == NULL) {
/* try default location, but ignore failure */
rados_conf_read_file(s->cluster, NULL);
+ } else if (conf[0] != '\0') {
+ r = qemu_rbd_set_conf(s->cluster, conf, true, errp);
+ if (r < 0) {
+ goto failed_shutdown;
+ }
}
if (conf[0] != '\0') {
- r = qemu_rbd_set_conf(s->cluster, conf, errp);
+ r = qemu_rbd_set_conf(s->cluster, conf, false, errp);
if (r < 0) {
goto failed_shutdown;
}
--
1.9.1
next prev parent reply other threads:[~2015-06-11 3:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-11 3:28 [Qemu-devel] [PATCH 0/4] rbd cleanup and settings precedence fixes Josh Durgin
2015-06-11 3:28 ` [Qemu-devel] [PATCH 1/4] rbd: remove unused constants and fields Josh Durgin
2015-06-30 19:47 ` Jeff Cody
2015-06-11 3:28 ` [Qemu-devel] [PATCH 2/4] MAINTAINERS: update email address Josh Durgin
2015-06-30 19:47 ` Jeff Cody
2015-06-11 3:28 ` [Qemu-devel] [PATCH 3/4] rbd: make qemu's cache setting override any ceph setting Josh Durgin
2015-06-30 19:47 ` Jeff Cody
2015-06-11 3:28 ` Josh Durgin [this message]
2015-06-30 18:28 ` [Qemu-devel] [PATCH 0/4] rbd cleanup and settings precedence fixes Josh Durgin
2015-07-09 9:59 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-07-14 14:20 ` Kevin Wolf
2015-07-14 19:42 ` Josh Durgin
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=1433993326-26294-5-git-send-email-jdurgin@redhat.com \
--to=jdurgin@redhat.com \
--cc=jcody@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).