From ee528ae80836e9d59ff50d124ae356ed1b07002a Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Mon, 9 Dec 2019 18:22:51 +0100 Subject: [PATCH] vmm: api: Make FsConfig defaults match between CLI and HTTP API In order to let the CLI and the HTTP API behave the same regarding the FsConfig structure, this patch defines some default values for num_queues, queue_size and the cache_size. num_queues is set to 1, queue_size is set to 1024, and cache_size is set to Some(8G) which means that DAX is enabled by default with a shared region of 8GiB. Fixes #508 Signed-off-by: Sebastien Boeuf --- vmm/src/api/openapi/cloud-hypervisor.yaml | 5 +++-- vmm/src/config.rs | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/vmm/src/api/openapi/cloud-hypervisor.yaml b/vmm/src/api/openapi/cloud-hypervisor.yaml index 7c03b3691..a1de44daf 100644 --- a/vmm/src/api/openapi/cloud-hypervisor.yaml +++ b/vmm/src/api/openapi/cloud-hypervisor.yaml @@ -312,8 +312,6 @@ components: required: - tag - sock - - num_queues - - queue_size type: object properties: tag: @@ -322,11 +320,14 @@ components: type: string num_queues: type: integer + default: 1 queue_size: type: integer + default: 1024 cache_size: type: integer format: int64 + default: 8589934592 PmemConfig: required: diff --git a/vmm/src/config.rs b/vmm/src/config.rs index a3e75226e..1516c9ead 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -427,11 +427,26 @@ impl Default for RngConfig { pub struct FsConfig { pub tag: String, pub sock: PathBuf, + #[serde(default = "default_fsconfig_num_queues")] pub num_queues: usize, + #[serde(default = "default_fsconfig_queue_size")] pub queue_size: u16, + #[serde(default = "default_fsconfig_cache_size")] pub cache_size: Option, } +fn default_fsconfig_num_queues() -> usize { + 1 +} + +fn default_fsconfig_queue_size() -> u16 { + 1024 +} + +fn default_fsconfig_cache_size() -> Option { + Some(0x0002_0000_0000) +} + impl FsConfig { pub fn parse(fs: &str) -> Result { // Split the parameters based on the comma delimiter @@ -460,11 +475,11 @@ impl FsConfig { } } - let mut num_queues: usize = 1; - let mut queue_size: u16 = 1024; + let mut num_queues: usize = default_fsconfig_num_queues(); + let mut queue_size: u16 = default_fsconfig_queue_size(); let mut dax: bool = true; // Default cache size set to 8Gib. - let mut cache_size: Option = Some(0x0002_0000_0000); + let mut cache_size: Option = default_fsconfig_cache_size(); if tag.is_empty() { return Err(Error::ParseFsTagParam);