Use arch specific PCI device filenames On arm64 the virtio block devices show up under /dev/disk/by-path/platform-808100000.pci-pci-0000. Change-Id: Ib3331dfb0b8bccba001da4990da38b3405df4727
diff --git a/src/bin/virtio_block_test_util.rs b/src/bin/virtio_block_test_util.rs index fdc2319..70a6845 100644 --- a/src/bin/virtio_block_test_util.rs +++ b/src/bin/virtio_block_test_util.rs
@@ -12,6 +12,12 @@ const PCI_DIR: &str = "/dev/disk/by-path"; +#[cfg(target_arch = "aarch64")] +const PCI_DEVICE: &str = "platform-808100000.pci-pci-0000"; + +#[cfg(target_arch = "x86_64")] +const PCI_DEVICE: &str = "virtio-pci-0000"; + // Ioctl requests are comprised of 32 bits: // [31:30] Access mode // [29:16] Size of the parameter structure @@ -59,8 +65,7 @@ fn open_block_device(pci_bus: u8, pci_device: u8, write: bool) -> std::io::Result<File> { let mut path = PathBuf::from(PCI_DIR); path.push(format!( - "virtio-pci-0000:{:02}:{:02}.0", - pci_bus, pci_device + "{}:{:02}:{:02}.0", PCI_DEVICE, pci_bus, pci_device )); OpenOptions::new().read(true).write(write).open(path) }