From 7b376fa8e0a28e2bd7b23c0a70782e568a83bc69 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 12 Jan 2021 15:10:05 +0000 Subject: [PATCH] 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 --- devices/src/acpi.rs | 10 +++++----- devices/src/lib.rs | 2 +- vmm/src/device_manager.rs | 4 ++-- vmm/src/vm.rs | 20 ++++++++++---------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/devices/src/acpi.rs b/devices/src/acpi.rs index 5a7d3c552..0bc90219a 100644 --- a/devices/src/acpi.rs +++ b/devices/src/acpi.rs @@ -9,7 +9,7 @@ use std::time::Instant; use vm_device::interrupt::InterruptSourceGroup; use vm_device::BusDevice; use vmm_sys_util::eventfd::EventFd; -use HotPlugNotificationFlags; +use AcpiNotificationFlags; /// A device for handling ACPI shutdown and reboot pub struct AcpiShutdownDevice { @@ -61,7 +61,7 @@ impl BusDevice for AcpiShutdownDevice { /// A device for handling ACPI GED event generation pub struct AcpiGEDDevice { interrupt: Arc>, - notification_type: HotPlugNotificationFlags, + notification_type: AcpiNotificationFlags, ged_irq: u32, } @@ -69,14 +69,14 @@ impl AcpiGEDDevice { pub fn new(interrupt: Arc>, ged_irq: u32) -> AcpiGEDDevice { AcpiGEDDevice { interrupt, - notification_type: HotPlugNotificationFlags::NO_DEVICES_CHANGED, + notification_type: AcpiNotificationFlags::NO_DEVICES_CHANGED, ged_irq, } } pub fn notify( &mut self, - notification_type: HotPlugNotificationFlags, + notification_type: AcpiNotificationFlags, ) -> Result<(), std::io::Error> { self.notification_type |= notification_type; self.interrupt.trigger(0) @@ -92,7 +92,7 @@ impl BusDevice for AcpiGEDDevice { // Spec has all fields as zero fn read(&mut self, _base: u64, _offset: u64, data: &mut [u8]) { data[0] = self.notification_type.bits(); - self.notification_type = HotPlugNotificationFlags::NO_DEVICES_CHANGED; + self.notification_type = AcpiNotificationFlags::NO_DEVICES_CHANGED; } } diff --git a/devices/src/lib.rs b/devices/src/lib.rs index bdfdf5f5c..21378fc42 100644 --- a/devices/src/lib.rs +++ b/devices/src/lib.rs @@ -38,7 +38,7 @@ pub mod legacy; pub use self::acpi::{AcpiGEDDevice, AcpiPMTimerDevice, AcpiShutdownDevice}; bitflags! { - pub struct HotPlugNotificationFlags: u8 { + pub struct AcpiNotificationFlags: u8 { const NO_DEVICES_CHANGED = 0; const CPU_DEVICES_CHANGED = 0b1; const MEMORY_DEVICES_CHANGED = 0b10; diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index fae3835df..9b49fdf6f 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -43,7 +43,7 @@ use devices::gic; use devices::ioapic; use devices::{ interrupt_controller, interrupt_controller::InterruptController, legacy::Serial, - HotPlugNotificationFlags, + AcpiNotificationFlags, }; #[cfg(feature = "kvm")] use hypervisor::kvm_ioctls::*; @@ -2871,7 +2871,7 @@ impl DeviceManager { pub fn notify_hotplug( &self, - _notification_type: HotPlugNotificationFlags, + _notification_type: AcpiNotificationFlags, ) -> DeviceManagerResult<()> { #[cfg(feature = "acpi")] return self diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index d05361314..76845d594 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -42,7 +42,7 @@ use arch::get_host_cpu_phys_bits; #[cfg(target_arch = "x86_64")] use arch::BootProtocol; use arch::EntryPoint; -use devices::HotPlugNotificationFlags; +use devices::AcpiNotificationFlags; use hypervisor::vm::{HypervisorVmError, VmmOps}; use linux_loader::cmdline::Cmdline; #[cfg(target_arch = "x86_64")] @@ -1115,7 +1115,7 @@ impl Vm { self.device_manager .lock() .unwrap() - .notify_hotplug(HotPlugNotificationFlags::CPU_DEVICES_CHANGED) + .notify_hotplug(AcpiNotificationFlags::CPU_DEVICES_CHANGED) .map_err(Error::DeviceManager)?; } self.config.lock().unwrap().cpus.boot_vcpus = desired_vcpus; @@ -1143,7 +1143,7 @@ impl Vm { self.device_manager .lock() .unwrap() - .notify_hotplug(HotPlugNotificationFlags::MEMORY_DEVICES_CHANGED) + .notify_hotplug(AcpiNotificationFlags::MEMORY_DEVICES_CHANGED) .map_err(Error::DeviceManager)?; } HotplugMethod::VirtioMem => {} @@ -1240,7 +1240,7 @@ impl Vm { self.device_manager .lock() .unwrap() - .notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED) + .notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED) .map_err(Error::DeviceManager)?; Ok(pci_device_info) @@ -1287,7 +1287,7 @@ impl Vm { self.device_manager .lock() .unwrap() - .notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED) + .notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED) .map_err(Error::DeviceManager)?; Ok(()) } @@ -1314,7 +1314,7 @@ impl Vm { self.device_manager .lock() .unwrap() - .notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED) + .notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED) .map_err(Error::DeviceManager)?; Ok(pci_device_info) @@ -1342,7 +1342,7 @@ impl Vm { self.device_manager .lock() .unwrap() - .notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED) + .notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED) .map_err(Error::DeviceManager)?; Ok(pci_device_info) @@ -1370,7 +1370,7 @@ impl Vm { self.device_manager .lock() .unwrap() - .notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED) + .notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED) .map_err(Error::DeviceManager)?; Ok(pci_device_info) @@ -1398,7 +1398,7 @@ impl Vm { self.device_manager .lock() .unwrap() - .notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED) + .notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED) .map_err(Error::DeviceManager)?; Ok(pci_device_info) @@ -1426,7 +1426,7 @@ impl Vm { self.device_manager .lock() .unwrap() - .notify_hotplug(HotPlugNotificationFlags::PCI_DEVICES_CHANGED) + .notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED) .map_err(Error::DeviceManager)?; Ok(pci_device_info)