Re: [PATCH v7 03/11] KVM: selftests: Read binary stats desc in lib

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 05, 2022, Sean Christopherson wrote:
> @@ -63,11 +63,12 @@ static void stats_test(int stats_fd)
>  			"Descriptor block is overlapped with data block");
> 
>  	/* Read kvm stats descriptors */
> -	stats_desc = read_stats_desc(stats_fd, &header);
> +	stats_desc = read_stats_descriptors(stats_fd, &header);
> 
>  	/* Sanity check for fields in descriptors */
>  	for (i = 0; i < header.num_desc; ++i) {
> -		pdesc = (void *)stats_desc + i * size_desc;
> +		pdesc = get_stats_descriptor(stats_desc, i, &header);
> +
>  		/* Check type,unit,base boundaries */
>  		TEST_ASSERT((pdesc->flags & KVM_STATS_TYPE_MASK)
>  				<= KVM_STATS_TYPE_MAX, "Unknown KVM stats type");

Drat, I missed two instances!  And more on top...

---
 tools/testing/selftests/kvm/kvm_binary_stats_test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kvm/kvm_binary_stats_test.c b/tools/testing/selftests/kvm/kvm_binary_stats_test.c
index 6252e3d6e964..6b5ce270b890 100644
--- a/tools/testing/selftests/kvm/kvm_binary_stats_test.c
+++ b/tools/testing/selftests/kvm/kvm_binary_stats_test.c
@@ -124,7 +124,7 @@ static void stats_test(int stats_fd)
 			"Data size is not correct");
 	/* Check stats offset */
 	for (i = 0; i < header.num_desc; ++i) {
-		pdesc = (void *)stats_desc + i * size_desc;
+		pdesc = get_stats_descriptor(stats_desc, i, &header);
 		TEST_ASSERT(pdesc->offset < size_data,
 			"Invalid offset (%u) for stats: %s",
 			pdesc->offset, pdesc->name);
@@ -139,7 +139,7 @@ static void stats_test(int stats_fd)
 	/* Read kvm stats data one by one */
 	size_data = 0;
 	for (i = 0; i < header.num_desc; ++i) {
-		pdesc = (void *)stats_desc + i * size_desc;
+		pdesc = get_stats_descriptor(stats_desc, i, &header);
 		ret = pread(stats_fd, stats_data,
 				pdesc->size * sizeof(*stats_data),
 				header.data_offset + size_data);

base-commit: 84185927b3e27502a70685848adffbe56a804d98
--




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux