diff options
author | Avi Kivity <avi@qumranet.com> | 2007-06-05 14:36:10 +0300 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-07-16 12:05:45 +0300 |
commit | 120e9a453b5e7d9a708caff7d97b71fc4ccd59e8 (patch) | |
tree | ed86703fbc2f50183f07dbc0fd7ce5dc7560a222 | |
parent | 7b53aa56508479507c6e5667bb252ca7c2cd19cf (diff) | |
download | op-kernel-dev-120e9a453b5e7d9a708caff7d97b71fc4ccd59e8.zip op-kernel-dev-120e9a453b5e7d9a708caff7d97b71fc4ccd59e8.tar.gz |
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>
-rw-r--r-- | drivers/kvm/kvm_main.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 3ff8ee5..230b25a 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -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; } |