From: Sasha Levin Subject: [PATCH 1/2] kvm tools: Add kvm__has_cap() to check whether a cap is available on the host Date: Wed, 14 Dec 2011 08:37:25 +0200 Message-ID: <1323844646-14156-1-git-send-email-levinsasha928@gmail.com> Cc: mingo@elte.hu, gorcunov@gmail.com, asias.hejun@gmail.com, kvm@vger.kernel.org, matt@ozlabs.org, Sasha Levin To: penberg@kernel.org Return-path: Received: from mail-ee0-f46.google.com ([74.125.83.46]:33429 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750942Ab1LNGhi (ORCPT ); Wed, 14 Dec 2011 01:37:38 -0500 Received: by eekc4 with SMTP id c4so436268eek.19 for ; Tue, 13 Dec 2011 22:37:37 -0800 (PST) Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Sasha Levin --- tools/kvm/include/kvm/kvm.h | 2 ++ tools/kvm/kvm.c | 5 +++++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h index 7159952..d24b70a 100644 --- a/tools/kvm/include/kvm/kvm.h +++ b/tools/kvm/include/kvm/kvm.h @@ -79,4 +79,6 @@ static inline void *guest_flat_to_host(struct kvm *kvm, unsigned long offset) return kvm->ram_start + offset; } +bool kvm__has_cap(struct kvm *kvm, u32 cap); + #endif /* KVM__KVM_H */ diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index 35ca2c5..a2f7a89 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -517,3 +517,8 @@ void kvm__notify_paused(void) mutex_lock(&pause_lock); mutex_unlock(&pause_lock); } + +bool kvm__has_cap(struct kvm *kvm, u32 cap) +{ + return ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION, cap) == 0; +} -- 1.7.8