From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2aFg-0000b1-Nb for qemu-devel@nongnu.org; Tue, 17 May 2016 04:21:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2aFe-0004Ci-AP for qemu-devel@nongnu.org; Tue, 17 May 2016 04:21:15 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:37717 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2aFd-000467-SH for qemu-devel@nongnu.org; Tue, 17 May 2016 04:21:14 -0400 From: "Denis V. Lunev" Date: Tue, 17 May 2016 11:20:31 +0300 Message-Id: <1463473231-491-4-git-send-email-den@openvz.org> In-Reply-To: <1463473231-491-1-git-send-email-den@openvz.org> References: <1463473231-491-1-git-send-email-den@openvz.org> Subject: [Qemu-devel] [PATCH 3/3] trace: enable tracing in qemu-nbd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: den@openvz.org, Paolo Bonzini , Stefan Hajnoczi , Kevin Wolf Pls note, trace_init_backends() must be called in the final process, i.e. after daemonization. This is necessary to keep tracing thread in the proper process. Signed-off-by: Denis V. Lunev CC: Paolo Bonzini CC: Stefan Hajnoczi CC: Kevin Wolf --- qemu-nbd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qemu-nbd.c b/qemu-nbd.c index 3e54113..8e59098 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -26,12 +26,14 @@ #include "qemu/main-loop.h" #include "qemu/error-report.h" #include "qemu/config-file.h" +#include "qemu/log.h" #include "block/snapshot.h" #include "qapi/util.h" #include "qapi/qmp/qstring.h" #include "qom/object_interfaces.h" #include "io/channel-socket.h" #include "crypto/init.h" +#include "trace/control.h" #include #include @@ -87,6 +89,7 @@ static void usage(const char *name) "General purpose options:\n" " --object type,id=ID,... define an object such as 'secret' for providing\n" " passwords and/or encryption keys\n" +" -T, --trace FILE enable trace events listed in the given file\n" #ifdef __linux__ "Kernel NBD client support:\n" " -c, --connect=DEV connect FILE to the local NBD device DEV\n" @@ -497,6 +500,7 @@ int main(int argc, char **argv) { "export-name", required_argument, NULL, 'x' }, { "tls-creds", required_argument, NULL, QEMU_NBD_OPT_TLSCREDS }, { "image-opts", no_argument, NULL, QEMU_NBD_OPT_IMAGE_OPTS }, + { "trace", required_argument, NULL, 'T' }, { NULL, 0, NULL, 0 } }; int ch; @@ -517,6 +521,7 @@ int main(int argc, char **argv) const char *tlscredsid = NULL; bool imageOpts = false; bool writethrough = true; + char *trace_file = NULL; /* The client thread uses SIGTERM to interrupt the server. A signal * handler ensures that "qemu-nbd -v -c" exits with a nice status code. @@ -533,6 +538,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); qemu_init_exec_dir(argv[0]); while ((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) { @@ -705,6 +711,9 @@ int main(int argc, char **argv) case QEMU_NBD_OPT_IMAGE_OPTS: imageOpts = true; break; + case 'T': + trace_file = trace_opt_parse(optarg, trace_file); + break; } } @@ -720,6 +729,12 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } + if (!trace_init_backends()) { + exit(1); + } + trace_init_file(trace_file); + qemu_set_log(LOG_TRACE); + if (tlscredsid) { if (sockpath) { error_report("TLS is only supported with IPv4/IPv6"); -- 2.1.4