vmm: Make --kernel optional

The kernel path was the only mandatory command line option.
With the addition of the --api-socket option, we can run without a
kernel path and get it later through the API.

Since we can end up with VM configurations that are no longer valid by
default, we need to provide a validation check for it. For now, if the
kernel path is not defined, the VM configuration is invalid.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz
2019-09-19 09:52:55 +02:00
parent f27aa21e3f
commit b14fd37db9
3 changed files with 31 additions and 25 deletions

View File

@@ -463,7 +463,8 @@ fn get_host_cpu_phys_bits() -> u8 {
impl Vm {
pub fn new(config: Arc<VmConfig>, exit_evt: EventFd, reset_evt: EventFd) -> Result<Self> {
let kvm = Kvm::new().map_err(Error::KvmNew)?;
let kernel = File::open(&config.kernel.path).map_err(Error::KernelFile)?;
let kernel =
File::open(&config.kernel.as_ref().unwrap().path).map_err(Error::KernelFile)?;
let fd = kvm.create_vm().map_err(Error::VmCreate)?;
let fd = Arc::new(fd);
let creation_ts = std::time::Instant::now();