From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: [PATCH] trace-cmd: Report unknown VMX exit reasons with code Date: Sun, 11 Aug 2013 09:59:43 +0200 Message-ID: <5207446F.1090703@web.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="58q3bbvEswqDtfOFaAqsjCVEhxEi3u7An" Cc: Linux Kernel Mailing List , kvm To: Steven Rostedt Return-path: Received: from mout.web.de ([212.227.17.12]:55798 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752462Ab3HKH7q (ORCPT ); Sun, 11 Aug 2013 03:59:46 -0400 Received: from mchn199C.mchp.siemens.de ([95.157.58.223]) by smtp.web.de (mrweb004) with ESMTPSA (Nemesis) id 0LkEaw-1VjQLK1Bgw-00c801 for ; Sun, 11 Aug 2013 09:59:44 +0200 Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --58q3bbvEswqDtfOFaAqsjCVEhxEi3u7An Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable From: Jan Kiszka Allows to parse the result even if the KVM plugin does not yet understand a specific exit code. Signed-off-by: Jan Kiszka --- plugin_kvm.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugin_kvm.c b/plugin_kvm.c index 8a25cf1..59443e5 100644 --- a/plugin_kvm.c +++ b/plugin_kvm.c @@ -240,9 +240,8 @@ static const char *find_exit_reason(unsigned isa, int= val) for (i =3D 0; strings[i].val >=3D 0; i++) if (strings[i].val =3D=3D val) break; - if (strings[i].str) - return strings[i].str; - return "UNKNOWN"; + + return strings[i].str; } =20 static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *r= ecord, @@ -251,6 +250,7 @@ static int kvm_exit_handler(struct trace_seq *s, stru= ct pevent_record *record, unsigned long long isa; unsigned long long val; unsigned long long info1 =3D 0, info2 =3D 0; + const char *reason; =20 if (pevent_get_field_val(s, event, "exit_reason", record, &val, 1) < 0)= return -1; @@ -258,7 +258,11 @@ static int kvm_exit_handler(struct trace_seq *s, str= uct pevent_record *record, if (pevent_get_field_val(s, event, "isa", record, &isa, 0) < 0) isa =3D 1; =20 - trace_seq_printf(s, "reason %s", find_exit_reason(isa, val)); + reason =3D find_exit_reason(isa, val); + if (reason) + trace_seq_printf(s, "reason %s", reason); + else + trace_seq_printf(s, "reason UNKNOWN (%llu)", val); =20 pevent_print_num_field(s, " rip 0x%lx", event, "guest_rip", record, 1);= =20 --=20 1.7.3.4 --58q3bbvEswqDtfOFaAqsjCVEhxEi3u7An Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlIHRG8ACgkQitSsb3rl5xS0vwCeJa9CrNKwZgpDZRVUnGZuAKWH Q7wAnAj5WSoLeeGml3VMQ9GHaDdvPM4t =AQhH -----END PGP SIGNATURE----- --58q3bbvEswqDtfOFaAqsjCVEhxEi3u7An--