From patchwork Fri Jun 17 14:44:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 9184451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9A1C9601C0 for ; Fri, 17 Jun 2016 15:43:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 582E2283ED for ; Fri, 17 Jun 2016 15:43:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B682283EF; Fri, 17 Jun 2016 15:43:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C37C4283ED for ; Fri, 17 Jun 2016 15:43:02 +0000 (UTC) Received: from localhost ([::1]:58484 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDvvC-0001eG-3e for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 Jun 2016 11:43:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDv0i-0008G3-Lm for qemu-devel@nongnu.org; Fri, 17 Jun 2016 10:44:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDv0g-0007Mu-FM for qemu-devel@nongnu.org; Fri, 17 Jun 2016 10:44:39 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:3156 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDv0X-0007L6-R1; Fri, 17 Jun 2016 10:44:30 -0400 Received: from irbis.sw.ru ([10.30.2.139]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id u5HEiEkp004617; Fri, 17 Jun 2016 17:44:27 +0300 (MSK) From: "Denis V. Lunev" To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Fri, 17 Jun 2016 17:44:14 +0300 Message-Id: <1466174654-30130-8-git-send-email-den@openvz.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1466174654-30130-1-git-send-email-den@openvz.org> References: <1466174654-30130-1-git-send-email-den@openvz.org> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 7/7] 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 , "Denis V. Lunev" , stefanha@redhat.com, Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The command will work this way: qemu-img --trace qcow2* create -f qcow2 1.img 64G Signed-off-by: Denis V. Lunev Suggested by: Daniel P. Berrange Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi CC: Paolo Bonzini CC: Kevin Wolf --- Makefile | 2 +- qemu-img.c | 19 ++++++++++++++++++- qemu-img.texi | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f9d369b..2b00a37 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: