[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 11/11] rbd: fix ceph settings precedence
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 11/11] rbd: fix ceph settings precedence |
Date: |
Tue, 14 Jul 2015 17:39:32 +0200 |
From: Josh Durgin <address@hidden>
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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
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.8.3.1
- [Qemu-block] [PULL 02/11] nvme: properly report volatile write caches, (continued)
- [Qemu-block] [PULL 02/11] nvme: properly report volatile write caches, Kevin Wolf, 2015/07/14
- [Qemu-block] [PULL 03/11] block: Move bdrv_attach_child() calls up the call chain, Kevin Wolf, 2015/07/14
- [Qemu-block] [PULL 01/11] nvme: implement the Flush command, Kevin Wolf, 2015/07/14
- [Qemu-block] [PULL 04/11] block: Introduce bdrv_open_child(), Kevin Wolf, 2015/07/14
- [Qemu-block] [PULL 05/11] block: Introduce bdrv_unref_child(), Kevin Wolf, 2015/07/14
- [Qemu-block] [PULL 06/11] block: Reorder cleanups in bdrv_close(), Kevin Wolf, 2015/07/14
- [Qemu-block] [PULL 08/11] rbd: remove unused constants and fields, Kevin Wolf, 2015/07/14
- [Qemu-block] [PULL 09/11] MAINTAINERS: update email address, Kevin Wolf, 2015/07/14
- [Qemu-block] [PULL 07/11] block: Fix backing file child when modifying graph, Kevin Wolf, 2015/07/14
- [Qemu-block] [PULL 10/11] rbd: make qemu's cache setting override any ceph setting, Kevin Wolf, 2015/07/14
- [Qemu-block] [PULL 11/11] rbd: fix ceph settings precedence,
Kevin Wolf <=
- Re: [Qemu-block] [Qemu-devel] [PULL 00/11] Block layer patches for 2.4.0-rc1, Peter Maydell, 2015/07/14