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

Fixes #309
This commit is contained in:
Ariadne Conill 2024-08-19 17:22:28 -07:00 committed by GitHub
parent 274136825a
commit 6a6b5b6e0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,6 @@
use anyhow::{anyhow, Result};
use krataloopdev::LoopControl;
use log::debug;
use std::{fs, path::PathBuf, str::FromStr, sync::Arc};
use tokio::sync::Semaphore;
use uuid::Uuid;
@ -168,6 +169,13 @@ pub struct Runtime {
impl Runtime {
pub async fn new() -> Result<Self> {
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 {
context,
launch_semaphore: Arc::new(Semaphore::new(10)),