Skip to content

Commit 3f21c3f

Browse files
committed
Add working (but messy) config to start qemu KVM inside docker. TODO: clean up
1 parent d73e848 commit 3f21c3f

File tree

7 files changed

+18
-5
lines changed

7 files changed

+18
-5
lines changed

.devcontainer.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// - https://code.visualstudio.com/docs/remote/devcontainerjson-reference
55
{
66
// Do not modify manually. This value is automatically updated by ./scripts/docker_build .
7-
"image": "sha256:ab889141f07b886f02ca3ec664341d7dfada94826c5538842b795b005bc1a417",
7+
"image": "sha256:81502d6208dfe50f2ca92ac79f1f68a4e8f7553e0773288d6a5bbb8bca0eb2fd",
88
"extensions": [
99
"bazelbuild.vscode-bazel",
1010
"bodil.prettier-toml",
@@ -23,5 +23,8 @@
2323
// See https://code.visualstudio.com/docs/remote/containers-advanced#_changing-the-default-source-code-mount.
2424
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=delegated",
2525
"workspaceFolder": "/workspace",
26+
"runArgs": [
27+
"--device=/dev/kvm"
28+
],
2629
"containerUser": "docker"
2730
}

Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ RUN mkdir --parents ${sccache_dir} \
334334

335335
# By default, sccache uses `~/.cache/sccache` locally: https://github.com/mozilla/sccache#local.
336336

337+
# Getting curl and certificates dependecies.
338+
# We're rate-limiting HTTP requests to 500 kB/s as otherwise we may get timeout errors
339+
# when downloading from snapshot.debian.org.
340+
341+
337342
ENV RUSTC_WRAPPER sccache
338343

339344
# Disable cargo incremental compilation, as it conflicts with sccache: https://github.com/mozilla/sccache#rust

experimental/uefi/app/.cargo/config.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ runner = "qemu-system-x86_64 -nodefaults -nographic -bios /usr/share/OVMF/OVMF_C
77

88
# Otherwise, (a) the first serial port gets routed to a log, and (b) the second serial gets attached to stdio.
99
[target.'cfg(not(test))']
10-
runner = "qemu-system-x86_64 -nodefaults -nographic -bios /usr/share/OVMF/OVMF_CODE.fd -serial file:target/console.log -serial stdio -machine q35 -device isa-debug-exit,iobase=0xf4,iosize=0x04 -kernel"
10+
runner = "qemu-system-x86_64 -enable-kvm -cpu Broadwell-IBRS,vme=on,f16c=on,rdrand=on -nodefaults -nographic -bios /usr/share/OVMF/OVMF_CODE.fd -serial file:target/console.log -serial stdio -machine q35 -device isa-debug-exit,iobase=0xf4,iosize=0x04 -kernel"
1111

1212
[unstable]
1313
build-std = ["core", "alloc"]

scripts/common

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ readonly DOCKER_IMAGE_NAME='gcr.io/oak-ci/oak:latest'
2020
# from a registry first.
2121

2222
# Do not modify manually. This value is automatically updated by ./scripts/docker_build .
23-
readonly DOCKER_IMAGE_ID='sha256:ab889141f07b886f02ca3ec664341d7dfada94826c5538842b795b005bc1a417'
23+
readonly DOCKER_IMAGE_ID='sha256:81502d6208dfe50f2ca92ac79f1f68a4e8f7553e0773288d6a5bbb8bca0eb2fd'
2424

2525
# Do not modify manually. This value is automatically updated by ./scripts/docker_push .
2626
readonly DOCKER_IMAGE_REPO_DIGEST='gcr.io/oak-ci/oak@sha256:8189809db8f834acb9c56c71f7a80e5ed00f8057ea3ac014b771443356534b1d'

scripts/docker_run

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ docker_run_flags=(
4848
# To do that, we map the socket from the host and add the right group
4949
'--volume=/var/run/docker.sock:/var/run/docker.sock'
5050
"--group-add=$HOST_DOCKER_GID"
51+
"--device=/dev/kvm"
5152
)
5253

5354
# Some CI systems (GitHub actions) do not run with an interactive TTY attached.

scripts/fix_docker_user_and_run

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ set -o pipefail
1313

1414
groupmod --gid="${HOST_GID}" docker
1515
usermod --uid="${HOST_UID}" --gid="${HOST_GID}" docker
16-
chown "${HOST_UID}":"${HOST_GID}" "/home/docker" "/home/docker/.cache"
16+
chown "${HOST_UID}":"${HOST_GID}" "/home/docker" "/home/docker/.cache" "/dev/kvm"
1717
su docker --session-command="$*"

third_party/ring/src/rand.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,11 @@ mod uefi {
452452
static mut OPENSSL_ia32cap_P: [u32; 4];
453453
}
454454
const FLAG: u32 = 1 << 30;
455-
unsafe { OPENSSL_ia32cap_P[1] & FLAG == FLAG }
455+
// Somehow this check continues to require patching, regardless
456+
// of qemu CPU config. :/. That is even though RDRAND is in fact
457+
// available and working.
458+
// unsafe { OPENSSL_ia32cap_P[1] & FLAG == FLAG }
459+
true
456460
}
457461

458462
// We must make sure current cpu support `rdrand`

0 commit comments

Comments
 (0)