Re: [kvm-devel] [PATCH] Fix QEMU vcpu thread race with apic_reset

2008-04-28 Thread Ulrich Drepper
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > @@ -369,6 +372,10 @@ static void *ap_main_loop(void *_env) > sigfillset(&signals); > sigprocmask(SIG_BLOCK, &signals, NULL); > kvm_create_vcpu(kvm_context, env->cpu_index); > +pthread_mutex_lock(&vcpu_mutex); > +vcpu->created =

Re: [kvm-devel] [PATCH] Fix QEMU vcpu thread race with apic_reset

2008-04-28 Thread Anthony Liguori
Ryan Harper wrote: > * Avi Kivity <[EMAIL PROTECTED]> [2008-04-26 02:23]: > >> Please reuse qemu_mutex for this, no need for a new one. >> > > I'm having a little trouble wrapping my head around all of the locking > here. If I avoid qemu_mutex and use a new one, I've got everything > worki

Re: [kvm-devel] [PATCH] Fix QEMU vcpu thread race with apic_reset

2008-04-28 Thread Ryan Harper
* Avi Kivity <[EMAIL PROTECTED]> [2008-04-26 02:23]: > > Please reuse qemu_mutex for this, no need for a new one. I'm having a little trouble wrapping my head around all of the locking here. If I avoid qemu_mutex and use a new one, I've got everything working. However, attemping to use qemu_mut

Re: [kvm-devel] [PATCH] Fix QEMU vcpu thread race with apic_reset

2008-04-26 Thread Anthony Liguori
Ulrich Drepper wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Ryan Harper wrote: > >> @@ -388,9 +395,10 @@ static void kvm_add_signal(struct qemu_kvm_signal_table >> *sigtab, int signum) >> >> void kvm_init_new_ap(int cpu, CPUState *env) >> { >> +pthread_mutex_lock(&vcpu_m

Re: [kvm-devel] [PATCH] Fix QEMU vcpu thread race with apic_reset

2008-04-26 Thread Ulrich Drepper
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ryan Harper wrote: > @@ -388,9 +395,10 @@ static void kvm_add_signal(struct qemu_kvm_signal_table > *sigtab, int signum) > > void kvm_init_new_ap(int cpu, CPUState *env) > { > +pthread_mutex_lock(&vcpu_mutex); > pthread_create(&vcpu_info[

Re: [kvm-devel] [PATCH] Fix QEMU vcpu thread race with apic_reset

2008-04-26 Thread Ulrich Drepper
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ryan Harper wrote: > +/* block until cond_wait occurs */ > +pthread_mutex_lock(&vcpu_mutex); > +/* now we can signal */ > +pthread_cond_signal(&qemu_vcpuup_cond); > +pthread_mutex_unlock(&vcpu_mutex); It is not necessary to take th

Re: [kvm-devel] [PATCH] Fix QEMU vcpu thread race with apic_reset

2008-04-26 Thread Avi Kivity
Ryan Harper wrote: > There is a race between when the vcpu thread issues a create ioctl and when > apic_reset() gets called resulting in getting a badfd error. > > The problem is indeed there, but the fix is wrong: > main threadvcpu thread > diff --git a/qemu/qemu-kvm.c b/qemu/

Re: [kvm-devel] [PATCH] Fix QEMU vcpu thread race with apic_reset

2008-04-25 Thread Ryan Harper
* Ryan Harper <[EMAIL PROTECTED]> [2008-04-26 00:27]: > There is a race between when the vcpu thread issues a create ioctl and when > apic_reset() gets called resulting in getting a badfd error. > > main threadvcpu thread guilt refresh clipped my text short. main thread

[kvm-devel] [PATCH] Fix QEMU vcpu thread race with apic_reset

2008-04-25 Thread Ryan Harper
There is a race between when the vcpu thread issues a create ioctl and when apic_reset() gets called resulting in getting a badfd error. main threadvcpu thread diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c index 78127de..3513e8c 100644 --- a/qemu/qemu-kvm.c +++ b/qemu/qemu-kvm.c @