[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220311055056.57265-102-seanjc@google.com>
Date: Fri, 11 Mar 2022 05:50:52 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: linux-kernel@...r.kernel.org
Cc: Sean Christopherson <seanjc@...gle.com>
Subject: [RFC PATCH 101/105] KVM: selftests: Require vCPU output array when
creating VM with vCPUs
Signed-off-by: Sean Christopherson <seanjc@...gle.com>
---
tools/testing/selftests/kvm/lib/kvm_util.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 861d18ed868d..3a09ed1a02d2 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -311,10 +311,11 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus
struct kvm_vcpu *vcpus[])
{
uint64_t vcpu_pages, extra_pg_pages, pages;
- struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
int i;
+ TEST_ASSERT(!nr_vcpus || vcpus, "Must provide vCPU array");
+
/* Force slot0 memory size not small than DEFAULT_GUEST_PHY_PAGES */
if (slot0_mem_pages < DEFAULT_GUEST_PHY_PAGES)
slot0_mem_pages = DEFAULT_GUEST_PHY_PAGES;
@@ -342,11 +343,8 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus
vm_create_irqchip(vm);
#endif
- for (i = 0; i < nr_vcpus; ++i) {
- vcpu = vm_vcpu_add(vm, i, guest_code);
- if (vcpus)
- vcpus[i] = vcpu;
- }
+ for (i = 0; i < nr_vcpus; ++i)
+ vcpus[i] = vm_vcpu_add(vm, i, guest_code);
return vm;
}
--
2.35.1.723.g4982287a31-goog
Powered by blists - more mailing lists