vmm: Make FsConfig owned

Convert Path to PathBuf, &str to String and remove the associated lifetime.

Fixes #298

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz 2019-09-23 19:23:17 +02:00 committed by Rob Bradford
parent 5323da031c
commit 00674cd850
2 changed files with 9 additions and 9 deletions

View File

@ -281,16 +281,16 @@ impl RngConfig {
} }
#[derive(Debug)] #[derive(Debug)]
pub struct FsConfig<'a> { pub struct FsConfig {
pub tag: &'a str, pub tag: String,
pub sock: &'a Path, pub sock: PathBuf,
pub num_queues: usize, pub num_queues: usize,
pub queue_size: u16, pub queue_size: u16,
pub cache_size: Option<u64>, pub cache_size: Option<u64>,
} }
impl<'a> FsConfig<'a> { impl FsConfig {
pub fn parse(fs: &'a str) -> Result<Self> { pub fn parse(fs: &str) -> Result<Self> {
// Split the parameters based on the comma delimiter // Split the parameters based on the comma delimiter
let params_list: Vec<&str> = fs.split(',').collect(); let params_list: Vec<&str> = fs.split(',').collect();
@ -359,8 +359,8 @@ impl<'a> FsConfig<'a> {
} }
Ok(FsConfig { Ok(FsConfig {
tag, tag: tag.to_string(),
sock: Path::new(sock), sock: PathBuf::from(sock),
num_queues, num_queues,
queue_size, queue_size,
cache_size, cache_size,
@ -616,7 +616,7 @@ pub struct VmConfig<'a> {
pub disks: Option<Vec<DiskConfig>>, pub disks: Option<Vec<DiskConfig>>,
pub net: Option<Vec<NetConfig>>, pub net: Option<Vec<NetConfig>>,
pub rng: RngConfig, pub rng: RngConfig,
pub fs: Option<Vec<FsConfig<'a>>>, pub fs: Option<Vec<FsConfig>>,
pub pmem: Option<Vec<PmemConfig<'a>>>, pub pmem: Option<Vec<PmemConfig<'a>>>,
pub serial: ConsoleConfig<'a>, pub serial: ConsoleConfig<'a>,
pub console: ConsoleConfig<'a>, pub console: ConsoleConfig<'a>,

View File

@ -676,7 +676,7 @@ impl DeviceManager {
let virtio_fs_device = vm_virtio::vhost_user::Fs::new( let virtio_fs_device = vm_virtio::vhost_user::Fs::new(
fs_sock, fs_sock,
fs_cfg.tag, &fs_cfg.tag,
fs_cfg.num_queues, fs_cfg.num_queues,
fs_cfg.queue_size, fs_cfg.queue_size,
cache, cache,