From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCVCP-0003hb-Qt for qemu-devel@nongnu.org; Mon, 13 Jun 2016 12:58:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCVCL-00087G-7o for qemu-devel@nongnu.org; Mon, 13 Jun 2016 12:58:53 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:26603 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCVCK-000847-Q2 for qemu-devel@nongnu.org; Mon, 13 Jun 2016 12:58:49 -0400 From: "Denis V. Lunev" Date: Mon, 13 Jun 2016 19:58:25 +0300 Message-Id: <1465837105-11206-7-git-send-email-den@openvz.org> In-Reply-To: <1465837105-11206-1-git-send-email-den@openvz.org> References: <1465837105-11206-1-git-send-email-den@openvz.org> Subject: [Qemu-devel] [PATCH 6/6] trace: enable tracing in qemu-img List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, qemu-block@nongnu.org Cc: eblake@redhat.com, "Denis V. Lunev" , Paolo Bonzini , Stefan Hajnoczi , Kevin Wolf 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 CC: Eric Blake CC: Paolo Bonzini CC: Stefan Hajnoczi CC: Kevin Wolf --- Makefile | 2 +- qemu-img.c | 18 +++++++++++++++++- qemu-img.texi | 2 ++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 49b9650..327c04f 100644 --- a/Makefile +++ b/Makefile @@ -546,7 +546,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 d22ebdf..128579f 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -31,6 +31,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" @@ -38,6 +39,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 \ @@ -92,6 +94,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) \ @@ -3476,10 +3480,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} }; @@ -3505,8 +3511,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(); @@ -3514,6 +3521,9 @@ int main(int argc, char **argv) case 'V': printf(QEMU_IMG_VERSION); return 0; + case 'T': + trace_file = trace_opt_parse(optarg, trace_file); + break; } } @@ -3527,6 +3537,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 5a47810..aa974b6 100644 --- a/qemu-img.texi +++ b/qemu-img.texi @@ -22,6 +22,8 @@ Standard options: Display this help and exit @item -V, --version Display version information and exit +@item -T, --trace [events=@var{file}][,file=@var{file}] +@include qemu-option-trace.texi @end table The following commands are supported: -- 2.5.0