mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-01 17:35:19 +00:00
vmm: Split create_gic() from configure_system()
Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
parent
9341cce8b3
commit
195eba188a
@ -131,30 +131,21 @@ pub fn arch_memory_regions(size: GuestUsize) -> Vec<(GuestAddress, usize, Region
|
||||
}
|
||||
|
||||
/// Configures the system and should be called once per vm before starting vcpu threads.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `guest_mem` - The memory to be used by the guest.
|
||||
/// * `num_cpus` - Number of virtual CPUs the guest will have.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn configure_system<T: DeviceInfoForFdt + Clone + Debug, S: ::std::hash::BuildHasher>(
|
||||
vm: &Arc<dyn hypervisor::Vm>,
|
||||
guest_mem: &GuestMemoryMmap,
|
||||
cmdline_cstring: &CStr,
|
||||
vcpu_count: u64,
|
||||
vcpu_mpidr: Vec<u64>,
|
||||
device_info: &HashMap<(DeviceType, String), T, S>,
|
||||
initrd: &Option<super::InitramfsConfig>,
|
||||
pci_space_address: &(u64, u64),
|
||||
) -> super::Result<Box<dyn GicDevice>> {
|
||||
let gic_device = gic::kvm::create_gic(vm, vcpu_count).map_err(Error::SetupGic)?;
|
||||
|
||||
gic_device: &dyn GicDevice,
|
||||
) -> super::Result<()> {
|
||||
let fdt_final = fdt::create_fdt(
|
||||
guest_mem,
|
||||
cmdline_cstring,
|
||||
vcpu_mpidr,
|
||||
device_info,
|
||||
&*gic_device,
|
||||
gic_device,
|
||||
initrd,
|
||||
pci_space_address,
|
||||
)
|
||||
@ -162,7 +153,7 @@ pub fn configure_system<T: DeviceInfoForFdt + Clone + Debug, S: ::std::hash::Bui
|
||||
|
||||
fdt::write_fdt_to_memory(fdt_final, guest_mem).map_err(Error::WriteFdtToMemory)?;
|
||||
|
||||
Ok(gic_device)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Returns the memory address where the initramfs could be loaded.
|
||||
|
@ -1021,17 +1021,22 @@ impl Vm {
|
||||
);
|
||||
}
|
||||
|
||||
// Call `configure_system` and pass the GIC devices out, so that
|
||||
// we can register the GIC device to the device manager.
|
||||
let gic_device = arch::configure_system(
|
||||
let gic_device = create_gic(
|
||||
&self.memory_manager.lock().as_ref().unwrap().vm,
|
||||
self.cpu_manager.lock().unwrap().boot_vcpus() as u64,
|
||||
)
|
||||
.map_err(|e| {
|
||||
Error::ConfigureSystem(arch::Error::AArch64Setup(arch::aarch64::Error::SetupGic(e)))
|
||||
})?;
|
||||
|
||||
arch::configure_system(
|
||||
&mem,
|
||||
&cmdline_cstring,
|
||||
self.cpu_manager.lock().unwrap().boot_vcpus() as u64,
|
||||
vcpu_mpidrs,
|
||||
device_info,
|
||||
&initramfs_config,
|
||||
&pci_space,
|
||||
&*gic_device,
|
||||
)
|
||||
.map_err(Error::ConfigureSystem)?;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user