feature(xen-preflight): test for hypervisor presence explicitly and error if missing

Fixes #309
This commit is contained in:
Ariadne Conill
2024-08-19 17:13:40 -07:00
parent 2ab2cda937
commit fa76ec1215

View File

@ -1,5 +1,6 @@
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use krataloopdev::LoopControl; use krataloopdev::LoopControl;
use log::debug;
use std::{fs, path::PathBuf, str::FromStr, sync::Arc}; use std::{fs, path::PathBuf, str::FromStr, sync::Arc};
use tokio::sync::Semaphore; use tokio::sync::Semaphore;
use uuid::Uuid; use uuid::Uuid;
@ -168,6 +169,13 @@ pub struct Runtime {
impl Runtime { impl Runtime {
pub async fn new() -> Result<Self> { pub async fn new() -> Result<Self> {
let context = RuntimeContext::new().await?; let context = RuntimeContext::new().await?;
debug!("testing for hypervisor presence");
context
.xen
.call
.get_version_capabilities()
.await
.map_err(|_| anyhow!("hypervisor is not present"))?;
Ok(Self { Ok(Self {
context, context,
launch_semaphore: Arc::new(Semaphore::new(10)), launch_semaphore: Arc::new(Semaphore::new(10)),