mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 16:27:50 +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...
|
//! hypervisors, so let's contain it...
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::Result;
|
use std::io::{self, Result};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
@ -974,7 +974,9 @@ impl ConfigOps for Hypervisor {
|
|||||||
if let Some(plugin) = get_hypervisor_plugin(hypervisor) {
|
if let Some(plugin) = get_hypervisor_plugin(hypervisor) {
|
||||||
plugin.adjust_configuration(conf)?;
|
plugin.adjust_configuration(conf)?;
|
||||||
// Safe to unwrap() because `hypervisor` is a valid key in the hash map.
|
// 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.blockdev_info.adjust_configuration()?;
|
||||||
hv.boot_info.adjust_configuration()?;
|
hv.boot_info.adjust_configuration()?;
|
||||||
hv.cpu_info.adjust_configuration()?;
|
hv.cpu_info.adjust_configuration()?;
|
||||||
|
Loading…
Reference in New Issue
Block a user