mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-07-01 22:50:54 +00:00
runtime-rs: ch: source virtio-fs queue size from toml
Now that `prepare_virtiofs` populates `ShareFsConfig` from `SharedFsInfo.virtio_fs_queue_size`, the CH-side fallback that substitutes `DEFAULT_FS_QUEUE_SIZE` (1024) when the incoming `queue_num`/`queue_size` are zero is no longer needed. Drop it from both `handle_share_fs_device` and `TryFrom<ShareFsSettings> for FsConfig` and use the values straight from the config. Drop the now unused `DEFAULT_FS_QUEUES` and `DEFAULT_FS_QUEUE_SIZE` constants. This also removes a latent bug in both call sites: the previous code gated `queue_size` on `queue_num > 0`, so a user setting only the queue size and not the (currently unconfigurable) queue count would have had their `queue_size` silently overwritten by the default. The CH config template (`configuration-clh-runtime-rs.toml.in`) did not ship the `virtio_fs_queue_size` key (unlike the qemu-runtime-rs templates), so without an explicit override the field would have deserialized to 0 and the fallback would have been the only thing keeping CH working. Add the key to the template, defaulted to `@DEFVIRTIOFSQUEUESIZE@` (1024), matching the qemu-runtime-rs templates. Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
This commit is contained in:
committed by
Fabiano Fidêncio
parent
0d5bde2181
commit
e2240b694a
@@ -97,6 +97,9 @@ virtio_fs_daemon = "@DEFVIRTIOFSDAEMON@"
|
|||||||
# Default size of DAX cache in MiB
|
# Default size of DAX cache in MiB
|
||||||
virtio_fs_cache_size = @DEFVIRTIOFSCACHESIZE@
|
virtio_fs_cache_size = @DEFVIRTIOFSCACHESIZE@
|
||||||
|
|
||||||
|
# Default size of virtqueues
|
||||||
|
virtio_fs_queue_size = @DEFVIRTIOFSQUEUESIZE@
|
||||||
|
|
||||||
# Extra args for virtiofsd daemon
|
# Extra args for virtiofsd daemon
|
||||||
#
|
#
|
||||||
# Format example:
|
# Format example:
|
||||||
|
|||||||
@@ -45,9 +45,6 @@ use std::path::PathBuf;
|
|||||||
|
|
||||||
const VIRTIO_FS: &str = "virtio-fs";
|
const VIRTIO_FS: &str = "virtio-fs";
|
||||||
|
|
||||||
pub const DEFAULT_FS_QUEUES: usize = 1;
|
|
||||||
const DEFAULT_FS_QUEUE_SIZE: u16 = 1024;
|
|
||||||
|
|
||||||
impl CloudHypervisorInner {
|
impl CloudHypervisorInner {
|
||||||
pub(crate) async fn add_device(&mut self, device: DeviceType) -> Result<DeviceType> {
|
pub(crate) async fn add_device(&mut self, device: DeviceType) -> Result<DeviceType> {
|
||||||
if self.state != VmmState::VmRunning {
|
if self.state != VmmState::VmRunning {
|
||||||
@@ -143,17 +140,8 @@ impl CloudHypervisorInner {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let num_queues: usize = if device.config.queue_num > 0 {
|
let num_queues = device.config.queue_num as usize;
|
||||||
device.config.queue_num as usize
|
let queue_size = u16::try_from(device.config.queue_size)?;
|
||||||
} else {
|
|
||||||
DEFAULT_FS_QUEUES
|
|
||||||
};
|
|
||||||
|
|
||||||
let queue_size: u16 = if device.config.queue_num > 0 {
|
|
||||||
u16::try_from(device.config.queue_size)?
|
|
||||||
} else {
|
|
||||||
DEFAULT_FS_QUEUE_SIZE
|
|
||||||
};
|
|
||||||
|
|
||||||
let socket_path = if device.config.sock_path.starts_with('/') {
|
let socket_path = if device.config.sock_path.starts_with('/') {
|
||||||
PathBuf::from(device.config.sock_path)
|
PathBuf::from(device.config.sock_path)
|
||||||
@@ -545,17 +533,8 @@ impl TryFrom<ShareFsSettings> for FsConfig {
|
|||||||
let cfg = settings.cfg;
|
let cfg = settings.cfg;
|
||||||
let vm_path = settings.vm_path;
|
let vm_path = settings.vm_path;
|
||||||
|
|
||||||
let num_queues: usize = if cfg.queue_num > 0 {
|
let num_queues = cfg.queue_num as usize;
|
||||||
cfg.queue_num as usize
|
let queue_size = u16::try_from(cfg.queue_size)?;
|
||||||
} else {
|
|
||||||
DEFAULT_FS_QUEUES
|
|
||||||
};
|
|
||||||
|
|
||||||
let queue_size: u16 = if cfg.queue_num > 0 {
|
|
||||||
u16::try_from(cfg.queue_size)?
|
|
||||||
} else {
|
|
||||||
DEFAULT_FS_QUEUE_SIZE
|
|
||||||
};
|
|
||||||
|
|
||||||
let socket_path = if cfg.sock_path.starts_with('/') {
|
let socket_path = if cfg.sock_path.starts_with('/') {
|
||||||
PathBuf::from(cfg.sock_path)
|
PathBuf::from(cfg.sock_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user