From d435712ccb811a618417d4c181bf5120052058ff Mon Sep 17 00:00:00 2001 From: "alex.lyn" Date: Fri, 11 Apr 2025 17:01:04 +0800 Subject: [PATCH] runtime-rs: Introduce PortDevice in resource manager in sandbox A new resource type `PortDevice` is introduced which is dedicated for handling root ports/switch ports during sandbox creation(VM). Fixes #10361 Signed-off-by: alex.lyn --- src/runtime-rs/crates/resource/src/lib.rs | 5 ++++- src/runtime-rs/crates/resource/src/manager_inner.rs | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/runtime-rs/crates/resource/src/lib.rs b/src/runtime-rs/crates/resource/src/lib.rs index 23669ccb0c..4648917901 100644 --- a/src/runtime-rs/crates/resource/src/lib.rs +++ b/src/runtime-rs/crates/resource/src/lib.rs @@ -17,7 +17,9 @@ pub mod manager; mod manager_inner; pub mod network; pub mod resource_persist; -use hypervisor::{BlockConfig, HybridVsockConfig, ProtectionDeviceConfig, VsockConfig}; +use hypervisor::{ + BlockConfig, HybridVsockConfig, PortDeviceConfig, ProtectionDeviceConfig, VsockConfig, +}; use network::NetworkConfig; pub mod rootfs; pub mod share_fs; @@ -36,6 +38,7 @@ pub enum ResourceConfig { HybridVsock(HybridVsockConfig), Vsock(VsockConfig), Protection(ProtectionDeviceConfig), + PortDevice(PortDeviceConfig), } #[derive(Debug, Clone, Copy, PartialEq)] diff --git a/src/runtime-rs/crates/resource/src/manager_inner.rs b/src/runtime-rs/crates/resource/src/manager_inner.rs index c151d81707..ba5eae5cf5 100644 --- a/src/runtime-rs/crates/resource/src/manager_inner.rs +++ b/src/runtime-rs/crates/resource/src/manager_inner.rs @@ -193,6 +193,14 @@ impl ResourceManagerInner { .await .context("do handle protection device failed.")?; } + ResourceConfig::PortDevice(pd) => { + do_handle_device( + &self.device_manager, + &DeviceConfig::PortDeviceCfg(pd.clone()), + ) + .await + .context("do handle port device failed.")?; + } }; }