diff --git a/devices/src/virtio/block.rs b/devices/src/virtio/block.rs index c828f1204e..83616cebc8 100644 --- a/devices/src/virtio/block.rs +++ b/devices/src/virtio/block.rs @@ -344,6 +344,7 @@ pub struct Block { kill_evt: Option, disk_image: Option, config_space: Vec, + avail_features: u64, } fn build_config_space(disk_size: u64) -> Vec { @@ -370,10 +371,14 @@ impl Block { disk_size, SECTOR_SIZE); } + + let mut avail_features: u64 = 1 << VIRTIO_BLK_F_FLUSH; + Ok(Block { kill_evt: None, disk_image: Some(disk_image), config_space: build_config_space(disk_size), + avail_features, }) } } @@ -400,7 +405,8 @@ impl VirtioDevice for Block { fn features(&self, page: u32) -> u32 { match page { - 0 => 1 << VIRTIO_BLK_F_FLUSH, + 0 => self.avail_features as u32, + 1 => (self.avail_features >> 32) as u32, _ => 0, } }