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

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