forked from arceos-hypervisor/arceos-umhv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.rs
48 lines (40 loc) · 1.82 KB
/
config.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use axvm::config::{AxVMConfig, AxVMCrateConfig};
use crate::vmm::{images::load_vm_images, vm_list::push_vm, VM};
pub mod config {
use alloc::vec::Vec;
/// Default static VM configs. Used when no VM config is provided.
#[allow(dead_code)]
pub fn default_static_vm_configs() -> Vec<&'static str> {
vec![
// #[cfg(target_arch = "x86_64")]
// core::include_str!("../../configs/nimbos-x86_64.toml"),
#[cfg(target_arch = "x86_64")]
core::include_str!("../../configs/arceos-x86_64.toml"),
// #[cfg(target_arch = "aarch64")]
// core::include_str!("../../configs/nimbos-aarch64.toml"),
// #[cfg(target_arch = "aarch64")]
// core::include_str!("../../configs/rk3588-aarch64.toml"),
#[cfg(target_arch = "aarch64")]
core::include_str!("../../configs/arceos-aarch64.toml"),
// #[cfg(target_arch = "riscv64")]
// core::include_str!("../../configs/nimbos-riscv64.toml"),
#[cfg(target_arch = "riscv64")]
core::include_str!("../../configs/arceos-riscv64.toml"),
]
}
include!(concat!(env!("OUT_DIR"), "/vm_configs.rs"));
}
pub fn init_guest_vms() {
let gvm_raw_configs = config::static_vm_configs();
for raw_cfg_str in gvm_raw_configs {
let vm_create_config =
AxVMCrateConfig::from_toml(raw_cfg_str).expect("Failed to resolve VM config");
let vm_config = AxVMConfig::from(vm_create_config.clone());
// Create VM.
let vm = VM::new(vm_config).expect("Failed to create VM");
push_vm(vm.clone());
// Load corresponding images for VM.
info!("VM[{}] created success, loading images...", vm.id());
load_vm_images(vm_create_config, vm.clone()).expect("Failed to load VM images");
}
}