mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-02 11:35:46 +00:00
vmm: device_manager: Add an MMIO devices creation routine
In order to reduce the DeviceManager's new() complexity, we can move the MMIO devices creation code into its own routine. Fixes: #441 Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
79b8f8e477
commit
a2ee681665
@ -472,29 +472,13 @@ impl DeviceManager {
|
|||||||
&interrupt_info,
|
&interrupt_info,
|
||||||
)?;
|
)?;
|
||||||
} else if cfg!(feature = "mmio_support") {
|
} else if cfg!(feature = "mmio_support") {
|
||||||
#[cfg(feature = "mmio_support")]
|
DeviceManager::add_mmio_devices(
|
||||||
{
|
vm_info,
|
||||||
for (device, _) in virtio_devices {
|
&address_manager,
|
||||||
let mmio_addr = address_manager
|
virtio_devices,
|
||||||
.allocator
|
&interrupt_info,
|
||||||
.lock()
|
&mut cmdline_additions,
|
||||||
.unwrap()
|
)?;
|
||||||
.allocate_mmio_addresses(None, MMIO_LEN, Some(MMIO_LEN));
|
|
||||||
if let Some(addr) = mmio_addr {
|
|
||||||
DeviceManager::add_virtio_mmio_device(
|
|
||||||
device,
|
|
||||||
vm_info.memory,
|
|
||||||
&address_manager,
|
|
||||||
vm_info.vm_fd,
|
|
||||||
&interrupt_info,
|
|
||||||
addr,
|
|
||||||
&mut cmdline_additions,
|
|
||||||
)?;
|
|
||||||
} else {
|
|
||||||
error!("Unable to allocate MMIO address!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(DeviceManager {
|
Ok(DeviceManager {
|
||||||
@ -610,6 +594,41 @@ impl DeviceManager {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables, unused_mut)]
|
||||||
|
fn add_mmio_devices(
|
||||||
|
vm_info: &VmInfo,
|
||||||
|
address_manager: &Arc<AddressManager>,
|
||||||
|
virtio_devices: Vec<(Box<dyn vm_virtio::VirtioDevice>, bool)>,
|
||||||
|
interrupt_info: &InterruptInfo,
|
||||||
|
mut cmdline_additions: &mut Vec<String>,
|
||||||
|
) -> DeviceManagerResult<()> {
|
||||||
|
#[cfg(feature = "mmio_support")]
|
||||||
|
{
|
||||||
|
for (device, _) in virtio_devices {
|
||||||
|
let mmio_addr = address_manager
|
||||||
|
.allocator
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.allocate_mmio_addresses(None, MMIO_LEN, Some(MMIO_LEN));
|
||||||
|
if let Some(addr) = mmio_addr {
|
||||||
|
DeviceManager::add_virtio_mmio_device(
|
||||||
|
device,
|
||||||
|
vm_info.memory,
|
||||||
|
&address_manager,
|
||||||
|
vm_info.vm_fd,
|
||||||
|
&interrupt_info,
|
||||||
|
addr,
|
||||||
|
&mut cmdline_additions,
|
||||||
|
)?;
|
||||||
|
} else {
|
||||||
|
error!("Unable to allocate MMIO address!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn make_ioapic(
|
fn make_ioapic(
|
||||||
vm_info: &VmInfo,
|
vm_info: &VmInfo,
|
||||||
address_manager: &Arc<AddressManager>,
|
address_manager: &Arc<AddressManager>,
|
||||||
|
Loading…
Reference in New Issue
Block a user