From cc9c915384900916a388e5a80e13ca96ed480b4e Mon Sep 17 00:00:00 2001 From: Zhongtao Hu Date: Wed, 10 May 2023 15:16:05 +0800 Subject: [PATCH] runtime-rs: implement trait for vfio device add the trait implementation for vfio device, Fixes:#5375 Signed-off-by: Zhongtao Hu Signed-off-by: alex.lyn --- .../hypervisor/src/device/driver/vfio.rs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs b/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs index fcee1bb8c6..4c43be0104 100644 --- a/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs +++ b/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs @@ -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 { + 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!() + } +}