summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/include/kvm_util_base.h
diff options
context:
space:
mode:
authorBen Gardon <bgardon@google.com>2022-06-13 21:25:15 +0000
committerPaolo Bonzini <pbonzini@redhat.com>2022-06-24 04:51:43 -0400
commit32faa0647cea46ffda9095c3a8c95b315e139f0f (patch)
tree07a55095af6bf355454d5702d8116d507a0e78c5 /tools/testing/selftests/kvm/include/kvm_util_base.h
parentfcd48a213f0ac45c2187b09e19d4849e14cb59f8 (diff)
KVM: selftests: Read binary stats header in lib
Move the code to read the binary stats header to the KVM selftests library. It will be re-used by other tests to check KVM behavior. No functional change intended. Reviewed-by: David Matlack <dmatlack@google.com> Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Ben Gardon <bgardon@google.com> Message-Id: <20220613212523.3436117-3-bgardon@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/include/kvm_util_base.h')
-rw-r--r--tools/testing/selftests/kvm/include/kvm_util_base.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h
index 7ebfc8c7de17..669fe4b400c2 100644
--- a/tools/testing/selftests/kvm/include/kvm_util_base.h
+++ b/tools/testing/selftests/kvm/include/kvm_util_base.h
@@ -308,6 +308,14 @@ static inline int vm_get_stats_fd(struct kvm_vm *vm)
return fd;
}
+static inline void read_stats_header(int stats_fd, struct kvm_stats_header *header)
+{
+ ssize_t ret;
+
+ ret = read(stats_fd, header, sizeof(*header));
+ TEST_ASSERT(ret == sizeof(*header), "Read stats header");
+}
+
void vm_create_irqchip(struct kvm_vm *vm);
void vm_set_user_memory_region(struct kvm_vm *vm, uint32_t slot, uint32_t flags,