mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-25 15:02:45 +00:00
runtime-rs: CloudHypervisorInner: Change config type
This commit change config in CloudHypervisorInner to normal HypervisorConfig to decrease the change of its type. Fixes: #10849 Signed-off-by: Hui Zhu <teawater@antgroup.com>
This commit is contained in:
parent
c9f5966f56
commit
e4cbc6abce
@ -27,7 +27,7 @@ pub struct CloudHypervisorInner {
|
|||||||
pub(crate) api_socket: Option<UnixStream>,
|
pub(crate) api_socket: Option<UnixStream>,
|
||||||
pub(crate) extra_args: Option<Vec<String>>,
|
pub(crate) extra_args: Option<Vec<String>>,
|
||||||
|
|
||||||
pub(crate) config: Option<HypervisorConfig>,
|
pub(crate) config: HypervisorConfig,
|
||||||
|
|
||||||
pub(crate) process: Option<Child>,
|
pub(crate) process: Option<Child>,
|
||||||
pub(crate) pid: Option<u32>,
|
pub(crate) pid: Option<u32>,
|
||||||
@ -101,7 +101,7 @@ impl CloudHypervisorInner {
|
|||||||
process: None,
|
process: None,
|
||||||
pid: None,
|
pid: None,
|
||||||
|
|
||||||
config: None,
|
config: Default::default(),
|
||||||
state: VmmState::NotReady,
|
state: VmmState::NotReady,
|
||||||
timeout_secs: CH_DEFAULT_TIMEOUT_SECS as i32,
|
timeout_secs: CH_DEFAULT_TIMEOUT_SECS as i32,
|
||||||
id: String::default(),
|
id: String::default(),
|
||||||
@ -124,11 +124,11 @@ impl CloudHypervisorInner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_hypervisor_config(&mut self, config: HypervisorConfig) {
|
pub fn set_hypervisor_config(&mut self, config: HypervisorConfig) {
|
||||||
self.config = Some(config);
|
self.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hypervisor_config(&self) -> HypervisorConfig {
|
pub fn hypervisor_config(&self) -> HypervisorConfig {
|
||||||
self.config.clone().unwrap_or_default()
|
self.config.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ impl Persist for CloudHypervisorInner {
|
|||||||
let (tx, rx) = channel(true);
|
let (tx, rx) = channel(true);
|
||||||
|
|
||||||
let mut ch = Self {
|
let mut ch = Self {
|
||||||
config: Some(hypervisor_state.config),
|
config: hypervisor_state.config,
|
||||||
state: VmmState::NotReady,
|
state: VmmState::NotReady,
|
||||||
id: hypervisor_state.id,
|
id: hypervisor_state.id,
|
||||||
vm_path: hypervisor_state.vm_path,
|
vm_path: hypervisor_state.vm_path,
|
||||||
|
@ -117,11 +117,7 @@ impl CloudHypervisorInner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn get_kernel_params(&self) -> Result<String> {
|
async fn get_kernel_params(&self) -> Result<String> {
|
||||||
let cfg = self
|
let cfg = &self.config;
|
||||||
.config
|
|
||||||
.as_ref()
|
|
||||||
.ok_or("no hypervisor config for CH")
|
|
||||||
.map_err(|e| anyhow!(e))?;
|
|
||||||
|
|
||||||
let enable_debug = cfg.debug_info.enable_debug;
|
let enable_debug = cfg.debug_info.enable_debug;
|
||||||
|
|
||||||
@ -200,15 +196,10 @@ impl CloudHypervisorInner {
|
|||||||
|
|
||||||
let vsock_socket_path = get_vsock_path(&self.id)?;
|
let vsock_socket_path = get_vsock_path(&self.id)?;
|
||||||
|
|
||||||
let hypervisor_config = self
|
|
||||||
.config
|
|
||||||
.as_ref()
|
|
||||||
.ok_or("no hypervisor config for CH")
|
|
||||||
.map_err(|e| anyhow!(e))?;
|
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
sl!(),
|
sl!(),
|
||||||
"generic Hypervisor configuration: {:?}", hypervisor_config
|
"generic Hypervisor configuration: {:?}",
|
||||||
|
self.config.clone()
|
||||||
);
|
);
|
||||||
|
|
||||||
let kernel_params = self.get_kernel_params().await?;
|
let kernel_params = self.get_kernel_params().await?;
|
||||||
@ -217,7 +208,7 @@ impl CloudHypervisorInner {
|
|||||||
kernel_params,
|
kernel_params,
|
||||||
sandbox_path,
|
sandbox_path,
|
||||||
vsock_socket_path,
|
vsock_socket_path,
|
||||||
cfg: hypervisor_config.clone(),
|
cfg: self.config.clone(),
|
||||||
guest_protection_to_use: self.guest_protection_to_use.clone(),
|
guest_protection_to_use: self.guest_protection_to_use.clone(),
|
||||||
shared_fs_devices,
|
shared_fs_devices,
|
||||||
network_devices,
|
network_devices,
|
||||||
@ -324,11 +315,7 @@ impl CloudHypervisorInner {
|
|||||||
async fn cloud_hypervisor_launch(&mut self, _timeout_secs: i32) -> Result<()> {
|
async fn cloud_hypervisor_launch(&mut self, _timeout_secs: i32) -> Result<()> {
|
||||||
self.cloud_hypervisor_ensure_not_launched().await?;
|
self.cloud_hypervisor_ensure_not_launched().await?;
|
||||||
|
|
||||||
let cfg = self
|
let cfg = &self.config;
|
||||||
.config
|
|
||||||
.as_ref()
|
|
||||||
.ok_or("no hypervisor config for CH")
|
|
||||||
.map_err(|e| anyhow!(e))?;
|
|
||||||
|
|
||||||
let debug = cfg.debug_info.enable_debug;
|
let debug = cfg.debug_info.enable_debug;
|
||||||
|
|
||||||
@ -338,13 +325,7 @@ impl CloudHypervisorInner {
|
|||||||
|
|
||||||
let _ = std::fs::remove_file(api_socket_path.clone());
|
let _ = std::fs::remove_file(api_socket_path.clone());
|
||||||
|
|
||||||
let binary_path = self
|
let binary_path = cfg.path.to_string();
|
||||||
.config
|
|
||||||
.as_ref()
|
|
||||||
.ok_or("no hypervisor config for CH")
|
|
||||||
.map_err(|e| anyhow!(e))?
|
|
||||||
.path
|
|
||||||
.to_string();
|
|
||||||
|
|
||||||
let path = Path::new(&binary_path).canonicalize()?;
|
let path = Path::new(&binary_path).canonicalize()?;
|
||||||
|
|
||||||
@ -567,11 +548,7 @@ impl CloudHypervisorInner {
|
|||||||
// call, if confidential_guest is set, a confidential
|
// call, if confidential_guest is set, a confidential
|
||||||
// guest will be created.
|
// guest will be created.
|
||||||
async fn handle_guest_protection(&mut self) -> Result<()> {
|
async fn handle_guest_protection(&mut self) -> Result<()> {
|
||||||
let cfg = self
|
let cfg = &self.config;
|
||||||
.config
|
|
||||||
.as_ref()
|
|
||||||
.ok_or("missing hypervisor config")
|
|
||||||
.map_err(|e| anyhow!(e))?;
|
|
||||||
|
|
||||||
let confidential_guest = cfg.security_info.confidential_guest;
|
let confidential_guest = cfg.security_info.confidential_guest;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user