Skip to content

Commit b1ab576

Browse files
committed
Remove mshv2 feature
Signed-off-by: Doru Blânzeanu <[email protected]>
1 parent 1986fed commit b1ab576

File tree

13 files changed

+106
-191
lines changed

13 files changed

+106
-191
lines changed

Cargo.lock

Lines changed: 3 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Justfile

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ clean-rust:
7878
# convenience recipe to run all tests with the given target and features (similar to CI)
7979
test-like-ci config=default-target hypervisor="kvm":
8080
@# with default features
81-
just test {{config}} {{ if hypervisor == "mshv" {"mshv2"} else {""} }}
81+
just test {{config}} {{ hypervisor }}
8282

8383
@# with only one driver enabled + build-metadata + init-paging
84-
just test {{config}} build-metadata,init-paging,{{ if hypervisor == "mshv" {"mshv2"} else if hypervisor == "mshv3" {"mshv3"} else {"kvm"} }}
84+
just test {{config}} build-metadata,init-paging,{{ hypervisor }}
8585

8686
@# make sure certain cargo features compile
8787
just check
@@ -93,7 +93,7 @@ test-like-ci config=default-target hypervisor="kvm":
9393
just test-rust-crashdump {{config}}
9494

9595
@# test the tracing related features
96-
{{ if os() == "linux" { "just test-rust-tracing " + config + " " + if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}
96+
{{ if os() == "linux" { "just test-rust-tracing " + config + " " + hypervisor } else { "" } }}
9797

9898
like-ci config=default-target hypervisor="kvm":
9999
@# Ensure up-to-date Cargo.lock
@@ -130,19 +130,19 @@ like-ci config=default-target hypervisor="kvm":
130130
{{ if os() == "windows" { "just run-rust-examples " + config } else { "" } }}
131131

132132
@# Run Rust examples - linux
133-
{{ if os() == "linux" { "just run-rust-examples-linux " + config + " " + if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}
133+
{{ if os() == "linux" { "just run-rust-examples-linux " + config + " " + hypervisor } else { "" } }}
134134

135135
@# Run Rust Gdb tests
136-
just test-rust-gdb-debugging {{ config }} {{ if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } }}
136+
just test-rust-gdb-debugging {{ config }} {{ hypervisor }}
137137

138138
@# Run Rust Crashdump tests
139-
just test-rust-crashdump {{config}} {{ if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } }}
139+
just test-rust-crashdump {{config}} {{ hypervisor }}
140140

141141
@# Run Rust Tracing tests - linux
142-
{{ if os() == "linux" { "just test-rust-tracing " + config + " " + if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}
142+
{{ if os() == "linux" { "just test-rust-tracing " + config + " " + hypervisor } else { "" } }}
143143

144144
@# Run benchmarks
145-
{{ if config == "release" { "just bench-ci main " + if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}
145+
{{ if config == "release" { "just bench-ci main " + hypervisor } else { "" } }}
146146

147147
# runs all tests
148148
test target=default-target features="": (test-unit target features) (test-isolated target features) (test-integration "rust" target features) (test-integration "c" target features) (test-doc target features)
@@ -172,14 +172,13 @@ test-integration guest target=default-target features="":
172172

173173
# tests compilation with no default features on different platforms
174174
test-compilation-no-default-features target=default-target:
175-
@# Linux should fail without a hypervisor feature (kvm, mshv, or mshv3)
175+
@# Linux should fail without a hypervisor feature (kvm, mshv)
176176
{{ if os() == "linux" { "! " + cargo-cmd + " check -p hyperlight-host --no-default-features "+target-triple-flag+" 2> /dev/null" } else { "" } }}
177177
@# Windows should succeed even without default features
178178
{{ if os() == "windows" { cargo-cmd + " check -p hyperlight-host --no-default-features" } else { "" } }}
179179
@# Linux should succeed with a hypervisor driver but without init-paging
180180
{{ if os() == "linux" { cargo-cmd + " check -p hyperlight-host --no-default-features --features kvm" } else { "" } }} {{ target-triple-flag }}
181-
{{ if os() == "linux" { cargo-cmd + " check -p hyperlight-host --no-default-features --features mshv2" } else { "" } }} {{ target-triple-flag }}
182-
{{ if os() == "linux" { cargo-cmd + " check -p hyperlight-host --no-default-features --features mshv3" } else { "" } }} {{ target-triple-flag }}
181+
{{ if os() == "linux" { cargo-cmd + " check -p hyperlight-host --no-default-features --features mshv" } else { "" } }} {{ target-triple-flag }}
183182

184183
# runs tests that exercise gdb debugging
185184
test-rust-gdb-debugging target=default-target features="":
@@ -308,7 +307,7 @@ tar-static-lib: (build-rust-capi "release") (build-rust-capi "debug")
308307
# Downloads the benchmarks result from the given release tag.
309308
# If tag is not given, defaults to latest release
310309
# Options for os: "Windows", or "Linux"
311-
# Options for Linux hypervisor: "kvm", "mshv", "mshv3"
310+
# Options for Linux hypervisor: "kvm", "mshv"
312311
# Options for Windows hypervisor: "hyperv"
313312
# Options for cpu: "amd", "intel"
314313
bench-download os hypervisor cpu tag="":

hack/clippy-package-features.sh

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ set -euo pipefail
44

55
# Check for required arguments
66
if [[ $# -lt 2 ]]; then
7-
echo "Usage: $0 <package> <target> [target_triple]" >&2
8-
echo "Example: $0 hyperlight-host debug x86_64-unknown-linux-musl" >&2
9-
exit 1
7+
echo "Usage: $0 <package> <target> [target_triple]" >&2
8+
echo "Example: $0 hyperlight-host debug x86_64-unknown-linux-musl" >&2
9+
exit 1
1010
fi
1111

1212
PACKAGE="$1"
@@ -18,20 +18,20 @@ CARGO="cargo"
1818
# Cargo target argument to append to cargo calls (empty if not provided)
1919
TRIPLE_ARG=""
2020
if [[ -n "${TARGET_TRIPLE}" ]]; then
21-
TRIPLE_ARG="--target ${TARGET_TRIPLE} --target-dir ./target/host"
22-
CARGO="cross"
21+
TRIPLE_ARG="--target ${TARGET_TRIPLE} --target-dir ./target/host"
22+
CARGO="cross"
2323
fi
2424

2525
# Convert target for cargo profile
2626
PROFILE=$([ "$TARGET" = "debug" ] && echo "dev" || echo "$TARGET")
2727

2828
# Required features needed so the rust packages can compile
2929
if [[ "$PACKAGE" == "hyperlight-host" ]]; then
30-
REQUIRED_FEATURES=("kvm" "mshv3")
30+
REQUIRED_FEATURES=("kvm" "mshv")
3131
elif [[ "$PACKAGE" == "hyperlight-guest-bin" ]]; then
32-
REQUIRED_FEATURES=("printf")
33-
else
34-
REQUIRED_FEATURES=()
32+
REQUIRED_FEATURES=("printf")
33+
else
34+
REQUIRED_FEATURES=()
3535
fi
3636

3737
# Get all features for the package (excluding default and required features)
@@ -40,42 +40,66 @@ features=$(cargo metadata --format-version 1 --no-deps | jq -r --arg pkg "$PACKA
4040

4141
# Convert required features array to comma-separated string for cargo
4242
if [[ ${#REQUIRED_FEATURES[@]} -gt 0 ]]; then
43-
required_features_str=$(IFS=,; echo "${REQUIRED_FEATURES[*]}")
43+
required_features_str=$(
44+
IFS=,
45+
echo "${REQUIRED_FEATURES[*]}"
46+
)
4447
else
45-
required_features_str=""
48+
required_features_str=""
4649
fi
4750

4851
# Test with minimal features
4952
if [[ ${#REQUIRED_FEATURES[@]} -gt 0 ]]; then
50-
echo "Testing $PACKAGE with required features only ($required_features_str)..."
51-
(set -x; "$CARGO" clippy -p "$PACKAGE" --all-targets --no-default-features --features "$required_features_str" --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings)
53+
echo "Testing $PACKAGE with required features only ($required_features_str)..."
54+
(
55+
set -x
56+
"$CARGO" clippy -p "$PACKAGE" --all-targets --no-default-features --features "$required_features_str" --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings
57+
)
5258
else
53-
echo "Testing $PACKAGE with no features..."
54-
(set -x; "$CARGO" clippy -p "$PACKAGE" --all-targets --no-default-features --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings)
59+
echo "Testing $PACKAGE with no features..."
60+
(
61+
set -x
62+
"$CARGO" clippy -p "$PACKAGE" --all-targets --no-default-features --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings
63+
)
5564
fi
5665

5766
echo "Testing $PACKAGE with default features..."
58-
(set -x; "$CARGO" clippy -p "$PACKAGE" --all-targets --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings)
67+
(
68+
set -x
69+
"$CARGO" clippy -p "$PACKAGE" --all-targets --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings
70+
)
5971

6072
# Test each additional feature individually
6173
for feature in $features; do
62-
if [[ ${#REQUIRED_FEATURES[@]} -gt 0 ]]; then
63-
echo "Testing $PACKAGE with feature: $required_features_str,$feature"
64-
(set -x; "$CARGO" clippy -p "$PACKAGE" --all-targets --no-default-features --features "$required_features_str,$feature" --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings)
65-
else
66-
echo "Testing $PACKAGE with feature: $feature"
67-
(set -x; "$CARGO" clippy -p "$PACKAGE" --all-targets --no-default-features --features "$feature" --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings)
68-
fi
74+
if [[ ${#REQUIRED_FEATURES[@]} -gt 0 ]]; then
75+
echo "Testing $PACKAGE with feature: $required_features_str,$feature"
76+
(
77+
set -x
78+
"$CARGO" clippy -p "$PACKAGE" --all-targets --no-default-features --features "$required_features_str,$feature" --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings
79+
)
80+
else
81+
echo "Testing $PACKAGE with feature: $feature"
82+
(
83+
set -x
84+
"$CARGO" clippy -p "$PACKAGE" --all-targets --no-default-features --features "$feature" --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings
85+
)
86+
fi
6987
done
7088

7189
# Test all features together
7290
if [[ -n "$features" ]]; then
73-
all_features=$(echo $features | tr '\n' ',' | sed 's/,$//')
74-
if [[ ${#REQUIRED_FEATURES[@]} -gt 0 ]]; then
75-
echo "Testing $PACKAGE with all features: $required_features_str,$all_features"
76-
(set -x; "$CARGO" clippy -p "$PACKAGE" --all-targets --no-default-features --features "$required_features_str,$all_features" --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings)
77-
else
78-
echo "Testing $PACKAGE with all features: $all_features"
79-
(set -x; "$CARGO" clippy -p "$PACKAGE" --all-targets --no-default-features --features "$all_features" --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings)
80-
fi
81-
fi
91+
all_features=$(echo $features | tr '\n' ',' | sed 's/,$//')
92+
if [[ ${#REQUIRED_FEATURES[@]} -gt 0 ]]; then
93+
echo "Testing $PACKAGE with all features: $required_features_str,$all_features"
94+
(
95+
set -x
96+
"$CARGO" clippy -p "$PACKAGE" --all-targets --no-default-features --features "$required_features_str,$all_features" --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings
97+
)
98+
else
99+
echo "Testing $PACKAGE with all features: $all_features"
100+
(
101+
set -x
102+
"$CARGO" clippy -p "$PACKAGE" --all-targets --no-default-features --features "$all_features" --profile="$PROFILE" ${TRIPLE_ARG} -- -D warnings
103+
)
104+
fi
105+
fi

src/hyperlight_host/Cargo.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ lazy_static = "1.4.0"
7777
[target.'cfg(unix)'.dependencies]
7878
kvm-bindings = { version = "0.14", features = ["fam-wrappers"], optional = true }
7979
kvm-ioctls = { version = "0.24", optional = true }
80-
mshv-bindings2 = { package="mshv-bindings", version = "=0.2.1", optional = true }
81-
mshv-ioctls2 = { package="mshv-ioctls", version = "=0.2.1", optional = true}
8280
mshv-bindings3 = { package="mshv-bindings", version = "0.6.1", optional = true }
8381
mshv-ioctls3 = { package="mshv-ioctls", version = "0.6.1", optional = true}
8482

@@ -125,7 +123,7 @@ cfg_aliases = "0.2.1"
125123
built = { version = "0.8.0", optional = true, features = ["chrono", "git2"] }
126124

127125
[features]
128-
default = ["kvm", "mshv3", "build-metadata", "init-paging"]
126+
default = ["kvm", "mshv", "build-metadata", "init-paging"]
129127
function_call_metrics = []
130128
executable_heap = []
131129
# This feature enables printing of debug information to stdout in debug builds
@@ -135,9 +133,7 @@ crashdump = ["dep:chrono"]
135133
trace_guest = ["dep:opentelemetry", "dep:tracing-opentelemetry", "dep:hyperlight-guest-tracing", "hyperlight-common/trace_guest"]
136134
mem_profile = [ "trace_guest", "dep:framehop", "dep:fallible-iterator", "hyperlight-common/mem_profile" ]
137135
kvm = ["dep:kvm-bindings", "dep:kvm-ioctls"]
138-
# This feature is deprecated in favor of mshv3
139-
mshv2 = ["dep:mshv-bindings2", "dep:mshv-ioctls2"]
140-
mshv3 = ["dep:mshv-bindings3", "dep:mshv-ioctls3"]
136+
mshv = ["dep:mshv-bindings3", "dep:mshv-ioctls3"]
141137
# This enables easy debug in the guest
142138
gdb = ["dep:gdbstub", "dep:gdbstub_arch"]
143139
fuzzing = ["hyperlight-common/fuzzing"]

src/hyperlight_host/build.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,16 @@ fn main() -> Result<()> {
8686
}
8787

8888
// Makes #[cfg(kvm)] == #[cfg(all(feature = "kvm", target_os = "linux"))]
89-
// and #[cfg(mshv)] == #[cfg(all(any(feature = "mshv2", feature = "mshv3"), target_os = "linux"))].
89+
// and #[cfg(mshv)] == #[cfg(all(feature = "mshv", target_os = "linux"))].
9090
// Essentially the kvm and mshv features are ignored on windows as long as you use #[cfg(kvm)] and not #[cfg(feature = "kvm")].
9191
// You should never use #[cfg(feature = "kvm")] or #[cfg(feature = "mshv")] in the codebase.
9292
cfg_aliases::cfg_aliases! {
9393
gdb: { all(feature = "gdb", debug_assertions) },
9494
kvm: { all(feature = "kvm", target_os = "linux") },
95-
mshv: { all(any(feature = "mshv2", feature = "mshv3"), target_os = "linux") },
95+
mshv: { all(feature = "mshv", target_os = "linux") },
9696
crashdump: { all(feature = "crashdump") },
9797
// print_debug feature is aliased with debug_assertions to make it only available in debug-builds.
9898
print_debug: { all(feature = "print_debug", debug_assertions) },
99-
// the following features are mutually exclusive but rather than enforcing that here we are enabling mshv2 to override mshv3 when both are enabled
100-
// because mshv3 is in the default feature set we want to allow users to enable mshv2 without having to set --no-default-features and the re-enable
101-
// the other features they want.
102-
mshv2: { all(feature = "mshv2", target_os = "linux") },
103-
mshv3: { all(feature = "mshv3", not(feature="mshv2"), target_os = "linux") },
10499
}
105100

106101
#[cfg(feature = "build-metadata")]

src/hyperlight_host/examples/guest-debugging/main.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ mod tests {
136136

137137
write_cmds_file(&cmd_file_path, cmd).expect("Failed to write gdb commands to file");
138138

139-
#[cfg(mshv2)] // mshv3 is a default feature is mutually exclusive with the mshv2 feature
140-
let features = "gdb,mshv2";
141-
#[cfg(not(mshv2))]
142139
let features = "gdb";
143140

144141
// build it before running to avoid a race condition below

src/hyperlight_host/src/error.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
#[cfg(mshv2)]
18-
extern crate mshv_ioctls2 as mshv_ioctls;
19-
20-
#[cfg(mshv3)]
17+
#[cfg(mshv)]
2118
extern crate mshv_ioctls3 as mshv_ioctls;
2219

2320
use std::array::TryFromSliceError;

src/hyperlight_host/src/hypervisor/gdb/mshv_debug.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,9 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
#[cfg(mshv2)]
18-
extern crate mshv_bindings2 as mshv_bindings;
19-
#[cfg(mshv2)]
20-
extern crate mshv_ioctls2 as mshv_ioctls;
21-
22-
#[cfg(mshv3)]
17+
#[cfg(mshv)]
2318
extern crate mshv_bindings3 as mshv_bindings;
24-
#[cfg(mshv3)]
19+
#[cfg(mshv)]
2520
extern crate mshv_ioctls3 as mshv_ioctls;
2621

2722
use std::collections::HashMap;

0 commit comments

Comments
 (0)