Commit fff895df authored by Lluís Vilanova's avatar Lluís Vilanova Committed by Stefan Hajnoczi
Browse files

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: default avatarLluís Vilanova <vilanova@ac.upc.edu>
Message-id: 148278747515.1404.6538173443841279200.stgit@fimbulvetr.bsc.es
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent 7de42283
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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;