From patchwork Thu Apr 5 15:51:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 151218 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A2E4EB7063 for ; Sat, 7 Apr 2012 03:24:50 +1000 (EST) Received: from localhost ([::1]:47474 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFowT-0003cR-MG for incoming@patchwork.ozlabs.org; Thu, 05 Apr 2012 11:49:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFovg-0001bP-UP for qemu-devel@nongnu.org; Thu, 05 Apr 2012 11:49:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SFovf-0006kb-3R for qemu-devel@nongnu.org; Thu, 05 Apr 2012 11:48:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43778) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFove-0006kK-Rr for qemu-devel@nongnu.org; Thu, 05 Apr 2012 11:48:55 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q35FmqHN003062 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 5 Apr 2012 11:48:52 -0400 Received: from dhcp-5-188.str.redhat.com (vpn1-4-41.ams2.redhat.com [10.36.4.41]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q35FmiHI007630; Thu, 5 Apr 2012 11:48:50 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Thu, 5 Apr 2012 17:51:42 +0200 Message-Id: <1333641144-13612-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1333641144-13612-1-git-send-email-kwolf@redhat.com> References: <1333641144-13612-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 04/46] qemu-io: add option to enable tracing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stefan Hajnoczi It can be useful to enable QEMU tracing when trying out block layer interfaces via qemu-io. Tracing can be enabled using the new -T FILE option where the given file contains a list of trace events to enable (just like the qemu --trace events=FILE option). $ echo qemu_vfree >my-events $ ./qemu-io -T my-events ... Remember to use ./configure --enable-trace-backend=BACKEND when building qemu-io. Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- qemu-io.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index 3189530..e6fcd77 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -17,6 +17,7 @@ #include "qemu-common.h" #include "block_int.h" #include "cmd.h" +#include "trace/control.h" #define VERSION "0.0.1" @@ -1783,6 +1784,7 @@ static void usage(const char *name) " -g, --growable allow file to grow (only applies to protocols)\n" " -m, --misalign misalign allocations for O_DIRECT\n" " -k, --native-aio use kernel AIO implementation (on Linux only)\n" +" -T, --trace FILE enable trace events listed in the given file\n" " -h, --help display this help and exit\n" " -V, --version output version information and exit\n" "\n", @@ -1794,7 +1796,7 @@ int main(int argc, char **argv) { int readonly = 0; int growable = 0; - const char *sopt = "hVc:rsnmgk"; + const char *sopt = "hVc:rsnmgkT:"; const struct option lopt[] = { { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, @@ -1806,6 +1808,7 @@ int main(int argc, char **argv) { "misalign", 0, NULL, 'm' }, { "growable", 0, NULL, 'g' }, { "native-aio", 0, NULL, 'k' }, + { "trace", 1, NULL, 'T' }, { NULL, 0, NULL, 0 } }; int c; @@ -1837,6 +1840,11 @@ int main(int argc, char **argv) case 'k': flags |= BDRV_O_NATIVE_AIO; break; + case 'T': + if (!trace_backend_init(optarg, NULL)) { + exit(1); /* error message will have been printed */ + } + break; case 'V': printf("%s version %s\n", progname, VERSION); exit(0);