From patchwork Tue Jun 28 21:27:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 641758 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rfJzg199jz9sdg for ; Wed, 29 Jun 2016 07:37:03 +1000 (AEST) Received: from localhost ([::1]:40049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bI0gn-0002Yl-4U for incoming@patchwork.ozlabs.org; Tue, 28 Jun 2016 17:37:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bI0Xp-00084j-5g for qemu-devel@nongnu.org; Tue, 28 Jun 2016 17:27:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bI0Xn-0005RH-3d for qemu-devel@nongnu.org; Tue, 28 Jun 2016 17:27:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36340) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bI0Xm-0005RA-Rr for qemu-devel@nongnu.org; Tue, 28 Jun 2016 17:27:43 -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 6DEF9C01AC40; Tue, 28 Jun 2016 21:27:42 +0000 (UTC) Received: from localhost (ovpn-112-80.ams2.redhat.com [10.36.112.80]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5SLRfdO005265; Tue, 28 Jun 2016 17:27:41 -0400 From: Stefan Hajnoczi To: Date: Tue, 28 Jun 2016 22:27:26 +0100 Message-Id: <1467149250-31165-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1467149250-31165-1-git-send-email-stefanha@redhat.com> References: <1467149250-31165-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 28 Jun 2016 21:27:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/8] trace: enable tracing in qemu-io X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Paolo Bonzini , Stefan Hajnoczi , "Denis V. Lunev" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Denis V. Lunev" Moving trace_init_backends() into trace_opt_parse() is not possible. This should be called after daemonize() in vl.c. Signed-off-by: Denis V. Lunev Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-id: 1466174654-30130-5-git-send-email-den@openvz.org CC: Paolo Bonzini CC: Kevin Wolf Signed-off-by: Stefan Hajnoczi --- qemu-io.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index d977a6e..db129ea 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -18,6 +18,7 @@ #include "qemu/option.h" #include "qemu/config-file.h" #include "qemu/readline.h" +#include "qemu/log.h" #include "qapi/qmp/qstring.h" #include "qom/object_interfaces.h" #include "sysemu/block-backend.h" @@ -253,7 +254,9 @@ static void usage(const char *name) " -k, --native-aio use kernel AIO implementation (on Linux only)\n" " -t, --cache=MODE use the given cache mode for the image\n" " -d, --discard=MODE use the given discard mode for the image\n" -" -T, --trace FILE enable trace events listed in the given file\n" +" -T, --trace [[enable=]][,events=][,file=]\n" +" specify tracing options\n" +" see qemu-img(1) man page for full description\n" " -h, --help display this help and exit\n" " -V, --version output version information and exit\n" "\n" @@ -458,6 +461,7 @@ int main(int argc, char **argv) Error *local_error = NULL; QDict *opts = NULL; const char *format = NULL; + char *trace_file = NULL; #ifdef CONFIG_POSIX signal(SIGPIPE, SIG_IGN); @@ -470,6 +474,7 @@ int main(int argc, char **argv) module_call_init(MODULE_INIT_QOM); qemu_add_opts(&qemu_object_opts); + qemu_add_opts(&qemu_trace_opts); bdrv_init(); while ((c = getopt_long(argc, argv, sopt, lopt, &opt_index)) != -1) { @@ -509,9 +514,8 @@ int main(int argc, char **argv) } break; case 'T': - if (!trace_init_backends()) { - exit(1); /* error message will have been printed */ - } + g_free(trace_file); + trace_file = trace_opt_parse(optarg); break; case 'V': printf("%s version %s\n", progname, QEMU_VERSION); @@ -557,6 +561,12 @@ int main(int argc, char **argv) exit(1); } + if (!trace_init_backends()) { + exit(1); + } + trace_init_file(trace_file); + qemu_set_log(LOG_TRACE); + /* initialize commands */ qemuio_add_command(&quit_cmd); qemuio_add_command(&open_cmd);