yeahuh / rpms / qemu-kvm

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