From 2d0a985b7bd5a69f0862b1af269173464afc6d86 Mon Sep 17 00:00:00 2001 From: Patrick Roy Date: Fri, 26 Sep 2025 17:42:04 +0100 Subject: [PATCH 1/5] test: check windows build run `cargo check` for the x86_64-pc-windows-gnu target, to ensure we don't accidentally break building the crate on windows. Hackily add rawfd and xen features to the cargo-all-features denylist for just this test. Signed-off-by: Patrick Roy --- .buildkite/custom-tests.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.buildkite/custom-tests.json b/.buildkite/custom-tests.json index 6f5415eb..3204f562 100644 --- a/.buildkite/custom-tests.json +++ b/.buildkite/custom-tests.json @@ -4,6 +4,13 @@ "test_name": "miri", "command": "RUST_BACKTRACE=1 MIRIFLAGS='-Zmiri-disable-isolation -Zmiri-backtrace=full' cargo +nightly miri test --features backend-mmap,backend-bitmap", "platform": ["x86_64", "aarch64"] + }, + { + "test_name": "check-windows-build", + "command": "printf '\ndenylist=[\"rawfd\", \"xen\"]' >> Cargo.toml; RUSTFLAGS=\"-D warnings\" cargo all-features check --all-targets --target x86_64-pc-windows-gnu", + "platform": [ + "x86_64" + ] } ] } From 1ef0e617cb21ed1ae2216267bef66ea17d8b589e Mon Sep 17 00:00:00 2001 From: Patrick Roy Date: Sat, 27 Sep 2025 19:49:38 +0100 Subject: [PATCH 2/5] windows: remove unused imports Signed-off-by: Patrick Roy --- src/bitmap/backend/atomic_bitmap.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitmap/backend/atomic_bitmap.rs b/src/bitmap/backend/atomic_bitmap.rs index c75567d3..ae8b0f9e 100644 --- a/src/bitmap/backend/atomic_bitmap.rs +++ b/src/bitmap/backend/atomic_bitmap.rs @@ -196,7 +196,7 @@ impl NewBitmap for AtomicBitmap { #[cfg(target_family = "windows")] let page_size = { - use winapi::um::sysinfoapi::{GetSystemInfo, LPSYSTEM_INFO, SYSTEM_INFO}; + use winapi::um::sysinfoapi::GetSystemInfo; let mut sysinfo = std::mem::MaybeUninit::zeroed(); // SAFETY: It's safe to call `GetSystemInfo` as `sysinfo` is rightly sized // allocated memory. From 26b22e7ff616dcb3c68cfa3249053410f861d57b Mon Sep 17 00:00:00 2001 From: Patrick Roy Date: Sat, 27 Sep 2025 19:55:27 +0100 Subject: [PATCH 3/5] windows: make tests work with only feature backend-mmap The tests module in mmap/windows.rs assumed that `crate::bitmap` was always available, but it is not. Hide the imports / usage of that crate behind appropriate cfgs. Fixes: 4757a4aafbed ("do not backdoor-enable backend-bitmap in unittests") Signed-off-by: Patrick Roy --- src/mmap/windows.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mmap/windows.rs b/src/mmap/windows.rs index 571fa7a2..6d723917 100644 --- a/src/mmap/windows.rs +++ b/src/mmap/windows.rs @@ -245,6 +245,7 @@ impl Drop for MmapRegion { mod tests { use std::os::windows::io::FromRawHandle; + #[cfg(feature = "backend-bitmap")] use crate::bitmap::AtomicBitmap; use crate::guest_memory::FileOffset; use crate::mmap::windows::INVALID_HANDLE_VALUE; @@ -260,6 +261,7 @@ mod tests { } #[test] + #[cfg(feature = "backend-bitmap")] fn test_dirty_tracking() { // Using the `crate` prefix because we aliased `MmapRegion` to `MmapRegion<()>` for // the rest of the unit tests above. From 202241719d729ca02ec7b76277de37d5e9a2d0eb Mon Sep 17 00:00:00 2001 From: Patrick Roy Date: Wed, 1 Oct 2025 09:28:52 +0100 Subject: [PATCH 4/5] fix(windows): enable dep:winapi crate with backend-bitmap Otherwise the crate does not compile on windows with --no-default-features --features backend-bitmap (not a particularly useful combination of features, since it gives bitmaps without mmap backends, which would usually drag in the winapi crate, but it should still work). Signed-off-by: Patrick Roy --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f26ed37c..69d5406c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ autobenches = false [features] default = ["rawfd"] -backend-bitmap = ["dep:libc"] +backend-bitmap = ["dep:libc", "dep:winapi"] backend-mmap = ["dep:libc", "dep:winapi"] backend-atomic = ["arc-swap"] rawfd = ["dep:libc"] From 108688075e285ffafe8a39c509774846865b5300 Mon Sep 17 00:00:00 2001 From: Patrick Roy Date: Wed, 1 Oct 2025 09:31:24 +0100 Subject: [PATCH 5/5] windows: be more explicit about unsupported features the rawfd and xen features do not work on windows (and don't even compile), so explicitly give a compile_error!() in this case. Signed-off-by: Patrick Roy --- src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 2f87f4c8..3d4ad1e9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,6 +24,12 @@ #[cfg(not(target_pointer_width = "64"))] compile_error!("vm-memory only supports 64-bit targets!"); +#[cfg(all(target_family = "windows", feature = "rawfd"))] +compile_error!("rawfd feature is not supported on Windows targets!"); + +#[cfg(all(target_family = "windows", feature = "xen"))] +compile_error!("xen feature is not supported on Windows targets!"); + #[macro_use] pub mod address; pub use address::{Address, AddressValue};