@@ -4,7 +4,7 @@ use alloc::vec::Vec;
44use anyhow:: bail;
55use axvm:: {
66 AxVMConfig , CpuId , GuestPhysAddr , Vm ,
7- config:: { AxVCpuConfig , AxVMCrateConfig , CpuNumType , VMImagesConfig } ,
7+ config:: { AxVCpuConfig , AxVMCrateConfig , CpuNumType , MemoryKind , VMImagesConfig } ,
88} ;
99
1010use crate :: vmm:: vm_list:: VMRef ;
@@ -45,6 +45,26 @@ pub fn build_vmconfig(cfg: AxVMCrateConfig) -> anyhow::Result<AxVMConfig> {
4545
4646 let image_config = super :: images:: load_images ( & cfg) ?;
4747
48+ let mut memory_regions = vec ! [ ] ;
49+
50+ for region in & cfg. kernel . memory_regions {
51+ let mem_region = match region. map_type {
52+ axvmconfig:: VmMemMappingType :: MapAlloc => MemoryKind :: Fixed {
53+ gpa : region. gpa . into ( ) ,
54+ size : region. size ,
55+ } ,
56+ axvmconfig:: VmMemMappingType :: MapIdentical => {
57+ MemoryKind :: Identical { size : region. size }
58+ }
59+ axvmconfig:: VmMemMappingType :: MapReserved => MemoryKind :: Passthrough {
60+ hpa : region. gpa . into ( ) ,
61+ size : region. size ,
62+ } ,
63+ } ;
64+
65+ memory_regions. push ( mem_region) ;
66+ }
67+
4868 Ok ( AxVMConfig {
4969 id : cfg. base . id ,
5070 name : cfg. base . name ,
@@ -54,6 +74,7 @@ pub fn build_vmconfig(cfg: AxVMCrateConfig) -> anyhow::Result<AxVMConfig> {
5474 ap_entry : GuestPhysAddr :: from ( cfg. kernel . entry_point ) ,
5575 } ,
5676 image_config,
77+ memory_regions,
5778 emu_devices : cfg. devices . emu_devices ,
5879 pass_through_devices : cfg. devices . passthrough_devices ,
5980 excluded_devices : cfg. devices . excluded_devices ,
0 commit comments