mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-01 17:35:19 +00:00
vmm: Store boot guest memory and use it for boot sequence
In order to differentiate the 'boot' memory regions from the virtio-mem regions, we store what we call 'boot_guest_memory'. This is useful to provide the adequate list of regions to the configure_system() function as it expects only the list of regions that should be exposed through the e820 table. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
9d8672afc6
commit
66fc557015
@ -86,6 +86,7 @@ impl MemoryZone {
|
||||
pub type MemoryZones = HashMap<String, MemoryZone>;
|
||||
|
||||
pub struct MemoryManager {
|
||||
boot_guest_memory: GuestMemoryMmap,
|
||||
guest_memory: GuestMemoryAtomic<GuestMemoryMmap>,
|
||||
next_memory_slot: u32,
|
||||
start_of_device_area: GuestAddress,
|
||||
@ -504,6 +505,8 @@ impl MemoryManager {
|
||||
let guest_memory =
|
||||
GuestMemoryMmap::from_arc_regions(mem_regions).map_err(Error::GuestMemory)?;
|
||||
|
||||
let boot_guest_memory = guest_memory.clone();
|
||||
|
||||
let end_of_device_area = GuestAddress(mmio_address_space_size() - 1);
|
||||
|
||||
let mut start_of_device_area = MemoryManager::start_addr(guest_memory.last_addr(), false);
|
||||
@ -580,6 +583,7 @@ impl MemoryManager {
|
||||
));
|
||||
|
||||
let memory_manager = Arc::new(Mutex::new(MemoryManager {
|
||||
boot_guest_memory,
|
||||
guest_memory: guest_memory.clone(),
|
||||
next_memory_slot: 0,
|
||||
start_of_device_area,
|
||||
@ -995,6 +999,10 @@ impl MemoryManager {
|
||||
self.guest_memory.clone()
|
||||
}
|
||||
|
||||
pub fn boot_guest_memory(&self) -> GuestMemoryMmap {
|
||||
self.boot_guest_memory.clone()
|
||||
}
|
||||
|
||||
pub fn allocator(&self) -> Arc<Mutex<SystemAllocator>> {
|
||||
self.allocator.clone()
|
||||
}
|
||||
|
@ -684,11 +684,10 @@ impl Vm {
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn configure_system(&mut self, entry_addr: EntryPoint) -> Result<()> {
|
||||
let cmdline_cstring = self.get_cmdline()?;
|
||||
let guest_memory = self.memory_manager.lock().as_ref().unwrap().guest_memory();
|
||||
let mem = guest_memory.memory();
|
||||
let mem = self.memory_manager.lock().unwrap().boot_guest_memory();
|
||||
|
||||
let initramfs_config = match self.initramfs {
|
||||
Some(_) => Some(self.load_initramfs(mem.deref())?),
|
||||
Some(_) => Some(self.load_initramfs(&mem)?),
|
||||
None => None,
|
||||
};
|
||||
|
||||
@ -700,7 +699,7 @@ impl Vm {
|
||||
#[cfg(feature = "acpi")]
|
||||
{
|
||||
rsdp_addr = Some(crate::acpi::create_acpi_tables(
|
||||
mem.deref(),
|
||||
&mem,
|
||||
&self.device_manager,
|
||||
&self.cpu_manager,
|
||||
&self.memory_manager,
|
||||
@ -753,10 +752,9 @@ impl Vm {
|
||||
fn configure_system(&mut self, _entry_addr: EntryPoint) -> Result<()> {
|
||||
let cmdline_cstring = self.get_cmdline()?;
|
||||
let vcpu_mpidrs = self.cpu_manager.lock().unwrap().get_mpidrs();
|
||||
let guest_memory = self.memory_manager.lock().as_ref().unwrap().guest_memory();
|
||||
let mem = guest_memory.memory();
|
||||
let mem = self.memory_manager.lock().unwrap().boot_guest_memory();
|
||||
let initramfs_config = match self.initramfs {
|
||||
Some(_) => Some(self.load_initramfs(mem.deref())?),
|
||||
Some(_) => Some(self.load_initramfs(&mem)?),
|
||||
None => None,
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user