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 <alex.lyn@antgroup.com>
This commit is contained in:
Alex Lyn
2024-03-11 16:02:39 +08:00
parent f571ec84d2
commit 9f6003adde

View File

@@ -34,6 +34,7 @@ pub struct QemuInner {
config: HypervisorConfig, config: HypervisorConfig,
devices: Vec<DeviceType>, devices: Vec<DeviceType>,
netns: Option<String>,
} }
impl QemuInner { impl QemuInner {
@@ -43,12 +44,14 @@ impl QemuInner {
qemu_process: None, qemu_process: None,
config: Default::default(), config: Default::default(),
devices: Vec::new(), devices: Vec::new(),
netns: None,
} }
} }
pub(crate) async fn prepare_vm(&mut self, id: &str, _netns: Option<String>) -> Result<()> { pub(crate) async fn prepare_vm(&mut self, id: &str, netns: Option<String>) -> Result<()> {
info!(sl!(), "Preparing QEMU VM"); info!(sl!(), "Preparing QEMU VM");
self.id = id.to_string(); self.id = id.to_string();
self.netns = netns;
let vm_path = [KATA_PATH, self.id.as_str()].join("/"); let vm_path = [KATA_PATH, self.id.as_str()].join("/");
std::fs::create_dir_all(vm_path)?; std::fs::create_dir_all(vm_path)?;
@@ -357,6 +360,7 @@ impl Persist for QemuInner {
qemu_process: None, qemu_process: None,
config: hypervisor_state.config, config: hypervisor_state.config,
devices: Vec::new(), devices: Vec::new(),
netns: None,
}) })
} }
} }