mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: hypervisor: simplify VM creation API
For MSHV customers don't want to make everything default during partition creation. For example nested support, some synthetic features could be controlled from CLI through platform argument. Create_vm API getting messy after adding more flags. This patch introduces common data struct to be passed from vmm crate to hypervisor crate during partition creation. Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
+21
-11
@@ -2861,14 +2861,16 @@ mod tests {
|
||||
use arch::layout::{BOOT_STACK_POINTER, ZERO_PAGE_START};
|
||||
use arch::x86_64::interrupts::*;
|
||||
use arch::x86_64::regs::*;
|
||||
use hypervisor::StandardRegisters;
|
||||
use hypervisor::arch::x86::{FpuState, LapicState};
|
||||
use hypervisor::{HypervisorVmConfig, StandardRegisters};
|
||||
use linux_loader::loader::bootparam::setup_header;
|
||||
|
||||
#[test]
|
||||
fn test_setlint() {
|
||||
let hv = hypervisor::new().unwrap();
|
||||
let vm = hv.create_vm().expect("new VM fd creation failed");
|
||||
let vm = hv
|
||||
.create_vm(HypervisorVmConfig::default())
|
||||
.expect("new VM fd creation failed");
|
||||
hv.check_required_extensions().unwrap();
|
||||
// Calling get_lapic will fail if there is no irqchip before hand.
|
||||
vm.create_irq_chip().unwrap();
|
||||
@@ -2894,7 +2896,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_setup_fpu() {
|
||||
let hv = hypervisor::new().unwrap();
|
||||
let vm = hv.create_vm().expect("new VM fd creation failed");
|
||||
let vm = hv
|
||||
.create_vm(HypervisorVmConfig::default())
|
||||
.expect("new VM fd creation failed");
|
||||
let vcpu = vm.create_vcpu(0, None).unwrap();
|
||||
setup_fpu(&vcpu).unwrap();
|
||||
|
||||
@@ -2918,7 +2922,9 @@ mod tests {
|
||||
use hypervisor::arch::x86::{MsrEntry, msr_index};
|
||||
|
||||
let hv = hypervisor::new().unwrap();
|
||||
let vm = hv.create_vm().expect("new VM fd creation failed");
|
||||
let vm = hv
|
||||
.create_vm(HypervisorVmConfig::default())
|
||||
.expect("new VM fd creation failed");
|
||||
let vcpu = vm.create_vcpu(0, None).unwrap();
|
||||
setup_msrs(&vcpu).unwrap();
|
||||
|
||||
@@ -2944,7 +2950,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_setup_regs_for_pvh() {
|
||||
let hv = hypervisor::new().unwrap();
|
||||
let vm = hv.create_vm().expect("new VM fd creation failed");
|
||||
let vm = hv
|
||||
.create_vm(HypervisorVmConfig::default())
|
||||
.expect("new VM fd creation failed");
|
||||
let vcpu = vm.create_vcpu(0, None).unwrap();
|
||||
|
||||
let mut expected_regs: StandardRegisters = vcpu.create_standard_regs();
|
||||
@@ -2968,7 +2976,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_setup_regs_for_bzimage() {
|
||||
let hv = hypervisor::new().unwrap();
|
||||
let vm = hv.create_vm().expect("new VM fd creation failed");
|
||||
let vm = hv
|
||||
.create_vm(HypervisorVmConfig::default())
|
||||
.expect("new VM fd creation failed");
|
||||
let vcpu = vm.create_vcpu(0, None).unwrap();
|
||||
|
||||
let mut expected_regs: StandardRegisters = vcpu.create_standard_regs();
|
||||
@@ -3000,7 +3010,6 @@ mod tests {
|
||||
use std::{mem, mem::offset_of};
|
||||
|
||||
use arch::layout;
|
||||
use hypervisor::HypervisorCpuError;
|
||||
use hypervisor::arch::aarch64::regs::MPIDR_EL1;
|
||||
#[cfg(feature = "kvm")]
|
||||
use hypervisor::arm64_core_reg_id;
|
||||
@@ -3010,11 +3019,12 @@ mod tests {
|
||||
use hypervisor::kvm::kvm_bindings::{
|
||||
KVM_REG_ARM_CORE, KVM_REG_ARM64, KVM_REG_ARM64_SYSREG, KVM_REG_SIZE_U64, user_pt_regs,
|
||||
};
|
||||
use hypervisor::{HypervisorCpuError, HypervisorVmConfig};
|
||||
|
||||
#[test]
|
||||
fn test_setup_regs() {
|
||||
let hv = hypervisor::new().unwrap();
|
||||
let vm = hv.create_vm().unwrap();
|
||||
let vm = hv.create_vm(HypervisorVmConfig::default()).unwrap();
|
||||
let vcpu = vm.create_vcpu(0, None).unwrap();
|
||||
|
||||
// Must fail when vcpu is not initialized yet.
|
||||
@@ -3030,7 +3040,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_read_mpidr() {
|
||||
let hv = hypervisor::new().unwrap();
|
||||
let vm = hv.create_vm().unwrap();
|
||||
let vm = hv.create_vm(HypervisorVmConfig::default()).unwrap();
|
||||
let vcpu = vm.create_vcpu(0, None).unwrap();
|
||||
let mut kvi = vcpu.create_vcpu_init();
|
||||
vm.get_preferred_target(&mut kvi).unwrap();
|
||||
@@ -3055,7 +3065,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_save_restore_core_regs() {
|
||||
let hv = hypervisor::new().unwrap();
|
||||
let vm = hv.create_vm().unwrap();
|
||||
let vm = hv.create_vm(HypervisorVmConfig::default()).unwrap();
|
||||
let vcpu = vm.create_vcpu(0, None).unwrap();
|
||||
let mut kvi = vcpu.create_vcpu_init();
|
||||
vm.get_preferred_target(&mut kvi).unwrap();
|
||||
@@ -3105,7 +3115,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_get_set_mpstate() {
|
||||
let hv = hypervisor::new().unwrap();
|
||||
let vm = hv.create_vm().unwrap();
|
||||
let vm = hv.create_vm(HypervisorVmConfig::default()).unwrap();
|
||||
let vcpu = vm.create_vcpu(0, None).unwrap();
|
||||
let mut kvi = vcpu.create_vcpu_init();
|
||||
vm.get_preferred_target(&mut kvi).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user