mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-27 07:48:55 +00:00
libs/types: fix implementation details
use ok_or_else to handle get_mut(hypervisor) to substitue unwrap Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
This commit is contained in:
parent
d96716b4d2
commit
05ad026fc0
@ -23,7 +23,7 @@
|
||||
//! hypervisors, so let's contain it...
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::io::Result;
|
||||
use std::io::{self, Result};
|
||||
use std::path::Path;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
@ -974,7 +974,9 @@ impl ConfigOps for Hypervisor {
|
||||
if let Some(plugin) = get_hypervisor_plugin(hypervisor) {
|
||||
plugin.adjust_configuration(conf)?;
|
||||
// Safe to unwrap() because `hypervisor` is a valid key in the hash map.
|
||||
let hv = conf.hypervisor.get_mut(hypervisor).unwrap();
|
||||
let hv = conf.hypervisor.get_mut(hypervisor).ok_or_else(|| {
|
||||
io::Error::new(io::ErrorKind::NotFound, "hypervisor not found".to_string())
|
||||
})?;
|
||||
hv.blockdev_info.adjust_configuration()?;
|
||||
hv.boot_info.adjust_configuration()?;
|
||||
hv.cpu_info.adjust_configuration()?;
|
||||
|
Loading…
Reference in New Issue
Block a user