Skip to content

Commit

Permalink
fix(xenclient): examples should use supported platform
Browse files Browse the repository at this point in the history
  • Loading branch information
azenla committed Dec 14, 2024
1 parent 4b0f378 commit e0bbeb5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 1 addition & 6 deletions crates/xen/xenclient/examples/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/xen/xenclient/examples/boot_speed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async fn create_domain(client: &XenClient, kernel: Arc<Vec<u8>>, 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,
Expand Down
8 changes: 8 additions & 0 deletions crates/xen/xenplatform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit e0bbeb5

Please sign in to comment.