diff --git a/block/src/lib.rs b/block/src/lib.rs index 1a7e1a9de..d4717e0f2 100644 --- a/block/src/lib.rs +++ b/block/src/lib.rs @@ -58,16 +58,14 @@ use versionize_derive::Versionize; use virtio_bindings::virtio_blk::*; use virtio_queue::DescriptorChain; use vm_memory::{ - bitmap::AtomicBitmap, bitmap::Bitmap, ByteValued, Bytes, GuestAddress, GuestMemory, - GuestMemoryError, GuestMemoryLoadGuard, + bitmap::Bitmap, ByteValued, Bytes, GuestAddress, GuestMemory, GuestMemoryError, + GuestMemoryLoadGuard, }; use vm_virtio::{AccessPlatform, Translatable}; use vmm_sys_util::aio; use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::{ioctl_io_nr, ioctl_ioc_nr}; -type GuestMemoryMmap = vm_memory::GuestMemoryMmap; - const SECTOR_SHIFT: u8 = 9; pub const SECTOR_SIZE: u64 = 0x01 << SECTOR_SHIFT; @@ -197,8 +195,8 @@ pub enum RequestType { Unsupported(u32), } -pub fn request_type( - mem: &GuestMemoryMmap, +pub fn request_type( + mem: &vm_memory::GuestMemoryMmap, desc_addr: GuestAddress, ) -> result::Result { let type_ = mem.read_obj(desc_addr).map_err(Error::GuestMemory)?; @@ -211,7 +209,10 @@ pub fn request_type( } } -fn sector(mem: &GuestMemoryMmap, desc_addr: GuestAddress) -> result::Result { +fn sector( + mem: &vm_memory::GuestMemoryMmap, + desc_addr: GuestAddress, +) -> result::Result { const SECTOR_OFFSET: usize = 8; let addr = match mem.checked_offset(desc_addr, SECTOR_OFFSET) { Some(v) => v, @@ -241,8 +242,8 @@ pub struct Request { } impl Request { - pub fn parse( - desc_chain: &mut DescriptorChain>, + pub fn parse( + desc_chain: &mut DescriptorChain>>, access_platform: Option<&Arc>, ) -> result::Result { let hdr_desc = desc_chain @@ -333,11 +334,11 @@ impl Request { Ok(req) } - pub fn execute( + pub fn execute( &self, disk: &mut T, disk_nsectors: u64, - mem: &GuestMemoryMmap, + mem: &vm_memory::GuestMemoryMmap, serial: &[u8], ) -> result::Result { disk.seek(SeekFrom::Start(self.sector << SECTOR_SHIFT)) @@ -390,9 +391,9 @@ impl Request { Ok(len) } - pub fn execute_async( + pub fn execute_async( &mut self, - mem: &GuestMemoryMmap, + mem: &vm_memory::GuestMemoryMmap, disk_nsectors: u64, disk_image: &mut dyn AsyncIo, serial: &[u8],