diff --git a/src/dragonball/crates/dbs_virtio_devices/src/block/device.rs b/src/dragonball/crates/dbs_virtio_devices/src/block/device.rs index 367ce93e85..f44d37b68d 100644 --- a/src/dragonball/crates/dbs_virtio_devices/src/block/device.rs +++ b/src/dragonball/crates/dbs_virtio_devices/src/block/device.rs @@ -700,6 +700,10 @@ mod tests { let mut q = vq.create_queue(); data_descs.clear(); // status desc read only + m.write_obj::(VIRTIO_BLK_T_GET_ID, GuestAddress(0x1000)) + .unwrap(); + vq.dtable(1) + .set(0x2000, 0x40, VIRTQ_DESC_F_NEXT | VIRTQ_DESC_F_WRITE, 2); vq.dtable(2).flags().store(0); assert!(matches!( Request::parse(&mut q.pop_descriptor_chain(m).unwrap(), &mut data_descs, 32), @@ -711,6 +715,10 @@ mod tests { let mut q = vq.create_queue(); data_descs.clear(); // status desc too small + m.write_obj::(VIRTIO_BLK_T_GET_ID, GuestAddress(0x1000)) + .unwrap(); + vq.dtable(1) + .set(0x2000, 0x40, VIRTQ_DESC_F_NEXT | VIRTQ_DESC_F_WRITE, 2); vq.dtable(2).flags().store(VIRTQ_DESC_F_WRITE); vq.dtable(2).len().store(0); assert!(matches!( @@ -1032,6 +1040,7 @@ mod tests { let mut dev = Block::>>::new( vec![disk_image], true, + false, Arc::new(vec![128]), epoll_mgr.clone(), vec![], @@ -1146,6 +1155,7 @@ mod tests { let mut dev = Block::>::new( vec![disk_image], true, + false, Arc::new(vec![128]), epoll_mgr, vec![], diff --git a/src/runtime-rs/crates/hypervisor/src/dragonball/inner_device.rs b/src/runtime-rs/crates/hypervisor/src/dragonball/inner_device.rs index 0197ee579a..4e16cd070e 100644 --- a/src/runtime-rs/crates/hypervisor/src/dragonball/inner_device.rs +++ b/src/runtime-rs/crates/hypervisor/src/dragonball/inner_device.rs @@ -70,6 +70,7 @@ impl DragonballInner { no_drop, is_direct, driver_option, + sparse, ) = { let dev = block_device.lock().await; let cfg = &dev.config; @@ -80,6 +81,7 @@ impl DragonballInner { cfg.no_drop, cfg.is_direct, cfg.driver_option.clone(), + cfg.discard_unmap, ) }; @@ -106,13 +108,15 @@ impl DragonballInner { no_drop, is_direct, use_pci_bus, + sparse, ) .context("add block modern device")?; info!( sl!(), "BlockModern hotplug result: device_id={}, guest_device_id={:?}", - device_id, guest_device_id + device_id, + guest_device_id ); if let Some(slot) = guest_device_id { @@ -132,6 +136,7 @@ impl DragonballInner { block.no_drop, None, None, + false, ) .context("add vhost user based block device")?; Ok(DeviceType::VhostUserBlk(block)) @@ -253,6 +258,7 @@ impl DragonballInner { Ok(()) } + #[allow(clippy::too_many_arguments)] fn add_block_device( &mut self, path: &str, @@ -261,6 +267,7 @@ impl DragonballInner { no_drop: bool, is_direct: Option, use_pci_bus: Option, + sparse: bool, ) -> Result> { let jailed_drive = self.get_resource(path, id).context("get resource")?; self.cached_block_devices.insert(id.to_string()); @@ -294,6 +301,7 @@ impl DragonballInner { no_drop, is_read_only: read_only, use_pci_bus, + sparse, rate_limiter: Some(block_rate_limit), ..Default::default() }; @@ -311,7 +319,10 @@ impl DragonballInner { .insert_block_device(blk_cfg, Duration::from_millis(DEFAULT_HOTPLUG_TIMEOUT)) .context("insert block device"); match &result { - Ok(guest_id) => info!(sl!(), "add_block_device success: id={}, guest_id={:?}", id, guest_id), + Ok(guest_id) => info!( + sl!(), + "add_block_device success: id={}, guest_id={:?}", id, guest_id + ), Err(e) => error!(sl!(), "add_block_device failed: id={}, error={:?}", id, e), } result