pub fn new(
        id: String,
        partuuid: Option<String>,
        cache_type: CacheType,
        disk_image_path: String,
        is_disk_read_only: bool,
        is_disk_root: bool,
        rate_limiter: RateLimiter,
    ) -> io::Result<Block> {
        let disk_properties = DiskProperties::new(disk_image_path, is_disk_read_only, cache_type)?;

        let mut avail_features = (1u64 << VIRTIO_F_VERSION_1) | (1u64 << VIRTIO_RING_F_EVENT_IDX);

        if cache_type == CacheType::Writeback {
            avail_features |= 1u64 << VIRTIO_BLK_F_FLUSH;
        }

        if is_disk_read_only {
            avail_features |= 1u64 << VIRTIO_BLK_F_RO;
        };

        let queue_evts = [EventFd::new(libc::EFD_NONBLOCK)?];

        let queues = QUEUE_SIZES.iter().map(|&s| Queue::new(s)).collect();

        Ok(Block {
            id,
            root_device: is_disk_root,
            partuuid,
            rate_limiter,
            config_space: disk_properties.virtio_block_config_space(),
            disk: disk_properties,
            avail_features,
            acked_features: 0u64,
            queue_evts,
            queues,
            device_state: DeviceState::Inactive,
            irq_trigger: IrqTrigger::new()?,
            activate_evt: EventFd::new(libc::EFD_NONBLOCK)?,
        })
    }
/// Create a new virtio block device that operates on the given file.
///
/// The given file must be seekable and sizable.
Create a new virtio block device that operates on the given file.
The given file must be seekable and sizable.
Create a new virtio block device that operates on the given file . The given file must be seekable and sizable .
pub fn new(
        id: String,
        partuuid: Option<String>,
        cache_type: CacheType,
        disk_image_path: String,
        is_disk_read_only: bool,
        is_disk_root: bool,
        rate_limiter: RateLimiter,
    ) -> io::Result<Block> {
        let disk_properties = DiskProperties::new(disk_image_path, is_disk_read_only, cache_type)?;
        let mut avail_features = (1u64 << VIRTIO_F_VERSION_1) | (1u64 << VIRTIO_RING_F_EVENT_IDX);
        if cache_type == CacheType::Writeback {
            avail_features |= 1u64 << VIRTIO_BLK_F_FLUSH;
        }
        if is_disk_read_only {
            avail_features |= 1u64 << VIRTIO_BLK_F_RO;
        };
        let queue_evts = [EventFd::new(libc::EFD_NONBLOCK)?];
        let queues = QUEUE_SIZES.iter().map(|&s| Queue::new(s)).collect();
        Ok(Block {
            id,
            root_device: is_disk_root,
            partuuid,
            rate_limiter,
            config_space: disk_properties.virtio_block_config_space(),
            disk: disk_properties,
            avail_features,
            acked_features: 0u64,
            queue_evts,
            queues,
            device_state: DeviceState::Inactive,
            irq_trigger: IrqTrigger::new()?,
            activate_evt: EventFd::new(libc::EFD_NONBLOCK)?,
        })
    }
pub fn new ( id : String , partuuid : Option < String > , cache_type : CacheType , disk_image_path : String , is_disk_read_only : bool , is_disk_root : bool , rate_limiter : RateLimiter , ) -> io :: Result < Block > { let disk_properties = DiskProperties :: new ( disk_image_path , is_disk_read_only , cache_type ) ? ; let mut avail_features = ( 1u64 << VIRTIO_F_VERSION_1 ) | ( 1u64 << VIRTIO_RING_F_EVENT_IDX ) ; if cache_type == CacheType :: Writeback { avail_features |= 1u64 << VIRTIO_BLK_F_FLUSH ; } if is_disk_read_only { avail_features |= 1u64 << VIRTIO_BLK_F_RO ; } ; let queue_evts = [ EventFd :: new ( libc :: EFD_NONBLOCK ) ? ] ; let queues = QUEUE_SIZES . iter ( ) . map ( | & s | Queue :: new ( s ) ) . collect ( ) ; Ok ( Block { id , root_device : is_disk_root , partuuid , rate_limiter , config_space : disk_properties . virtio_block_config_space ( ) , disk : disk_properties , avail_features , acked_features : 0u64 , queue_evts , queues , device_state : DeviceState :: Inactive , irq_trigger : IrqTrigger :: new ( ) ? , activate_evt : EventFd :: new ( libc :: EFD_NONBLOCK ) ? , } ) }
Create a new virtio block device that operates on the given file.
Create a new virtio block device that operates on the given file .
id
String
partuuid
Option<String>
cache_type
CacheType
disk_image_path
String
is_disk_read_only
bool
is_disk_root
bool
rate_limiter
RateLimiter
id
String
partuuid
Option<String>
cache_type
CacheType
disk_image_path
String
is_disk_read_only
bool
is_disk_root
bool
rate_limiter
RateLimiter