Skip to contentSkip to conversation

kvm tools: Use kvm__supports_extension instead of kvm__has_cap

PATCH New Sasha Levin 1 participant 2 messages Dec 15, 2011 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 kvm tools: Use kvm__supports_extension instead of kvm__has_cap

kvm__supports_extension has been there before, and it's does it's job right unlike kvm__has_cap.

---
 tools/kvm/include/kvm/kvm.h |    1 +
 tools/kvm/ioeventfd.c       |    2 +-
 tools/kvm/kvm.c             |    2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)
tools/kvm/include/kvm/kvm.h +1 -0
index 35bb400..7996dfd 100644
@@ -82,5 +82,6 @@ static inline void *guest_flat_to_host(struct kvm *kvm, unsigned long offset)
 }
 
 bool kvm__has_cap(struct kvm *kvm, u32 cap);
+bool kvm__supports_extension(struct kvm *kvm, unsigned int extension);
 
 #endif /* KVM__KVM_H */
tools/kvm/ioeventfd.c +1 -1
index 75dd3f2..1d6a7ac 100644
@@ -22,7 +22,7 @@ static bool	ioeventfd_avail;
 
 void ioeventfd__init(struct kvm *kvm)
 {
-	ioeventfd_avail = kvm__has_cap(kvm, KVM_CAP_IOEVENTFD);
+	ioeventfd_avail = kvm__supports_extension(kvm, KVM_CAP_IOEVENTFD);
 	if (!ioeventfd_avail)
 		return;
 
tools/kvm/kvm.c +1 -1
index 9583ab2..24b8a60 100644
@@ -90,7 +90,7 @@ const char *kvm__get_dir(void)
 	return kvm_dir;
 }
 
-static bool kvm__supports_extension(struct kvm *kvm, unsigned int extension)
+bool kvm__supports_extension(struct kvm *kvm, unsigned int extension)
 {
 	int ret;
 
Signature · 1 line
1.7.8
#1 lore raw

PATCH 2/2 Revert "kvm tools: Add kvm__has_cap() to check whether a cap is available on the host"

We already had kvm__has_extension, no need for two functions that do the same.

This reverts commit 42efb1abf4ebebeedd14af34c073e673923e2898.

Conflicts:

tools/kvm/include/kvm/kvm.h

---
 tools/kvm/include/kvm/kvm.h |    1 -
 tools/kvm/kvm.c             |    5 -----
 2 files changed, 0 insertions(+), 6 deletions(-)
tools/kvm/include/kvm/kvm.h +0 -1
index 7996dfd..4927caa 100644
@@ -81,7 +81,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);
 bool kvm__supports_extension(struct kvm *kvm, unsigned int extension);
 
 #endif /* KVM__KVM_H */
tools/kvm/kvm.c +0 -5
index 24b8a60..3cdac70 100644
@@ -520,8 +520,3 @@ 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;
-}
Signature · 1 line
1.7.8