From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eduardo Habkost Subject: [PATCH 2/2] kvmtrace: Add -f option to clean up existing trace setup Date: Wed, 22 Oct 2008 15:35:28 -0200 Message-ID: <1224696928-22187-3-git-send-email-ehabkost@redhat.com> References: <1224696928-22187-1-git-send-email-ehabkost@redhat.com> Cc: kvm@vger.kernel.org, Eduardo Habkost To: Avi Kivity Return-path: Received: from mx2.redhat.com ([66.187.237.31]:37190 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757598AbYJVRfq (ORCPT ); Wed, 22 Oct 2008 13:35:46 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id m9MHZkOP025018 for ; Wed, 22 Oct 2008 13:35:46 -0400 In-Reply-To: <1224696928-22187-1-git-send-email-ehabkost@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: If kvmtrace crashes or gets killed while collecting trace data, stale trace setup information may be enabled, and currently there is no way to force the previous trace setup to be overwritten or disabled. The -f option will allow the user to forcibly clean up an existing trace setup before enabling trace, on those cases. Signed-off-by: Eduardo Habkost --- user/kvmtrace.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/user/kvmtrace.c b/user/kvmtrace.c index 5d154c1..f06574f 100644 --- a/user/kvmtrace.c +++ b/user/kvmtrace.c @@ -54,7 +54,7 @@ static char kvmtrace_version[] = "0.1"; #define max(a, b) ((a) > (b) ? (a) : (b)) -#define S_OPTS "r:o:w:?Vb:n:D:" +#define S_OPTS "r:o:w:?Vb:n:D:f" static struct option l_opts[] = { { .name = "relay", @@ -155,6 +155,7 @@ static int stop_watch; static unsigned long buf_size = BUF_SIZE; static unsigned long buf_nr = BUF_NR; static unsigned int page_size; +static int force_disable; #define for_each_cpu_online(cpu) \ for (cpu = 0; cpu < ncpus; cpu++) @@ -481,6 +482,9 @@ static int start_trace(void) kuts.buf_size = trace_information.buf_size = buf_size; kuts.buf_nr = trace_information.buf_nr = buf_nr; + if (force_disable) + disable_trace(); + if (ioctl(trace_information.fd , KVM_TRACE_ENABLE, &kuts) < 0) { perror("KVM_TRACE_ENABLE"); close(fd); @@ -600,6 +604,7 @@ static char usage_str[] = \ "\t-w Stop after defined time, in seconds\n" \ "\t-b Sub buffer size in KiB\n" \ "\t-n Number of sub buffers\n" \ + "\t-f Force: cleanup previous tracing setup before enabling tracing\n" \ "\t-V Print program version info\n\n"; static void show_usage(char *prog) @@ -614,6 +619,9 @@ void parse_args(int argc, char **argv) while ((c = getopt_long(argc, argv, S_OPTS, l_opts, NULL)) >= 0) { switch (c) { + case 'f': + force_disable = 1; + break; case 'r': debugfs_path = optarg; break; -- 1.5.6.rc3.11.g5f54d