qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Lluís Vilanova" <vilanova@ac.upc.edu>,
	"Stefan Hajnoczi" <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL 2/4] trace: Lock vCPU list when initializing dynamic tracing state
Date: Mon, 16 Jan 2017 13:44:53 +0000	[thread overview]
Message-ID: <20170116134455.28636-3-stefanha@redhat.com> (raw)
In-Reply-To: <20170116134455.28636-1-stefanha@redhat.com>

From: Lluís Vilanova <vilanova@ac.upc.edu>

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 | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

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;
-- 
2.9.3

  parent reply	other threads:[~2017-01-16 13:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16 13:44 [Qemu-devel] [PULL 0/4] Tracing patches Stefan Hajnoczi
2017-01-16 13:44 ` [Qemu-devel] [PULL 1/4] trace-events: spelling fix Stefan Hajnoczi
2017-01-16 13:44 ` Stefan Hajnoczi [this message]
2017-01-16 13:44 ` [Qemu-devel] [PULL 3/4] trace: Fix dynamic event state on vCPU hot-unplug Stefan Hajnoczi
2017-01-16 13:44 ` [Qemu-devel] [PULL 4/4] trace: Add event "guest_cpu_exit" Stefan Hajnoczi
2017-01-19 10:46 ` [Qemu-devel] [PULL 0/4] Tracing patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170116134455.28636-3-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vilanova@ac.upc.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).