@@ -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,
@@ -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 */