From: Avi Kivity Date: Thu, 7 Jun 2007 16:11:53 +0000 (+0300) Subject: KVM: Keep an upper bound of initialized vcpus X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=39c3b86e5c193e09f69f0e99c93600a4999ffc60;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git KVM: Keep an upper bound of initialized vcpus That way, we don't need to loop for KVM_MAX_VCPUS for a single vcpu vm. Signed-off-by: Avi Kivity --- 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 { struct list_head active_mmu_pages; int n_free_mmu_pages; struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES]; + int nvcpus; struct kvm_vcpu vcpus[KVM_MAX_VCPUS]; int memory_config_version; 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) if (r < 0) goto out_free_vcpus; + spin_lock(&kvm_lock); + if (n >= kvm->nvcpus) + kvm->nvcpus = n + 1; + spin_unlock(&kvm_lock); + return r; out_free_vcpus: