提交 5260db3e 编写于 作者: S Sean Christopherson 提交者: Paolo Bonzini

KVM: selftests: Require vCPU output array when creating VM with vCPUs

Require the caller of __vm_create_with_vcpus() to provide a non-NULL
array of vCPUs now that all callers do so.  It's extremely unlikely a
test will have a legitimate use case for creating a VM with vCPUs without
wanting to do something with those vCPUs, and if there is such a use case,
requiring that one-off test to provide a dummy array is a minor
annoyance.
Signed-off-by: NSean Christopherson <seanjc@google.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 64a1aacc
...@@ -302,10 +302,11 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus ...@@ -302,10 +302,11 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus
struct kvm_vcpu *vcpus[]) struct kvm_vcpu *vcpus[])
{ {
uint64_t vcpu_pages, extra_pg_pages, pages; uint64_t vcpu_pages, extra_pg_pages, pages;
struct kvm_vcpu *vcpu;
struct kvm_vm *vm; struct kvm_vm *vm;
int i; int i;
TEST_ASSERT(!nr_vcpus || vcpus, "Must provide vCPU array");
/* Force slot0 memory size not small than DEFAULT_GUEST_PHY_PAGES */ /* Force slot0 memory size not small than DEFAULT_GUEST_PHY_PAGES */
if (slot0_mem_pages < DEFAULT_GUEST_PHY_PAGES) if (slot0_mem_pages < DEFAULT_GUEST_PHY_PAGES)
slot0_mem_pages = DEFAULT_GUEST_PHY_PAGES; slot0_mem_pages = DEFAULT_GUEST_PHY_PAGES;
...@@ -326,11 +327,8 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus ...@@ -326,11 +327,8 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus
vm = __vm_create(mode, pages); vm = __vm_create(mode, pages);
for (i = 0; i < nr_vcpus; ++i) { for (i = 0; i < nr_vcpus; ++i)
vcpu = vm_vcpu_add(vm, i, guest_code); vcpus[i] = vm_vcpu_add(vm, i, guest_code);
if (vcpus)
vcpus[i] = vcpu;
}
return vm; return vm;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册