public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: kvm-devel <kvm@vger.kernel.org>
Subject: [PATCH 2/3] qemu-kvm: Introduce single vcpu pause/resume
Date: Fri, 23 May 2008 03:59:04 +0200	[thread overview]
Message-ID: <483624E8.8040601@web.de> (raw)
In-Reply-To: <483622F6.8020805@web.de>

Small helpers that allow to pause and resume only a single vcpu thread.

Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
---
 qemu/qemu-kvm.c |   29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

Index: b/qemu/qemu-kvm.c
===================================================================
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -207,6 +207,17 @@ static int all_threads_paused(void)
     return 1;
 }
 
+static void pause_vcpu_thread(int index)
+{
+    assert(cpu_single_env->cpu_index != index);
+
+    vcpu_info[index].stop = 1;
+    pthread_kill(vcpu_info[index].thread, SIG_IPI);
+
+    while (!vcpu_info[index].stopped)
+	qemu_cond_wait(&qemu_pause_cond);
+}
+
 static void pause_all_threads(void)
 {
     int i;
@@ -221,17 +232,21 @@ static void pause_all_threads(void)
 	qemu_cond_wait(&qemu_pause_cond);
 }
 
+static void resume_vcpu_thread(int index)
+{
+    assert(!cpu_single_env);
+
+    vcpu_info[index].stop = 0;
+    vcpu_info[index].stopped = 0;
+    pthread_kill(vcpu_info[index].thread, SIG_IPI);
+}
+
 static void resume_all_threads(void)
 {
     int i;
 
-    assert(!cpu_single_env);
-
-    for (i = 0; i < smp_cpus; ++i) {
-	vcpu_info[i].stop = 0;
-	vcpu_info[i].stopped = 0;
-	pthread_kill(vcpu_info[i].thread, SIG_IPI);
-    }
+    for (i = 0; i < smp_cpus; ++i)
+	resume_vcpu_thread(i);
 }
 
 static void kvm_vm_state_change_handler(void *context, int running)

  parent reply	other threads:[~2008-05-23  1:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-23  1:50 [PATCH 0/3] Rework guest debug interface Jan Kiszka
2008-05-23  1:57 ` [PATCH 1/3] KVM: Rework guest debugging interface Jan Kiszka
2008-05-23  1:59 ` Jan Kiszka [this message]
2008-05-23 15:49   ` [PATCH 2/3] qemu-kvm: Introduce single vcpu pause/resume Jan Kiszka
2008-05-23  2:01 ` [PATCH 3/3] kvm-userspace: Switch to KVM_SET_GUEST_DEBUG Jan Kiszka

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=483624E8.8040601@web.de \
    --to=jan.kiszka@web.de \
    --cc=kvm@vger.kernel.org \
    /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