mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-19 07:49:17 +00:00
runtime-rs: implement trait for vhost-user device
add the trait implementation for vhost-user device Fixes:#5375 Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
This commit is contained in:
@@ -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,
|
||||
|
@@ -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<String>,
|
||||
/// 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<u64> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn get_device_info(&self) -> DeviceConfig {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn increase_attach_count(&mut self) -> Result<bool> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn decrease_attach_count(&mut self) -> Result<bool> {
|
||||
todo!()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user