Blame SOURCES/0009-RH-don-t-start-without-a-config-file.patch

5c2e41
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
5c2e41
From: Benjamin Marzinski <bmarzins@redhat.com>
5c2e41
Date: Wed, 15 Oct 2014 10:39:30 -0500
5c2e41
Subject: [PATCH] RH: don't start without a config file
5c2e41
5c2e41
If /etc/multipath.conf doesn't exist, don't start multipathd and blacklist
5c2e41
all devices when running multipath.  A completely blank configuration file
5c2e41
is almost never what users want.  Also, people may have the multipath
5c2e41
packages installed but don't want to use them.  This patch provides a
5c2e41
simple way to disable multipath.  Simply removing or renaming
5c2e41
/etc/multipath.conf will keep multipath from doing anything.
5c2e41
5c2e41
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
5c2e41
---
5c2e41
 libmultipath/config.c         | 15 +++++++++++++++
5c2e41
 libmultipath/config.h         |  1 +
5c2e41
 multipath/multipath.rules     |  1 +
5c2e41
 multipathd/multipathd.8       |  2 ++
5c2e41
 multipathd/multipathd.service |  1 +
5c2e41
 5 files changed, 20 insertions(+)
5c2e41
5c2e41
diff --git a/libmultipath/config.c b/libmultipath/config.c
5c2e41
index 0aef186..6a9340a 100644
5c2e41
--- a/libmultipath/config.c
5c2e41
+++ b/libmultipath/config.c
5c2e41
@@ -26,6 +26,7 @@
5c2e41
 #include "devmapper.h"
5c2e41
 #include "mpath_cmd.h"
5c2e41
 #include "propsel.h"
5c2e41
+#include "version.h"
5c2e41
 
5c2e41
 static int
5c2e41
 hwe_strmatch (const struct hwentry *hwe1, const struct hwentry *hwe2)
5c2e41
@@ -745,6 +746,20 @@ load_config (char * file)
5c2e41
 			goto out;
5c2e41
 		}
5c2e41
 		factorize_hwtable(conf->hwtable, builtin_hwtable_size, file);
5c2e41
+	} else {
5c2e41
+		condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices.");
5c2e41
+		if (conf->blist_devnode == NULL) {
5c2e41
+			conf->blist_devnode = vector_alloc();
5c2e41
+			if (!conf->blist_devnode) {
5c2e41
+				condlog(0, "cannot allocate blacklist\n");
5c2e41
+				goto out;
5c2e41
+			}
5c2e41
+		}
5c2e41
+		if (store_ble(conf->blist_devnode, strdup(".*"),
5c2e41
+		              ORIGIN_NO_CONFIG)) {
5c2e41
+			condlog(0, "cannot store default no-config blacklist\n");
5c2e41
+			goto out;
5c2e41
+		}
5c2e41
 	}
5c2e41
 
5c2e41
 	conf->processed_main_config = 1;
5c2e41
diff --git a/libmultipath/config.h b/libmultipath/config.h
5c2e41
index 7d0cd9a..d7fb8e2 100644
5c2e41
--- a/libmultipath/config.h
5c2e41
+++ b/libmultipath/config.h
5c2e41
@@ -9,6 +9,7 @@
5c2e41
 
5c2e41
 #define ORIGIN_DEFAULT 0
5c2e41
 #define ORIGIN_CONFIG  1
5c2e41
+#define ORIGIN_NO_CONFIG 2
5c2e41
 
5c2e41
 /*
5c2e41
  * In kernel, fast_io_fail == 0 means immediate failure on rport delete.
5c2e41
diff --git a/multipath/multipath.rules b/multipath/multipath.rules
5c2e41
index d658073..b3f54d7 100644
5c2e41
--- a/multipath/multipath.rules
5c2e41
+++ b/multipath/multipath.rules
5c2e41
@@ -9,6 +9,7 @@ IMPORT{cmdline}="nompath"
5c2e41
 ENV{nompath}=="?*", GOTO="end_mpath"
5c2e41
 IMPORT{cmdline}="multipath"
5c2e41
 ENV{multipath}=="off", GOTO="end_mpath"
5c2e41
+TEST!="/etc/multipath.conf", GOTO="end_mpath"
5c2e41
 
5c2e41
 ENV{DEVTYPE}!="partition", GOTO="test_dev"
5c2e41
 IMPORT{parent}="DM_MULTIPATH_DEVICE_PATH"
5c2e41
diff --git a/multipathd/multipathd.8 b/multipathd/multipathd.8
5c2e41
index 94c3f97..ed13efd 100644
5c2e41
--- a/multipathd/multipathd.8
5c2e41
+++ b/multipathd/multipathd.8
5c2e41
@@ -38,6 +38,8 @@ map regains its maximum performance and redundancy.
5c2e41
 This daemon executes the external \fBmultipath\fR tool when events occur.
5c2e41
 In turn, the multipath tool signals the multipathd daemon when it is done with
5c2e41
 devmap reconfiguration, so that it can refresh its failed path list.
5c2e41
+
5c2e41
+In this Linux distribution, multipathd does not run unless a /etc/multipath.conf file exists.
5c2e41
 .
5c2e41
 .
5c2e41
 .\" ----------------------------------------------------------------------------
5c2e41
diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service
5c2e41
index ba24983..17434ce 100644
5c2e41
--- a/multipathd/multipathd.service
5c2e41
+++ b/multipathd/multipathd.service
5c2e41
@@ -4,6 +4,7 @@ Wants=systemd-udev-trigger.service systemd-udev-settle.service
5c2e41
 Before=iscsi.service iscsid.service lvm2-activation-early.service
5c2e41
 Before=local-fs-pre.target blk-availability.service
5c2e41
 After=multipathd.socket systemd-udev-trigger.service systemd-udev-settle.service
5c2e41
+ConditionPathExists=/etc/multipath.conf
5c2e41
 DefaultDependencies=no
5c2e41
 Conflicts=shutdown.target
5c2e41
 ConditionKernelCommandLine=!nompath
5c2e41
-- 
5c2e41
2.7.4
5c2e41