Skip to content

Commit 35c456c

Browse files
committed
Merge branch 'main' into move-hv-partition-setup-to-hv-handler
2 parents 3e2bb6a + 6d4c3a8 commit 35c456c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+4283
-308
lines changed

.devcontainer/Dockerfile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
## Dockerfile for devcontainer
2+
3+
FROM mcr.microsoft.com/devcontainers/base:debian AS base
4+
5+
ARG USER=vscode
6+
ARG GROUP=vscode
7+
8+
ENV HOME="/home/${USER}"
9+
ENV PATH="$HOME/.cargo/bin:$PATH"
10+
11+
# Install dependencies
12+
RUN apt-get update \
13+
&& apt-get -y install \
14+
build-essential \
15+
cmake \
16+
curl \
17+
git \
18+
gnupg \
19+
gnuplot \
20+
lsb-release \
21+
make \
22+
software-properties-common \
23+
sudo \
24+
wget
25+
26+
ARG LLVM_VERSION=17
27+
28+
# Install llvm
29+
RUN wget https://apt.llvm.org/llvm.sh \
30+
&& chmod +x ./llvm.sh \
31+
&& sudo ./llvm.sh ${LLVM_VERSION} all \
32+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/clang-cl /usr/bin/clang-cl \
33+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/llvm-lib /usr/bin/llvm-lib \
34+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/lld-link /usr/bin/lld-link \
35+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/llvm-ml /usr/bin/llvm-ml \
36+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/ld.lld /usr/bin/ld.lld \
37+
&& sudo ln -s /usr/lib/llvm-${LLVM_VERSION}/bin/clang /usr/bin/clang
38+
39+
FROM base AS dev
40+
41+
# Make sure the devcontainer user has sudo access
42+
RUN chown -R "${USER}:${GROUP}" /home/${USER} \
43+
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
44+
45+
# Persist bash hystory
46+
RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \
47+
&& mkdir /commandhistory \
48+
&& touch /commandhistory/.bash_history \
49+
&& chown -R "${USER}" /commandhistory \
50+
&& echo "$SNIPPET" >> "/home/${USER}/.bashrc"
51+
52+
USER $USER
53+
54+
ARG RUST_TOOLCHAIN=1.81.0
55+
56+
# Install rust
57+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
58+
&& rustup default ${RUST_TOOLCHAIN} \
59+
&& rustup target add x86_64-unknown-linux-gnu \
60+
&& rustup target add x86_64-unknown-none \
61+
&& rustup target add x86_64-pc-windows-msvc \
62+
&& rustup toolchain add nightly-x86_64-unknown-linux-gnu \
63+
&& cargo install just
64+

.devcontainer/devcontainer.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// For more info on the configuration below, check out the link:
2+
// https://code.visualstudio.com/docs/devcontainers/create-dev-container
3+
{
4+
"name": "Hyperlight",
5+
6+
"image": "ghcr.io/hyperlight-dev/hyperlight-devcontainer:latest",
7+
8+
"containerUser": "vscode",
9+
// Environment for the container also used by the `postCreateCommand`
10+
"containerEnv": {
11+
"DEVICE": "/dev/kvm",
12+
"KVM_SHOULD_BE_PRESENT": "true",
13+
"REMOTE_USER": "vscode",
14+
"REMOTE_GROUP": "vscode"
15+
},
16+
17+
"runArgs": [
18+
"--device=/dev/kvm"
19+
],
20+
21+
// Use 'postCreateCommand' to run commands after the container is created
22+
"postCreateCommand": "bash .devcontainer/setup.sh",
23+
24+
"customizations": {
25+
"vscode": {
26+
"extensions": [
27+
"ms-vscode.cmake-tools",
28+
"rust-lang.rust-analyzer",
29+
"vadimcn.vscode-lldb"
30+
],
31+
"settings": {
32+
"rust-analyzer.rustfmt.extraArgs": [
33+
"+nightly" // required for rustfmt.toml which uses nightly features
34+
]
35+
}
36+
}
37+
}
38+
}

