mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-05 12:25:19 +00:00
vmm: x86_64: Split payload loading into it's own function
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
2856074d12
commit
763ea7da42
@ -1076,6 +1076,26 @@ impl Vm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
fn load_payload(
|
||||||
|
payload: &PayloadConfig,
|
||||||
|
memory_manager: Arc<Mutex<MemoryManager>>,
|
||||||
|
) -> Result<EntryPoint> {
|
||||||
|
let kernel = payload
|
||||||
|
.kernel
|
||||||
|
.as_ref()
|
||||||
|
.map(File::open)
|
||||||
|
.transpose()
|
||||||
|
.map_err(Error::KernelFile)?;
|
||||||
|
|
||||||
|
if let Some(kernel) = kernel {
|
||||||
|
let cmdline = Self::generate_cmdline(payload)?;
|
||||||
|
Self::load_kernel(kernel, cmdline, memory_manager)
|
||||||
|
} else {
|
||||||
|
Err(Error::InvalidPayload)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
fn load_payload_async(
|
fn load_payload_async(
|
||||||
memory_manager: &Arc<Mutex<MemoryManager>>,
|
memory_manager: &Arc<Mutex<MemoryManager>>,
|
||||||
@ -1098,21 +1118,7 @@ impl Vm {
|
|||||||
|
|
||||||
std::thread::Builder::new()
|
std::thread::Builder::new()
|
||||||
.name("payload_loader".into())
|
.name("payload_loader".into())
|
||||||
.spawn(move || {
|
.spawn(move || Self::load_payload(&payload, memory_manager))
|
||||||
let kernel = payload
|
|
||||||
.kernel
|
|
||||||
.as_ref()
|
|
||||||
.map(File::open)
|
|
||||||
.transpose()
|
|
||||||
.map_err(Error::KernelFile)?;
|
|
||||||
|
|
||||||
if let Some(kernel) = kernel {
|
|
||||||
let cmdline = Self::generate_cmdline(&payload)?;
|
|
||||||
Self::load_kernel(kernel, cmdline, memory_manager)
|
|
||||||
} else {
|
|
||||||
Err(Error::InvalidPayload)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.map_err(Error::KernelLoadThreadSpawn)
|
.map_err(Error::KernelLoadThreadSpawn)
|
||||||
})
|
})
|
||||||
.transpose()
|
.transpose()
|
||||||
|
Loading…
Reference in New Issue
Block a user