|
|
9ae3a8 |
From 109d7dedc79629f58fd9b685ccd9990b90f374e9 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
Date: Thu, 5 Nov 2015 15:20:58 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 3/6] rbd: fix ceph settings precedence
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1446736858-29005-3-git-send-email-stefanha@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 68294
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.2.z qemu-kvm PATCH 2/2] rbd: fix ceph settings precedence
|
|
|
9ae3a8 |
Bugzilla: 1277248 1279389
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Josh Durgin <jdurgin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Apply the ceph settings from a config file before any ceph settings
|
|
|
9ae3a8 |
from the command line. Since the ceph config file location may be
|
|
|
9ae3a8 |
specified on the command line, parse it once to read the config file,
|
|
|
9ae3a8 |
and do a second pass to apply the rest of the command line ceph
|
|
|
9ae3a8 |
options.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Josh Durgin <jdurgin@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit e34d8f297d51b7ffa5dce72df1e45fa94cff989c)
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
block/rbd.c - downstream does not use Error*
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/rbd.c | 34 +++++++++++++++++++++++++---------
|
|
|
9ae3a8 |
1 file changed, 25 insertions(+), 9 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/rbd.c b/block/rbd.c
|
|
|
9ae3a8 |
index 11a39ac..b982658 100644
|
|
|
9ae3a8 |
--- a/block/rbd.c
|
|
|
9ae3a8 |
+++ b/block/rbd.c
|
|
|
9ae3a8 |
@@ -235,7 +235,8 @@ static char *qemu_rbd_parse_clientname(const char *conf, char *clientname)
|
|
|
9ae3a8 |
return NULL;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static int qemu_rbd_set_conf(rados_t cluster, const char *conf)
|
|
|
9ae3a8 |
+static int qemu_rbd_set_conf(rados_t cluster, const char *conf,
|
|
|
9ae3a8 |
+ bool only_read_conf_file)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
char *p, *buf;
|
|
|
9ae3a8 |
char name[RBD_MAX_CONF_NAME_SIZE];
|
|
|
9ae3a8 |
@@ -267,14 +268,18 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf)
|
|
|
9ae3a8 |
qemu_rbd_unescape(value);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (strcmp(name, "conf") == 0) {
|
|
|
9ae3a8 |
- ret = rados_conf_read_file(cluster, value);
|
|
|
9ae3a8 |
- if (ret < 0) {
|
|
|
9ae3a8 |
- error_report("error reading conf file %s", value);
|
|
|
9ae3a8 |
- break;
|
|
|
9ae3a8 |
+ /* read the conf file alone, so it doesn't override more
|
|
|
9ae3a8 |
+ specific settings for a particular device */
|
|
|
9ae3a8 |
+ if (only_read_conf_file) {
|
|
|
9ae3a8 |
+ ret = rados_conf_read_file(cluster, value);
|
|
|
9ae3a8 |
+ if (ret < 0) {
|
|
|
9ae3a8 |
+ error_report("error reading conf file %s", value);
|
|
|
9ae3a8 |
+ break;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
} else if (strcmp(name, "id") == 0) {
|
|
|
9ae3a8 |
/* ignore, this is parsed by qemu_rbd_parse_clientname() */
|
|
|
9ae3a8 |
- } else {
|
|
|
9ae3a8 |
+ } else if (!only_read_conf_file) {
|
|
|
9ae3a8 |
ret = rados_conf_set(cluster, name, value);
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
error_report("invalid conf option %s", name);
|
|
|
9ae3a8 |
@@ -341,12 +346,17 @@ static int qemu_rbd_create(const char *filename, QEMUOptionParameter *options,
|
|
|
9ae3a8 |
if (strstr(conf, "conf=") == NULL) {
|
|
|
9ae3a8 |
/* try default location, but ignore failure */
|
|
|
9ae3a8 |
rados_conf_read_file(cluster, NULL);
|
|
|
9ae3a8 |
+ } else if (conf[0] != '\0' &&
|
|
|
9ae3a8 |
+ qemu_rbd_set_conf(cluster, conf, true) < 0) {
|
|
|
9ae3a8 |
+ rados_shutdown(cluster);
|
|
|
9ae3a8 |
+ error_report("error setting config options");
|
|
|
9ae3a8 |
+ return -EIO;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (conf[0] != '\0' &&
|
|
|
9ae3a8 |
- qemu_rbd_set_conf(cluster, conf) < 0) {
|
|
|
9ae3a8 |
- error_report("error setting config options");
|
|
|
9ae3a8 |
+ qemu_rbd_set_conf(cluster, conf, false) < 0) {
|
|
|
9ae3a8 |
rados_shutdown(cluster);
|
|
|
9ae3a8 |
+ error_report("error setting config options");
|
|
|
9ae3a8 |
return -EIO;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -504,10 +514,16 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
9ae3a8 |
if (strstr(conf, "conf=") == NULL) {
|
|
|
9ae3a8 |
/* try default location, but ignore failure */
|
|
|
9ae3a8 |
rados_conf_read_file(s->cluster, NULL);
|
|
|
9ae3a8 |
+ } else if (conf[0] != '\0') {
|
|
|
9ae3a8 |
+ r = qemu_rbd_set_conf(s->cluster, conf, true);
|
|
|
9ae3a8 |
+ if (r < 0) {
|
|
|
9ae3a8 |
+ error_report("error setting config options");
|
|
|
9ae3a8 |
+ goto failed_shutdown;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (conf[0] != '\0') {
|
|
|
9ae3a8 |
- r = qemu_rbd_set_conf(s->cluster, conf);
|
|
|
9ae3a8 |
+ r = qemu_rbd_set_conf(s->cluster, conf, false);
|
|
|
9ae3a8 |
if (r < 0) {
|
|
|
9ae3a8 |
error_report("error setting config options");
|
|
|
9ae3a8 |
goto failed_shutdown;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|