.devcontainer/setup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
# Change device ownership
4+
sudo chown -R $REMOTE_USER:$REMOTE_GROUP $DEVICE
5+

.github/workflows/Benchmarks.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,18 @@ jobs:
1717
strategy:
1818
fail-fast: true
1919
matrix:
20-
build: [windows-2022-release, linux-kvm-release, linux-hyperv-release]
21-
include:
22-
- build: windows-2022-release
23-
os: [self-hosted, Windows, X64, "1ES.Pool=hld-win2022-amd"]
24-
hypervisor: none
25-
- build: linux-kvm-release
26-
os: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd"]
27-
hypervisor: kvm
28-
- build: linux-hyperv-release
29-
os: [self-hosted, Linux, X64, "1ES.Pool=hld-mshv-amd"]
30-
hypervisor: hyperv
20+
hypervisor: [hyperv, mshv, kvm] # hyperv is windows, mshv and kvm are linux
21+
cpu: [amd, intel]
22+
config: [release] # don't want to benchmark debug-builds
3123

32-
runs-on: ${{ matrix.os }}
24+
runs-on: ${{ fromJson(format('["self-hosted", "{0}", "X64", "1ES.Pool=hld-{1}-{2}"]', matrix.hypervisor == 'hyperv' && 'Windows' || 'Linux', matrix.hypervisor == 'hyperv' && 'win2022' || matrix.hypervisor, matrix.cpu)) }}
25+
3326
steps:
3427
### Setup ###
3528

3629
- uses: actions/checkout@v4
3730

38-
- uses: hyperlight-dev/ci-setup-workflow@v1.0.0
31+
- uses: hyperlight-dev/ci-setup-workflow@v1.1.0
3932
with:
4033
rust-toolchain: "1.81.0"
4134
env:
@@ -68,7 +61,7 @@ jobs:
6861
run: git fetch --tags origin
6962

7063
- name: Download benchmarks from most recent release
71-
run: just bench-download ${{ runner.os }} ${{ matrix.hypervisor }} # skip tag parameter to compare to latest stable release
64+
run: just bench-download ${{ runner.os }} ${{ matrix.hypervisor }} ${{ matrix.cpu }} # skip tag parameter to compare to latest stable release
7265
continue-on-error: true
7366
env:
7467
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -78,6 +71,6 @@ jobs:
7871

7972
- uses: actions/upload-artifact@v4
8073
with:
81-
name: benchmarks_${{runner.os}}_${{matrix.hypervisor}}
74+
name: benchmarks_${{runner.os}}_${{matrix.hypervisor}}_${{ matrix.cpu }}
8275
path: ./target/criterion/
8376
if-no-files-found: error

.github/workflows/CargoPublish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
fetch-depth: 0
3333
fetch-tags: true
3434

