diff --git a/src/runtime-rs/crates/hypervisor/src/device/driver/mod.rs b/src/runtime-rs/crates/hypervisor/src/device/driver/mod.rs index a108a9a90f..ec2c569a9f 100644 --- a/src/runtime-rs/crates/hypervisor/src/device/driver/mod.rs +++ b/src/runtime-rs/crates/hypervisor/src/device/driver/mod.rs @@ -24,9 +24,9 @@ pub use vfio::{ pub use vhost_user::{VhostUserConfig, VhostUserDevice, VhostUserType}; pub use vhost_user_net::VhostUserNetDevice; pub use virtio_blk::{ - BlockConfig, BlockDevice, BlockDeviceAio, KATA_BLK_DEV_TYPE, KATA_CCW_DEV_TYPE, - KATA_MMIO_BLK_DEV_TYPE, KATA_NVDIMM_DEV_TYPE, KATA_SCSI_DEV_TYPE, VIRTIO_BLOCK_CCW, - VIRTIO_BLOCK_MMIO, VIRTIO_BLOCK_PCI, VIRTIO_PMEM, + BlockConfig, BlockDevice, BlockDeviceAio, BlockDeviceFormat, KATA_BLK_DEV_TYPE, + KATA_CCW_DEV_TYPE, KATA_MMIO_BLK_DEV_TYPE, KATA_NVDIMM_DEV_TYPE, KATA_SCSI_DEV_TYPE, + VIRTIO_BLOCK_CCW, VIRTIO_BLOCK_MMIO, VIRTIO_BLOCK_PCI, VIRTIO_PMEM, }; pub use virtio_fs::{ ShareFsConfig, ShareFsDevice, ShareFsMountConfig, ShareFsMountOperation, ShareFsMountType, diff --git a/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_blk.rs b/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_blk.rs index fcfdfeaf74..0913ed53f7 100644 --- a/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_blk.rs +++ b/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_blk.rs @@ -59,6 +59,23 @@ impl std::fmt::Display for BlockDeviceAio { } } +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub enum BlockDeviceFormat { + #[default] + Raw, + Vmdk, +} + +impl std::fmt::Display for BlockDeviceFormat { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let to_string = match *self { + BlockDeviceFormat::Raw => "raw".to_string(), + BlockDeviceFormat::Vmdk => "vmdk".to_string(), + }; + write!(f, "{to_string}") + } +} + #[derive(Debug, Clone, Default)] pub struct BlockConfig { /// Path of the drive. @@ -71,6 +88,9 @@ pub struct BlockConfig { /// Don't close `path_on_host` file when dropping the device. pub no_drop: bool, + /// raw, vmdk, etc. And default to raw if not set. + pub format: BlockDeviceFormat, + /// Specifies cache-related options for block devices. /// Denotes whether use of O_DIRECT (bypass the host page cache) is enabled. /// If not set, use configurarion block_device_cache_direct.