aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-06-05 07:36:10 -0400
committerAvi Kivity <avi@qumranet.com>2007-07-16 05:05:45 -0400
commit120e9a453b5e7d9a708caff7d97b71fc4ccd59e8 (patch)
treeed86703fbc2f50183f07dbc0fd7ce5dc7560a222 /drivers/kvm
parent7b53aa56508479507c6e5667bb252ca7c2cd19cf (diff)
KVM: Fix adding an smp virtual machine to the vm list
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>
Diffstat (limited to 'drivers/kvm')
-rw-r--r--drivers/kvm/kvm_main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 3ff8ee56279c..230b25aa469c 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -319,6 +319,9 @@ static struct kvm *kvm_create_vm(void)
319 319
320 spin_lock_init(&kvm->lock); 320 spin_lock_init(&kvm->lock);
321 INIT_LIST_HEAD(&kvm->active_mmu_pages); 321 INIT_LIST_HEAD(&kvm->active_mmu_pages);
322 spin_lock(&kvm_lock);
323 list_add(&kvm->vm_list, &vm_list);
324 spin_unlock(&kvm_lock);
322 for (i = 0; i < KVM_MAX_VCPUS; ++i) { 325 for (i = 0; i < KVM_MAX_VCPUS; ++i) {
323 struct kvm_vcpu *vcpu = &kvm->vcpus[i]; 326 struct kvm_vcpu *vcpu = &kvm->vcpus[i];
324 327
@@ -326,9 +329,6 @@ static struct kvm *kvm_create_vm(void)
326 vcpu->cpu = -1; 329 vcpu->cpu = -1;
327 vcpu->kvm = kvm; 330 vcpu->kvm = kvm;
328 vcpu->mmu.root_hpa = INVALID_PAGE; 331 vcpu->mmu.root_hpa = INVALID_PAGE;
329 spin_lock(&kvm_lock);
330 list_add(&kvm->vm_list, &vm_list);
331 spin_unlock(&kvm_lock);
332 } 332 }
333 return kvm; 333 return kvm;
334} 334}