summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/include/kvm_util_base.h
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2022-04-19 14:21:38 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2022-06-11 11:46:34 -0400
commit3f44e7fdca4eaeed3728d0b898ace5258f9ed474 (patch)
tree0f48b0d3127f41ad2e649a515b663467af38abf3 /tools/testing/selftests/kvm/include/kvm_util_base.h
parentcfe122db3ea6908d44f51c239fb1f1608e71522b (diff)
downloadlwn-3f44e7fdca4eaeed3728d0b898ace5258f9ed474.tar.gz
lwn-3f44e7fdca4eaeed3728d0b898ace5258f9ed474.zip
KVM: selftests: Make vm_create() a wrapper that specifies VM_MODE_DEFAULT
Add ____vm_create() to be the innermost helper, and turn vm_create() into a wrapper the specifies VM_MODE_DEFAULT. Most of the vm_create() callers just want the default mode, or more accurately, don't care about the mode. Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/include/kvm_util_base.h')
-rw-r--r--tools/testing/selftests/kvm/include/kvm_util_base.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h
index b09ef551d61b..6418b1c04bc0 100644
--- a/tools/testing/selftests/kvm/include/kvm_util_base.h
+++ b/tools/testing/selftests/kvm/include/kvm_util_base.h
@@ -247,7 +247,6 @@ static inline void vm_enable_cap(struct kvm_vm *vm, uint32_t cap, uint64_t arg0)
void vm_enable_dirty_ring(struct kvm_vm *vm, uint32_t ring_size);
const char *vm_guest_mode_string(uint32_t i);
-struct kvm_vm *__vm_create(enum vm_guest_mode mode, uint64_t phy_pages);
void kvm_vm_free(struct kvm_vm *vmp);
void kvm_vm_restart(struct kvm_vm *vmp);
void kvm_vm_release(struct kvm_vm *vmp);
@@ -595,9 +594,21 @@ vm_paddr_t vm_phy_pages_alloc(struct kvm_vm *vm, size_t num,
vm_paddr_t paddr_min, uint32_t memslot);
vm_paddr_t vm_alloc_page_table(struct kvm_vm *vm);
+/*
+ * ____vm_create() does KVM_CREATE_VM and little else. __vm_create() also
+ * loads the test binary into guest memory and creates an IRQ chip (x86 only).
+ */
+struct kvm_vm *____vm_create(enum vm_guest_mode mode, uint64_t nr_pages);
+struct kvm_vm *__vm_create(enum vm_guest_mode mode, uint64_t nr_pages);
+
static inline struct kvm_vm *vm_create_barebones(void)
{
- return __vm_create(VM_MODE_DEFAULT, 0);
+ return ____vm_create(VM_MODE_DEFAULT, 0);
+}
+
+static inline struct kvm_vm *vm_create(uint64_t nr_pages)
+{
+ return __vm_create(VM_MODE_DEFAULT, nr_pages);
}
/*
@@ -629,9 +640,6 @@ struct kvm_vm *vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus,
uint32_t num_percpu_pages, void *guest_code,
uint32_t vcpuids[]);
-/* Create a default VM without any vcpus. */
-struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t pages);
-
/*
* Create a VM with a single vCPU with reasonable defaults and @extra_mem_pages
* additional pages of guest memory. Returns the VM and vCPU (via out param).