From: Glauber Costa Date: Wed, 7 Oct 2009 19:38:03 +0000 (-0300) Subject: unlock iothread mutex before running kvm ioctl X-Git-Tag: v0.12.0-rc0~701 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d549db5a732ef2ec145b84c5008a7585cf17cf67;p=users%2Fdwmw2%2Fqemu.git unlock iothread mutex before running kvm ioctl Without this, kvm will hold the mutex while it issues its run ioctl, and never be able to step out of it, causing a deadlock. Patchworks-ID: 35359 Signed-off-by: Glauber Costa Signed-off-by: Anthony Liguori --- diff --git a/kvm-all.c b/kvm-all.c index 5ea0dd8b1e..48ae26caed 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -605,7 +605,9 @@ int kvm_cpu_exec(CPUState *env) } kvm_arch_pre_run(env, run); + qemu_mutex_unlock_iothread(); ret = kvm_vcpu_ioctl(env, KVM_RUN, 0); + qemu_mutex_lock_iothread(); kvm_arch_post_run(env, run); if (ret == -EINTR || ret == -EAGAIN) { diff --git a/qemu-common.h b/qemu-common.h index 12e7dd0ada..820dd37a5d 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -146,6 +146,9 @@ char *qemu_strndup(const char *str, size_t size); void *get_mmap_addr(unsigned long size); +void qemu_mutex_lock_iothread(void); +void qemu_mutex_unlock_iothread(void); + /* Error handling. */ void QEMU_NORETURN hw_error(const char *fmt, ...) diff --git a/vl.c b/vl.c index 374f85be33..afe01af9d7 100644 --- a/vl.c +++ b/vl.c @@ -3560,8 +3560,8 @@ void qemu_notify_event(void) } } -#define qemu_mutex_lock_iothread() do { } while (0) -#define qemu_mutex_unlock_iothread() do { } while (0) +void qemu_mutex_lock_iothread(void) {} +void qemu_mutex_unlock_iothread(void) {} void vm_stop(int reason) { @@ -3760,7 +3760,7 @@ static void qemu_signal_lock(unsigned int msecs) qemu_mutex_unlock(&qemu_fair_mutex); } -static void qemu_mutex_lock_iothread(void) +void qemu_mutex_lock_iothread(void) { if (kvm_enabled()) { qemu_mutex_lock(&qemu_fair_mutex); @@ -3770,7 +3770,7 @@ static void qemu_mutex_lock_iothread(void) qemu_signal_lock(100); } -static void qemu_mutex_unlock_iothread(void) +void qemu_mutex_unlock_iothread(void) { qemu_mutex_unlock(&qemu_global_mutex); }