diff options
author | David Hildenbrand <dahi@linux.vnet.ibm.com> | 2015-11-05 09:03:50 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-12-09 14:03:23 -0500 |
commit | af2bcce2e22c7d59816e890d67ab1af91fe0d95a (patch) | |
tree | 7f07a5961c4f20cb2314d716056394e4c5f5c7db /include/linux | |
parent | 3ba8381fd8653d7438cdd3fe3e7fc4d9004b7c27 (diff) | |
download | lwn-af2bcce2e22c7d59816e890d67ab1af91fe0d95a.tar.gz lwn-af2bcce2e22c7d59816e890d67ab1af91fe0d95a.zip |
KVM: Provide function for VCPU lookup by id
commit db27a7a37aa0b1f8b373f8b0fb72a2ccaafb85b7 upstream.
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]
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux')
-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 ad45054309a0..29a57a5b7cee 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -423,6 +423,17 @@ static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i) (vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \ idx++) +static inline struct kvm_vcpu *kvm_get_vcpu_by_id(struct kvm *kvm, int id) +{ + struct kvm_vcpu *vcpu; + int i; + + kvm_for_each_vcpu(i, vcpu, kvm) + if (vcpu->vcpu_id == id) + return vcpu; + return NULL; +} + #define kvm_for_each_memslot(memslot, slots) \ for (memslot = &slots->memslots[0]; \ memslot < slots->memslots + KVM_MEM_SLOTS_NUM && memslot->npages;\ |