From 79a02f9171d1b845c79a33c2581203ec6ab6a7e7 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 23 Sep 2019 19:27:56 +0200 Subject: [PATCH] vmm: Make PmemConfig owned Convert Path to PathBuf and remove the associated lifetime. Fixes #298 Signed-off-by: Samuel Ortiz --- vmm/src/config.rs | 12 ++++++------ vmm/src/device_manager.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 37aee2cae..7909c887c 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -368,13 +368,13 @@ impl FsConfig { } } -pub struct PmemConfig<'a> { - pub file: &'a Path, +pub struct PmemConfig { + pub file: PathBuf, pub size: u64, } -impl<'a> PmemConfig<'a> { - pub fn parse(pmem: &'a str) -> Result { +impl PmemConfig { + pub fn parse(pmem: &str) -> Result { // Split the parameters based on the comma delimiter let params_list: Vec<&str> = pmem.split(',').collect(); @@ -394,7 +394,7 @@ impl<'a> PmemConfig<'a> { } Ok(PmemConfig { - file: Path::new(file_str), + file: PathBuf::from(file_str), size: parse_size(size_str)?, }) } @@ -617,7 +617,7 @@ pub struct VmConfig<'a> { pub net: Option>, pub rng: RngConfig, pub fs: Option>, - pub pmem: Option>>, + pub pmem: Option>, pub serial: ConsoleConfig<'a>, pub console: ConsoleConfig<'a>, pub devices: Option>>, diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 82e2c95d1..ee4346c7a 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -719,7 +719,7 @@ impl DeviceManager { .read(true) .write(true) .custom_flags(custom_flags) - .open(pmem_cfg.file) + .open(&pmem_cfg.file) .map_err(DeviceManagerError::PmemFileOpen)?; if set_len {