aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/kvm/lib/kvm_util.c
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2022-05-27 15:13:03 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2022-06-11 11:47:28 -0400
commit3ea9b809650b4eda5d4ae18ed7bb080e499af154 (patch)
tree69a88487730d38d154c7e7fea7af84973b8ac713 /tools/testing/selftests/kvm/lib/kvm_util.c
parentKVM: selftests: Return an 'unsigned int' from kvm_check_cap() (diff)
downloadlinux-dev-3ea9b809650b4eda5d4ae18ed7bb080e499af154.tar.xz
linux-dev-3ea9b809650b4eda5d4ae18ed7bb080e499af154.zip
KVM: selftests: Add kvm_has_cap() to provide syntactic sugar
Add kvm_has_cap() to wrap kvm_check_cap() and return a bool for the use cases where the caller only wants check if a capability is supported, i.e. doesn't care about the value beyond whether or not it's non-zero. The "check" terminology is somewhat ambiguous as the non-boolean return suggests that '0' might mean "success", i.e. suggests that the ioctl uses the 0/-errno pattern. Provide a wrapper instead of trying to find a new name for the raw helper; the "check" terminology is derived from the name of the ioctl, so using e.g. "get" isn't a clear win. Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/lib/kvm_util.c')
-rw-r--r--tools/testing/selftests/kvm/lib/kvm_util.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 4cf0e6bf33bb..f93b0d9334e5 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -80,7 +80,7 @@ unsigned int kvm_check_cap(long cap)
close(kvm_fd);
- return ret;
+ return (unsigned int)ret;
}
void vm_enable_dirty_ring(struct kvm_vm *vm, uint32_t ring_size)
@@ -93,7 +93,7 @@ static void vm_open(struct kvm_vm *vm)
{
vm->kvm_fd = _open_kvm_dev_path_or_exit(O_RDWR);
- if (!kvm_check_cap(KVM_CAP_IMMEDIATE_EXIT)) {
+ if (!kvm_has_cap(KVM_CAP_IMMEDIATE_EXIT)) {
print_skip("immediate_exit not available");
exit(KSFT_SKIP);
}