Received: from eggs.gnu.org ([140.186.70.92]:47521) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qhf4V-00029t-9k for qemu-devel@nongnu.org; Fri, 15 Jul 2011 05:52:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qhf4T-0008Iv-6P for qemu-devel@nongnu.org; Fri, 15 Jul 2011 05:52:34 -0400 Received: from mail-fx0-f47.google.com ([209.85.161.47]:62542) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qhf4S-0008Ii-JG for qemu-devel@nongnu.org; Fri, 15 Jul 2011 05:52:32 -0400 Received: by fxg11 with SMTP id 11so2966800fxg.34 for ; Fri, 15 Jul 2011 02:52:31 -0700 (PDT) Date: Fri, 15 Jul 2011 10:41:11 +0100 From: Stefan Hajnoczi Message-ID: <20110715094111.GC6856@stefanha-thinkpad.localdomain> References: <20110628165254.23482.17825.stgit@ginnungagap.bsc.es> <20110628165308.23482.66207.stgit@ginnungagap.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20110628165308.23482.66207.stgit@ginnungagap.bsc.es> Subject: Re: [Qemu-devel] [PATCH v5 02/10] trace: avoid conditional code compilation during option parsing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?Llu=EDs?= Cc: qemu-devel@nongnu.org, chouteau@adacore.com On Tue, Jun 28, 2011 at 06:53:08PM +0200, Lluís wrote: > diff --git a/vl.c b/vl.c > index b2f41fd..b766dc7 100644 > --- a/vl.c > +++ b/vl.c > @@ -2861,14 +2861,23 @@ int main(int argc, char **argv, char **envp) > } > xen_mode = XEN_ATTACH; > break; > -#ifdef CONFIG_SIMPLE_TRACE > case QEMU_OPTION_trace: > opts = qemu_opts_parse(qemu_find_opts("trace"), optarg, 0); > - if (opts) { > - trace_file = qemu_opt_get(opts, "file"); > + if (!opts) { > + exit(1); > } > - break; > +#if defined(CONFIG_TRACE_NOP) > + fprintf(stderr, "qemu: option \"-%s\" is not supported by this tracing backend\n", popt->name); > + exit(1); > #endif > + trace_file = qemu_opt_get(opts, "file"); > +#if !defined(CONFIG_SIMPLE_TRACE) > + if (trace_file) { > + fprintf(stderr, "qemu: suboption \"-%s file\" is not supported by this tracing backend\n", popt->name); > + exit(1); > + } > +#endif This doesn't account for other trace backends. For example with dtrace or ust the option would be compiled in and not rejected at runtime. Instead of checking all possible trace backend CONFIG_* we could always compile the -trace option in. Specific backends can validate their options (if used). This approach will not reject unused options but it's simple and doesn't use #ifdefs. Stefan