vmm: api: Adjust FsConfig for OpenAPI

The FsConfig structure has been recently adjusted so that the default
value matches between OpenAPI and CLI. Unfortunately, with the current
description, there is no way from the OpenAPI to describe a cache_size
value "None", so that DAX does not get enabled. Usually, using a Rust
"Option" works because the default value is None. But in this case, the
default value is Some(8G), which means we cannot describe a None.

This commit tackles the problem, introducing an explicit parameter
"dax", and leaving "cache_size" as a simple u64 integer.

This way, the default value is dax=true and cache_size=8G, but it lets
the opportunity to disable DAX entirely with dax=false, which will
simply ignore the cache_size value.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2019-12-11 10:44:26 +01:00
committed by Rob Bradford
parent 4bfd51cc42
commit 64c5e3d8cb
3 changed files with 25 additions and 12 deletions
+8 -5
View File
@@ -977,8 +977,8 @@ impl DeviceManager {
if let Some(fs_list_cfg) = &vm_info.vm_cfg.lock().unwrap().fs {
for fs_cfg in fs_list_cfg.iter() {
if let Some(fs_sock) = fs_cfg.sock.to_str() {
let mut cache: Option<(VirtioSharedMemoryList, u64)> = None;
if let Some(fs_cache) = fs_cfg.cache_size {
let cache: Option<(VirtioSharedMemoryList, u64)> = if fs_cfg.dax {
let fs_cache = fs_cfg.cache_size;
// The memory needs to be 2MiB aligned in order to support
// hugepages.
let fs_guest_addr = allocator
@@ -1023,15 +1023,18 @@ impl DeviceManager {
offset: 0,
len: fs_cache,
});
cache = Some((
Some((
VirtioSharedMemoryList {
addr: fs_guest_addr,
len: fs_cache as GuestUsize,
region_list,
},
addr as u64,
));
}
))
} else {
None
};
let virtio_fs_device = vm_virtio::vhost_user::Fs::new(
fs_sock,