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 <avi@qumranet.com>
This commit is contained in:
@@ -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:
|
||||
|
Reference in New Issue
Block a user