]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
trace: Fix dynamic event state on vCPU hot-unplug
authorLluís Vilanova <vilanova@ac.upc.edu>
Mon, 26 Dec 2016 21:24:40 +0000 (22:24 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Mon, 16 Jan 2017 13:40:56 +0000 (13:40 +0000)
We need to disable per-vCPU events on a vCPU that is hot-unplugged to
keep the dynamic event state global counters consistent.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Message-id: 148278748055.1404.1570530281528619895.stgit@fimbulvetr.bsc.es
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
qom/cpu.c
trace/control.c
trace/control.h

index 03d9190f8ce8eb60ed81a1e748869f9e82164955..93e41056d98360cb26c8ce9de4f0ea099b8a2c4b 100644 (file)
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -348,6 +348,8 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
 static void cpu_common_unrealizefn(DeviceState *dev, Error **errp)
 {
     CPUState *cpu = CPU(dev);
+    /* NOTE: latest generic point before the cpu is fully unrealized */
+    trace_fini_vcpu(cpu);
     cpu_exec_unrealizefn(cpu);
 }
 
index 1a7bee6ddcbb00d221522eae1820a585a7e0e2f7..cb79bb17ecf2259c0bbdb339c4263a1254187618 100644 (file)
@@ -259,6 +259,22 @@ void trace_init_file(const char *file)
 #endif
 }
 
+void trace_fini_vcpu(CPUState *vcpu)
+{
+    TraceEventIter iter;
+    TraceEvent *ev;
+
+    trace_event_iter_init(&iter, NULL);
+    while ((ev = trace_event_iter_next(&iter)) != NULL) {
+        if (trace_event_is_vcpu(ev) &&
+            trace_event_get_state_static(ev) &&
+            trace_event_get_vcpu_state_dynamic(vcpu, ev)) {
+            /* must disable to affect the global counter */
+            trace_event_set_vcpu_state_dynamic(vcpu, ev, false);
+        }
+    }
+}
+
 bool trace_init_backends(void)
 {
 #ifdef CONFIG_TRACE_SIMPLE
index ccaeac8552d7ff112de8453e340c233d92a6a553..4ea53e298683b51955a7a2b2bed00b027b44d04f 100644 (file)
@@ -201,6 +201,14 @@ void trace_init_file(const char *file);
  */
 void trace_init_vcpu(CPUState *vcpu);
 
+/**
+ * trace_fini_vcpu:
+ * @vcpu: Removed vCPU.
+ *
+ * Disable dynamic event state for a hot-unplugged vCPU.
+ */
+void trace_fini_vcpu(CPUState *vcpu);
+
 /**
  * trace_list_events:
  *