/* Create a default VM without any vcpus. */
struct kvm_vm *vm_create_without_vcpus(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).
+ */
+struct kvm_vm *__vm_create_with_one_vcpu(struct vcpu **vcpu,
+ uint64_t extra_mem_pages,
+ void *guest_code);
+
+static inline struct kvm_vm *vm_create_with_one_vcpu(struct vcpu **vcpu,
+ void *guest_code)
+{
+ return __vm_create_with_one_vcpu(vcpu, 0, guest_code);
+}
+
+struct vcpu *vm_recreate_with_one_vcpu(struct kvm_vm *vm);
+
/*
* Adds a vCPU with reasonable defaults (e.g. a stack)
*
(uint32_t []){ vcpuid });
}
+struct kvm_vm *__vm_create_with_one_vcpu(struct vcpu **vcpu,
+ uint64_t extra_mem_pages,
+ void *guest_code)
+{
+ struct kvm_vm *vm = vm_create_default(0, extra_mem_pages, guest_code);
+
+ *vcpu = vcpu_get(vm, 0);
+ return vm;
+}
+
/*
* VM Restart
*
}
}
+struct vcpu *vm_recreate_with_one_vcpu(struct kvm_vm *vm)
+{
+ kvm_vm_restart(vm);
+
+ vm_vcpu_add(vm, 0);
+ return vcpu_get(vm, 0);
+}
+
/*
* Userspace Memory Region Find
*