From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn3Ni-0004ZR-Tn for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:45:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn3Ne-00027O-JJ for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:45:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55238) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn3Ne-000273-1D for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:45:34 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 848F0923BF for ; Thu, 22 Sep 2016 12:45:33 +0000 (UTC) Date: Thu, 22 Sep 2016 13:45:30 +0100 From: "Daniel P. Berrange" Message-ID: <20160922124530.GM352@redhat.com> Reply-To: "Daniel P. Berrange" References: <1474533652-31170-1-git-send-email-berrange@redhat.com> <1474533652-31170-3-git-send-email-berrange@redhat.com> <87mvj0p1md.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87mvj0p1md.fsf@fimbulvetr.bsc.es> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 02/17] trace: convert code to use event iterators List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Stefan Hajnoczi On Thu, Sep 22, 2016 at 02:20:26PM +0200, Llu=C3=ADs Vilanova wrote: > Daniel P Berrange writes: >=20 > > This converts the HMP/QMP monitor API implementations > > and some internal trace control methods to use the new > > trace event iterator APIs. >=20 > > Reviewed-by: Stefan Hajnoczi > > Signed-off-by: Daniel P. Berrange > > --- > > monitor.c | 26 ++++++++++-------- > > trace/control.c | 85 +++++++++++++++++++++++++++++++----------------= ---------- > > trace/qmp.c | 16 +++++++---- > > 3 files changed, 70 insertions(+), 57 deletions(-) > > diff --git a/trace/qmp.c b/trace/qmp.c > > index 11d2564..88a907b 100644 > > --- a/trace/qmp.c > > +++ b/trace/qmp.c > > @@ -52,8 +52,10 @@ static bool check_events(bool has_vcpu, bool ignor= e_unavailable, bool is_pattern > > return true; > > } else { > > /* error for unavailable events */ > > - TraceEvent *ev =3D NULL; > > - while ((ev =3D trace_event_pattern(name, ev)) !=3D NULL) { > > + TraceEventIter iter; > > + TraceEvent *ev; > > + trace_event_iter_init(&iter, name); > > + while ((ev =3D trace_event_iter_next(&iter)) !=3D NULL) { > > if (!ignore_unavailable && !trace_event_get_state_static= (ev)) { > > error_setg(errp, "event \"%s\" is disabled", trace_e= vent_get_name(ev)); > > return false; > > @@ -69,6 +71,7 @@ TraceEventInfoList *qmp_trace_event_get_state(const= char *name, > > { > > Error *err =3D NULL; > > TraceEventInfoList *events =3D NULL; > > + TraceEventIter iter; > > TraceEvent *ev; > > bool is_pattern =3D trace_event_is_pattern(name); > > CPUState *cpu; > > @@ -86,8 +89,8 @@ TraceEventInfoList *qmp_trace_event_get_state(const= char *name, > > } > =20 > > /* Get states (all errors checked above) */ > > - ev =3D NULL; > > - while ((ev =3D trace_event_pattern(name, ev)) !=3D NULL) { > > + trace_event_iter_init(&iter, is_pattern ? name : NULL); >=20 > I think you should always pass name, otherwise a non-pattern name (when= the user > wants an exact name match) will return the state of all events. Hm, yes, don't know why i did that - its clearly wrong. Regards, Daniel --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vn= c :|