mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: device_manager: Get device range from MemoryManager
This removes the duplication of these values. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
@@ -403,15 +403,14 @@ pub struct DeviceManager {
|
|||||||
#[cfg(feature = "acpi")]
|
#[cfg(feature = "acpi")]
|
||||||
ged_notification_device: Option<Arc<Mutex<devices::AcpiGEDDevice>>>,
|
ged_notification_device: Option<Arc<Mutex<devices::AcpiGEDDevice>>>,
|
||||||
|
|
||||||
// Dimensions of the device area
|
|
||||||
start_of_device_area: GuestAddress,
|
|
||||||
end_of_device_area: GuestAddress,
|
|
||||||
|
|
||||||
// VM configuration
|
// VM configuration
|
||||||
config: Arc<Mutex<VmConfig>>,
|
config: Arc<Mutex<VmConfig>>,
|
||||||
|
|
||||||
// Migratable devices
|
// Migratable devices
|
||||||
migratable_devices: Vec<Arc<Mutex<dyn Migratable>>>,
|
migratable_devices: Vec<Arc<Mutex<dyn Migratable>>>,
|
||||||
|
|
||||||
|
// Memory Manager
|
||||||
|
memory_manager: Arc<Mutex<MemoryManager>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeviceManager {
|
impl DeviceManager {
|
||||||
@@ -497,8 +496,6 @@ impl DeviceManager {
|
|||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let start_of_device_area = vm_info.start_of_device_area;
|
|
||||||
let end_of_device_area = vm_info.end_of_device_area;
|
|
||||||
let config = vm_info.vm_cfg.clone();
|
let config = vm_info.vm_cfg.clone();
|
||||||
|
|
||||||
Ok(DeviceManager {
|
Ok(DeviceManager {
|
||||||
@@ -510,10 +507,9 @@ impl DeviceManager {
|
|||||||
virt_iommu,
|
virt_iommu,
|
||||||
#[cfg(feature = "acpi")]
|
#[cfg(feature = "acpi")]
|
||||||
ged_notification_device,
|
ged_notification_device,
|
||||||
start_of_device_area,
|
|
||||||
end_of_device_area,
|
|
||||||
config,
|
config,
|
||||||
migratable_devices,
|
migratable_devices,
|
||||||
|
memory_manager,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1695,6 +1691,8 @@ fn create_ged_device(ged_irq: u32) -> Vec<u8> {
|
|||||||
impl Aml for DeviceManager {
|
impl Aml for DeviceManager {
|
||||||
fn to_aml_bytes(&self) -> Vec<u8> {
|
fn to_aml_bytes(&self) -> Vec<u8> {
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
|
let start_of_device_area = self.memory_manager.lock().unwrap().start_of_device_area().0;
|
||||||
|
let end_of_device_area = self.memory_manager.lock().unwrap().end_of_device_area().0;
|
||||||
let pci_dsdt_data = aml::Device::new(
|
let pci_dsdt_data = aml::Device::new(
|
||||||
"_SB_.PCI0".into(),
|
"_SB_.PCI0".into(),
|
||||||
vec![
|
vec![
|
||||||
@@ -1721,8 +1719,8 @@ impl Aml for DeviceManager {
|
|||||||
&aml::AddressSpace::new_memory(
|
&aml::AddressSpace::new_memory(
|
||||||
aml::AddressSpaceCachable::NotCacheable,
|
aml::AddressSpaceCachable::NotCacheable,
|
||||||
true,
|
true,
|
||||||
self.start_of_device_area.0,
|
start_of_device_area,
|
||||||
self.end_of_device_area.0,
|
end_of_device_area,
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -162,8 +162,6 @@ pub struct VmInfo<'a> {
|
|||||||
pub memory: &'a Arc<RwLock<GuestMemoryMmap>>,
|
pub memory: &'a Arc<RwLock<GuestMemoryMmap>>,
|
||||||
pub vm_fd: &'a Arc<VmFd>,
|
pub vm_fd: &'a Arc<VmFd>,
|
||||||
pub vm_cfg: Arc<Mutex<VmConfig>>,
|
pub vm_cfg: Arc<Mutex<VmConfig>>,
|
||||||
pub start_of_device_area: GuestAddress,
|
|
||||||
pub end_of_device_area: GuestAddress,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
|
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
|
||||||
@@ -318,15 +316,11 @@ impl Vm {
|
|||||||
)
|
)
|
||||||
.map_err(Error::MemoryManager)?;
|
.map_err(Error::MemoryManager)?;
|
||||||
|
|
||||||
let start_of_device_area = memory_manager.lock().unwrap().start_of_device_area();
|
|
||||||
let end_of_device_area = memory_manager.lock().unwrap().end_of_device_area();
|
|
||||||
let guest_memory = memory_manager.lock().unwrap().guest_memory();
|
let guest_memory = memory_manager.lock().unwrap().guest_memory();
|
||||||
let vm_info = VmInfo {
|
let vm_info = VmInfo {
|
||||||
memory: &guest_memory,
|
memory: &guest_memory,
|
||||||
vm_fd: &fd,
|
vm_fd: &fd,
|
||||||
vm_cfg: config.clone(),
|
vm_cfg: config.clone(),
|
||||||
start_of_device_area,
|
|
||||||
end_of_device_area,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let device_manager = DeviceManager::new(
|
let device_manager = DeviceManager::new(
|
||||||
|
|||||||
Reference in New Issue
Block a user