Skip to content
This repository was archived by the owner on Nov 6, 2024. It is now read-only.

Switch to rust-vmm-ci #16

Merged
merged 5 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This workaround is needed because the linker is unable to find __addtf3,
# __multf3 and __subtf3.
# Related issue: https://github.com/rust-lang/compiler-builtins/issues/201
[target.aarch64-unknown-linux-musl]
rustflags = [ "-C", "target-feature=+crt-static", "-C", "link-arg=-lgcc"]
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "rust-vmm-ci"]
path = rust-vmm-ci
url = https://github.com/rust-vmm/rust-vmm-ci.git
14 changes: 12 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ cp arm/mod.rs arm64/

Also, you will need to add the new architecture to `kvm-bindings/lib.rs`.

# Future Improvements
### Future Improvements
All the above steps are scriptable, so in the next iteration I will add a
script to generate the bindings.
script to generate the bindings.

# Testing

This crate is tested using
[rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) and
[Buildkite](https://buildkite.com/) pipelines. Each new feature added to this crate must be
accompanied by Buildkite steps for testing the following:
- Release builds (using musl/gnu) with the new feature on arm and x86
- Coverage test as specified in the
[rust-vmm-ci readme](https://github.com/rust-vmm/rust-vmm-ci#getting-started-with-rust-vmm-ci).
5 changes: 5 additions & 0 deletions coverage_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"coverage_score": 67.4,
"exclude_path": "",
"crate_features": "fam-wrappers"
}
1 change: 1 addition & 0 deletions rust-vmm-ci
Submodule rust-vmm-ci added at c309d0
27 changes: 15 additions & 12 deletions src/arm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

#[cfg(feature = "kvm-v4_14_0")]
// Export 4.14 bindings when the feature kvm-v4_20_0 is not specified.
#[cfg(all(feature = "kvm-v4_14_0", not(feature = "kvm-v4_20_0")))]
#[allow(clippy::all)]
mod bindings_v4_14_0;
#[cfg(feature = "kvm-v4_20_0")]
mod bindings_v4_20_0;

// Major hack to have a default version in case no feature is specified:
// If no version is specified by using the features, just use the latest one
// which currently is 4.20.
#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))]
// Export 4.20 bindings when kvm-v4_20_0 is specified or no kernel version
// related features are specified.
#[cfg(any(
feature = "kvm-v4_20_0",
all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0"))
))]
#[allow(clippy::all)]
mod bindings_v4_20_0;

pub mod bindings {
#[cfg(feature = "kvm-v4_14_0")]
#[cfg(all(feature = "kvm-v4_14_0", not(feature = "kvm-v4_20_0")))]
pub use super::bindings_v4_14_0::*;

#[cfg(feature = "kvm-v4_20_0")]
pub use super::bindings_v4_20_0::*;

#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))]
#[cfg(any(
feature = "kvm-v4_20_0",
all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0"))
))]
pub use super::bindings_v4_20_0::*;
}
27 changes: 15 additions & 12 deletions src/arm64/mod.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

#[cfg(feature = "kvm-v4_14_0")]
// Export 4.14 bindings when the feature kvm-v4_20_0 is not specified.
#[cfg(all(feature = "kvm-v4_14_0", not(feature = "kvm-v4_20_0")))]
#[allow(clippy::all)]
mod bindings_v4_14_0;
#[cfg(feature = "kvm-v4_20_0")]
mod bindings_v4_20_0;

// Major hack to have a default version in case no feature is specified:
// If no version is specified by using the features, just use the latest one
// which currently is 4.20.
#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))]
// Export 4.20 bindings when kvm-v4_20_0 is specified or no kernel version
// related features are specified.
#[cfg(any(
feature = "kvm-v4_20_0",
all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0"))
))]
#[allow(clippy::all)]
mod bindings_v4_20_0;

pub mod bindings {
#[cfg(feature = "kvm-v4_14_0")]
#[cfg(all(feature = "kvm-v4_14_0", not(feature = "kvm-v4_20_0")))]
pub use super::bindings_v4_14_0::*;

#[cfg(feature = "kvm-v4_20_0")]
pub use super::bindings_v4_20_0::*;

#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))]
#[cfg(any(
feature = "kvm-v4_20_0",
all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0"))
))]
pub use super::bindings_v4_20_0::*;
}
9 changes: 1 addition & 8 deletions src/x86/fam_wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@

use vmm_sys_util::fam::{FamStruct, FamStructWrapper};

#[cfg(feature = "kvm-v4_14_0")]
use super::bindings_v4_14_0::*;

#[cfg(feature = "kvm-v4_20_0")]
use super::bindings_v4_20_0::*;

#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))]
use super::bindings_v4_20_0::*;
use x86::bindings::*;

/// Maximum number of CPUID entries that can be returned by a call to KVM ioctls.
///
Expand Down
27 changes: 15 additions & 12 deletions src/x86/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,28 @@
#[cfg(feature = "fam-wrappers")]
mod fam_wrappers;

#[cfg(feature = "kvm-v4_14_0")]
// Export 4.14 bindings when the feature kvm-v4_20_0 is not specified.
#[cfg(all(feature = "kvm-v4_14_0", not(feature = "kvm-v4_20_0")))]
#[allow(clippy::all)]
mod bindings_v4_14_0;
#[cfg(feature = "kvm-v4_20_0")]
mod bindings_v4_20_0;

// Major hack to have a default version in case no feature is specified:
// If no version is specified by using the features, just use the latest one
// which currently is 4.20.
#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))]
// Export 4.20 bindings when kvm-v4_20_0 is specified or no kernel version
// related features are specified.
#[cfg(any(
feature = "kvm-v4_20_0",
all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0"))
))]
#[allow(clippy::all)]
mod bindings_v4_20_0;

pub mod bindings {
#[cfg(feature = "kvm-v4_14_0")]
#[cfg(all(feature = "kvm-v4_14_0", not(feature = "kvm-v4_20_0")))]
pub use super::bindings_v4_14_0::*;

#[cfg(feature = "kvm-v4_20_0")]
pub use super::bindings_v4_20_0::*;

#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))]
#[cfg(any(
feature = "kvm-v4_20_0",
all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0"))
))]
pub use super::bindings_v4_20_0::*;

#[cfg(feature = "fam-wrappers")]
Expand Down