35-
- uses: hyperlight-dev/ci-setup-workflow@v1.0.0
35+
- uses: hyperlight-dev/ci-setup-workflow@v1.1.0
3636
with:
3737
rust-toolchain: "1.81.0"
3838

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Create and publish devcontainer Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
paths:
8+
- ".devcontainer/Dockerfile"
9+
- ".github/workflows/CreateDevcontainerImage.yml"
10+
- "rust-toolchain.toml"
11+
12+
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}-devcontainer
16+
USER: vscode
17+
GROUP: vscode
18+
LLVM_VERSION: 17
19+
RUST_TOOLCHAIN_DEFAULT: 1.81.0
20+
RUST_TOOLCHAIN_FILE: rust-toolchain.toml
21+
22+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
23+
jobs:
24+
build-and-push-image:
25+
runs-on: ubuntu-latest
26+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
27+
permissions:
28+
contents: read
29+
packages: write
30+
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
- name: Read Rust toolchain version from ${{ env.RUST_TOOLCHAIN_FILE }}
36+
id: toolchain
37+
run: |
38+
version=$(cat ${{ env.RUST_TOOLCHAIN_FILE }} | sed -n '/\[toolchain\]/,/^\[/{/^\s*channel = /s/[^"]*"\([^"]*\)".*/\1/p}')
39+
cat ${{ env.RUST_TOOLCHAIN_FILE }} | grep $version &> /dev/null \
40+
&& echo "RUST_TOOLCHAIN=${version}" >> "$GITHUB_OUTPUT" \
41+
|| echo "RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN_FILE }}" >> "$GITHUB_OUTPUT"
42+
43+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
44+
- name: Log in to the Container registry
45+
uses: docker/login-action@v3
46+
with:
47+
registry: ${{ env.REGISTRY }}
48+
username: ${{ github.actor }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Extract metadata (tags, labels) for Docker
52+
id: meta
53+
uses: docker/metadata-action@v5
54+
with:
55+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
56+
57+
- name: Build and push Docker image
58+
id: push
59+
uses: docker/build-push-action@v6
60+
with:
61+
context: ./.devcontainer
62+
push: true
63+
tags: |
64+
${{ steps.meta.outputs.tags }}
65+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
66+
labels: ${{ steps.meta.outputs.labels }}
67+
build-args: |
68+
USER=${{ env.USER }}
69+
GROUP=${{ env.GROUP }}
70+
LLVM_VERSION=${{ env.LLVM_VERSION }}
71+
RUST_TOOLCHAIN=${{ steps.toolchain.outputs.RUST_TOOLCHAIN }}

.github/workflows/CreateRelease.yml

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323

24-
- uses: hyperlight-dev/ci-setup-workflow@v1.0.0
24+
- uses: hyperlight-dev/ci-setup-workflow@v1.1.0
2525
with:
2626
rust-toolchain: "1.81.0"
2727
env:
@@ -41,7 +41,7 @@ jobs:
4141
steps:
4242
- uses: actions/checkout@v4
4343

44-
- uses: hyperlight-dev/ci-setup-workflow@v1.0.0
44+
- uses: hyperlight-dev/ci-setup-workflow@v1.1.0
4545
with:
4646
rust-toolchain: "1.81.0"
4747
env:
@@ -109,7 +109,7 @@ jobs:
109109
fetch-depth: 0
110110
fetch-tags: true
111111

112-
- uses: hyperlight-dev/ci-setup-workflow@v1.0.0
112+
- uses: hyperlight-dev/ci-setup-workflow@v1.1.0
113113
with:
114114
rust-toolchain: "1.81.0"
115115
env:
@@ -155,29 +155,20 @@ jobs:
155155
just tar-headers
156156
just tar-static-lib
157157
158-
- name: Download benchmarks (Windows)
158+
- name: Download all benchmarks
159159
uses: actions/download-artifact@v4
160160
with:
161-
name: benchmarks_Windows_none
162-
path: benchmarks_Windows_none
163-
164-
- name: Download benchmarks (Linux hyperv)
165-
uses: actions/download-artifact@v4
166-
with:
167-
name: benchmarks_Linux_hyperv
168-
path: benchmarks_Linux_hyperv
169-
170-
- name: Download benchmarks (Linux kvm)
171-
uses: actions/download-artifact@v4
172-
with:
173-
name: benchmarks_Linux_kvm
174-
path: benchmarks_Linux_kvm
161+
pattern: benchmarks_*
162+
# note: artifacts retain their upload name, so we don't have to specify the path
175163

176164
- name: Archive benchmarks
177165
run: |
178-
tar -zcvf benchmarks_Windows_none.tar.gz benchmarks_Windows_none
179-
tar -zcvf benchmarks_Linux_hyperv.tar.gz benchmarks_Linux_hyperv
180-
tar -zcvf benchmarks_Linux_kvm.tar.gz benchmarks_Linux_kvm
166+
tar -zcvf benchmarks_Windows_hyperv_amd.tar.gz benchmarks_Windows_hyperv_amd
167+
tar -zcvf benchmarks_Linux_hyperv_amd.tar.gz benchmarks_Linux_hyperv_amd
168+
tar -zcvf benchmarks_Linux_kvm_amd.tar.gz benchmarks_Linux_kvm_amd
169+
tar -zcvf benchmarks_Windows_hyperv_intel.tar.gz benchmarks_Windows_hyperv_intel
170+
tar -zcvf benchmarks_Linux_hyperv_intel.tar.gz benchmarks_Linux_hyperv_intel
171+
tar -zcvf benchmarks_Linux_kvm_intel.tar.gz benchmarks_Linux_kvm_intel
181172
182173
- name: Install github-cli
183174
run: |
@@ -202,9 +193,12 @@ jobs:
202193
src/tests/rust_guests/bin/${{ env.CONFIG }}/simpleguest `
203194
src/tests/rust_guests/bin/${{ env.CONFIG }}/simpleguest.exe `
204195
src/tests/rust_guests/bin/${{ env.CONFIG }}/dummyguest `
205-
benchmarks_Windows_none.tar.gz `
206-
benchmarks_Linux_hyperv.tar.gz `
207-
benchmarks_Linux_kvm.tar.gz `
196+
benchmarks_Windows_hyperv_amd.tar.gz `
197+
benchmarks_Linux_hyperv_amd.tar.gz `
198+
benchmarks_Linux_kvm_amd.tar.gz `
199+
benchmarks_Windows_hyperv_intel.tar.gz `
200+
benchmarks_Linux_hyperv_intel.tar.gz `
201+
benchmarks_Linux_kvm_intel.tar.gz `
208202
hyperlight-guest-c-api-linux.tar.gz `
209203
hyperlight-guest-c-api-windows.tar.gz `
210204
include.tar.gz
@@ -221,9 +215,12 @@ jobs:
221215
src/tests/rust_guests/bin/${{ env.CONFIG }}/simpleguest `
222216
src/tests/rust_guests/bin/${{ env.CONFIG }}/simpleguest.exe `
223217
src/tests/rust_guests/bin/${{ env.CONFIG }}/dummyguest `
224-
benchmarks_Windows_none.tar.gz `
225-
benchmarks_Linux_hyperv.tar.gz `
226-
benchmarks_Linux_kvm.tar.gz `
218+
benchmarks_Windows_hyperv_amd.tar.gz `
219+
benchmarks_Linux_hyperv_amd.tar.gz `
220+
benchmarks_Linux_kvm_amd.tar.gz `
221+
benchmarks_Windows_hyperv_intel.tar.gz `
222+
benchmarks_Linux_hyperv_intel.tar.gz `
223+
benchmarks_Linux_kvm_intel.tar.gz `
227224
hyperlight-guest-c-api-linux.tar.gz `
228225
hyperlight-guest-c-api-windows.tar.gz `
229226
include.tar.gz

.github/workflows/PRLabelChecker.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@ jobs:
1414
- uses: actions/checkout@v4
1515
- name: Check for specific labels
1616
run: |
17-
PR_NUMBER=$(echo ${{ github.event.pull_request.number }})
18-
LABELS_JSON=$(gh pr view $PR_NUMBER --json labels -q '.labels.[] | .name')
19-
REQUIRED_LABELS=("chore" "ignore" "breaking-change" "enhancement" "feature" "dependencies" "bug" "security" "performance" "refactor" "testing" "documentation" "github-actions")
20-
for REQUIRED_LABEL in "${REQUIRED_LABELS[@]}"; do
21-
if echo "$LABELS_JSON" | grep -q "$REQUIRED_LABEL"; then
22-
echo "One of the required labels is present"
17+
# Fetch repository labels from the GitHub API
18+
REPO_LABELS=$(gh api repos/${{ github.repository }}/labels --jq '.[].name')
19+
20+
# Fetch labels applied to the current PR
21+
PR_NUMBER=${{ github.event.pull_request.number }}
22+
PR_LABELS=$(gh pr view $PR_NUMBER --json labels -q '.labels.[] | .name')
23+
24+
# Check if any PR label matches a repository label
25+
for PR_LABEL in $PR_LABELS; do
26+
if echo "$REPO_LABELS" | grep -qw "$PR_LABEL"; then
27+
echo "Label '$PR_LABEL' matches a repository label."
2328
exit 0
2429
fi
2530
done
26-
echo "None of the required labels are present"
31+
32+
echo "None of the PR labels match repository labels."
2733
exit 1
2834
env:
29-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)