mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-02 11:35:46 +00:00
devices: acpi: Generalise the HotPlugNotificationFlags
Renamed this bitfield as it will also be used for non-hotplug purposes such as synthesising a power button. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
23afe89089
commit
7b376fa8e0
@ -9,7 +9,7 @@ use std::time::Instant;
|
|||||||
use vm_device::interrupt::InterruptSourceGroup;
|
use vm_device::interrupt::InterruptSourceGroup;
|
||||||
use vm_device::BusDevice;
|
use vm_device::BusDevice;
|
||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
use HotPlugNotificationFlags;
|
use AcpiNotificationFlags;
|
||||||
|
|
||||||
/// A device for handling ACPI shutdown and reboot
|
/// A device for handling ACPI shutdown and reboot
|
||||||
pub struct AcpiShutdownDevice {
|
pub struct AcpiShutdownDevice {
|
||||||
@ -61,7 +61,7 @@ impl BusDevice for AcpiShutdownDevice {
|
|||||||
/// A device for handling ACPI GED event generation
|
/// A device for handling ACPI GED event generation
|
||||||
pub struct AcpiGEDDevice {
|
pub struct AcpiGEDDevice {
|
||||||
interrupt: Arc<Box<dyn InterruptSourceGroup>>,
|
interrupt: Arc<Box<dyn InterruptSourceGroup>>,
|
||||||
notification_type: HotPlugNotificationFlags,
|
notification_type: AcpiNotificationFlags,
|
||||||
ged_irq: u32,
|
ged_irq: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,14 +69,14 @@ impl AcpiGEDDevice {
|
|||||||
pub fn new(interrupt: Arc<Box<dyn InterruptSourceGroup>>, ged_irq: u32) -> AcpiGEDDevice {
|
pub fn new(interrupt: Arc<Box<dyn InterruptSourceGroup>>, ged_irq: u32) -> AcpiGEDDevice {
|
||||||
AcpiGEDDevice {
|
AcpiGEDDevice {
|
||||||
interrupt,
|
interrupt,
|
||||||
notification_type: HotPlugNotificationFlags::NO_DEVICES_CHANGED,
|
notification_type: AcpiNotificationFlags::NO_DEVICES_CHANGED,
|
||||||
ged_irq,
|
ged_irq,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn notify(
|
pub fn notify(
|
||||||
&mut self,
|
&mut self,
|
||||||
notification_type: HotPlugNotificationFlags,
|
notification_type: AcpiNotificationFlags,
|
||||||
) -> Result<(), std::io::Error> {
|
) -> Result<(), std::io::Error> {
|
||||||
self.notification_type |= notification_type;
|
self.notification_type |= notification_type;
|
||||||
self.interrupt.trigger(0)
|
self.interrupt.trigger(0)
|
||||||
@ -92,7 +92,7 @@ impl BusDevice for AcpiGEDDevice {
|
|||||||
// Spec has all fields as zero
|
// Spec has all fields as zero
|
||||||
fn read(&mut self, _base: u64, _offset: u64, data: &mut [u8]) {
|
fn read(&mut self, _base: u64, _offset: u64, data: &mut [u8]) {
|
||||||
data[0] = self.notification_type.bits();
|
data[0] = self.notification_type.bits();
|
||||||
self.notification_type = HotPlugNotificationFlags::NO_DEVICES_CHANGED;
|
self.notification_type = AcpiNotificationFlags::NO_DEVICES_CHANGED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ pub mod legacy;
|
|||||||
pub use self::acpi::{AcpiGEDDevice, AcpiPMTimerDevice, AcpiShutdownDevice};
|
pub use self::acpi::{AcpiGEDDevice, AcpiPMTimerDevice, AcpiShutdownDevice};
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
pub struct HotPlugNotificationFlags: u8 {
|
pub struct AcpiNotificationFlags: u8 {
|
||||||
const NO_DEVICES_CHANGED = 0;
|
const NO_DEVICES_CHANGED = 0;
|
||||||
const CPU_DEVICES_CHANGED = 0b1;
|
const CPU_DEVICES_CHANGED = 0b1;
|
||||||
const MEMORY_DEVICES_CHANGED = 0b10;
|
const MEMORY_DEVICES_CHANGED = 0b10;
|
||||||
|
@ -43,7 +43,7 @@ use devices::gic;
|
|||||||
use devices::ioapic;
|
use devices::ioapic;
|
||||||
use devices::{
|
use devices::{
|
||||||
interrupt_controller, interrupt_controller::InterruptController, legacy::Serial,
|
interrupt_controller, interrupt_controller::InterruptController, legacy::Serial,
|
||||||
HotPlugNotificationFlags,
|
AcpiNotificationFlags,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "kvm")]
|
#[cfg(feature = "kvm")]
|
||||||
use hypervisor::kvm_ioctls::*;
|
use hypervisor::kvm_ioctls::*;
|
||||||
@ -2871,7 +2871,7 @@ impl DeviceManager {
|
|||||||
|
|
||||||
pub fn notify_hotplug(
|
pub fn notify_hotplug(
|
||||||
&self,
|
&self,
|
||||||
_notification_type: HotPlugNotificationFlags,
|
_notification_type: AcpiNotificationFlags,
|
||||||
) -> DeviceManagerResult<()> {
|
) -> DeviceManagerResult<()> {
|
||||||
#[cfg(feature = "acpi")]
|
#[cfg(feature = "acpi")]
|
||||||
return self
|
return self
|
||||||
|
@ -42,7 +42,7 @@ use arch::get_host_cpu_phys_bits;
|
|||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
use arch::BootProtocol;
|
use arch::BootProtocol;
|
||||||
use arch::EntryPoint;
|
use arch::EntryPoint;
|
||||||
use devices::HotPlugNotificationFlags;
|
use devices::AcpiNotificationFlags;
|
||||||
use hypervisor::vm::{HypervisorVmError, VmmOps};
|
use hypervisor::vm::{HypervisorVmError, VmmOps};
|
||||||
use linux_loader::cmdline::Cmdline;
|
use linux_loader::cmdline::Cmdline;
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
@ -1115,7 +1115,7 @@ impl Vm {
|
|||||||
self.device_manager
|
self.device_manager
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.notify_hotplug(HotPlugNotificationFlags::CPU_DEVICES_CHANGED)
|
.notify_hotplug(AcpiNotificationFlags::CPU_DEVICES_CHANGED)
|
||||||
.map_err(Error::DeviceManager)?;
|
.map_err(Error::DeviceManager)?;
|
||||||
}
|
}
|
||||||
self.config.lock().unwrap().cpus.boot_vcpus = desired_vcpus;
|
self.config.lock().unwrap().cpus.boot_vcpus = desired_vcpus;
|
||||||
@ -1143,7 +1143,7 @@ impl Vm {
|
|||||||
self.device_manager
|
self.device_manager
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.notify_hotplug(HotPlugNotificationFlags::MEMORY_DEVICES_CHANGED)
|
.notify_hotplug(AcpiNotificationFlags::MEMORY_DEVICES_CHANGED)
|
||||||
.map_err(Error::DeviceManager)?;
|
.map_err(Error::DeviceManager)?;
|
||||||
}
|
}
|
||||||
HotplugMethod::VirtioMem => {}
|
HotplugMethod::VirtioMem => {}
|
||||||
@ -1240,7 +1240,7 @@ impl Vm {
|
|||||||
self.device_manager
|
self.device_manager
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED)
|
.notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED)
|
||||||
.map_err(Error::DeviceManager)?;
|
.map_err(Error::DeviceManager)?;
|
||||||
|
|
||||||
Ok(pci_device_info)
|
Ok(pci_device_info)
|
||||||
@ -1287,7 +1287,7 @@ impl Vm {
|
|||||||
self.device_manager
|
self.device_manager
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED)
|
.notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED)
|
||||||
.map_err(Error::DeviceManager)?;
|
.map_err(Error::DeviceManager)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -1314,7 +1314,7 @@ impl Vm {
|
|||||||
self.device_manager
|
self.device_manager
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED)
|
.notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED)
|
||||||
.map_err(Error::DeviceManager)?;
|
.map_err(Error::DeviceManager)?;
|
||||||
|
|
||||||
Ok(pci_device_info)
|
Ok(pci_device_info)
|
||||||
@ -1342,7 +1342,7 @@ impl Vm {
|
|||||||
self.device_manager
|
self.device_manager
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED)
|
.notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED)
|
||||||
.map_err(Error::DeviceManager)?;
|
.map_err(Error::DeviceManager)?;
|
||||||
|
|
||||||
Ok(pci_device_info)
|
Ok(pci_device_info)
|
||||||
@ -1370,7 +1370,7 @@ impl Vm {
|
|||||||
self.device_manager
|
self.device_manager
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED)
|
.notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED)
|
||||||
.map_err(Error::DeviceManager)?;
|
.map_err(Error::DeviceManager)?;
|
||||||
|
|
||||||
Ok(pci_device_info)
|
Ok(pci_device_info)
|
||||||
@ -1398,7 +1398,7 @@ impl Vm {
|
|||||||
self.device_manager
|
self.device_manager
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED)
|
.notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED)
|
||||||
.map_err(Error::DeviceManager)?;
|
.map_err(Error::DeviceManager)?;
|
||||||
|
|
||||||
Ok(pci_device_info)
|
Ok(pci_device_info)
|
||||||
@ -1426,7 +1426,7 @@ impl Vm {
|
|||||||
self.device_manager
|
self.device_manager
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED)
|
.notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED)
|
||||||
.map_err(Error::DeviceManager)?;
|
.map_err(Error::DeviceManager)?;
|
||||||
|
|
||||||
Ok(pci_device_info)
|
Ok(pci_device_info)
|
||||||
|
Loading…
Reference in New Issue
Block a user