@@ -11,7 +11,9 @@ use zerocopy::{AsBytes, FromBytes};
1111
1212const QUEUE : u16 = 0 ;
1313const QUEUE_SIZE : u16 = 16 ;
14- const SUPPORTED_FEATURES : BlkFeature = BlkFeature :: RO . union ( BlkFeature :: FLUSH ) ;
14+ const SUPPORTED_FEATURES : BlkFeature = BlkFeature :: RO
15+ . union ( BlkFeature :: FLUSH )
16+ . union ( BlkFeature :: RING_INDIRECT_DESC ) ;
1517
1618/// Driver for a VirtIO block device.
1719///
@@ -68,7 +70,11 @@ impl<H: Hal, T: Transport> VirtIOBlk<H, T> {
6870 } ;
6971 info ! ( "found a block device of size {}KB" , capacity / 2 ) ;
7072
71- let queue = VirtQueue :: new ( & mut transport, QUEUE ) ?;
73+ let queue = VirtQueue :: new (
74+ & mut transport,
75+ QUEUE ,
76+ negotiated_features. contains ( BlkFeature :: RING_INDIRECT_DESC ) ,
77+ ) ?;
7278 transport. finish_init ( ) ;
7379
7480 Ok ( VirtIOBlk {
@@ -601,7 +607,7 @@ mod tests {
601607 let transport = FakeTransport {
602608 device_type : DeviceType :: Block ,
603609 max_queue_size : QUEUE_SIZE . into ( ) ,
604- device_features : 0 ,
610+ device_features : BlkFeature :: RING_INDIRECT_DESC . bits ( ) ,
605611 config_space : NonNull :: from ( & mut config_space) ,
606612 state : state. clone ( ) ,
607613 } ;
@@ -671,7 +677,7 @@ mod tests {
671677 let transport = FakeTransport {
672678 device_type : DeviceType :: Block ,
673679 max_queue_size : QUEUE_SIZE . into ( ) ,
674- device_features : 0 ,
680+ device_features : BlkFeature :: RING_INDIRECT_DESC . bits ( ) ,
675681 config_space : NonNull :: from ( & mut config_space) ,
676682 state : state. clone ( ) ,
677683 } ;
@@ -746,7 +752,7 @@ mod tests {
746752 let transport = FakeTransport {
747753 device_type : DeviceType :: Block ,
748754 max_queue_size : QUEUE_SIZE . into ( ) ,
749- device_features : BlkFeature :: FLUSH . bits ( ) ,
755+ device_features : ( BlkFeature :: RING_INDIRECT_DESC | BlkFeature :: FLUSH ) . bits ( ) ,
750756 config_space : NonNull :: from ( & mut config_space) ,
751757 state : state. clone ( ) ,
752758 } ;
@@ -813,7 +819,7 @@ mod tests {
813819 let transport = FakeTransport {
814820 device_type : DeviceType :: Block ,
815821 max_queue_size : QUEUE_SIZE . into ( ) ,
816- device_features : 0 ,
822+ device_features : BlkFeature :: RING_INDIRECT_DESC . bits ( ) ,
817823 config_space : NonNull :: from ( & mut config_space) ,
818824 state : state. clone ( ) ,
819825 } ;
0 commit comments