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 <[EMAIL PROTECTED]>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to