mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-01 17:06:28 +00:00
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:
@@ -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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user