mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 02:55:45 +00:00
vmm: Add an identifier to the --fs device
By giving the devices ids this effectively enables the removal of the device. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com> Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
7e0ab6b56d
commit
9ed880d74e
@ -865,6 +865,8 @@ pub struct FsConfig {
|
|||||||
pub dax: bool,
|
pub dax: bool,
|
||||||
#[serde(default = "default_fsconfig_cache_size")]
|
#[serde(default = "default_fsconfig_cache_size")]
|
||||||
pub cache_size: u64,
|
pub cache_size: u64,
|
||||||
|
#[serde(default)]
|
||||||
|
pub id: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_fsconfig_num_queues() -> usize {
|
fn default_fsconfig_num_queues() -> usize {
|
||||||
@ -892,6 +894,7 @@ impl Default for FsConfig {
|
|||||||
queue_size: default_fsconfig_queue_size(),
|
queue_size: default_fsconfig_queue_size(),
|
||||||
dax: default_fsconfig_dax(),
|
dax: default_fsconfig_dax(),
|
||||||
cache_size: default_fsconfig_cache_size(),
|
cache_size: default_fsconfig_cache_size(),
|
||||||
|
id: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -900,7 +903,7 @@ impl FsConfig {
|
|||||||
pub const SYNTAX: &'static str = "virtio-fs parameters \
|
pub const SYNTAX: &'static str = "virtio-fs parameters \
|
||||||
\"tag=<tag_name>,sock=<socket_path>,num_queues=<number_of_queues>,\
|
\"tag=<tag_name>,sock=<socket_path>,num_queues=<number_of_queues>,\
|
||||||
queue_size=<size_of_each_queue>,dax=on|off,cache_size=<DAX cache size: \
|
queue_size=<size_of_each_queue>,dax=on|off,cache_size=<DAX cache size: \
|
||||||
default 8Gib>\"";
|
default 8Gib>,id=<device_id>\"";
|
||||||
|
|
||||||
pub fn parse(fs: &str) -> Result<Self> {
|
pub fn parse(fs: &str) -> Result<Self> {
|
||||||
let mut parser = OptionParser::new();
|
let mut parser = OptionParser::new();
|
||||||
@ -941,6 +944,8 @@ impl FsConfig {
|
|||||||
.unwrap_or_else(|| ByteSized(default_fsconfig_cache_size()))
|
.unwrap_or_else(|| ByteSized(default_fsconfig_cache_size()))
|
||||||
.0;
|
.0;
|
||||||
|
|
||||||
|
let id = parser.get("id");
|
||||||
|
|
||||||
Ok(FsConfig {
|
Ok(FsConfig {
|
||||||
tag,
|
tag,
|
||||||
sock,
|
sock,
|
||||||
@ -948,6 +953,7 @@ impl FsConfig {
|
|||||||
queue_size,
|
queue_size,
|
||||||
dax,
|
dax,
|
||||||
cache_size,
|
cache_size,
|
||||||
|
id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,7 @@ const MMIO_LEN: u64 = 0x1000;
|
|||||||
const VFIO_DEVICE_NAME_PREFIX: &str = "vfio";
|
const VFIO_DEVICE_NAME_PREFIX: &str = "vfio";
|
||||||
|
|
||||||
const DISK_DEVICE_NAME_PREFIX: &str = "disk";
|
const DISK_DEVICE_NAME_PREFIX: &str = "disk";
|
||||||
|
const FS_DEVICE_NAME_PREFIX: &str = "fs";
|
||||||
const NET_DEVICE_NAME_PREFIX: &str = "net";
|
const NET_DEVICE_NAME_PREFIX: &str = "net";
|
||||||
const PMEM_DEVICE_NAME_PREFIX: &str = "pmem";
|
const PMEM_DEVICE_NAME_PREFIX: &str = "pmem";
|
||||||
const VSOCK_DEVICE_NAME_PREFIX: &str = "vsock";
|
const VSOCK_DEVICE_NAME_PREFIX: &str = "vsock";
|
||||||
@ -1426,8 +1427,12 @@ impl DeviceManager {
|
|||||||
|
|
||||||
fn make_virtio_fs_device(
|
fn make_virtio_fs_device(
|
||||||
&mut self,
|
&mut self,
|
||||||
fs_cfg: &FsConfig,
|
fs_cfg: &mut FsConfig,
|
||||||
) -> DeviceManagerResult<(VirtioDeviceArc, bool, Option<String>)> {
|
) -> DeviceManagerResult<(VirtioDeviceArc, bool, Option<String>)> {
|
||||||
|
if fs_cfg.id.is_none() {
|
||||||
|
fs_cfg.id = self.next_device_name(FS_DEVICE_NAME_PREFIX)?;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(fs_sock) = fs_cfg.sock.to_str() {
|
if let Some(fs_sock) = fs_cfg.sock.to_str() {
|
||||||
let cache = if fs_cfg.dax {
|
let cache = if fs_cfg.dax {
|
||||||
let fs_cache = fs_cfg.cache_size;
|
let fs_cache = fs_cfg.cache_size;
|
||||||
@ -1499,7 +1504,7 @@ impl DeviceManager {
|
|||||||
Ok((
|
Ok((
|
||||||
Arc::clone(&virtio_fs_device) as VirtioDeviceArc,
|
Arc::clone(&virtio_fs_device) as VirtioDeviceArc,
|
||||||
false,
|
false,
|
||||||
None,
|
fs_cfg.id.clone(),
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
Err(DeviceManagerError::NoVirtioFsSock)
|
Err(DeviceManagerError::NoVirtioFsSock)
|
||||||
@ -1511,12 +1516,13 @@ impl DeviceManager {
|
|||||||
) -> DeviceManagerResult<Vec<(VirtioDeviceArc, bool, Option<String>)>> {
|
) -> DeviceManagerResult<Vec<(VirtioDeviceArc, bool, Option<String>)>> {
|
||||||
let mut devices = Vec::new();
|
let mut devices = Vec::new();
|
||||||
|
|
||||||
let fs_devices = self.config.lock().unwrap().fs.clone();
|
let mut fs_devices = self.config.lock().unwrap().fs.clone();
|
||||||
if let Some(fs_list_cfg) = &fs_devices {
|
if let Some(fs_list_cfg) = &mut fs_devices {
|
||||||
for fs_cfg in fs_list_cfg.iter() {
|
for fs_cfg in fs_list_cfg.iter_mut() {
|
||||||
devices.push(self.make_virtio_fs_device(fs_cfg)?);
|
devices.push(self.make_virtio_fs_device(fs_cfg)?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self.config.lock().unwrap().fs = fs_devices;
|
||||||
|
|
||||||
Ok(devices)
|
Ok(devices)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user