vmm: api: Match VhostUserBlkConfig defaults between CLI and HTTP API

In order to let the CLI and the HTTP API behave the same regarding the
VhostUserBlkConfig structure, this patch defines some default values
for num_queues, queue_size and wce.

num_queues is 1, queue_size is 128 and wce is true.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2019-12-10 17:15:43 +01:00 committed by Rob Bradford
parent 1c2587f8cb
commit 4bfd51cc42
2 changed files with 23 additions and 6 deletions

View File

@ -391,19 +391,19 @@ components:
VhostUserBlkConfig:
required:
- sock
- num_queues
- queue_size
- wce
type: object
properties:
sock:
type: string
num_queues:
type: integer
default: 1
queue_size:
type: integer
default: 128
wce:
type: boolean
default: true
VsockConfig:
required:

View File

@ -17,6 +17,8 @@ pub const DEFAULT_MEMORY_MB: u64 = 512;
pub const DEFAULT_RNG_SOURCE: &str = "/dev/urandom";
pub const DEFAULT_NUM_QUEUES_VUNET: usize = 2;
pub const DEFAULT_QUEUE_SIZE_VUNET: u16 = 256;
pub const DEFAULT_NUM_QUEUES_VUBLK: usize = 1;
pub const DEFAULT_QUEUE_SIZE_VUBLK: u16 = 128;
/// Errors associated with VM configuration parameters.
#[derive(Debug)]
@ -812,11 +814,26 @@ impl VsockConfig {
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct VhostUserBlkConfig {
pub sock: String,
#[serde(default = "default_vublkconfig_num_queues")]
pub num_queues: usize,
#[serde(default = "default_vublkconfig_queue_size")]
pub queue_size: u16,
#[serde(default = "default_vublkconfig_wce")]
pub wce: bool,
}
fn default_vublkconfig_num_queues() -> usize {
DEFAULT_NUM_QUEUES_VUBLK
}
fn default_vublkconfig_queue_size() -> u16 {
DEFAULT_QUEUE_SIZE_VUBLK
}
fn default_vublkconfig_wce() -> bool {
true
}
impl VhostUserBlkConfig {
pub fn parse(vhost_user_blk: &str) -> Result<Self> {
// Split the parameters based on the comma delimiter
@ -839,9 +856,9 @@ impl VhostUserBlkConfig {
}
}
let mut num_queues: usize = 1;
let mut queue_size: u16 = 128;
let mut wce: bool = true;
let mut num_queues: usize = default_vublkconfig_num_queues();
let mut queue_size: u16 = default_vublkconfig_queue_size();
let mut wce: bool = default_vublkconfig_wce();
if !num_queues_str.is_empty() {
num_queues = num_queues_str