All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Christophe Varoqui <christophe.varoqui@gmail.com>
Cc: Hannes Reinecke <hare@suse.com>, dm-devel@redhat.com
Subject: [PATCH 23/26] multipathd: Fixup commandline argument handling
Date: Mon, 20 Jun 2016 10:09:10 +0200	[thread overview]
Message-ID: <1466410153-23896-24-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1466410153-23896-1-git-send-email-hare@suse.de>

multipathd would attempt to store the commandline arguments in
an empty configuration, which would later be overwritten when
reading in the main configuration.
And it would not pass in the arguments correctly when using the
CLI interface.
So with this patch the commandline arguments are stored in
global variables, which then will always overwrite settings
from the configuration file.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 multipathd/main.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/multipathd/main.c b/multipathd/main.c
index 6771f60..1dfc884 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -99,6 +99,9 @@ struct mpath_event_param
 unsigned int mpath_mx_alloc_len;
 
 int logsink;
+int verbosity;
+int bindings_read_only;
+int ignore_new_devs;
 enum daemon_status running_state = DAEMON_INIT;
 pid_t daemon_pid;
 pthread_mutex_t config_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -1893,9 +1896,12 @@ reconfigure (struct vectors * vecs)
 
 	if (!load_config(DEFAULT_CONFIGFILE)) {
 		dm_drv_version(conf->version, TGT_MPATH);
-		conf->verbosity = old->verbosity;
-		conf->bindings_read_only = old->bindings_read_only;
-		conf->ignore_new_devs = old->ignore_new_devs;
+		if (verbosity)
+			conf->verbosity = verbosity;
+		if (bindings_read_only)
+			conf->bindings_read_only = bindings_read_only;
+		if (ignore_new_devs)
+			conf->ignore_new_devs = ignore_new_devs;
 		configure(vecs, 1);
 		multipath_conf = conf;
 		free_config(old);
@@ -2121,6 +2127,12 @@ child (void * param)
 	if (load_config(DEFAULT_CONFIGFILE))
 		goto failed;
 
+	if (verbosity)
+		conf->verbosity = verbosity;
+	if (bindings_read_only)
+		conf->bindings_read_only = bindings_read_only;
+	if (ignore_new_devs)
+		conf->ignore_new_devs = ignore_new_devs;
 	uxsock_timeout = conf->uxsock_timeout;
 	multipath_conf = conf;
 	dm_init(conf->verbosity);
@@ -2392,11 +2404,6 @@ main (int argc, char *argv[])
 			strerror(errno));
 	umask(umask(077) | 022);
 
-	conf = alloc_config();
-
-	if (!conf)
-		exit(1);
-
 	udev = udev_new();
 
 	while ((arg = getopt(argc, argv, ":dsv:k::Bn")) != EOF ) {
@@ -2412,7 +2419,7 @@ main (int argc, char *argv[])
 			    !isdigit(optarg[0]))
 				exit(1);
 
-			conf->verbosity = atoi(optarg);
+			verbosity = atoi(optarg);
 			break;
 		case 's':
 			logsink = -1;
@@ -2420,13 +2427,15 @@ main (int argc, char *argv[])
 		case 'k':
 			if (load_config(DEFAULT_CONFIGFILE))
 				exit(1);
+			if (verbosity)
+				conf->verbosity = verbosity;
 			uxclnt(optarg, uxsock_timeout + 100);
 			exit(0);
 		case 'B':
-			conf->bindings_read_only = 1;
+			bindings_read_only = 1;
 			break;
 		case 'n':
