mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-11-04 19:11:11 +00:00
vmm: Add num_queues and queue_size parameters to virtio-blk
The number of queues and the size of each queue were not configurable. In anticipation for adding multiqueue support, this commit introduces some new parameters to let the user decide about the number of queues and the queue size. Note that the default values for each of these parameters are identical to the default values used for vhost-user-blk, that is 1 for the number of queues and 128 for the queue size. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
c4b3ed7223
commit
08e47ebd4b
@ -122,7 +122,9 @@ fn create_app<'a, 'b>(
|
||||
.long("disk")
|
||||
.help(
|
||||
"Disk parameters \"path=<disk_image_path>,\
|
||||
readonly=on|off,iommu=on|off\"",
|
||||
readonly=on|off,iommu=on|off,\
|
||||
num_queues=<number_of_queues>,\
|
||||
queue_size=<size_of_each_queue>\"",
|
||||
)
|
||||
.takes_value(true)
|
||||
.min_values(1)
|
||||
|
@ -277,6 +277,12 @@ components:
|
||||
iommu:
|
||||
type: boolean
|
||||
default: false
|
||||
num_queues:
|
||||
type: integer
|
||||
default: 1
|
||||
queue_size:
|
||||
type: integer
|
||||
default: 128
|
||||
|
||||
NetConfig:
|
||||
type: object
|
||||
|
@ -39,6 +39,10 @@ pub enum Error {
|
||||
ParseCmdlineParams,
|
||||
/// Failed parsing disks parameters.
|
||||
ParseDisksParams,
|
||||
/// Failed parsing disk queue number parameter.
|
||||
ParseDiskNumQueuesParam(std::num::ParseIntError),
|
||||
/// Failed parsing disk queue size parameter.
|
||||
ParseDiskQueueSizeParam(std::num::ParseIntError),
|
||||
/// Failed parsing random number generator parameters.
|
||||
ParseRngParams,
|
||||
/// Failed parsing network ip parameter.
|
||||
@ -344,6 +348,18 @@ pub struct DiskConfig {
|
||||
pub direct: bool,
|
||||
#[serde(default)]
|
||||
pub iommu: bool,
|
||||
#[serde(default = "default_diskconfig_num_queues")]
|
||||
pub num_queues: usize,
|
||||
#[serde(default = "default_diskconfig_queue_size")]
|
||||
pub queue_size: u16,
|
||||
}
|
||||
|
||||
fn default_diskconfig_num_queues() -> usize {
|
||||
DEFAULT_NUM_QUEUES_VUBLK
|
||||
}
|
||||
|
||||
fn default_diskconfig_queue_size() -> u16 {
|
||||
DEFAULT_QUEUE_SIZE_VUBLK
|
||||
}
|
||||
|
||||
impl DiskConfig {
|
||||
@ -355,6 +371,8 @@ impl DiskConfig {
|
||||
let mut readonly_str: &str = "";
|
||||
let mut direct_str: &str = "";
|
||||
let mut iommu_str: &str = "";
|
||||
let mut num_queues_str: &str = "";
|
||||
let mut queue_size_str: &str = "";
|
||||
|
||||
for param in params_list.iter() {
|
||||
if param.starts_with("path=") {
|
||||
@ -365,14 +383,34 @@ impl DiskConfig {
|
||||
direct_str = ¶m[7..];
|
||||
} else if param.starts_with("iommu=") {
|
||||
iommu_str = ¶m[6..];
|
||||
} else if param.starts_with("num_queues=") {
|
||||
num_queues_str = ¶m[11..];
|
||||
} else if param.starts_with("queue_size=") {
|
||||
queue_size_str = ¶m[11..];
|
||||
}
|
||||
}
|
||||
|
||||
let mut num_queues: usize = default_diskconfig_num_queues();
|
||||
let mut queue_size: u16 = default_diskconfig_queue_size();
|
||||
|
||||
if !num_queues_str.is_empty() {
|
||||
num_queues = num_queues_str
|
||||
.parse()
|
||||
.map_err(Error::ParseDiskNumQueuesParam)?;
|
||||
}
|
||||
if !queue_size_str.is_empty() {
|
||||
queue_size = queue_size_str
|
||||
.parse()
|
||||
.map_err(Error::ParseDiskQueueSizeParam)?;
|
||||
}
|
||||
|
||||
Ok(DiskConfig {
|
||||
path: PathBuf::from(path_str),
|
||||
readonly: parse_on_off(readonly_str)?,
|
||||
direct: parse_on_off(direct_str)?,
|
||||
iommu: parse_on_off(iommu_str)?,
|
||||
num_queues,
|
||||
queue_size,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user