runtime-rs: move the rate limiter to hypervisor config

Since the rate limiter would be shared by cloud-hypervisor
and firecracker etc, thus move it from clh's config to
hypervisor config crate which would be shared by other vmm.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
This commit is contained in:
Fupan Li
2025-09-10 17:38:51 +08:00
committed by Fabiano Fidêncio
parent 73e31ea19a
commit e0caeb32fc
4 changed files with 11 additions and 5 deletions

View File

@@ -48,6 +48,9 @@ pub use self::ch::{CloudHypervisorConfig, HYPERVISOR_NAME_CH};
mod remote;
pub use self::remote::{RemoteConfig, HYPERVISOR_NAME_REMOTE};
mod rate_limiter;
pub use self::rate_limiter::RateLimiterConfig;
/// Virtual PCI block device driver.
pub const VIRTIO_BLK_PCI: &str = "virtio-blk-pci";

View File

@@ -1,5 +1,7 @@
// Copyright (c) 2022-2023 Intel Corporation
//
// Copyright (c) 2024-2025 Ant Group
//
// SPDX-License-Identifier: Apache-2.0
use serde::{Deserialize, Serialize};
@@ -16,10 +18,13 @@ pub struct TokenBucketConfig {
pub refill_time: u64,
}
/// Rate limiter configuration for rust vmm hypervisor
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct RateLimiterConfig {
/// Bandwidth rate limiter options
pub bandwidth: Option<TokenBucketConfig>,
/// Operations rate limiter options
pub ops: Option<TokenBucketConfig>,
}

View File

@@ -9,11 +9,10 @@ use std::path::PathBuf;
pub mod ch_api;
pub mod convert;
pub mod net_util;
mod virtio_devices;
pub use crate::virtio_devices::RateLimiterConfig;
use kata_sys_util::protection::GuestProtection;
use kata_types::config::hypervisor::Hypervisor as HypervisorConfig;
use kata_types::config::hypervisor::RateLimiterConfig;
pub use net_util::MacAddr;
pub const MAX_NUM_PCI_SEGMENTS: u16 = 16;

View File

@@ -24,9 +24,8 @@ use ch_config::ch_api::{
};
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, DeviceConfig, FsConfig, NetConfig, RateLimiterConfig, VsockConfig,
};
use ch_config::{net_util::MacAddr, DeviceConfig, FsConfig, NetConfig, VsockConfig};
use kata_types::config::hypervisor::RateLimiterConfig;
use safe_path::scoped_join;
use std::convert::TryFrom;
use std::path::PathBuf;