-			conf->ignore_new_devs = 1;
+			ignore_new_devs = 1;
 			break;
 		default:
 			fprintf(stderr, "Invalid argument '-%c'\n",
@@ -2441,6 +2450,8 @@ main (int argc, char *argv[])
 
 		if (load_config(DEFAULT_CONFIGFILE))
 			exit(1);
+		if (verbosity)
+			conf->verbosity = verbosity;
 		memset(cmd, 0x0, CMDSIZE);
 		while (optind < argc) {
 			if (strchr(argv[optind], ' '))
-- 
2.6.6

  parent reply	other threads:[~2016-06-20  8:09 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-20  8:08 [PATCH 00/26] Userspace-RCU for config accesses Hannes Reinecke
2016-06-20  8:08 ` [PATCH 01/26] Revert patch 'move filter_devnode() under vector lock' Hannes Reinecke
2016-06-20  8:08 ` [PATCH 02/26] Use 'mptable' as argument for find_mpe() and get_mpe_wwid() Hannes Reinecke
2016-07-01 19:48   ` Benjamin Marzinski
2016-06-20  8:08 ` [PATCH 03/26] config: set 'deferred_remove' defaults at correct call Hannes Reinecke
2016-06-20  8:08 ` [PATCH 04/26] devmapper: explicit config settings Hannes Reinecke
2016-06-20  8:08 ` [PATCH 05/26] dmparser: use 'is_daemon' as argument for disassemble_map() Hannes Reinecke
2016-06-20  8:08 ` [PATCH 06/26] libmultipath: use 'is_daemon' as argument for domap() etc Hannes Reinecke
2016-06-20  8:08 ` [PATCH 07/26] libmultipath: drop 'daemon' configuration setting Hannes Reinecke
2016-06-20  8:08 ` [PATCH 08/26] libmultipath: Do not access 'conf->cmd' in domap() Hannes Reinecke
2016-06-20  8:08 ` [PATCH 09/26] libmultipath: add 'cmd' as argument for get_refwwid() Hannes Reinecke
2016-06-20  8:08 ` [PATCH 10/26] libmultipath: fallback to checking environment variable in get_udev_uid() Hannes Reinecke
2016-06-20  8:08 ` [PATCH 11/26] multipath: make 'cmd' internal to multipath program Hannes Reinecke
2016-06-20  8:08 ` [PATCH 12/26] multipath: make 'dev_type' internal to the " Hannes Reinecke
2016-06-20  8:09 ` [PATCH 13/26] multipath: make 'dev' " Hannes Reinecke
2016-06-20  8:09 ` [PATCH 14/26] libmultipath: separate out 'udev' config entry Hannes Reinecke
2016-06-20  8:09 ` [PATCH 15/26] libmultipath: use 'checkint' as argument for sysfs_set_scsi_tmo() Hannes Reinecke
2016-06-20  8:09 ` [PATCH 16/26] discovery: Pass in 'hwtable' for get_state() and scsi_sysfs_discovery() Hannes Reinecke
2016-06-20  8:09 ` [PATCH 17/26] libmultipath: use 'struct config' as argument for pathinfo() Hannes Reinecke
2016-07-01 20:25   ` Benjamin Marzinski
2016-07-04  5:49     ` Hannes Reinecke
2016-06-20  8:09 ` [PATCH 18/26] checkers: use 'multipath_dir' as argument Hannes Reinecke
2016-06-20  8:09 ` [PATCH 19/26] prio: " Hannes Reinecke
2016-06-20  8:09 ` [PATCH 20/26] libmultipath: use 'timeout' as argument for getprio() Hannes Reinecke
2016-06-20  8:09 ` [PATCH 21/26] libmultipath: use explicit 'config' argument for configuration file parsing Hannes Reinecke
2016-06-20  8:09 ` [PATCH 22/26] libmultipath: use (get, put)_multipath_config() accessors Hannes Reinecke
2016-06-20  8:09 ` Hannes Reinecke [this message]
2016-06-20  8:09 ` [PATCH 24/26] multipath: make 'struct config' a local variable Hannes Reinecke
2016-06-20  8:09 ` [PATCH 25/26] multipathd: use userspace RCU to access configuration Hannes Reinecke
2016-06-20  8:09 ` [PATCH 26/26] libmultipath: Allocate keywords directly Hannes Reinecke
2016-07-01 20:44 ` [PATCH 00/26] Userspace-RCU for config accesses Benjamin Marzinski
2016-07-04  7:08 [PATCHv2 " Hannes Reinecke
2016-07-04  7:08 ` [PATCH 23/26] multipathd: Fixup commandline argument handling Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466410153-23896-24-git-send-email-hare@suse.de \
    --to=hare@suse.de \
    --cc=christophe.varoqui@gmail.com \
    --cc=dm-devel@redhat.com \
    --cc=hare@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.