From patchwork Mon Jul 4 07:08:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 9211749 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 73BA160572 for ; Mon, 4 Jul 2016 07:13:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F1BF27C2C for ; Mon, 4 Jul 2016 07:13:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53F6428470; Mon, 4 Jul 2016 07:13:15 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 96D2327C2C for ; Mon, 4 Jul 2016 07:13:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u6479cw6008853; Mon, 4 Jul 2016 03:09:38 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u6479CZu017737 for ; Mon, 4 Jul 2016 03:09:12 -0400 Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6479CwI002718 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 4 Jul 2016 03:09:12 -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 9936F60BA; Mon, 4 Jul 2016 07:09:11 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DC692AD6D; Mon, 4 Jul 2016 07:09:05 +0000 (UTC) From: Hannes Reinecke To: Christophe Varoqui Date: Mon, 4 Jul 2016 09:08:43 +0200 Message-Id: <1467616126-10036-24-git-send-email-hare@suse.de> In-Reply-To: <1467616126-10036-1-git-send-email-hare@suse.de> References: <1467616126-10036-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.30]); Mon, 04 Jul 2016 07:09:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 04 Jul 2016 07:09:11 +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.188 (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.27 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 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 84dd1f8..c4d6f9f 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], ' '))