From patchwork Tue Jun 28 21:27:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 641753 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 3rfJpn5MG9z9sdg for ; Wed, 29 Jun 2016 07:29:21 +1000 (AEST) Received: from localhost ([::1]:40011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bI0ZL-0000sE-Lu for incoming@patchwork.ozlabs.org; Tue, 28 Jun 2016 17:29:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bI0Xv-0008B1-Eb for qemu-devel@nongnu.org; Tue, 28 Jun 2016 17:27:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bI0Xu-0005Sb-8y for qemu-devel@nongnu.org; Tue, 28 Jun 2016 17:27:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33459) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bI0Xu-0005SU-1N for qemu-devel@nongnu.org; Tue, 28 Jun 2016 17:27:50 -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 9D5DD1176A9; Tue, 28 Jun 2016 21:27:49 +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 u5SLRlYn005287; Tue, 28 Jun 2016 17:27:48 -0400 From: Stefan Hajnoczi To: Date: Tue, 28 Jun 2016 22:27:29 +0100 Message-Id: <1467149250-31165-8-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.38]); Tue, 28 Jun 2016 21:27:49 +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 7/8] trace: enable tracing in qemu-img 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" The command will work this way: qemu-img --trace "qcow2*" create -f qcow2 1.img 64G [Quote "qcow2*" to protect against shell globbing as suggested by Eric Blake . --Stefan] Signed-off-by: Denis V. Lunev Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-id: 1466174654-30130-8-git-send-email-den@openvz.org Suggested by: Daniel P. Berrange Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi CC: Paolo Bonzini CC: Kevin Wolf Signed-off-by: Stefan Hajnoczi --- Makefile | 2 +- qemu-img.c | 19 ++++++++++++++++++- qemu-img.texi | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2d31af0..9d12dc6 100644 --- a/Makefile +++ b/Makefile @@ -566,7 +566,7 @@ qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi " GEN $@") qemu.1: qemu-option-trace.texi -qemu-img.1: qemu-img.texi qemu-img-cmds.texi +qemu-img.1: qemu-img.texi qemu-option-trace.texi qemu-img-cmds.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-img.pod && \ $(POD2MAN) --section=1 --center=" " --release=" " qemu-img.pod > $@, \ diff --git a/qemu-img.c b/qemu-img.c index 2194c2d..3322a1e 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -32,6 +32,7 @@ #include "qemu/config-file.h" #include "qemu/option.h" #include "qemu/error-report.h" +#include "qemu/log.h" #include "qom/object_interfaces.h" #include "sysemu/sysemu.h" #include "sysemu/block-backend.h" @@ -39,6 +40,7 @@ #include "block/blockjob.h" #include "block/qapi.h" #include "crypto/init.h" +#include "trace/control.h" #include #define QEMU_IMG_VERSION "qemu-img version " QEMU_VERSION QEMU_PKGVERSION \ @@ -96,6 +98,8 @@ static void QEMU_NORETURN help(void) "\n" " '-h', '--help' display this help and exit\n" " '-V', '--version' output version information and exit\n" + " '-T', '--trace' [[enable=]][,events=][,file=]\n" + " specify tracing options\n" "\n" "Command syntax:\n" #define DEF(option, callback, arg_string) \ @@ -3806,10 +3810,12 @@ int main(int argc, char **argv) const img_cmd_t *cmd; const char *cmdname; Error *local_error = NULL; + char *trace_file = NULL; int c; static const struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, + {"trace", required_argument, NULL, 'T'}, {0, 0, 0, 0} }; @@ -3835,8 +3841,9 @@ int main(int argc, char **argv) qemu_add_opts(&qemu_object_opts); qemu_add_opts(&qemu_source_opts); + qemu_add_opts(&qemu_trace_opts); - while ((c = getopt_long(argc, argv, "+hV", long_options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "+hVT:", long_options, NULL)) != -1) { switch (c) { case 'h': help(); @@ -3844,6 +3851,10 @@ int main(int argc, char **argv) case 'V': printf(QEMU_IMG_VERSION); return 0; + case 'T': + g_free(trace_file); + trace_file = trace_opt_parse(optarg); + break; } } @@ -3857,6 +3868,12 @@ int main(int argc, char **argv) argv += optind; optind = 1; + if (!trace_init_backends()) { + exit(1); + } + trace_init_file(trace_file); + qemu_set_log(LOG_TRACE); + /* find the command */ for (cmd = img_cmds; cmd->name != NULL; cmd++) { if (!strcmp(cmdname, cmd->name)) { diff --git a/qemu-img.texi b/qemu-img.texi index f1b874d..449a19c 100644 --- a/qemu-img.texi +++ b/qemu-img.texi @@ -22,6 +22,9 @@ Standard options: Display this help and exit @item -V, --version Display version information and exit +@item -T, --trace [[enable=]@var{pattern}][,events=@var{file}][,file=@var{file}] +@findex --trace +@include qemu-option-trace.texi @end table The following commands are supported: