lkml.org 
[lkml]   [2022]   [Jun]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 126/144] KVM: selftests: Convert kvm_binary_stats_test away from vCPU IDs
On Fri, Jun 10, 2022, Andrew Jones wrote:
> On Fri, Jun 03, 2022 at 12:43:13AM +0000, Sean Christopherson wrote:
> > @@ -220,17 +221,21 @@ int main(int argc, char *argv[])
> > /* Create VMs and VCPUs */
> > vms = malloc(sizeof(vms[0]) * max_vm);
> > TEST_ASSERT(vms, "Allocate memory for storing VM pointers");
> > +
> > + vcpus = malloc(sizeof(struct kvm_vcpu *) * max_vm * max_vcpu);
> > + TEST_ASSERT(vcpus, "Allocate memory for storing vCPU pointers");
> > +
> > for (i = 0; i < max_vm; ++i) {
> > vms[i] = vm_create_barebones();
> > for (j = 0; j < max_vcpu; ++j)
> > - __vm_vcpu_add(vms[i], j);
> > + vcpus[j * max_vcpu + i] = __vm_vcpu_add(vms[i], j);
>
> The expression for the index should be 'i * max_vcpu + j'. The swapped
> i,j usage isn't causing problems now because
> DEFAULT_NUM_VM == DEFAULT_NUM_VCPU, but that could change.

It's better to be lucky than good?

Thanks much, I appreciate the reviews!

\
 
 \ /
  Last update: 2022-06-10 16:34    [W:0.149 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site