Skip to content

Commit e0bbeb5

Browse files
committed
fix(xenclient): examples should use supported platform
1 parent 4b0f378 commit e0bbeb5

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

crates/xen/xenclient/examples/boot.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,10 @@ async fn main() -> Result<()> {
2424
let initrd_path = args.get(2).expect("argument not specified");
2525
let client = XenClient::new().await?;
2626

27-
#[cfg(target_arch = "x86_64")]
28-
let runtime_platform = RuntimePlatformType::Pv;
29-
#[cfg(not(target_arch = "x86_64"))]
30-
let runtime_platform = RuntimePlatformType::Unsupported;
31-
3227
let mut config = DomainConfig::new();
3328
config.platform(PlatformDomainConfig {
3429
uuid: Uuid::new_v4(),
35-
platform: runtime_platform,
30+
platform: RuntimePlatformType::supported(),
3631
kernel: PlatformKernelConfig {
3732
data: Arc::new(fs::read(&kernel_image_path).await?),
3833
format: KernelFormat::ElfCompressed,

crates/xen/xenclient/examples/boot_speed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async fn create_domain(client: &XenClient, kernel: Arc<Vec<u8>>, i: u32) -> Resu
4242
let mut config = DomainConfig::new();
4343
config.platform(PlatformDomainConfig {
4444
uuid: Uuid::new_v4(),
45-
platform: RuntimePlatformType::Pv,
45+
platform: RuntimePlatformType::supported(),
4646
kernel: PlatformKernelConfig {
4747
data: kernel,
4848
format: KernelFormat::ElfUncompressed,

crates/xen/xenplatform/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ impl RuntimePlatformType {
5454
RuntimePlatformType::Pv => RuntimePlatform::Pv(x86pv::X86PvPlatform::new()),
5555
}
5656
}
57+
58+
pub fn supported() -> RuntimePlatformType {
59+
if cfg!(target_arch = "x86_64") {
60+
RuntimePlatformType::Pv
61+
} else {
62+
RuntimePlatformType::Unsupported
63+
}
64+
}
5765
}
5866

5967
#[allow(clippy::large_enum_variant)]

0 commit comments

Comments
 (0)