KVM: selftests: Push vm_adjust_num_guest_pages() into "w/o vCPUs" helper
authorSean Christopherson <seanjc@google.com>
Mon, 18 Apr 2022 19:58:44 +0000 (12:58 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 11 Jun 2022 15:46:30 +0000 (11:46 -0400)
Move the call to vm_adjust_num_guest_pages() from vm_create_with_vcpus()
down into vm_create_without_vcpus().  This will allow a future patch to
make the "w/o vCPUs" variant the common inner helper, e.g. so that the
"with_vcpus" helper calls the "without_vcpus" helper, instead of having
them be separate paths.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/lib/kvm_util.c
tools/testing/selftests/kvm/x86_64/monitor_mwait_test [new file with mode: 0755]

index 1c5caf2..8c03100 100644 (file)
@@ -282,6 +282,8 @@ struct kvm_vm *vm_create_without_vcpus(enum vm_guest_mode mode, uint64_t pages)
 {
        struct kvm_vm *vm;
 
+       pages = vm_adjust_num_guest_pages(mode, pages);
+
        vm = __vm_create(mode, pages);
 
        kvm_vm_elf_load(vm, program_invocation_name);
@@ -341,8 +343,6 @@ struct kvm_vm *vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus,
                    "nr_vcpus = %d too large for host, max-vcpus = %d",
                    nr_vcpus, kvm_check_cap(KVM_CAP_MAX_VCPUS));
 
-       pages = vm_adjust_num_guest_pages(mode, pages);
-
        vm = vm_create_without_vcpus(mode, pages);
 
        for (i = 0; i < nr_vcpus; ++i) {
diff --git a/tools/testing/selftests/kvm/x86_64/monitor_mwait_test b/tools/testing/selftests/kvm/x86_64/monitor_mwait_test
new file mode 100755 (executable)
index 0000000..598b597
Binary files /dev/null and b/tools/testing/selftests/kvm/x86_64/monitor_mwait_test differ