[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221024113445.1022147-3-wei.w.wang@intel.com>
Date: Mon, 24 Oct 2022 19:34:29 +0800
From: Wei Wang <wei.w.wang@...el.com>
To: seanjc@...gle.com, pbonzini@...hat.com
Cc: dmatlack@...gle.com, vipinsh@...gle.com, ajones@...tanamicro.com,
eric.auger@...hat.com, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, Wei Wang <wei.w.wang@...el.com>
Subject: [PATCH v1 02/18] KVM: selftests/kvm_util: use vm->vcpus[] when create vm with vcpus
The kvm_vm struct has been changed to maintain vcpus via an array of
vcpu pointers, there is no need to require users to allocate and pass
in another vcpu array when create the vm.
Signed-off-by: Wei Wang <wei.w.wang@...el.com>
---
tools/testing/selftests/kvm/lib/kvm_util.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 941f6c3ea9dc..1f69f5ca8356 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -371,12 +371,10 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus
struct kvm_vm *vm;
int i;
- TEST_ASSERT(!nr_vcpus || vcpus, "Must provide vCPU array");
-
vm = __vm_create(mode, nr_vcpus, extra_mem_pages);
for (i = 0; i < nr_vcpus; ++i)
- vcpus[i] = vm_vcpu_add(vm, i, guest_code);
+ vm->vcpus[i] = vm_vcpu_add(vm, i, guest_code);
return vm;
}
@@ -385,13 +383,12 @@ struct kvm_vm *__vm_create_with_one_vcpu(struct kvm_vcpu **vcpu,
uint64_t extra_mem_pages,
void *guest_code)
{
- struct kvm_vcpu *vcpus[1];
struct kvm_vm *vm;
vm = __vm_create_with_vcpus(VM_MODE_DEFAULT, 1, extra_mem_pages,
- guest_code, vcpus);
+ guest_code, NULL);
- *vcpu = vcpus[0];
+ *vcpu = vm->vcpus[0];
return vm;
}
--
2.27.0
Powered by blists - more mailing lists