diff options
-rw-r--r-- | drivers/kvm/kvm.h | 1 | ||||
-rw-r--r-- | drivers/kvm/kvm_main.c | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h index d49b16cae27a..528a56b1790e 100644 --- a/drivers/kvm/kvm.h +++ b/drivers/kvm/kvm.h | |||
@@ -379,6 +379,7 @@ struct kvm { | |||
379 | struct list_head active_mmu_pages; | 379 | struct list_head active_mmu_pages; |
380 | int n_free_mmu_pages; | 380 | int n_free_mmu_pages; |
381 | struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES]; | 381 | struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES]; |
382 | int nvcpus; | ||
382 | struct kvm_vcpu vcpus[KVM_MAX_VCPUS]; | 383 | struct kvm_vcpu vcpus[KVM_MAX_VCPUS]; |
383 | int memory_config_version; | 384 | int memory_config_version; |
384 | int busy; | 385 | int busy; |
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 556416962541..4e1a017f3db7 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
@@ -2391,6 +2391,11 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n) | |||
2391 | if (r < 0) | 2391 | if (r < 0) |
2392 | goto out_free_vcpus; | 2392 | goto out_free_vcpus; |
2393 | 2393 | ||
2394 | spin_lock(&kvm_lock); | ||
2395 | if (n >= kvm->nvcpus) | ||
2396 | kvm->nvcpus = n + 1; | ||
2397 | spin_unlock(&kvm_lock); | ||
2398 | |||
2394 | return r; | 2399 | return r; |
2395 | 2400 | ||
2396 | out_free_vcpus: | 2401 | out_free_vcpus: |