mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 04:34:27 +00:00
hotplug: add room for future acpi hotplug mechanism
In order to support ACPI hotplug in the future with the cooperative work from the Kata community, we add ACPI feature and dbs-upcall feature to add room for ACPI hotplug. Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
This commit is contained in:
parent
8bb00a3dc8
commit
71db2dd5b8
@ -45,8 +45,9 @@ slog-term = "2.9.0"
|
|||||||
slog-async = "2.7.0"
|
slog-async = "2.7.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
acpi = []
|
||||||
atomic-guest-memory = []
|
atomic-guest-memory = []
|
||||||
hotplug = ["dbs-upcall", "virtio-vsock"]
|
hotplug = ["virtio-vsock"]
|
||||||
virtio-vsock = ["dbs-virtio-devices/virtio-vsock", "virtio-queue"]
|
virtio-vsock = ["dbs-virtio-devices/virtio-vsock", "virtio-queue"]
|
||||||
|
|
||||||
[patch.'crates-io']
|
[patch.'crates-io']
|
||||||
|
@ -29,10 +29,10 @@ use dbs_virtio_devices::{
|
|||||||
VirtioDevice,
|
VirtioDevice,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "hotplug")]
|
#[cfg(all(feature = "hotplug", feature = "dbs-upcall"))]
|
||||||
use dbs_upcall::{
|
use dbs_upcall::{
|
||||||
MmioDevRequest, DevMgrRequest, DevMgrService, UpcallClient, UpcallClientError,
|
DevMgrRequest, DevMgrService, MmioDevRequest, UpcallClient, UpcallClientError,
|
||||||
UpcallClientRequest, UpcallClientResponse
|
UpcallClientRequest, UpcallClientResponse,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::address_space_manager::GuestAddressSpaceImpl;
|
use crate::address_space_manager::GuestAddressSpaceImpl;
|
||||||
@ -90,7 +90,7 @@ pub enum DeviceMgrError {
|
|||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Virtio(virtio::Error),
|
Virtio(virtio::Error),
|
||||||
|
|
||||||
#[cfg(feature = "hotplug")]
|
#[cfg(all(feature = "hotplug", feature = "dbs-upcall"))]
|
||||||
/// Failed to hotplug the device.
|
/// Failed to hotplug the device.
|
||||||
#[error("failed to hotplug virtual device")]
|
#[error("failed to hotplug virtual device")]
|
||||||
HotplugDevice(#[source] UpcallClientError),
|
HotplugDevice(#[source] UpcallClientError),
|
||||||
@ -199,7 +199,7 @@ pub struct DeviceOpContext {
|
|||||||
logger: slog::Logger,
|
logger: slog::Logger,
|
||||||
is_hotplug: bool,
|
is_hotplug: bool,
|
||||||
|
|
||||||
#[cfg(feature = "hotplug")]
|
#[cfg(all(feature = "hotplug", feature = "dbs-upcall"))]
|
||||||
upcall_client: Option<Arc<UpcallClient<DevMgrService>>>,
|
upcall_client: Option<Arc<UpcallClient<DevMgrService>>>,
|
||||||
#[cfg(feature = "dbs-virtio-devices")]
|
#[cfg(feature = "dbs-virtio-devices")]
|
||||||
virtio_devices: Vec<Arc<DbsMmioV2Device>>,
|
virtio_devices: Vec<Arc<DbsMmioV2Device>>,
|
||||||
@ -233,7 +233,7 @@ impl DeviceOpContext {
|
|||||||
address_space,
|
address_space,
|
||||||
logger,
|
logger,
|
||||||
is_hotplug,
|
is_hotplug,
|
||||||
#[cfg(feature = "hotplug")]
|
#[cfg(all(feature = "hotplug", feature = "dbs-upcall"))]
|
||||||
upcall_client: None,
|
upcall_client: None,
|
||||||
#[cfg(feature = "dbs-virtio-devices")]
|
#[cfg(feature = "dbs-virtio-devices")]
|
||||||
virtio_devices: Vec::new(),
|
virtio_devices: Vec::new(),
|
||||||
@ -301,7 +301,7 @@ impl DeviceOpContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "hotplug")]
|
#[cfg(all(feature = "hotplug", feature = "dbs-upcall"))]
|
||||||
impl DeviceOpContext {
|
impl DeviceOpContext {
|
||||||
fn call_hotplug_device(
|
fn call_hotplug_device(
|
||||||
&self,
|
&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.
|
/// Device manager for virtual machines, which manages all device for a virtual machine.
|
||||||
pub struct DeviceManager {
|
pub struct DeviceManager {
|
||||||
io_manager: Arc<ArcSwap<IoManager>>,
|
io_manager: Arc<ArcSwap<IoManager>>,
|
||||||
|
@ -15,7 +15,7 @@ use std::sync::mpsc::{channel, Receiver, RecvError, RecvTimeoutError, Sender};
|
|||||||
use std::sync::{Arc, Barrier, Mutex, RwLock};
|
use std::sync::{Arc, Barrier, Mutex, RwLock};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
#[cfg(feature = "hotplug")]
|
#[cfg(all(feature = "hotplug", feature = "dbs-upcall"))]
|
||||||
use dbs_upcall::{DevMgrService, UpcallClient};
|
use dbs_upcall::{DevMgrService, UpcallClient};
|
||||||
use dbs_utils::epoll_manager::{EpollManager, EventOps, EventSet, Events, MutEventSubscriber};
|
use dbs_utils::epoll_manager::{EpollManager, EventOps, EventSet, Events, MutEventSubscriber};
|
||||||
use dbs_utils::time::TimestampUs;
|
use dbs_utils::time::TimestampUs;
|
||||||
@ -206,7 +206,7 @@ pub struct VcpuManager {
|
|||||||
vcpus_in_action: (VcpuAction, Vec<u8>),
|
vcpus_in_action: (VcpuAction, Vec<u8>),
|
||||||
pub(crate) reset_event_fd: Option<EventFd>,
|
pub(crate) reset_event_fd: Option<EventFd>,
|
||||||
|
|
||||||
#[cfg(feature = "hotplug")]
|
#[cfg(all(feature = "hotplug", feature = "dbs-upcall"))]
|
||||||
upcall_channel: Option<Arc<UpcallClient<DevMgrService>>>,
|
upcall_channel: Option<Arc<UpcallClient<DevMgrService>>>,
|
||||||
|
|
||||||
// X86 specific fields.
|
// X86 specific fields.
|
||||||
@ -290,7 +290,7 @@ impl VcpuManager {
|
|||||||
action_sycn_tx: None,
|
action_sycn_tx: None,
|
||||||
vcpus_in_action: (VcpuAction::None, Vec::new()),
|
vcpus_in_action: (VcpuAction::None, Vec::new()),
|
||||||
reset_event_fd: None,
|
reset_event_fd: None,
|
||||||
#[cfg(feature = "hotplug")]
|
#[cfg(all(feature = "hotplug", feature = "dbs-upcall"))]
|
||||||
upcall_channel: None,
|
upcall_channel: None,
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
supported_cpuid,
|
supported_cpuid,
|
||||||
@ -794,6 +794,7 @@ mod hotplug {
|
|||||||
#[cfg(all(target_arch = "aarch64", not(test)))]
|
#[cfg(all(target_arch = "aarch64", not(test)))]
|
||||||
const APIC_VERSION: u8 = 0;
|
const APIC_VERSION: u8 = 0;
|
||||||
|
|
||||||
|
#[cfg(feature = "dbs-upcall")]
|
||||||
impl VcpuManager {
|
impl VcpuManager {
|
||||||
/// add upcall channel for vcpu manager
|
/// add upcall channel for vcpu manager
|
||||||
pub fn set_upcall_channel(
|
pub fn set_upcall_channel(
|
||||||
|
Loading…
Reference in New Issue
Block a user