mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: vm: Validate configuration on API boot
When performing an API boot validate the configuration. For now only some very basic validation is performed but in subsequent commits the validation will be extended. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
@@ -25,7 +25,9 @@ extern crate vm_allocator;
|
||||
extern crate vm_memory;
|
||||
extern crate vm_virtio;
|
||||
|
||||
use crate::config::{DeviceConfig, DiskConfig, HotplugMethod, NetConfig, PmemConfig, VmConfig};
|
||||
use crate::config::{
|
||||
DeviceConfig, DiskConfig, HotplugMethod, NetConfig, PmemConfig, ValidationError, VmConfig,
|
||||
};
|
||||
use crate::cpu;
|
||||
use crate::device_manager::{get_win_size, Console, DeviceManager, DeviceManagerError};
|
||||
use crate::memory_manager::{Error as MemoryManagerError, MemoryManager};
|
||||
@@ -191,6 +193,9 @@ pub enum Error {
|
||||
|
||||
/// Cannot convert source URL from Path into &str
|
||||
RestoreSourceUrlPathToStr,
|
||||
|
||||
/// Failed to validate config
|
||||
ConfigValidation(ValidationError),
|
||||
}
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
@@ -309,6 +314,12 @@ impl Vm {
|
||||
reset_evt: EventFd,
|
||||
vmm_path: PathBuf,
|
||||
) -> Result<Self> {
|
||||
config
|
||||
.lock()
|
||||
.unwrap()
|
||||
.validate()
|
||||
.map_err(Error::ConfigValidation)?;
|
||||
|
||||
let device_manager = DeviceManager::new(
|
||||
fd.clone(),
|
||||
config.clone(),
|
||||
|
||||
Reference in New Issue
Block a user