mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-27 07:48:55 +00:00
dragonball: add vcpu manager
Manage vcpu related operations. Signed-off-by: Liu Jiang <gerry@linux.alibaba.com> Signed-off-by: jingshan <jingshan@linux.alibaba.com> Signed-off-by: Chao Wu <chaowu@linux.alibaba.com> Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
This commit is contained in:
parent
78c9718752
commit
07f44c3e0a
@ -446,7 +446,7 @@ impl DeviceManager {
|
||||
self.set_guest_kernel_log_stream(dmesg_fifo)
|
||||
.map_err(|_| StartMicrovmError::EventFd)?;
|
||||
|
||||
slog::info!(self.logger, "init console path: {:?}", com1_sock_path);
|
||||
info!(self.logger, "init console path: {:?}", com1_sock_path);
|
||||
if let Some(path) = com1_sock_path {
|
||||
if let Some(legacy_manager) = self.legacy_manager.as_ref() {
|
||||
let com1 = legacy_manager.get_com1_serial();
|
||||
@ -482,19 +482,6 @@ impl DeviceManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Restore legacy devices
|
||||
pub fn restore_legacy_devices(
|
||||
&mut self,
|
||||
dmesg_fifo: Option<Box<dyn io::Write + Send>>,
|
||||
com1_sock_path: Option<String>,
|
||||
) -> std::result::Result<(), StartMicrovmError> {
|
||||
self.set_guest_kernel_log_stream(dmesg_fifo)
|
||||
.map_err(|_| StartMicrovmError::EventFd)?;
|
||||
slog::info!(self.logger, "restore console path: {:?}", com1_sock_path);
|
||||
// TODO: restore console
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Reset the console into canonical mode.
|
||||
pub fn reset_console(&self) -> Result<()> {
|
||||
self.con_manager.reset_console()
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
mod sm;
|
||||
pub mod vcpu_impl;
|
||||
pub mod vcpu_manager;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use dbs_arch::cpuid::VpmuFeatureLevel;
|
||||
|
@ -19,7 +19,7 @@ use dbs_utils::time::TimestampUs;
|
||||
use kvm_bindings::{KVM_SYSTEM_EVENT_RESET, KVM_SYSTEM_EVENT_SHUTDOWN};
|
||||
use kvm_ioctls::{VcpuExit, VcpuFd};
|
||||
use libc::{c_int, c_void, siginfo_t};
|
||||
use log::{error, info, warn};
|
||||
use log::{error, info};
|
||||
use seccompiler::{apply_filter, BpfProgram, Error as SecError};
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
use vmm_sys_util::signal::{register_signal_handler, Killable};
|
||||
@ -216,8 +216,8 @@ pub enum VcpuResponse {
|
||||
|
||||
/// List of events that the vcpu_state_sender can send.
|
||||
pub enum VcpuStateEvent {
|
||||
/// For Hotplug
|
||||
Hotplug((bool, u32)),
|
||||
/// (result, response) for hotplug, result 0 means failure, 1 means success.
|
||||
Hotplug((i32, u32)),
|
||||
}
|
||||
|
||||
/// Wrapper over vCPU that hides the underlying interactions with the vCPU thread.
|
||||
@ -541,7 +541,7 @@ impl Vcpu {
|
||||
MAGIC_IOPORT_DEBUG_INFO => {
|
||||
if data.len() == 4 {
|
||||
let data = unsafe { std::ptr::read(data.as_ptr() as *const u32) };
|
||||
warn!("KDBG: guest kernel debug info: 0x{:x}", data);
|
||||
log::warn!("KDBG: guest kernel debug info: 0x{:x}", data);
|
||||
checked = true;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,3 +18,79 @@ pub struct NumaRegionInfo {
|
||||
/// vcpu ids belonging to this region
|
||||
pub vcpu_ids: Vec<u32>,
|
||||
}
|
||||
|
||||
/// Information for cpu topology to guide guest init
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
pub struct CpuTopology {
|
||||
/// threads per core to indicate hyperthreading is enabled or not
|
||||
pub threads_per_core: u8,
|
||||
/// cores per die to guide guest cpu topology init
|
||||
pub cores_per_die: u8,
|
||||
/// dies per socket to guide guest cpu topology
|
||||
pub dies_per_socket: u8,
|
||||
/// number of sockets
|
||||
pub sockets: u8,
|
||||
}
|
||||
|
||||
impl Default for CpuTopology {
|
||||
fn default() -> Self {
|
||||
CpuTopology {
|
||||
threads_per_core: 1,
|
||||
cores_per_die: 1,
|
||||
dies_per_socket: 1,
|
||||
sockets: 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuration information for virtual machine instance.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct VmConfigInfo {
|
||||
/// Number of vcpu to start.
|
||||
pub vcpu_count: u8,
|
||||
/// Max number of vcpu can be added
|
||||
pub max_vcpu_count: u8,
|
||||
/// Enable or disable hyperthreading.
|
||||
pub ht_enabled: bool,
|
||||
/// cpu power management.
|
||||
pub cpu_pm: String,
|
||||
/// cpu topology information
|
||||
pub cpu_topology: CpuTopology,
|
||||
/// vpmu support level
|
||||
pub vpmu_feature: u8,
|
||||
|
||||
/// Memory type that can be either hugetlbfs or shmem, default is shmem
|
||||
pub mem_type: String,
|
||||
/// Memory file path
|
||||
pub mem_file_path: String,
|
||||
/// The memory size in MiB.
|
||||
pub mem_size_mib: usize,
|
||||
/// reserve memory bytes
|
||||
pub reserve_memory_bytes: u64,
|
||||
|
||||
/// sock path
|
||||
pub serial_path: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for VmConfigInfo {
|
||||
fn default() -> Self {
|
||||
VmConfigInfo {
|
||||
vcpu_count: 1,
|
||||
max_vcpu_count: 1,
|
||||
ht_enabled: false,
|
||||
cpu_pm: String::from("on"),
|
||||
cpu_topology: CpuTopology {
|
||||
threads_per_core: 1,
|
||||
cores_per_die: 1,
|
||||
dies_per_socket: 1,
|
||||
sockets: 1,
|
||||
},
|
||||
vpmu_feature: 0,
|
||||
mem_type: String::from("shmem"),
|
||||
mem_file_path: String::from(""),
|
||||
mem_size_mib: 128,
|
||||
reserve_memory_bytes: 0,
|
||||
serial_path: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user