devices: Add e820/memory_map to fw_cfg device

We build the memory map in the fw_cfg device based on the memory size.

Signed-off-by: Alex Orozco <alexorozco@google.com>
This commit is contained in:
Alex Orozco
2025-04-18 16:20:58 +00:00
committed by Bo Chen
parent 623fadfa9d
commit f0b69d56d0
2 changed files with 90 additions and 0 deletions

View File

@@ -351,6 +351,10 @@ pub enum Error {
#[cfg(feature = "fw_cfg")]
#[error("Fw Cfg missing kernel cmdline")]
MissingFwCfgCmdline,
#[cfg(feature = "fw_cfg")]
#[error("Error creating e820 map")]
CreatingE820Map(#[source] io::Error),
}
pub type Result<T> = result::Result<T, Error>;
@@ -801,6 +805,15 @@ impl Vm {
device_manager: &Arc<Mutex<DeviceManager>>,
config: &Arc<Mutex<VmConfig>>,
) -> Result<()> {
device_manager
.lock()
.unwrap()
.fw_cfg()
.expect("fw_cfg device must be present")
.lock()
.unwrap()
.add_e820(config.lock().unwrap().memory.size as usize)
.map_err(Error::CreatingE820Map)?;
let kernel = config
.lock()
.unwrap()