qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v5 02/10] trace: avoid conditional code compilat


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v5 02/10] trace: avoid conditional code compilation during option parsing
Date: Fri, 15 Jul 2011 10:41:11 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]