|
@@ -2257,7 +2257,7 @@ static int create_vcpu_fd(struct kvm_vcpu *vcpu)
|
|
|
static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
|
|
|
{
|
|
|
int r;
|
|
|
- struct kvm_vcpu *vcpu, *v;
|
|
|
+ struct kvm_vcpu *vcpu;
|
|
|
|
|
|
if (id >= KVM_MAX_VCPUS)
|
|
|
return -EINVAL;
|
|
@@ -2281,12 +2281,10 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
|
|
|
r = -EINVAL;
|
|
|
goto unlock_vcpu_destroy;
|
|
|
}
|
|
|
-
|
|
|
- kvm_for_each_vcpu(r, v, kvm)
|
|
|
- if (v->vcpu_id == id) {
|
|
|
- r = -EEXIST;
|
|
|
- goto unlock_vcpu_destroy;
|
|
|
- }
|
|
|
+ if (kvm_get_vcpu_by_id(kvm, id)) {
|
|
|
+ r = -EEXIST;
|
|
|
+ goto unlock_vcpu_destroy;
|
|
|
+ }
|
|
|
|
|
|
BUG_ON(kvm->vcpus[atomic_read(&kvm->online_vcpus)]);
|
|
|
|