Skip to content

Commit

Permalink
Check that Windows version is 11 or Server 2022 or later
Browse files Browse the repository at this point in the history
Adds a check when creating a new uninitialisedsandbox to ensure that we are running on at least Windows 11 or Windows Server 2022

Signed-off-by: Simon Davies <[email protected]>
  • Loading branch information
simongdavies committed Dec 17, 2024
1 parent 0e8fbf1 commit 63ceac0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ the [./src/tests/rust_guests](./src/tests/rust_guests) directory for Rust guests
You can run Hyperlight on:

- [Linux with KVM][kvm].
- [Windows with Windows Hypervisor Platform (WHP)][whp].
- Windows Subsystem for Linux 2 ([WSL2][wsl2]) with KVM.
- [Windows with Windows Hypervisor Platform (WHP).][whp] - Note that you need Windows 11 / Windows Server 2022 or later to use hyperlight, if you are running on earlier versions of Windows then you should consider using our devcontainer on [GitHub codepsaces]((https://codespaces.new/hyperlight-dev/hyperlight)) or WSL2.
- Windows Subsystem for Linux 2 (see instructions [here](https://learn.microsoft.com/en-us/windows/wsl/install) for Windows client and [here](https://learn.microsoft.com/en-us/windows/wsl/install-on-server) for Windows Server) with KVM.
- Azure Linux with mshv (note that you need mshv to be installed to use Hyperlight)

After having an environment with a hypervisor setup, running the example has the following pre-requisites:
Expand Down
1 change: 1 addition & 0 deletions src/hyperlight_host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ windows-sys = { version = "0.59", features = ["Win32"] }
windows-result = "0.2"
rust-embed = { version = "8.3.0", features = ["debug-embed", "include-exclude", "interpolate-folder-path"] }
sha256 = "1.4.0"
windows-version = "0.1"

[target.'cfg(unix)'.dependencies]
seccompiler = { version = "0.4.0", optional = true }
Expand Down
28 changes: 28 additions & 0 deletions src/hyperlight_host/src/sandbox/uninitialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ impl UninitializedSandbox {
) -> Result<Self> {
log_build_details();

// hyperlight is only supported on Windows 11 and Windows Server 2022 and later
#[cfg(target_os = "windows")]
check_windows_version()?;

// If the guest binary is a file make sure it exists
let guest_binary = match guest_binary {
GuestBinary::FilePath(binary_path) => {
Expand Down Expand Up @@ -303,6 +307,30 @@ impl UninitializedSandbox {
}
}
}
// Check to see if the current version of Windows is supported
// Hyperlight is only supported on Windows 11 and Windows Server 2022 and later
#[cfg(target_os = "windows")]
fn check_windows_version() -> Result<()> {
use windows_version::{is_server, OsVersion};
const WINDOWS_MAJOR: u32 = 10;
const WINDOWS_MINOR: u32 = 0;
const WINDOWS_PACK: u32 = 0;

// Windows Server 2022 has version numbers 10.0.20348 or greater
if is_server() {
if OsVersion::current() < OsVersion::new(WINDOWS_MAJOR, WINDOWS_MINOR, WINDOWS_PACK, 20348)
{
return Err(new_error!(
"Hyperlight Requires Windows Server 2022 or newer"
));
}
} else if OsVersion::current()
< OsVersion::new(WINDOWS_MAJOR, WINDOWS_MINOR, WINDOWS_PACK, 22000)
{
return Err(new_error!("Hyperlight Requires Windows 11 or newer"));
}
Ok(())
}

#[cfg(test)]
mod tests {
Expand Down

0 comments on commit 63ceac0

Please sign in to comment.