Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion build/ci/qemu-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,23 @@ trap 'kill "$swtpm_pid" 2>/dev/null; rm -rf "$tpmstate"' EXIT
statedisk="$tpmstate/state.img"
truncate -s 2G "$statedisk"

# A UKI is a PE/EFI executable, not a bzImage — QEMU's -kernel uses the Linux
# boot protocol, so OVMF rejects a UKI passed that way ("Bad kernel image: Load
# error"). Present it the way firmware expects: on an EFI System Partition at the
# removable-media fallback path EFI/BOOT/BOOTX64.EFI, which OVMF auto-launches.
# QEMU's VVFAT (fat:rw:<dir>) serves the directory as a FAT ESP.
esp="$tpmstate/esp"
mkdir -p "$esp/EFI/BOOT"
cp "$uki" "$esp/EFI/BOOT/BOOTX64.EFI"

qemu-system-x86_64 \
-machine q35,accel=kvm:tcg -m 2048 -nographic \
-drive if=pflash,format=raw,unit=0,readonly=on,file="$OVMF_CODE" \
-drive if=pflash,format=raw,unit=1,file="$OVMF_VARS" \
-chardev socket,id=chrtpm,path="$tpmstate/swtpm-sock" \
-tpmdev emulator,id=tpm0,chardev=chrtpm \
-device tpm-tis,tpmdev=tpm0 \
-drive format=raw,file="fat:rw:$esp" \
-drive format=raw,file="$statedisk" \
-kernel "$uki" \
-netdev user,id=n0,hostfwd=tcp:127.0.0.1:4443-:443 \
-device virtio-net-pci,netdev=n0
13 changes: 12 additions & 1 deletion test/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,26 @@ func startQEMU(t *testing.T, e env, uki, swtpmSock, dir string) {
vars := filepath.Join(dir, "OVMF_VARS.fd")
copyFile(t, e.ovmfVars, vars)

// A UKI is a PE/EFI executable, not a bzImage: -kernel uses the Linux boot
// protocol, which OVMF rejects for a UKI ("Bad kernel image: Load error").
// Present it on an EFI System Partition at the removable-media fallback path
// so OVMF auto-launches it; QEMU's VVFAT (fat:rw:<dir>) serves the directory
// as a FAT ESP.
esp := filepath.Join(dir, "esp")
if err := os.MkdirAll(filepath.Join(esp, "EFI", "BOOT"), 0o755); err != nil {
t.Fatalf("create esp: %v", err)
}
copyFile(t, uki, filepath.Join(esp, "EFI", "BOOT", "BOOTX64.EFI"))

cmd := exec.Command(e.qemu,
"-machine", "q35,accel=kvm:tcg", "-m", "2048", "-nographic",
"-drive", "if=pflash,format=raw,unit=0,readonly=on,file="+e.ovmfCode,
"-drive", "if=pflash,format=raw,unit=1,file="+vars,
"-chardev", "socket,id=chrtpm,path="+swtpmSock,
"-tpmdev", "emulator,id=tpm0,chardev=chrtpm",
"-device", "tpm-tis,tpmdev=tpm0",
"-drive", "format=raw,file=fat:rw:"+esp,
"-drive", "format=raw,file="+statedisk,
"-kernel", uki,
"-netdev", "user,id=n0,hostfwd=tcp:127.0.0.1:4443-:443",
"-device", "virtio-net-pci,netdev=n0",
)
Expand Down