pub fn new(
        id: String,
        partuuid: Option<String>,
        cache_type: CacheType,
        disk_image_path: String,
        is_disk_read_only: bool,
        is_disk_root: bool,
    ) -> 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_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,
            config_space: disk_properties.virtio_block_config_space(),
            disk: disk_properties,
            avail_features,
            acked_features: 0u64,
            interrupt_status: Arc::new(AtomicUsize::new(0)),
            interrupt_evt: EventFd::new(libc::EFD_NONBLOCK)?,
            queue_evts,
            queues,
            device_state: DeviceState::Inactive,
            activate_evt: EventFd::new(libc::EFD_NONBLOCK)?,
            intc: None,
            irq_line: None,
        })
    }
/// 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,
    ) -> 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_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,
            config_space: disk_properties.virtio_block_config_space(),
            disk: disk_properties,
            avail_features,
            acked_features: 0u64,
            interrupt_status: Arc::new(AtomicUsize::new(0)),
            interrupt_evt: EventFd::new(libc::EFD_NONBLOCK)?,
            queue_evts,
            queues,
            device_state: DeviceState::Inactive,
            activate_evt: EventFd::new(libc::EFD_NONBLOCK)?,
            intc: None,
            irq_line: None,
        })
    }
pub fn new ( id : String , partuuid : Option < String > , cache_type : CacheType , disk_image_path : String , is_disk_read_only : bool , is_disk_root : bool , ) -> 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_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 , config_space : disk_properties . virtio_block_config_space ( ) , disk : disk_properties , avail_features , acked_features : 0u64 , interrupt_status : Arc :: new ( AtomicUsize :: new ( 0 ) ) , interrupt_evt : EventFd :: new ( libc :: EFD_NONBLOCK ) ? , queue_evts , queues , device_state : DeviceState :: Inactive , activate_evt : EventFd :: new ( libc :: EFD_NONBLOCK ) ? , intc : None , irq_line : None , } ) }
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