From patchwork Mon Jun 20 08:09:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 9186811 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1F56760756 for ; Mon, 20 Jun 2016 08:13:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AEA424B5B for ; Mon, 20 Jun 2016 08:13:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3BFA2522B; Mon, 20 Jun 2016 08:13:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 93E2124B5B for ; Mon, 20 Jun 2016 08:13:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5K89m7S047742; Mon, 20 Jun 2016 04:09:48 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u5K89Yow031163 for ; Mon, 20 Jun 2016 04:09:34 -0400 Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5K89Yb1023674 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 20 Jun 2016 04:09:34 -0400 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1ED3137E64; Mon, 20 Jun 2016 08:09:33 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id EFA54AD69; Mon, 20 Jun 2016 08:09:26 +0000 (UTC) From: Hannes Reinecke To: Christophe Varoqui Date: Mon, 20 Jun 2016 10:09:10 +0200 Message-Id: <1466410153-23896-24-git-send-email-hare@suse.de> In-Reply-To: <1466410153-23896-1-git-send-email-hare@suse.de> References: <1466410153-23896-1-git-send-email-hare@suse.de> X-Greylist: Sender IP whitelisted by DNSRBL, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 20 Jun 2016 08:09:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 20 Jun 2016 08:09:33 +0000 (UTC) for IP:'195.135.220.15' DOMAIN:'mx2.suse.de' HELO:'mx2.suse.de' FROM:'hare@suse.de' RCPT:'' X-RedHat-Spam-Score: -3.327 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_PASS) 195.135.220.15 mx2.suse.de 195.135.220.15 mx2.suse.de X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-loop: dm-devel@redhat.com Cc: Hannes Reinecke , dm-devel@redhat.com Subject: [dm-devel] [PATCH 23/26] multipathd: Fixup commandline argument handling X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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], ' '))