lkml.org 
[lkml]   [2022]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH v9 02/10] KVM: selftests: Read binary stats header in lib
From
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>
---
tools/testing/selftests/kvm/include/kvm_util_base.h | 8 ++++++++
tools/testing/selftests/kvm/kvm_binary_stats_test.c | 4 ++--
2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h
index cdaea2383543..3d3dd144f427 100644
--- a/tools/testing/selftests/kvm/include/kvm_util_base.h
+++ b/tools/testing/selftests/kvm/include/kvm_util_base.h
@@ -303,6 +303,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,
diff --git a/tools/testing/selftests/kvm/kvm_binary_stats_test.c b/tools/testing/selftests/kvm/kvm_binary_stats_test.c
index ae48d4153f85..64db17faacd2 100644
--- a/tools/testing/selftests/kvm/kvm_binary_stats_test.c
+++ b/tools/testing/selftests/kvm/kvm_binary_stats_test.c
@@ -33,8 +33,8 @@ static void stats_test(int stats_fd)
struct kvm_stats_desc *pdesc;

/* Read kvm stats header */
- ret = read(stats_fd, &header, sizeof(header));
- TEST_ASSERT(ret == sizeof(header), "Read stats header");
+ read_stats_header(stats_fd, &header);
+
size_desc = sizeof(*stats_desc) + header.name_size;

/* Read kvm stats id string */
--
2.36.1.476.g0c4daa206d-goog
\
 
 \ /
  Last update: 2022-06-13 23:33    [W:0.106 / U:2.596 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site