]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
KVM: Fix adding an smp virtual machine to the vm list
authorAvi Kivity <avi@qumranet.com>
Tue, 5 Jun 2007 11:36:10 +0000 (14:36 +0300)
committerAvi Kivity <avi@qumranet.com>
Mon, 16 Jul 2007 09:05:45 +0000 (12:05 +0300)
If we add the vm once per vcpu, we corrupt the list if the guest has
multiple vcpus.

Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/kvm_main.c

index 3ff8ee56279cfb436ec07de78a80a985db87ca2e..230b25aa469c27c8cb4ef304a594e9493e5fab5d 100644 (file)
@@ -319,6 +319,9 @@ static struct kvm *kvm_create_vm(void)
 
        spin_lock_init(&kvm->lock);
        INIT_LIST_HEAD(&kvm->active_mmu_pages);
+       spin_lock(&kvm_lock);
+       list_add(&kvm->vm_list, &vm_list);
+       spin_unlock(&kvm_lock);
        for (i = 0; i < KVM_MAX_VCPUS; ++i) {
                struct kvm_vcpu *vcpu = &kvm->vcpus[i];
 
@@ -326,9 +329,6 @@ static struct kvm *kvm_create_vm(void)
                vcpu->cpu = -1;
                vcpu->kvm = kvm;
                vcpu->mmu.root_hpa = INVALID_PAGE;
-               spin_lock(&kvm_lock);
-               list_add(&kvm->vm_list, &vm_list);
-               spin_unlock(&kvm_lock);
        }
        return kvm;
 }