runtime-rs: implement trait for vfio device

add the trait implementation for vfio device,

Fixes:#5375
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
This commit is contained in:
Zhongtao Hu 2023-05-10 15:16:05 +08:00
parent e4c5c74a75
commit cc9c915384

View File

@ -6,9 +6,13 @@
use std::{fs, path::Path, process::Command};
use crate::{driver::hypervisor, DeviceConfig};
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
use anyhow::anyhow;
use anyhow::{Context, Result};
use async_trait::async_trait;
use crate::Device;
fn override_driver(bdf: &str, driver: &str) -> Result<()> {
let driver_override = format!("/sys/bus/pci/devices/{}/driver_override", bdf);
@ -145,3 +149,26 @@ pub fn bind_device_to_host(bdf: &str, host_driver: &str, _vendor_device_id: &str
Ok(())
}
#[async_trait]
impl Device for VfioConfig {
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!()
}
}