summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/kvm/lib/kvm_util.c
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2022-05-03 15:26:02 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2022-06-11 11:47:27 -0400
commit032604529827cf889e470dc9b3ad18b2a40311b3 (patch)
tree61c8ca725c9b188bb4d8892ff4116de601e63bd7 /tools/testing/selftests/kvm/lib/kvm_util.c
parent38081d28835c84e73ff414f23663d57946cc2234 (diff)
downloadlinux-032604529827cf889e470dc9b3ad18b2a40311b3.tar.bz2
KVM: selftests: Drop DEFAULT_GUEST_PHY_PAGES, open code the magic number
Remove DEFAULT_GUEST_PHY_PAGES and open code the magic number (with a comment) in vm_nr_pages_required(). Exposing DEFAULT_GUEST_PHY_PAGES to tests was a symptom of the VM creation APIs not cleanly supporting tests that create runnable vCPUs, but can't do so immediately. Now that tests don't have to manually compute the amount of memory needed for basic operation, make it harder for tests to do things that should be handled by the framework, i.e. force developers to improve the framework instead of hacking around flaws in individual tests. Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/lib/kvm_util.c')
-rw-r--r--tools/testing/selftests/kvm/lib/kvm_util.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 620c35561122..86e7f5afce63 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -271,7 +271,13 @@ static uint64_t vm_nr_pages_required(enum vm_guest_mode mode,
"nr_vcpus = %d too large for host, max-vcpus = %d",
nr_runnable_vcpus, kvm_check_cap(KVM_CAP_MAX_VCPUS));
- nr_pages = DEFAULT_GUEST_PHY_PAGES;
+ /*
+ * Arbitrarily allocate 512 pages (2mb when page size is 4kb) for the
+ * test code and other per-VM assets that will be loaded into memslot0.
+ */
+ nr_pages = 512;
+
+ /* Account for the per-vCPU stacks on behalf of the test. */
nr_pages += nr_runnable_vcpus * DEFAULT_STACK_PGS;
/*