aboutsummaryrefslogtreecommitdiff
path: root/trace/control-target.c
diff options
context:
space:
mode:
authorLluís Vilanova <vilanova@ac.upc.edu>2016-12-26 22:24:35 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2017-01-16 13:40:56 +0000
commitfff895dfdbe41965f7b0430e3d9e8b7bd8fc8eda (patch)
treecdf9540d888b9507b5de6228a0314c40449cedd8 /trace/control-target.c
parent7de422834447b635fefe3a7a250e3b581ce4ae6e (diff)
downloadqemu-fff895dfdbe41965f7b0430e3d9e8b7bd8fc8eda.zip
qemu-fff895dfdbe41965f7b0430e3d9e8b7bd8fc8eda.tar.gz
qemu-fff895dfdbe41965f7b0430e3d9e8b7bd8fc8eda.tar.bz2
trace: Lock vCPU list when initializing dynamic tracing state
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>
Diffstat (limited to 'trace/control-target.c')
-rw-r--r--trace/control-target.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/trace/control-target.c b/trace/control-target.c
index 7ebf6e0..e2e138a 100644
--- a/trace/control-target.c
+++ b/trace/control-target.c
@@ -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;