From f4ee2ad205b5e014575252c9eccd0ae0bb306b8a Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Wed, 24 Oct 2018 13:07:02 -0700 Subject: devices: make all virtio devices report version 1 Our virtio devices are all "modern" (no legacy/transitional support). Add VIRTIO_F_VERSION_1 to the features() handler for all virtio devices that didn't already have it. This lets us remove the hack that forced VIRTIO_F_VERSION_1 on for all devices. BUG=None TEST=build_test; boot crosvm on kevin Change-Id: I008926a9075679aae46069aa37a14504f10e8584 Signed-off-by: Daniel Verkamp Reviewed-on: https://chromium-review.googlesource.com/1313013 Reviewed-by: Zach Reizner --- devices/src/virtio/block.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'devices/src/virtio/block.rs') diff --git a/devices/src/virtio/block.rs b/devices/src/virtio/block.rs index f2ddb2c..7d5fb02 100644 --- a/devices/src/virtio/block.rs +++ b/devices/src/virtio/block.rs @@ -22,7 +22,10 @@ use sys_util::{ use data_model::{DataInit, Le16, Le32, Le64}; -use super::{DescriptorChain, Queue, VirtioDevice, INTERRUPT_STATUS_USED_RING, TYPE_BLOCK}; +use super::{ + DescriptorChain, Queue, VirtioDevice, INTERRUPT_STATUS_USED_RING, TYPE_BLOCK, + VIRTIO_F_VERSION_1, +}; const QUEUE_SIZE: u16 = 256; const QUEUE_SIZES: &'static [u16] = &[QUEUE_SIZE]; @@ -655,6 +658,7 @@ impl Block { avail_features |= 1 << VIRTIO_BLK_F_DISCARD; avail_features |= 1 << VIRTIO_BLK_F_WRITE_ZEROES; } + avail_features |= 1 << VIRTIO_F_VERSION_1; Ok(Block { kill_evt: None, @@ -798,8 +802,8 @@ mod tests { let f = File::create(&path).unwrap(); let b = Block::new(f, false).unwrap(); // writable device should set VIRTIO_BLK_F_FLUSH + VIRTIO_BLK_F_DISCARD - // + VIRTIO_BLK_F_WRITE_ZEROES - assert_eq!(0x6200, b.features()); + // + VIRTIO_BLK_F_WRITE_ZEROES + VIRTIO_F_VERSION_1 + assert_eq!(0x100006200, b.features()); } // read-only block device @@ -807,7 +811,8 @@ mod tests { let f = File::create(&path).unwrap(); let b = Block::new(f, true).unwrap(); // read-only device should set VIRTIO_BLK_F_FLUSH and VIRTIO_BLK_F_RO - assert_eq!(0x220, b.features()); + // + VIRTIO_F_VERSION_1 + assert_eq!(0x100000220, b.features()); } } } -- cgit 1.4.1