From patchwork Sat Jan 4 17:19:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 3433961 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E6D1C9F295 for ; Sat, 4 Jan 2014 17:21:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 354052015A for ; Sat, 4 Jan 2014 17:21:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 760D920145 for ; Sat, 4 Jan 2014 17:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754890AbaADRUw (ORCPT ); Sat, 4 Jan 2014 12:20:52 -0500 Received: from mout.web.de ([212.227.15.4]:58216 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754691AbaADRUH (ORCPT ); Sat, 4 Jan 2014 12:20:07 -0500 Received: from mchn199C.home ([95.157.58.223]) by smtp.web.de (mrweb004) with ESMTPSA (Nemesis) id 0Lr59f-1VVg3S3uz5-00efOp for ; Sat, 04 Jan 2014 18:20:06 +0100 From: Jan Kiszka To: Steven Rostedt Cc: linux-trace-users@vger.kernel.org, Linux Kernel Mailing List , kvm Subject: [PATCH 2/3] trace-cmd: Factor out print_exit_reason in kvm plugin Date: Sat, 4 Jan 2014 18:19:49 +0100 Message-Id: <619c418c8af87f03027b8c8013b0443996605700.1388855989.git.jan.kiszka@web.de> X-Mailer: git-send-email 1.8.1.1.298.ge7eed54 In-Reply-To: References: In-Reply-To: References: X-Provags-ID: V03:K0:FnJam81wAUWVvgK41t6B975Bn/S2N7hn7iMXa5GBZJBxyW7Pc59 KZLpHivSOzd2JFv+XLpskf0JCopJ96GnNFew/XwbhLIOOvSAfUEDo/wREgLEbRHouERBHJ+ lE7zAj/RaXiaZ9VAR/NMYcNoQGvMHnPP7w17UtcTOCxIXwFtizQMJavBzh/gqJ12dsswMRe kHhyvxeqy2jRH0Vn7w25A== Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jan Kiszka We will reuse it for nested vmexit tracepoints. Signed-off-by: Jan Kiszka --- plugin_kvm.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugin_kvm.c b/plugin_kvm.c index 59443e5..c407e55 100644 --- a/plugin_kvm.c +++ b/plugin_kvm.c @@ -244,15 +244,14 @@ static const char *find_exit_reason(unsigned isa, int val) return strings[i].str; } -static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record, - struct event_format *event, void *context) +static int print_exit_reason(struct trace_seq *s, struct pevent_record *record, + struct event_format *event, const char *field) { unsigned long long isa; unsigned long long val; - unsigned long long info1 = 0, info2 = 0; const char *reason; - if (pevent_get_field_val(s, event, "exit_reason", record, &val, 1) < 0) + if (pevent_get_field_val(s, event, field, record, &val, 1) < 0) return -1; if (pevent_get_field_val(s, event, "isa", record, &isa, 0) < 0) @@ -263,6 +262,16 @@ static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record, trace_seq_printf(s, "reason %s", reason); else trace_seq_printf(s, "reason UNKNOWN (%llu)", val); + return 0; +} + +static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record, + struct event_format *event, void *context) +{ + unsigned long long info1 = 0, info2 = 0; + + if (print_exit_reason(s, record, event, "exit_reason") < 0) + return -1; pevent_print_num_field(s, " rip 0x%lx", event, "guest_rip", record, 1);