mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 21:55:20 +00:00
vmm: config: Add poll_queue property to DiskConfig
Recently, vhost_user_block gained the ability of actively polling the queue, a feature that can be disabled with the poll_queue property. This change adds this property to DiskConfig, so it can be used through the "disk" argument. For the moment, it can only be used when vhost_user=true, but this will change once virtio-block gets the poll_queue feature too. Fixes: #787 Signed-off-by: Sergio Lopez <slp@redhat.com>
This commit is contained in:
parent
378dd81204
commit
d2f1749edb
@ -297,6 +297,9 @@ components:
|
||||
wce:
|
||||
type: boolean
|
||||
default: true
|
||||
poll_queue:
|
||||
type: boolean
|
||||
default: true
|
||||
|
||||
NetConfig:
|
||||
type: object
|
||||
|
@ -41,6 +41,8 @@ pub enum Error {
|
||||
ParseDisksParams,
|
||||
/// Failed parsing disk queue number parameter.
|
||||
ParseDiskNumQueuesParam(std::num::ParseIntError),
|
||||
/// Failed parsing disk poll_queue parameter.
|
||||
ParseDiskPollQueueParam(std::str::ParseBoolError),
|
||||
/// Failed parsing disk queue size parameter.
|
||||
ParseDiskQueueSizeParam(std::num::ParseIntError),
|
||||
/// Failed to parse vhost parameters
|
||||
@ -365,6 +367,8 @@ pub struct DiskConfig {
|
||||
pub vhost_socket: Option<String>,
|
||||
#[serde(default = "default_diskconfig_wce")]
|
||||
pub wce: bool,
|
||||
#[serde(default = "default_diskconfig_poll_queue")]
|
||||
pub poll_queue: bool,
|
||||
}
|
||||
|
||||
fn default_diskconfig_num_queues() -> usize {
|
||||
@ -379,6 +383,10 @@ fn default_diskconfig_wce() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn default_diskconfig_poll_queue() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
impl DiskConfig {
|
||||
pub fn parse(disk: &str) -> Result<Self> {
|
||||
// Split the parameters based on the comma delimiter
|
||||
@ -393,6 +401,7 @@ impl DiskConfig {
|
||||
let mut vhost_socket_str: &str = "";
|
||||
let mut vhost_user_str: &str = "";
|
||||
let mut wce_str: &str = "";
|
||||
let mut poll_queue_str: &str = "";
|
||||
|
||||
for param in params_list.iter() {
|
||||
if param.starts_with("path=") {
|
||||
@ -413,6 +422,8 @@ impl DiskConfig {
|
||||
vhost_socket_str = ¶m[7..];
|
||||
} else if param.starts_with("wce=") {
|
||||
wce_str = ¶m[4..];
|
||||
} else if param.starts_with("poll_queue=") {
|
||||
poll_queue_str = ¶m[11..];
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,6 +432,7 @@ impl DiskConfig {
|
||||
let mut vhost_user = false;
|
||||
let mut vhost_socket = None;
|
||||
let mut wce: bool = default_diskconfig_wce();
|
||||
let mut poll_queue: bool = default_diskconfig_poll_queue();
|
||||
|
||||
if !num_queues_str.is_empty() {
|
||||
num_queues = num_queues_str
|
||||
@ -444,6 +456,14 @@ impl DiskConfig {
|
||||
}
|
||||
wce = wce_str.parse().map_err(Error::ParseDiskWceParam)?;
|
||||
}
|
||||
if !poll_queue_str.is_empty() {
|
||||
if !vhost_user {
|
||||
warn!("poll_queue parameter currently only has effect when used vhost_user=true");
|
||||
}
|
||||
poll_queue = poll_queue_str
|
||||
.parse()
|
||||
.map_err(Error::ParseDiskPollQueueParam)?;
|
||||
}
|
||||
|
||||
Ok(DiskConfig {
|
||||
path: PathBuf::from(path_str),
|
||||
@ -455,6 +475,7 @@ impl DiskConfig {
|
||||
vhost_socket,
|
||||
vhost_user,
|
||||
wce,
|
||||
poll_queue,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user