]> Git Repo - qemu.git/commitdiff
trace: Properly initialize dynamic event states in hot-plugged vCPUs
authorLluís Vilanova <[email protected]>
Mon, 19 Sep 2016 12:55:07 +0000 (14:55 +0200)
committerStefan Hajnoczi <[email protected]>
Wed, 28 Sep 2016 18:17:55 +0000 (19:17 +0100)
Every time a vCPU is hot-plugged, it will "inherit" its tracing state
from the global state array. That is, if *any* existing vCPU has an
event enabled, new vCPUs will have too.

Signed-off-by: Lluís Vilanova <[email protected]>
Message-id: 147428970768.15111.7664565956870423529[email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
bsd-user/main.c
linux-user/main.c
qom/cpu.c
stubs/trace-control.c
trace/control-target.c
trace/control.c
trace/control.h
vl.c

index 0fb08e405d5f976929a33c3a330de97a782659e1..f58bb435795262f6dc53104aa914400bbd08cba2 100644 (file)
@@ -1133,7 +1133,6 @@ int main(int argc, char **argv)
         gdbserver_start (gdbstub_port);
         gdb_handlesig(cpu, 0);
     }
-    trace_init_vcpu_events();
     cpu_loop(env);
     /* never exits */
     return 0;
index 8daebe076705e5292957ce4d75ee75129a226a31..424f2b6f7b8343b4d5d2da976ee61ad710d95d70 100644 (file)
@@ -4800,7 +4800,6 @@ int main(int argc, char **argv, char **envp)
         }
         gdb_handlesig(cpu, 0);
     }
-    trace_init_vcpu_events();
     cpu_loop(env);
     /* never exits */
     return 0;
index f783b5a6bd68e45d8fd00b5ee437d8b829e3c97a..f87fffabd12e3c93ed702948bcb83387f6d8d6de 100644 (file)
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -333,6 +333,9 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
         cpu_synchronize_post_init(cpu);
         cpu_resume(cpu);
     }
+
+    /* NOTE: latest generic point where the cpu is fully realized */
+    trace_init_vcpu(cpu);
 }
 
 static void cpu_common_initfn(Object *obj)
index 2dfcd9fb2bd706c07d2c51d89961e6f945675343..f765a02018890c8df5996232ce9b6dcead23fc4c 100644 (file)
@@ -44,3 +44,9 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
     /* should never be called on non-target binaries */
     abort();
 }
+
+void trace_init_vcpu(CPUState *vcpu)
+{
+    /* should never be called on non-target binaries */
+    abort();
+}
index 72081e2a34f7df1b5a8e2bba495bba0c1957b831..3b7d99b44cf831815be88abb0d825484356939c5 100644 (file)
@@ -81,3 +81,40 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
         }
     }
 }
+
+static bool adding_first_cpu(void)
+{
+    CPUState *cpu;
+    size_t count = 0;
+    CPU_FOREACH(cpu) {
+        count++;
+        if (count > 1) {
+            return false;
+        }
+    }
+    return true;
+}
+
+void trace_init_vcpu(CPUState *vcpu)
+{
+    TraceEvent *ev = NULL;
+
+    while ((ev = trace_event_pattern("*", ev)) != NULL) {
+        if (trace_event_is_vcpu(ev) &&
+            trace_event_get_state_static(ev) &&
+            trace_event_get_state_dynamic(ev)) {
+            TraceEventID id = trace_event_get_id(ev);
+            if (adding_first_cpu()) {
+                /* check preconditions */
+                assert(trace_events_dstate[id] == 1);
+                /* disable early-init state ... */
+                trace_events_dstate[id] = 0;
+                trace_events_enabled_count--;
+                /* ... and properly re-enable */
+                trace_event_set_vcpu_state_dynamic(vcpu, ev, true);
+            } else {
+                trace_event_set_vcpu_state_dynamic(vcpu, ev, true);
+            }
+        }
+    }
+}
index 05d85accbd7c82b9bae1a638796704600d906857..10b3e9babad6365636c0ec4747a666eaa1ee8a65 100644 (file)
@@ -269,22 +269,3 @@ char *trace_opt_parse(const char *optarg)
 
     return trace_file;
 }
-
-void trace_init_vcpu_events(void)
-{
-    TraceEvent *ev = NULL;
-    while ((ev = trace_event_pattern("*", ev)) != NULL) {
-        if (trace_event_is_vcpu(ev) &&
-            trace_event_get_state_static(ev) &&
-            trace_event_get_state_dynamic(ev)) {
-            TraceEventID id = trace_event_get_id(ev);
-            /* check preconditions */
-            assert(trace_events_dstate[id] == 1);
-            /* disable early-init state ... */
-            trace_events_dstate[id] = 0;
-            trace_events_enabled_count--;
-            /* ... and properly re-enable */
-            trace_event_set_state_dynamic(ev, true);
-        }
-    }
-}
index 27a16fc955704c6ce91486819b6d9d39418056e6..a22d11242e0fb211c36ac9135b9d66ad77b70391 100644 (file)
@@ -238,6 +238,14 @@ bool trace_init_backends(void);
  */
 void trace_init_file(const char *file);
 
+/**
+ * trace_init_vcpu:
+ * @vcpu: Added vCPU.
+ *
+ * Set initial dynamic event state for a hot-plugged vCPU.
+ */
+void trace_init_vcpu(CPUState *vcpu);
+
 /**
  * trace_list_events:
  *
@@ -269,17 +277,6 @@ extern QemuOptsList qemu_trace_opts;
  */
 char *trace_opt_parse(const char *optarg);
 
-/**
- * trace_init_vcpu_events:
- *
- * Re-synchronize initial event state with vCPUs (which can be created after
- * trace_init_events()).
- *
- * Precondition: event states won't be changed between trace_enable_events() and
- * trace_init_vcpu_events() (e.g., through QMP).
- */
-void trace_init_vcpu_events(void);
-
 
 #include "trace/control-internal.h"
 
diff --git a/vl.c b/vl.c
index eafda8d737310db0efe2dd91926877183d27f94a..04fc1725f3293950ed585847c94b0a28c30444d5 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -4658,7 +4658,6 @@ int main(int argc, char **argv, char **envp)
 
     os_setup_post();
 
-    trace_init_vcpu_events();
     main_loop();
     replay_disable_events();
     iothread_stop_all();
This page took 0.035774 seconds and 4 git commands to generate.