diff --git a/crates/xen/xenclient/examples/boot.rs b/crates/xen/xenclient/examples/boot.rs index b007bcb0..d9eef140 100644 --- a/crates/xen/xenclient/examples/boot.rs +++ b/crates/xen/xenclient/examples/boot.rs @@ -24,15 +24,10 @@ async fn main() -> Result<()> { let initrd_path = args.get(2).expect("argument not specified"); let client = XenClient::new().await?; - #[cfg(target_arch = "x86_64")] - let runtime_platform = RuntimePlatformType::Pv; - #[cfg(not(target_arch = "x86_64"))] - let runtime_platform = RuntimePlatformType::Unsupported; - let mut config = DomainConfig::new(); config.platform(PlatformDomainConfig { uuid: Uuid::new_v4(), - platform: runtime_platform, + platform: RuntimePlatformType::supported(), kernel: PlatformKernelConfig { data: Arc::new(fs::read(&kernel_image_path).await?), format: KernelFormat::ElfCompressed, diff --git a/crates/xen/xenclient/examples/boot_speed.rs b/crates/xen/xenclient/examples/boot_speed.rs index b56c7d96..6b7f8a7e 100644 --- a/crates/xen/xenclient/examples/boot_speed.rs +++ b/crates/xen/xenclient/examples/boot_speed.rs @@ -42,7 +42,7 @@ async fn create_domain(client: &XenClient, kernel: Arc>, i: u32) -> Resu let mut config = DomainConfig::new(); config.platform(PlatformDomainConfig { uuid: Uuid::new_v4(), - platform: RuntimePlatformType::Pv, + platform: RuntimePlatformType::supported(), kernel: PlatformKernelConfig { data: kernel, format: KernelFormat::ElfUncompressed, diff --git a/crates/xen/xenplatform/src/lib.rs b/crates/xen/xenplatform/src/lib.rs index fac9ce33..63617645 100644 --- a/crates/xen/xenplatform/src/lib.rs +++ b/crates/xen/xenplatform/src/lib.rs @@ -54,6 +54,14 @@ impl RuntimePlatformType { RuntimePlatformType::Pv => RuntimePlatform::Pv(x86pv::X86PvPlatform::new()), } } + + pub fn supported() -> RuntimePlatformType { + if cfg!(target_arch = "x86_64") { + RuntimePlatformType::Pv + } else { + RuntimePlatformType::Unsupported + } + } } #[allow(clippy::large_enum_variant)]