From: Mihai Dontu <mdontu@xxxxxxxxxxxxxxx> This is a helper used by the introspection subsystem to find a specific VM by UUID or to build a list of UUIDs. Signed-off-by: Mihai Dontu <mdontu@xxxxxxxxxxxxxxx> --- include/linux/kvm_host.h | 2 ++ virt/kvm/kvm_main.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 48cd2d856132..88d4e4cbaba5 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -549,6 +549,8 @@ static inline void kvm_irqfd_exit(void) int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, struct module *module); void kvm_exit(void); +void kvm_enum(int (*enum_cb) (const struct kvm *kvm, void *param), + void *param); void kvm_get_kvm(struct kvm *kvm); void kvm_put_kvm(struct kvm *kvm); diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index f0fe9d02f6bb..cfd2d1bf8ac4 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -4046,3 +4046,15 @@ void kvm_exit(void) kvm_vfio_ops_exit(); } EXPORT_SYMBOL_GPL(kvm_exit); + +void kvm_enum(int (*enum_cb) (const struct kvm *kvm, void *param), void *param) +{ + struct kvm *kvm; + + spin_lock(&kvm_lock); + list_for_each_entry(kvm, &vm_list, vm_list) { + if (enum_cb(kvm, param)) + break; + } + spin_unlock(&kvm_lock); +} -- 2.12.2