Messages in this thread | | | Date | Fri, 10 Jun 2022 14:33:11 +0000 | From | Sean Christopherson <> | Subject | Re: [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!
| |