From 9f6003adde33ffa4d3280a7da1405931ff8c1f1a Mon Sep 17 00:00:00 2001 From: Alex Lyn Date: Mon, 11 Mar 2024 16:02:39 +0800 Subject: [PATCH] runtime-rs: add a new netns field in struct QemuInner. We need add a new netns field in struct QemuInner, and initialize it with argument passed down in prepare_vm(). Fixes: #8865 Signed-off-by: Alex Lyn --- src/runtime-rs/crates/hypervisor/src/qemu/inner.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs b/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs index 732843d123..b5614dd3c7 100644 --- a/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs +++ b/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs @@ -34,6 +34,7 @@ pub struct QemuInner { config: HypervisorConfig, devices: Vec, + netns: Option, } impl QemuInner { @@ -43,12 +44,14 @@ impl QemuInner { qemu_process: None, config: Default::default(), devices: Vec::new(), + netns: None, } } - pub(crate) async fn prepare_vm(&mut self, id: &str, _netns: Option) -> Result<()> { + pub(crate) async fn prepare_vm(&mut self, id: &str, netns: Option) -> Result<()> { info!(sl!(), "Preparing QEMU VM"); self.id = id.to_string(); + self.netns = netns; let vm_path = [KATA_PATH, self.id.as_str()].join("/"); std::fs::create_dir_all(vm_path)?; @@ -357,6 +360,7 @@ impl Persist for QemuInner { qemu_process: None, config: hypervisor_state.config, devices: Vec::new(), + netns: None, }) } }