diff --git a/vmm/src/config.rs b/vmm/src/config.rs index eabd877fd..6c618f4d4 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -205,14 +205,14 @@ impl CmdlineConfig { } #[derive(Debug)] -pub struct DiskConfig<'a> { - pub path: &'a Path, +pub struct DiskConfig { + pub path: PathBuf, } -impl<'a> DiskConfig<'a> { - pub fn parse(disk: &'a str) -> Result { +impl DiskConfig { + pub fn parse(disk: &str) -> Result { Ok(DiskConfig { - path: Path::new(disk), + path: PathBuf::from(disk), }) } } @@ -613,7 +613,7 @@ pub struct VmConfig<'a> { pub memory: MemoryConfig, pub kernel: KernelConfig, pub cmdline: CmdlineConfig, - pub disks: Option>>, + pub disks: Option>, pub net: Option>>, pub rng: RngConfig<'a>, pub fs: Option>>, diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index d392faf8d..fe1e56b3a 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -540,7 +540,7 @@ impl DeviceManager { let raw_img: File = OpenOptions::new() .read(true) .write(true) - .open(disk_cfg.path) + .open(&disk_cfg.path) .map_err(DeviceManagerError::Disk)?; let image_type = qcow::detect_image_type(&raw_img) @@ -548,17 +548,15 @@ impl DeviceManager { let block = match image_type { ImageType::Raw => { let raw_img = vm_virtio::RawFile::new(raw_img); - let dev = - vm_virtio::Block::new(raw_img, disk_cfg.path.to_path_buf(), false) - .map_err(DeviceManagerError::CreateVirtioBlock)?; + let dev = vm_virtio::Block::new(raw_img, disk_cfg.path.clone(), false) + .map_err(DeviceManagerError::CreateVirtioBlock)?; Box::new(dev) as Box } ImageType::Qcow2 => { let qcow_img = QcowFile::from(raw_img) .map_err(DeviceManagerError::QcowDeviceCreate)?; - let dev = - vm_virtio::Block::new(qcow_img, disk_cfg.path.to_path_buf(), false) - .map_err(DeviceManagerError::CreateVirtioBlock)?; + let dev = vm_virtio::Block::new(qcow_img, disk_cfg.path.clone(), false) + .map_err(DeviceManagerError::CreateVirtioBlock)?; Box::new(dev) as Box } };