Skip to content

Commit 3098bc4

Browse files
committed
Check that Windows version is 11 or Server 2022 or later
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]>
1 parent a9be4b3 commit 3098bc4

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ the [./src/tests/rust_guests](./src/tests/rust_guests) directory for Rust guests
174174
You can run Hyperlight on:
175175

176176
- [Linux with KVM][kvm].
177-
- [Windows with Windows Hypervisor Platform (WHP)][whp].
178-
- Windows Subsystem for Linux 2 ([WSL2][wsl2]) with KVM.
177+
- [Windows with Windows Hypervisor Platform (WHP).][whp] - Note that you need Windows 11 or Windows Server 2022 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.
178+
- 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.
179179
- Azure Linux with mshv (note that you need mshv to be installed to use Hyperlight)
180180

181181
After having an environment with a hypervisor setup, running the example has the following pre-requisites:

src/hyperlight_host/src/sandbox/uninitialized.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ impl UninitializedSandbox {
142142
) -> Result<Self> {
143143
log_build_details();
144144

145+
// hyperlight is only supported on Windows 11 and Windows Server 2022 and later
146+
#[cfg(target_os = "windows")]
147+
check_windows_version()?;
148+
145149
// If the guest binary is a file make sure it exists
146150
let guest_binary = match guest_binary {
147151
GuestBinary::FilePath(binary_path) => {
@@ -303,6 +307,31 @@ impl UninitializedSandbox {
303307
}
304308
}
305309
}
310+
// Check to see if the current version of Windows is supported
311+
// Hyperlight is only supported on Windows 11 and Windows Server 2022 and later
312+
#[cfg(target_os = "windows")]
313+
fn check_windows_version() -> Result<()> {
314+
use windows_version::{is_server, OsVersion};
315+
const WINDOWS_MAJOR: u32 = 10;
316+
const WINDOWS_MINOR: u32 = 0;
317+
const WINDOWS_PACK: u32 = 0;
318+
319+
// Windows Server 2022 has version numbers 10.0.20348 or greater
320+
if is_server() {
321+
if OsVersion::current() < OsVersion::new(WINDOWS_MAJOR, WINDOWS_MINOR, WINDOWS_PACK, 20348)
322+
{
323+
return Err(new_error!(
324+
"Hyperlight Requires Windows Server 2022 or newer"
325+
));
326+
}
327+
} else {
328+
if OsVersion::current() < OsVersion::new(WINDOWS_MAJOR, WINDOWS_MINOR, WINDOWS_PACK, 22000)
329+
{
330+
return Err(new_error!("Hyperlight Requires Windows 11 or newer"));
331+
}
332+
}
333+
Ok(())
334+
}
306335

307336
#[cfg(test)]
308337
mod tests {

0 commit comments

Comments
 (0)