diff options
author | Daniel Verkamp <dverkamp@chromium.org> | 2020-02-25 10:17:50 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-27 22:24:14 +0000 |
commit | 46d61ba80df1ccf8364d9589170b3a7bff1268ee (patch) | |
tree | 2ccfe4f87db71a929163c55e73c77c82430fa4af /src/linux.rs | |
parent | 767333820014495f77b09f54de254e004bd8a5f9 (diff) | |
download | crosvm-46d61ba80df1ccf8364d9589170b3a7bff1268ee.tar crosvm-46d61ba80df1ccf8364d9589170b3a7bff1268ee.tar.gz crosvm-46d61ba80df1ccf8364d9589170b3a7bff1268ee.tar.bz2 crosvm-46d61ba80df1ccf8364d9589170b3a7bff1268ee.tar.lz crosvm-46d61ba80df1ccf8364d9589170b3a7bff1268ee.tar.xz crosvm-46d61ba80df1ccf8364d9589170b3a7bff1268ee.tar.zst crosvm-46d61ba80df1ccf8364d9589170b3a7bff1268ee.zip |
linux: add disk path to open error message
Previously, if a disk could not be opened, the error message did not include the path of the disk, e.g.: The architecture failed to build the vm: error creating devices: failed to load disk image: Read-only file system (os error 30) To make debugging easier, add the path to Error::Disk. BUG=b:150181514 TEST=crosvm run --rwdisk ro.img vm_kernel Change-Id: I7b319c419b889334ecadbb0497dc4b3dc5115aa6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2070844 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'src/linux.rs')
-rw-r--r-- | src/linux.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/linux.rs b/src/linux.rs index ba1ccf0..f5d2d1c 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -100,7 +100,7 @@ pub enum Error { CreateVfioDevice(devices::vfio::VfioError), DeviceJail(io_jail::Error), DevicePivotRoot(io_jail::Error), - Disk(io::Error), + Disk(PathBuf, io::Error), DiskImageLock(sys_util::Error), DropCapabilities(sys_util::Error), FsDeviceNew(virtio::fs::Error), @@ -187,7 +187,7 @@ impl Display for Error { CreateVfioDevice(e) => write!(f, "Failed to create vfio device {}", e), DeviceJail(e) => write!(f, "failed to jail device: {}", e), DevicePivotRoot(e) => write!(f, "failed to pivot root device: {}", e), - Disk(e) => write!(f, "failed to load disk image: {}", e), + Disk(p, e) => write!(f, "failed to load disk image {}: {}", p.display(), e), DiskImageLock(e) => write!(f, "failed to lock disk image: {}", e), DropCapabilities(e) => write!(f, "failed to drop process capabilities: {}", e), FsDeviceNew(e) => write!(f, "failed to create fs device: {}", e), @@ -424,7 +424,7 @@ fn create_block_device( .read(true) .write(!disk.read_only) .open(&disk.path) - .map_err(Error::Disk)? + .map_err(|e| Error::Disk(disk.path.to_path_buf(), e))? }; // Lock the disk image to prevent other crosvm instances from using it. let lock_op = if disk.read_only { @@ -883,10 +883,11 @@ fn create_pmem_device( .read(true) .write(!disk.read_only) .open(&disk.path) - .map_err(Error::Disk)?; + .map_err(|e| Error::Disk(disk.path.to_path_buf(), e))?; let (disk_size, arena_size) = { - let metadata = std::fs::metadata(&disk.path).map_err(Error::Disk)?; + let metadata = + std::fs::metadata(&disk.path).map_err(|e| Error::Disk(disk.path.to_path_buf(), e))?; let disk_len = metadata.len(); // Linux requires pmem region sizes to be 2 MiB aligned. Linux will fill any partial page // at the end of an mmap'd file and won't write back beyond the actual file length, but if |