aboutsummaryrefslogtreecommitdiff
path: root/qemu-img.c
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2016-06-17 17:44:14 +0300
committerStefan Hajnoczi <stefanha@redhat.com>2016-06-28 21:14:12 +0100
commit06a1e0c197ec631a2a3e47a803c52609a8405f69 (patch)
treec405f848a472b13dcbd2b28c9247aace09f31309 /qemu-img.c
parent10985131e337a0c52c5bd1e191fd7867a6ff8d02 (diff)
downloadqemu-06a1e0c197ec631a2a3e47a803c52609a8405f69.zip
qemu-06a1e0c197ec631a2a3e47a803c52609a8405f69.tar.gz
qemu-06a1e0c197ec631a2a3e47a803c52609a8405f69.tar.bz2
trace: enable tracing in qemu-img
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 <eblake@redhat.com>. --Stefan] Signed-off-by: Denis V. Lunev <den@openvz.org> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1466174654-30130-8-git-send-email-den@openvz.org Suggested by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> CC: Paolo Bonzini <pbonzini@redhat.com> CC: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'qemu-img.c')
-rw-r--r--qemu-img.c19
1 files changed, 18 insertions, 1 deletions
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 <getopt.h>
#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=]<pattern>][,events=<file>][,file=<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)) {