qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v4 4/7] trace: [monitor] Use new event control i


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v4 4/7] trace: [monitor] Use new event control interface
Date: Mon, 11 Jun 2012 10:35:07 +0100

On Tue, May 8, 2012 at 3:38 PM, Lluís Vilanova <address@hidden> wrote:
> Signed-off-by: Lluís Vilanova <address@hidden>
> ---
>  monitor.c |   15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 8946a10..86c2538 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -625,10 +625,19 @@ static void do_trace_event_set_state(Monitor *mon, 
> const QDict *qdict)
>  {
>     const char *tp_name = qdict_get_str(qdict, "name");
>     bool new_state = qdict_get_bool(qdict, "option");
> -    int ret = trace_event_set_state(tp_name, new_state);
>
> -    if (!ret) {
> -        monitor_printf(mon, "unknown event name \"%s\"\n", tp_name);
> +    if (trace_event_is_pattern(tp_name)) {
> +        TraceEvent *ev = NULL;
> +        while ((ev = trace_event_pattern(tp_name, ev)) != NULL) {
> +            trace_event_set_state_dynamic(ev, new_state);
> +        }
> +    } else {
> +        TraceEvent *ev = trace_event_name(tp_name);
> +        if (ev == NULL) {
> +            monitor_printf(mon, "unknown event name \"%s\"\n", tp_name);
> +        } else {
> +            trace_event_set_state_dynamic(ev, new_state);
> +        }

Why check for a pattern and split the code in two?  How about just:

while ((ev = trace_event_pattern(tp_name, ev)) != NULL) {
    ...
}

That should cover both the single trace event name case and the wildcard case.

Stefan



reply via email to

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