Skip to contentSkip to conversation

kvm tools: Fix 'lkvm stop' when guest is pasued.

PATCH New Asias He 1 participant 2 messages Dec 21, 2011 KVM

lore
Share & tools
lore

Asias He

author
#0 lore raw

PATCH 1/2 kvm tools: Fix 'lkvm stop' when guest is pasued.

Currently, 'lkvm stop' can not stop a pasued guest becasue guest is blocked on the pause_lock.

This patch fixes it by un-pausing the guest before stops it.

The pthread_kill() call is not needed.

---
 tools/kvm/kvm-cpu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/kvm/kvm-cpu.c +1 -1
index 52db84a..bdefa09 100644
@@ -39,7 +39,7 @@ static void kvm_cpu_signal_handler(int signum)
 	if (signum == SIGKVMEXIT) {
 		if (current_kvm_cpu && current_kvm_cpu->is_running) {
 			current_kvm_cpu->is_running = false;
-			pthread_kill(pthread_self(), SIGKVMEXIT);
+			kvm__continue();
 		}
 	} else if (signum == SIGKVMPAUSE) {
 		current_kvm_cpu->paused = 1;
Signature · 1 line
1.7.7.3
author
#1 lore raw

PATCH 2/2 kvm tools: Do not run guest if it is stopped.

If the guest is stopped, there is no need to run it. This patch fixes this when running 'lkvm stop'.

KVM_RUN failed: Bad address

---
 tools/kvm/kvm-cpu.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
tools/kvm/kvm-cpu.c +3 -0
index bdefa09..12791dd 100644
@@ -29,6 +29,9 @@ void kvm_cpu__run(struct kvm_cpu *vcpu)
 {
 	int err;
 
+	if (!vcpu->is_running)
+		return;
+
 	err = ioctl(vcpu->vcpu_fd, KVM_RUN, 0);
 	if (err < 0 && (errno != EINTR && errno != EAGAIN))
 		die_perror("KVM_RUN failed");
Signature · 1 line
1.7.7.3