mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 11:22:26 +00:00
vmm: device_manager: Add an ACPI device creation routine
In order to reduce the DeviceManager's new() complexity, we can move the ACPI device creation code into its own routine. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
cfca2759fc
commit
ce1765c8af
@ -403,7 +403,7 @@ pub struct DeviceManager {
|
|||||||
impl DeviceManager {
|
impl DeviceManager {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
vm_info: &VmInfo,
|
vm_info: &VmInfo,
|
||||||
mut allocator: SystemAllocator,
|
allocator: SystemAllocator,
|
||||||
_msi_capable: bool,
|
_msi_capable: bool,
|
||||||
userspace_ioapic: bool,
|
userspace_ioapic: bool,
|
||||||
mut mem_slots: u32,
|
mut mem_slots: u32,
|
||||||
@ -432,22 +432,6 @@ impl DeviceManager {
|
|||||||
ioapic: &ioapic,
|
ioapic: &ioapic,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "acpi")]
|
|
||||||
{
|
|
||||||
let acpi_device = Arc::new(Mutex::new(devices::AcpiShutdownDevice::new(
|
|
||||||
_exit_evt.try_clone().map_err(DeviceManagerError::EventFd)?,
|
|
||||||
reset_evt.try_clone().map_err(DeviceManagerError::EventFd)?,
|
|
||||||
)));
|
|
||||||
|
|
||||||
allocator
|
|
||||||
.allocate_io_addresses(Some(GuestAddress(0x3c0)), 0x4, None)
|
|
||||||
.ok_or(DeviceManagerError::AllocateIOPort)?;
|
|
||||||
|
|
||||||
io_bus
|
|
||||||
.insert(acpi_device.clone(), 0x3c0, 0x4)
|
|
||||||
.map_err(DeviceManagerError::BusError)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut virtio_devices: Vec<(Box<dyn vm_virtio::VirtioDevice>, bool)> = Vec::new();
|
let mut virtio_devices: Vec<(Box<dyn vm_virtio::VirtioDevice>, bool)> = Vec::new();
|
||||||
let mut mmap_regions = Vec::new();
|
let mut mmap_regions = Vec::new();
|
||||||
|
|
||||||
@ -485,6 +469,12 @@ impl DeviceManager {
|
|||||||
reset_evt.try_clone().map_err(DeviceManagerError::EventFd)?,
|
reset_evt.try_clone().map_err(DeviceManagerError::EventFd)?,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
DeviceManager::add_acpi_device(
|
||||||
|
&address_manager,
|
||||||
|
reset_evt.try_clone().map_err(DeviceManagerError::EventFd)?,
|
||||||
|
_exit_evt.try_clone().map_err(DeviceManagerError::EventFd)?,
|
||||||
|
)?;
|
||||||
|
|
||||||
if cfg!(feature = "pci_support") {
|
if cfg!(feature = "pci_support") {
|
||||||
#[cfg(feature = "pci_support")]
|
#[cfg(feature = "pci_support")]
|
||||||
{
|
{
|
||||||
@ -612,6 +602,27 @@ impl DeviceManager {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
fn add_acpi_device(
|
||||||
|
address_manager: &Arc<AddressManager>,
|
||||||
|
reset_evt: EventFd,
|
||||||
|
exit_evt: EventFd,
|
||||||
|
) -> DeviceManagerResult<()> {
|
||||||
|
#[cfg(feature = "acpi")]
|
||||||
|
{
|
||||||
|
let acpi_device = Arc::new(Mutex::new(devices::AcpiShutdownDevice::new(
|
||||||
|
exit_evt, reset_evt,
|
||||||
|
)));
|
||||||
|
|
||||||
|
address_manager
|
||||||
|
.io_bus
|
||||||
|
.insert(acpi_device.clone(), 0x3c0, 0x4)
|
||||||
|
.map_err(DeviceManagerError::BusError)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn add_legacy_devices(
|
fn add_legacy_devices(
|
||||||
_vm_info: &VmInfo,
|
_vm_info: &VmInfo,
|
||||||
address_manager: &Arc<AddressManager>,
|
address_manager: &Arc<AddressManager>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user