diff --git a/src/dragonball/Cargo.toml b/src/dragonball/Cargo.toml index 3fa2dc5064..3cc17de1dd 100644 --- a/src/dragonball/Cargo.toml +++ b/src/dragonball/Cargo.toml @@ -45,8 +45,9 @@ slog-term = "2.9.0" slog-async = "2.7.0" [features] +acpi = [] atomic-guest-memory = [] -hotplug = ["dbs-upcall", "virtio-vsock"] +hotplug = ["virtio-vsock"] virtio-vsock = ["dbs-virtio-devices/virtio-vsock", "virtio-queue"] [patch.'crates-io'] diff --git a/src/dragonball/src/device_manager/mod.rs b/src/dragonball/src/device_manager/mod.rs index 0c485963ea..2ad26e0d01 100644 --- a/src/dragonball/src/device_manager/mod.rs +++ b/src/dragonball/src/device_manager/mod.rs @@ -29,10 +29,10 @@ use dbs_virtio_devices::{ VirtioDevice, }; -#[cfg(feature = "hotplug")] +#[cfg(all(feature = "hotplug", feature = "dbs-upcall"))] use dbs_upcall::{ - MmioDevRequest, DevMgrRequest, DevMgrService, UpcallClient, UpcallClientError, - UpcallClientRequest, UpcallClientResponse + DevMgrRequest, DevMgrService, MmioDevRequest, UpcallClient, UpcallClientError, + UpcallClientRequest, UpcallClientResponse, }; use crate::address_space_manager::GuestAddressSpaceImpl; @@ -90,7 +90,7 @@ pub enum DeviceMgrError { #[error(transparent)] Virtio(virtio::Error), - #[cfg(feature = "hotplug")] + #[cfg(all(feature = "hotplug", feature = "dbs-upcall"))] /// Failed to hotplug the device. #[error("failed to hotplug virtual device")] HotplugDevice(#[source] UpcallClientError), @@ -199,7 +199,7 @@ pub struct DeviceOpContext { logger: slog::Logger, is_hotplug: bool, - #[cfg(feature = "hotplug")] + #[cfg(all(feature = "hotplug", feature = "dbs-upcall"))] upcall_client: Option>>, #[cfg(feature = "dbs-virtio-devices")] virtio_devices: Vec>, @@ -233,7 +233,7 @@ impl DeviceOpContext { address_space, logger, is_hotplug, - #[cfg(feature = "hotplug")] + #[cfg(all(feature = "hotplug", feature = "dbs-upcall"))] upcall_client: None, #[cfg(feature = "dbs-virtio-devices")] virtio_devices: Vec::new(), @@ -301,7 +301,7 @@ impl DeviceOpContext { } } -#[cfg(feature = "hotplug")] +#[cfg(all(feature = "hotplug", feature = "dbs-upcall"))] impl DeviceOpContext { fn call_hotplug_device( &self, @@ -362,6 +362,11 @@ impl DeviceOpContext { } } +#[cfg(all(feature = "hotplug", feature = "acpi"))] +impl DeviceOpContext { + // TODO: We will implement this when we develop ACPI virtualization +} + /// Device manager for virtual machines, which manages all device for a virtual machine. pub struct DeviceManager { io_manager: Arc>, diff --git a/src/dragonball/src/vcpu/vcpu_manager.rs b/src/dragonball/src/vcpu/vcpu_manager.rs index f548035b2c..189dfc6155 100644 --- a/src/dragonball/src/vcpu/vcpu_manager.rs +++ b/src/dragonball/src/vcpu/vcpu_manager.rs @@ -15,7 +15,7 @@ use std::sync::mpsc::{channel, Receiver, RecvError, RecvTimeoutError, Sender}; use std::sync::{Arc, Barrier, Mutex, RwLock}; use std::time::Duration; -#[cfg(feature = "hotplug")] +#[cfg(all(feature = "hotplug", feature = "dbs-upcall"))] use dbs_upcall::{DevMgrService, UpcallClient}; use dbs_utils::epoll_manager::{EpollManager, EventOps, EventSet, Events, MutEventSubscriber}; use dbs_utils::time::TimestampUs; @@ -206,7 +206,7 @@ pub struct VcpuManager { vcpus_in_action: (VcpuAction, Vec), pub(crate) reset_event_fd: Option, - #[cfg(feature = "hotplug")] + #[cfg(all(feature = "hotplug", feature = "dbs-upcall"))] upcall_channel: Option>>, // X86 specific fields. @@ -290,7 +290,7 @@ impl VcpuManager { action_sycn_tx: None, vcpus_in_action: (VcpuAction::None, Vec::new()), reset_event_fd: None, - #[cfg(feature = "hotplug")] + #[cfg(all(feature = "hotplug", feature = "dbs-upcall"))] upcall_channel: None, #[cfg(target_arch = "x86_64")] supported_cpuid, @@ -794,6 +794,7 @@ mod hotplug { #[cfg(all(target_arch = "aarch64", not(test)))] const APIC_VERSION: u8 = 0; + #[cfg(feature = "dbs-upcall")] impl VcpuManager { /// add upcall channel for vcpu manager pub fn set_upcall_channel(