Commit 32faa064 authored by Ben Gardon's avatar Ben Gardon Committed by Paolo Bonzini

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: default avatarDavid Matlack <dmatlack@google.com>
Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
Signed-off-by: default avatarBen Gardon <bgardon@google.com>
Message-Id: <20220613212523.3436117-3-bgardon@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent fcd48a21
...@@ -308,6 +308,14 @@ static inline int vm_get_stats_fd(struct kvm_vm *vm) ...@@ -308,6 +308,14 @@ static inline int vm_get_stats_fd(struct kvm_vm *vm)
return fd; 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_create_irqchip(struct kvm_vm *vm);
void vm_set_user_memory_region(struct kvm_vm *vm, uint32_t slot, uint32_t flags, void vm_set_user_memory_region(struct kvm_vm *vm, uint32_t slot, uint32_t flags,
......
...@@ -33,8 +33,8 @@ static void stats_test(int stats_fd) ...@@ -33,8 +33,8 @@ static void stats_test(int stats_fd)
struct kvm_stats_desc *pdesc; struct kvm_stats_desc *pdesc;
/* Read kvm stats header */ /* Read kvm stats header */
ret = read(stats_fd, &header, sizeof(header)); read_stats_header(stats_fd, &header);
TEST_ASSERT(ret == sizeof(header), "Read stats header");
size_desc = sizeof(*stats_desc) + header.name_size; size_desc = sizeof(*stats_desc) + header.name_size;
/* Read kvm stats id string */ /* Read kvm stats id string */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment