Re: [PATCH] execute kvm_init_vcpu in the end of pc_new_cpu

Marcelo Tosatti
2009-05-06T13:53:49Z

On Tue, May 05, 2009 at 11:16:19PM -0400, Glauber Costa wrote:
> When we create a new vcpu, we need to make sure that
> all of the state it is going to use (apic state, for example)
> already exists. We can do it nicely by making sure kvm_init_vcpu
> is executed after everything else in cpu creation.
>
> After that, the first call to KVM_SET_LAPIC ioctl will not find an
> existant vcpu. So we introduce a function that tell us that the vcpu
> is already initialized, and is it safe to call the ioctl. Otherwise,
> just don't botter.

Why did you decide to drop the additional wait vcpu->inited thing you
had in the previous patch? I think its nice to make the synchronization
explicit.

Isnt your current solution somewhat trickier?

And if you disagree with me (which you should avoid for safety reasons),
you need to regenerate the patch since it'll reject against qemu-kvm.git
as of today.

> We then force the execution of the KVM_SET_LAPIC from within the new
> vcpu thread.
>
> Signed-off-by: Glauber Costa <glommer@redhat.com>
> ---
> hw/apic.c | 21 +++++++++++----------
> hw/pc.c | 2 ++
> qemu-kvm.c | 10 ++++++++++
> qemu-kvm.h | 4 ++++
> target-i386/helper.c | 2 --
> 5 files changed, 27 insertions(+), 12 deletions(-)
>