Merge pull request #8566 from liubogithub/liubo/dev/panic_fix

runtime-rs: fix panic when hypervisor mismatches with configuration
This commit is contained in:
Chao Wu 2023-12-10 21:33:59 +08:00 committed by GitHub
commit df7f416cb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -479,8 +479,18 @@ impl Annotation {
let u32_err = io::Error::new(io::ErrorKind::InvalidData, "parse u32 error".to_string());
let u64_err = io::Error::new(io::ErrorKind::InvalidData, "parse u64 error".to_string());
let i32_err = io::Error::new(io::ErrorKind::InvalidData, "parse i32 error".to_string());
let hv = config.hypervisor.get_mut(hypervisor_name).unwrap();
let ag = config.agent.get_mut(agent_name).unwrap();
let hv = config.hypervisor.get_mut(hypervisor_name).ok_or_else(|| {
io::Error::new(
io::ErrorKind::InvalidData,
format!("Invalid hypervisor name {}", hypervisor_name),
)
})?;
let ag = config.agent.get_mut(agent_name).ok_or_else(|| {
io::Error::new(
io::ErrorKind::InvalidData,
format!("Invalid agent name {}", agent_name),
)
})?;
for (key, value) in &self.annotations {
if hv.security_info.is_annotation_enabled(key) {
match key.as_str() {