]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
trace: Lock vCPU list when initializing dynamic tracing state
authorLluís Vilanova <vilanova@ac.upc.edu>
Mon, 26 Dec 2016 21:24:35 +0000 (22:24 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Mon, 16 Jan 2017 13:40:56 +0000 (13:40 +0000)
Fixes potential corruption when a vCPU is hot-(un)plugged while
initializing the current one.

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

index 7ebf6e0bcb91eb4d69343b1e5a2d8fb662db4dcf..e2e138a3f0de90016ced9aff5bc3814ffdbb6f0c 100644 (file)
@@ -79,7 +79,7 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
     }
 }
 
-static bool adding_first_cpu(void)
+static bool adding_first_cpu1(void)
 {
     CPUState *cpu;
     size_t count = 0;
@@ -92,6 +92,15 @@ static bool adding_first_cpu(void)
     return true;
 }
 
+static bool adding_first_cpu(void)
+{
+    bool res;
+    cpu_list_lock();
+    res = adding_first_cpu1();
+    cpu_list_unlock();
+    return res;
+}
+
 void trace_init_vcpu(CPUState *vcpu)
 {
     TraceEventIter iter;