diff --git a/.buildkite/README.md b/.buildkite/README.md deleted file mode 100644 index 2fba68d3..00000000 --- a/.buildkite/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# buildkite custom pipelines - -This folder contains the custom pipelines for this repository. - -If we add a new pipeline we need to enable it in -https://buildkite.com/rust-vmm/vhost-ci/steps - -Custom pipelines currently defined are: -- `custom-tests.json` - Custom tests to enable only certain features. - -- `rust-vmm-ci-tests.json` - This is based on `rust-vmm-ci/.buildkite/test_description.json`. - We can't run rust-vmm-ci tests because they enable all the features with - `--all-features` and our crates have features that may not be compatible with - others (e.g. `xen`). Waiting to solve this problem in rust-vmm-ci (see - https://github.com/rust-vmm/rust-vmm-ci/issues/152), we use a custom - pipeline based on that but that does not use `--all-features`. diff --git a/.buildkite/custom-tests.json b/.buildkite/custom-tests.json index 892cbb5b..573f53e2 100644 --- a/.buildkite/custom-tests.json +++ b/.buildkite/custom-tests.json @@ -1,25 +1,4 @@ { "tests": [ - { - "test_name": "build-vhost-kern", - "command": "cargo build --features=vhost-kern", - "platform": [ - "x86_64" - ] - }, - { - "test_name": "build-vhost-user-frontend", - "command": "cargo build --features=vhost-user-frontend", - "platform": [ - "x86_64" - ] - }, - { - "test_name": "build-vhost-user-backend", - "command": "cargo build --features=vhost-user-backend", - "platform": [ - "x86_64" - ] - } ] } diff --git a/.buildkite/rust-vmm-ci-tests.json b/.buildkite/rust-vmm-ci-tests.json deleted file mode 100644 index 630fc618..00000000 --- a/.buildkite/rust-vmm-ci-tests.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "tests": [ - { - "test_name": "build-gnu", - "command": "RUSTFLAGS=\"-D warnings\" cargo build --release", - "platform": [ - "x86_64", - "aarch64" - ] - }, - { - "test_name": "build-musl", - "command": "RUSTFLAGS=\"-D warnings\" cargo build --release --target {target_platform}-unknown-linux-musl", - "platform": [ - "x86_64", - "aarch64" - ] - }, - { - "test_name": "style", - "command": "cargo fmt --all -- --check --config format_code_in_doc_comments=true" - }, - { - "test_name": "unittests-gnu-all-with-xen", - "command": "cargo test --workspace --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,xen", - "platform": [ - "x86_64", - "aarch64" - ] - }, - { - "test_name": "unittests-gnu-all-without-xen", - "command": "cargo test --workspace --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,postcopy", - "platform": [ - "x86_64", - "aarch64" - ] - }, - { - "test_name": "unittests-musl-all-with-xen", - "command": "cargo test --workspace --target {target_platform}-unknown-linux-musl --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,xen", - "platform": [ - "x86_64", - "aarch64" - ] - }, - { - "test_name": "unittests-musl-all-without-xen", - "command": "cargo test --workspace --target {target_platform}-unknown-linux-musl --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,postcopy", - "platform": [ - "x86_64", - "aarch64" - ] - }, - { - "test_name": "clippy-all-with-xen", - "command": "cargo clippy --workspace --bins --examples --benches --all-targets --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,xen -- -D warnings -D clippy::undocumented_unsafe_blocks", - "platform": [ - "x86_64", - "aarch64" - ] - }, - { - "test_name": "clippy-all-without-xen", - "command": "cargo clippy --workspace --bins --examples --benches --all-targets --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,postcopy -- -D warnings -D clippy::undocumented_unsafe_blocks", - "platform": [ - "x86_64", - "aarch64" - ] - }, - { - "test_name": "check-warnings-all-with-xen", - "command": "RUSTFLAGS=\"-D warnings\" cargo check --all-targets --workspace --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,xen", - "platform": [ - "x86_64", - "aarch64" - ] - }, - { - "test_name": "check-warnings-all-without-xen", - "command": "RUSTFLAGS=\"-D warnings\" cargo check --all-targets --workspace --no-default-features --features test-utils,vhost-vsock,vhost-kern,vhost-vdpa,vhost-net,vhost-user,vhost-user-frontend,vhost-user-backend,postcopy", - "platform": [ - "x86_64", - "aarch64" - ] - }, - { - "test_name": "coverage", - "command": "pytest $(find . -type f -name \"test_coverage.py\")", - "docker_plugin": { - "privileged": true - }, - "platform": [ - "x86_64" - ] - }, - { - "test_name": "commit-format", - "command": "pytest $(find . -type f -name \"test_commit_format.py\")", - "docker_plugin": { - "propagate-environment": true - } - }, - { - "test_name": "cargo-audit", - "command": "[ -e Cargo.lock ] || cargo generate-lockfile; cargo audit -q --deny warnings", - "platform": [ - "x86_64" - ] - } - ] -} diff --git a/.buildkite/rust-vmm-ci-tests.json b/.buildkite/rust-vmm-ci-tests.json new file mode 120000 index 00000000..586acc34 --- /dev/null +++ b/.buildkite/rust-vmm-ci-tests.json @@ -0,0 +1 @@ +../rust-vmm-ci/.buildkite/test_description.json \ No newline at end of file diff --git a/rust-vmm-ci b/rust-vmm-ci index c0f5d4c3..3e248353 160000 --- a/rust-vmm-ci +++ b/rust-vmm-ci @@ -1 +1 @@ -Subproject commit c0f5d4c3f58094c90ea12200f513b21e457983bd +Subproject commit 3e248353468a9aa0efa844d39eecf24e1dbdc3f3 diff --git a/vhost-user-backend/Cargo.toml b/vhost-user-backend/Cargo.toml index 9e380a2d..bd00652a 100644 --- a/vhost-user-backend/Cargo.toml +++ b/vhost-user-backend/Cargo.toml @@ -8,6 +8,10 @@ repository = "https://github.com/rust-vmm/vhost" edition = "2021" license = "Apache-2.0" +[package.metadata.docs.rs] +all-features = true +rustc-args = ['--cfg RUTSDOC_disable_feature_compat_errors'] + [features] xen = ["vm-memory/xen", "vhost/xen"] postcopy = ["vhost/postcopy", "userfaultfd"] @@ -28,3 +32,11 @@ uuid = { version = "1.8.0", features=["v4"] } vhost = { path = "../vhost", version = "0.14.0", features = ["test-utils", "vhost-user-frontend", "vhost-user-backend"] } vm-memory = { workspace = true, features = ["backend-mmap", "backend-atomic"] } tempfile = "3.2.0" + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(RUTSDOC_disable_feature_compat_errors)'] } + +[package.metadata.cargo-all-features] +skip_feature_sets = [ + ["xen", "postcopy"] +] diff --git a/vhost-user-backend/src/lib.rs b/vhost-user-backend/src/lib.rs index 7e1db9e4..5936e10a 100644 --- a/vhost-user-backend/src/lib.rs +++ b/vhost-user-backend/src/lib.rs @@ -36,10 +36,15 @@ pub use self::vring::{ VringMutex, VringRwLock, VringState, VringStateGuard, VringStateMutGuard, VringT, }; -/// Due to the way `xen` handles memory mappings we can not combine it with -/// `postcopy` feature which relies on persistent memory mappings. Thus we -/// disallow enabling both features at the same time. -#[cfg(all(feature = "postcopy", feature = "xen"))] +// Due to the way `xen` handles memory mappings we can not combine it with +// `postcopy` feature which relies on persistent memory mappings. Thus we +// disallow enabling both features at the same time. +#[cfg(all( + not(RUTSDOC_disable_feature_compat_errors), + not(doc), + feature = "postcopy", + feature = "xen" +))] compile_error!("Both `postcopy` and `xen` features can not be enabled at the same time."); /// An alias for `GuestMemoryAtomic>` to simplify code. diff --git a/vhost/CHANGELOG.md b/vhost/CHANGELOG.md index 3eb54b88..02f12374 100644 --- a/vhost/CHANGELOG.md +++ b/vhost/CHANGELOG.md @@ -12,6 +12,8 @@ ### Deprecated ### Fixed - [[#304]](https://github.com/rust-vmm/vhost/pull/304) Fix building docs. +- [[#326]](https://github.com/rust-vmm/vhots/pull/326) Fix `get_vring_base()` returning 0 instead of + the vring base for vhost-kern backends when compiling in release mode. ## v0.14.0 diff --git a/vhost/Cargo.toml b/vhost/Cargo.toml index 355490a6..d35696f9 100644 --- a/vhost/Cargo.toml +++ b/vhost/Cargo.toml @@ -12,6 +12,7 @@ edition = "2021" [package.metadata.docs.rs] all-features = true +rustc-args = ['--cfg RUTSDOC_disable_feature_compat_errors'] [features] default = [] @@ -37,3 +38,13 @@ vm-memory = { workspace = true, features=["backend-mmap"] } [dev-dependencies] tempfile = "3.2.0" serial_test = "3.0" + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(RUTSDOC_disable_feature_compat_errors)'] } + +[package.metadata.cargo-all-features] +skip_feature_sets = [ + ["xen", "postcopy"] +] + +denylist = ["test_utils"] diff --git a/vhost/src/lib.rs b/vhost/src/lib.rs index 6a2c0e1a..d386a59c 100644 --- a/vhost/src/lib.rs +++ b/vhost/src/lib.rs @@ -51,10 +51,15 @@ pub mod vhost_user; #[cfg(feature = "vhost-vsock")] pub mod vsock; -/// Due to the way `xen` handles memory mappings we can not combine it with -/// `postcopy` feature which relies on persistent memory mappings. Thus we -/// disallow enabling both features at the same time. -#[cfg(all(not(doc), feature = "postcopy", feature = "xen"))] +// Due to the way `xen` handles memory mappings we can not combine it with +// `postcopy` feature which relies on persistent memory mappings. Thus we +// disallow enabling both features at the same time. +#[cfg(all( + not(RUTSDOC_disable_feature_compat_errors), + not(doc), + feature = "postcopy", + feature = "xen" +))] compile_error!("Both `postcopy` and `xen` features can not be enabled at the same time."); /// Error codes for vhost operations diff --git a/vhost/src/vhost_kern/mod.rs b/vhost/src/vhost_kern/mod.rs index 4888c08d..a1f404f6 100644 --- a/vhost/src/vhost_kern/mod.rs +++ b/vhost/src/vhost_kern/mod.rs @@ -235,12 +235,12 @@ impl VhostBackend for T { /// Get a bitmask of supported virtio/vhost features. fn get_vring_base(&self, queue_index: usize) -> Result { - let vring_state = vhost_vring_state { + let mut vring_state = vhost_vring_state { index: queue_index as u32, num: 0, }; // SAFETY: This ioctl is called on a valid vhost fd and has its return value checked. - let ret = unsafe { ioctl_with_ref(self, VHOST_GET_VRING_BASE(), &vring_state) }; + let ret = unsafe { ioctl_with_mut_ref(self, VHOST_GET_VRING_BASE(), &mut vring_state) }; ioctl_result(ret, vring_state.num) } diff --git a/vhost/src/vhost_user/mod.rs b/vhost/src/vhost_user/mod.rs index 0ecb686e..f8d3384c 100644 --- a/vhost/src/vhost_user/mod.rs +++ b/vhost/src/vhost_user/mod.rs @@ -18,7 +18,6 @@ //! Most messages that can be sent via the Unix domain socket implementing vhost-user have an //! equivalent ioctl to the kernel implementation. -use std::fs::File; use std::io::Error as IOError; pub mod message; @@ -214,7 +213,8 @@ pub type HandlerResult = std::result::Result; /// Utility function to take the first element from option of a vector of files. /// Returns `None` if the vector contains no file or more than one file. -pub(crate) fn take_single_file(files: Option>) -> Option { +#[cfg(any(feature = "vhost-user-backend", feature = "vhost-user-frontend"))] +pub(crate) fn take_single_file(files: Option>) -> Option { let mut files = files?; if files.len() != 1 { return None;