From 5f8a62f3d0f9c616fe0b546a9b6fbf6e94f7f489 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 23 Sep 2019 19:31:41 +0200 Subject: [PATCH] vmm: Make DeviceConfig 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 b732c5bdf..704adb466 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -451,14 +451,14 @@ impl ConsoleConfig { } #[derive(Debug)] -pub struct DeviceConfig<'a> { - pub path: &'a Path, +pub struct DeviceConfig { + pub path: PathBuf, } -impl<'a> DeviceConfig<'a> { - pub fn parse(device: &'a str) -> Result { +impl DeviceConfig { + pub fn parse(device: &str) -> Result { Ok(DeviceConfig { - path: Path::new(device), + path: PathBuf::from(device), }) } } @@ -620,7 +620,7 @@ pub struct VmConfig<'a> { pub pmem: Option>, pub serial: ConsoleConfig, pub console: ConsoleConfig, - pub devices: Option>>, + pub devices: Option>, pub vhost_user_net: Option>>, pub vhost_user_blk: Option>>, pub vsock: Option>>, diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 567282ae4..e26a3e5c8 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -857,7 +857,7 @@ impl DeviceManager { for device_cfg in device_list_cfg.iter() { let vfio_device = - VfioDevice::new(device_cfg.path, device_fd.clone(), vm_info.memory.clone()) + VfioDevice::new(&device_cfg.path, device_fd.clone(), vm_info.memory.clone()) .map_err(DeviceManagerError::VfioCreate)?; let mut vfio_pci_device = VfioPciDevice::new(vm_info.vm_fd, allocator, vfio_device)