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 984422b7be..71db1e4fd5 100644 --- a/src/runtime-rs/crates/hypervisor/src/device/driver/mod.rs +++ b/src/runtime-rs/crates/hypervisor/src/device/driver/mod.rs @@ -4,6 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 // +mod vhost_user; mod virtio_blk; pub use virtio_blk::{ BlockConfig, KATA_BLK_DEV_TYPE, KATA_MMIO_BLK_DEV_TYPE, VIRTIO_BLOCK_MMIO, VIRTIO_BLOCK_PCI, diff --git a/src/runtime-rs/crates/hypervisor/src/device/driver/vhost_user.rs b/src/runtime-rs/crates/hypervisor/src/device/driver/vhost_user.rs new file mode 100644 index 0000000000..53d4a0e019 --- /dev/null +++ b/src/runtime-rs/crates/hypervisor/src/device/driver/vhost_user.rs @@ -0,0 +1,53 @@ +// Copyright (c) 2019-2023 Alibaba Cloud +// Copyright (c) 2019-2023 Ant Group +// +// SPDX-License-Identifier: Apache-2.0 +// + +use crate::Device; +use crate::{driver::hypervisor, DeviceConfig}; +use anyhow::Result; +use async_trait::async_trait; + +/// VhostUserConfig represents data shared by most vhost-user devices +pub struct VhostUserConfig { + /// Device id + pub dev_id: String, + /// Socket path + pub socket_path: String, + /// Mac_address is only meaningful for vhost user net device + pub mac_address: String, + /// These are only meaningful for vhost user fs devices + pub tag: String, + pub cache: String, + pub device_type: String, + /// Pci_addr is the PCI address used to identify the slot at which the drive is attached. + pub pci_addr: Option, + /// Block index of the device if assigned + pub index: u8, + pub cache_size: u32, + pub queue_siez: u32, +} + +#[async_trait] +impl Device for VhostUserConfig { + async fn attach(&self, _h: &dyn hypervisor) -> Result<()> { + todo!() + } + + async fn detach(&self, _h: &dyn hypervisor) -> Result { + todo!() + } + + async fn get_device_info(&self) -> DeviceConfig { + todo!() + } + + async fn increase_attach_count(&mut self) -> Result { + todo!() + } + + async fn decrease_attach_count(&mut self) -> Result { + todo!() + } +}