diff options
author | David Hildenbrand <dahi@linux.vnet.ibm.com> | 2015-11-05 03:03:50 -0500 |
---|---|---|
committer | Christian Borntraeger <borntraeger@de.ibm.com> | 2015-11-30 06:47:04 -0500 |
commit | e09fefdeeb517ff653516dea8a882ce001e99237 (patch) | |
tree | b9cdb7b637b93779ea96f05cfc56fdead30f9b25 /virt/kvm/kvm_main.c | |
parent | bb11c6c96544737aede6a2eb92e5c6bc8b46534b (diff) |
KVM: Use common function for VCPU lookup by id
Let's reuse the new common function for VPCU lookup by id.
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
[split out the new function into a separate patch]
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r-- | virt/kvm/kvm_main.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 73cbb4120d0b..9649a42ee990 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -2257,7 +2257,7 @@ static int create_vcpu_fd(struct kvm_vcpu *vcpu) | |||
2257 | static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id) | 2257 | static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id) |
2258 | { | 2258 | { |
2259 | int r; | 2259 | int r; |
2260 | struct kvm_vcpu *vcpu, *v; | 2260 | struct kvm_vcpu *vcpu; |
2261 | 2261 | ||
2262 | if (id >= KVM_MAX_VCPUS) | 2262 | if (id >= KVM_MAX_VCPUS) |
2263 | return -EINVAL; | 2263 | return -EINVAL; |
@@ -2281,12 +2281,10 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id) | |||
2281 | r = -EINVAL; | 2281 | r = -EINVAL; |
2282 | goto unlock_vcpu_destroy; | 2282 | goto unlock_vcpu_destroy; |
2283 | } | 2283 | } |
2284 | 2284 | if (kvm_get_vcpu_by_id(kvm, id)) { | |
2285 | kvm_for_each_vcpu(r, v, kvm) | 2285 | r = -EEXIST; |
2286 | if (v->vcpu_id == id) { | 2286 | goto unlock_vcpu_destroy; |
2287 | r = -EEXIST; | 2287 | } |
2288 | goto unlock_vcpu_destroy; | ||
2289 | } | ||
2290 | 2288 | ||
2291 | BUG_ON(kvm->vcpus[atomic_read(&kvm->online_vcpus)]); | 2289 | BUG_ON(kvm->vcpus[atomic_read(&kvm->online_vcpus)]); |
2292 | 2290 | ||