mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-11-04 19:11:11 +00:00
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:
parent
1c2587f8cb
commit
4bfd51cc42
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user