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

e65fa3
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
e65fa3
From: Benjamin Marzinski <bmarzins@redhat.com>
e65fa3
Date: Wed, 15 Oct 2014 10:39:30 -0500
e65fa3
Subject: [PATCH] RH: don't start without a config file
e65fa3
e65fa3
If /etc/multipath.conf doesn't exist, don't start multipathd and blacklist
e65fa3
all devices when running multipath.  A completely blank configuration file
e65fa3
is almost never what users want.  Also, people may have the multipath
e65fa3
packages installed but don't want to use them.  This patch provides a
e65fa3
simple way to disable multipath.  Simply removing or renaming
e65fa3
/etc/multipath.conf will keep multipath from doing anything.
e65fa3
e65fa3
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
e65fa3
---
e65fa3
 libmultipath/config.c         | 13 +++++++++++++
e65fa3
 libmultipath/config.h         |  1 +
e65fa3
 multipath/multipath.rules     |  1 +
e65fa3
 multipathd/multipathd.8       |  2 ++
e65fa3
 multipathd/multipathd.service |  1 +
e65fa3
 multipathd/multipathd.socket  |  1 +
e65fa3
 6 files changed, 19 insertions(+)
e65fa3
e65fa3
diff --git a/libmultipath/config.c b/libmultipath/config.c
e65fa3
index 30046a17..5f35c3d3 100644
e65fa3
--- a/libmultipath/config.c
e65fa3
+++ b/libmultipath/config.c
e65fa3
@@ -895,6 +895,19 @@ int _init_config (const char *file, struct config *conf)
e65fa3
 			goto out;
e65fa3
 		}
e65fa3
 		factorize_hwtable(conf->hwtable, builtin_hwtable_size, file);
e65fa3
+	} else {
e65fa3
+		condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices.");
e65fa3
+		if (conf->blist_devnode == NULL) {
e65fa3
+			conf->blist_devnode = vector_alloc();
e65fa3
+			if (!conf->blist_devnode) {
e65fa3
+				condlog(0, "cannot allocate blacklist\n");
e65fa3
+				goto out;
e65fa3
+			}
e65fa3
+		}
e65fa3
+		if (store_ble(conf->blist_devnode, ".*", ORIGIN_NO_CONFIG)) {
e65fa3
+			condlog(0, "cannot store default no-config blacklist\n");
e65fa3
+			goto out;
e65fa3
+		}
e65fa3
 	}
e65fa3
 
e65fa3
 	conf->processed_main_config = 1;
e65fa3
diff --git a/libmultipath/config.h b/libmultipath/config.h
e65fa3
index 933fe0d1..5f01c1fc 100644
e65fa3
--- a/libmultipath/config.h
e65fa3
+++ b/libmultipath/config.h
e65fa3
@@ -9,6 +9,7 @@
e65fa3
 
e65fa3
 #define ORIGIN_DEFAULT 0
e65fa3
 #define ORIGIN_CONFIG  1
e65fa3
+#define ORIGIN_NO_CONFIG 2
e65fa3
 
e65fa3
 enum devtypes {
e65fa3
 	DEV_NONE,
e65fa3
diff --git a/multipath/multipath.rules b/multipath/multipath.rules
e65fa3
index 9df11a95..0486bf70 100644
e65fa3
--- a/multipath/multipath.rules
e65fa3
+++ b/multipath/multipath.rules
e65fa3
@@ -9,6 +9,7 @@ IMPORT{cmdline}="nompath"
e65fa3
 ENV{nompath}=="?*", GOTO="end_mpath"
e65fa3
 IMPORT{cmdline}="multipath"
e65fa3
 ENV{multipath}=="off", GOTO="end_mpath"
e65fa3
+TEST!="/etc/multipath.conf", GOTO="end_mpath"
e65fa3
 
e65fa3
 ENV{DEVTYPE}!="partition", GOTO="test_dev"
e65fa3
 IMPORT{parent}="DM_MULTIPATH_DEVICE_PATH"
e65fa3
diff --git a/multipathd/multipathd.8 b/multipathd/multipathd.8
e65fa3
index 048a838d..8bd47a80 100644
e65fa3
--- a/multipathd/multipathd.8
e65fa3
+++ b/multipathd/multipathd.8
e65fa3
@@ -39,6 +39,8 @@ map regains its maximum performance and redundancy.
e65fa3
 This daemon executes the external \fBmultipath\fR tool when events occur.
e65fa3
 In turn, the multipath tool signals the multipathd daemon when it is done with
e65fa3
 devmap reconfiguration, so that it can refresh its failed path list.
e65fa3
+
e65fa3
+In this Linux distribution, multipathd does not run unless a /etc/multipath.conf file exists.
e65fa3
 .
e65fa3
 .
e65fa3
 .\" ----------------------------------------------------------------------------
e65fa3
diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service
e65fa3
index 0b2ac814..6d57c7e8 100644
e65fa3
--- a/multipathd/multipathd.service
e65fa3
+++ b/multipathd/multipathd.service
e65fa3
@@ -4,6 +4,7 @@ Wants=systemd-udev-trigger.service systemd-udev-settle.service
e65fa3
 Before=iscsi.service iscsid.service lvm2-activation-early.service
e65fa3
 Before=local-fs-pre.target blk-availability.service shutdown.target
e65fa3
 After=multipathd.socket systemd-udev-trigger.service systemd-udev-settle.service
e65fa3
+ConditionPathExists=/etc/multipath.conf
e65fa3
 DefaultDependencies=no
e65fa3
 Conflicts=shutdown.target
e65fa3
 ConditionKernelCommandLine=!nompath
e65fa3
diff --git a/multipathd/multipathd.socket b/multipathd/multipathd.socket
e65fa3
index c777e5e3..3c20a2ff 100644
e65fa3
--- a/multipathd/multipathd.socket
e65fa3
+++ b/multipathd/multipathd.socket
e65fa3
@@ -1,6 +1,7 @@
e65fa3
 [Unit]
e65fa3
 Description=multipathd control socket
e65fa3
 DefaultDependencies=no
e65fa3
+ConditionPathExists=/etc/multipath.conf
e65fa3
 ConditionKernelCommandLine=!nompath
e65fa3
 ConditionKernelCommandLine=!multipath=off
e65fa3
 ConditionVirtualization=!container