mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 12:14:48 +00:00
runtime-rs: ch: Add more consts
Introduce a few new constants (for PCI segment count and FS queues) and move the disk queue constants to `convert.rs` to allow them to be used there too. > **Note:** > > This change gives the `ShareFs` code it's own set of values rather > than relying on the disk queue constants. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
parent
dea8065811
commit
523399c329
@ -28,6 +28,11 @@ const DEFAULT_CH_MAX_PHYS_BITS: u8 = 46;
|
||||
|
||||
const DEFAULT_VSOCK_CID: u64 = 3;
|
||||
|
||||
pub const DEFAULT_NUM_PCI_SEGMENTS: u16 = 1;
|
||||
|
||||
pub const DEFAULT_DISK_QUEUES: usize = 1;
|
||||
pub const DEFAULT_DISK_QUEUE_SIZE: u16 = 128;
|
||||
|
||||
impl TryFrom<NamedHypervisorConfig> for VmConfig {
|
||||
type Error = VmConfigError;
|
||||
|
||||
@ -355,6 +360,8 @@ impl TryFrom<BootInfo> for DiskConfig {
|
||||
let disk = DiskConfig {
|
||||
path: Some(path),
|
||||
readonly: true,
|
||||
num_queues: DEFAULT_DISK_QUEUES,
|
||||
queue_size: DEFAULT_DISK_QUEUE_SIZE,
|
||||
|
||||
..Default::default()
|
||||
};
|
||||
@ -438,6 +445,7 @@ fn get_platform_cfg(tdx_enabled: bool) -> Option<PlatformConfig> {
|
||||
if tdx_enabled {
|
||||
let platform = PlatformConfig {
|
||||
tdx: true,
|
||||
num_pci_segments: DEFAULT_NUM_PCI_SEGMENTS,
|
||||
|
||||
..Default::default()
|
||||
};
|
||||
@ -584,6 +592,8 @@ mod tests {
|
||||
let disk_config = DiskConfig {
|
||||
path: Some(PathBuf::from(path)),
|
||||
readonly: true,
|
||||
num_queues: DEFAULT_DISK_QUEUES,
|
||||
queue_size: DEFAULT_DISK_QUEUE_SIZE,
|
||||
|
||||
..Default::default()
|
||||
};
|
||||
@ -788,6 +798,7 @@ mod tests {
|
||||
tdx_enabled: true,
|
||||
result: Some(PlatformConfig {
|
||||
tdx: true,
|
||||
num_pci_segments: DEFAULT_NUM_PCI_SEGMENTS,
|
||||
|
||||
..Default::default()
|
||||
}),
|
||||
|
@ -13,6 +13,7 @@ use crate::ShareFsDeviceConfig;
|
||||
use crate::VmmState;
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use ch_config::ch_api::{cloud_hypervisor_vm_blockdev_add, cloud_hypervisor_vm_fs_add};
|
||||
use ch_config::convert::{DEFAULT_DISK_QUEUES, DEFAULT_DISK_QUEUE_SIZE, DEFAULT_NUM_PCI_SEGMENTS};
|
||||
use ch_config::DiskConfig;
|
||||
use ch_config::{net_util::MacAddr, FsConfig, NetConfig};
|
||||
use safe_path::scoped_join;
|
||||
@ -20,8 +21,9 @@ use std::convert::TryFrom;
|
||||
use std::path::PathBuf;
|
||||
|
||||
const VIRTIO_FS: &str = "virtio-fs";
|
||||
const DEFAULT_DISK_QUEUES: usize = 1;
|
||||
const DEFAULT_DISK_QUEUE_SIZE: u16 = 1024;
|
||||
|
||||
pub const DEFAULT_FS_QUEUES: usize = 1;
|
||||
const DEFAULT_FS_QUEUE_SIZE: u16 = 1024;
|
||||
|
||||
impl CloudHypervisorInner {
|
||||
pub(crate) async fn add_device(&mut self, device: DeviceType) -> Result<()> {
|
||||
@ -93,13 +95,13 @@ impl CloudHypervisorInner {
|
||||
let num_queues: usize = if cfg.queue_num > 0 {
|
||||
cfg.queue_num as usize
|
||||
} else {
|
||||
1
|
||||
DEFAULT_FS_QUEUES
|
||||
};
|
||||
|
||||
let queue_size: u16 = if cfg.queue_num > 0 {
|
||||
u16::try_from(cfg.queue_size)?
|
||||
} else {
|
||||
1024
|
||||
DEFAULT_FS_QUEUE_SIZE
|
||||
};
|
||||
|
||||
let socket_path = if cfg.sock_path.starts_with('/') {
|
||||
@ -113,6 +115,8 @@ impl CloudHypervisorInner {
|
||||
socket: socket_path,
|
||||
num_queues,
|
||||
queue_size,
|
||||
pci_segment: DEFAULT_NUM_PCI_SEGMENTS,
|
||||
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@ -233,13 +237,13 @@ impl TryFrom<ShareFsSettings> for FsConfig {
|
||||
let num_queues: usize = if cfg.queue_num > 0 {
|
||||
cfg.queue_num as usize
|
||||
} else {
|
||||
DEFAULT_DISK_QUEUES
|
||||
DEFAULT_FS_QUEUES
|
||||
};
|
||||
|
||||
let queue_size: u16 = if cfg.queue_num > 0 {
|
||||
u16::try_from(cfg.queue_size)?
|
||||
} else {
|
||||
DEFAULT_DISK_QUEUE_SIZE
|
||||
DEFAULT_FS_QUEUE_SIZE
|
||||
};
|
||||
|
||||
let socket_path = if cfg.sock_path.starts_with('/') {
|
||||
|
Loading…
Reference in New Issue
Block a user