Skip to content
This repository has been archived by the owner on Dec 20, 2021. It is now read-only.

Commit

Permalink
vfio_device: make buildkite happy
Browse files Browse the repository at this point in the history
Rust does not support mutually exclusive features. Buildkite enables all
features. These two factors combined causes pipeline failures.

Turn the feature gates in code a bit. Whenever "kvm" is specify, surface
KVM's definitions. Make available MSHV if and only if "mshv" is
specified.

Add custom tests for MSHV.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
  • Loading branch information
liuw authored and jiangliu committed Sep 7, 2021
1 parent 7120e0b commit a8ee64b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
14 changes: 14 additions & 0 deletions .buildkite/custom-tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"tests": [
{
"test_name": "build-mshv",
"command": "cargo build --release --no-default-features --features mshv",
"platform": ["x86_64"]
},
{
"test_name": "clippy-mshv",
"command": "cargo clippy --workspace --bins --examples --benches --no-default-features --features mshv --all-targets -- -D warnings",
"platform": ["x86_64"]
}
]
}
8 changes: 4 additions & 4 deletions src/vfio_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ use kvm_bindings::{
#[cfg(feature = "kvm")]
use kvm_ioctls::DeviceFd;
use log::{debug, error, warn};
#[cfg(feature = "mshv")]
#[cfg(all(feature = "mshv", not(feature = "kvm")))]
use mshv_bindings::{
mshv_device_attr, MSHV_DEV_VFIO_GROUP, MSHV_DEV_VFIO_GROUP_ADD, MSHV_DEV_VFIO_GROUP_DEL,
};
#[cfg(feature = "mshv")]
#[cfg(all(feature = "mshv", not(feature = "kvm")))]
use mshv_ioctls::DeviceFd;
use vfio_bindings::bindings::vfio::*;
use vm_memory::{Address, GuestMemory, GuestMemoryRegion, MemoryRegionAddress};
Expand Down Expand Up @@ -243,7 +243,7 @@ impl VfioContainer {
addr: group_fd_ptr as u64,
};

#[cfg(feature = "mshv")]
#[cfg(all(feature = "mshv", not(feature = "kvm")))]
let dev_attr = mshv_device_attr {
flags: 0,
group: MSHV_DEV_VFIO_GROUP,
Expand All @@ -266,7 +266,7 @@ impl VfioContainer {
addr: group_fd_ptr as u64,
};

#[cfg(feature = "mshv")]
#[cfg(all(feature = "mshv", not(feature = "kvm")))]
let dev_attr = mshv_device_attr {
flags: 0,
group: MSHV_DEV_VFIO_GROUP,
Expand Down

0 comments on commit a8ee64b

Please sign in to comment.