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-19 08:25:32 -0500 |
commit | db27a7a37aa0b1f8b373f8b0fb72a2ccaafb85b7 (patch) | |
tree | 025d4d37a375089756e393715d7ddcbf870ae809 | |
parent | 03c02807e25ef0f44767f28e939efc2c5deb0f3d (diff) |
KVM: Provide function for VCPU lookup by id
Let's provide a function to lookup a VCPU 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 patch from refactoring patch]
-rw-r--r-- | include/linux/kvm_host.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 5706a2108f0a..c923350ca20a 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -460,6 +460,17 @@ static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i) | |||
460 | (vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \ | 460 | (vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \ |
461 | idx++) | 461 | idx++) |
462 | 462 | ||
463 | static inline struct kvm_vcpu *kvm_get_vcpu_by_id(struct kvm *kvm, int id) | ||
464 | { | ||
465 | struct kvm_vcpu *vcpu; | ||
466 | int i; | ||
467 | |||
468 | kvm_for_each_vcpu(i, vcpu, kvm) | ||
469 | if (vcpu->vcpu_id == id) | ||
470 | return vcpu; | ||
471 | return NULL; | ||
472 | } | ||
473 | |||
463 | #define kvm_for_each_memslot(memslot, slots) \ | 474 | #define kvm_for_each_memslot(memslot, slots) \ |
464 | for (memslot = &slots->memslots[0]; \ | 475 | for (memslot = &slots->memslots[0]; \ |
465 | memslot < slots->memslots + KVM_MEM_SLOTS_NUM && memslot->npages;\ | 476 | memslot < slots->memslots + KVM_MEM_SLOTS_NUM && memslot->npages;\ |