#!/bin/bash

set -x

# Create a pristine OVMF "VARS" file.
cp /usr/share/edk2/ovmf/OVMF_VARS.fd /export/uefi-ovmf-tests/foo-VARS.fd

OVMF_BINARY=/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd
UEFI_SHELL_ISO=/usr/share/edk2/ovmf/UefiShell.iso
OVMF_VARS_FILE=/export/uefi-ovmf-tests/foo-VARS.fd

qemu-system-x86_64              \
-machine q35,smm=on,accel=kvm   \
-display none                   \
-no-user-config                 \
-nodefaults                     \
-m 2048                         \
-smp 2,sockets=2,cores=1,threads=1 \
-chardev pty,id=charserial1     \
-device isa-serial,chardev=charserial1,id=serial1 \
-global driver=cfi.pflash01,property=secure,value=on \
-drive file=$OVMF_BINARY,if=pflash,format=raw,unit=0,readonly=on \
-drive file=$OVMF_VARS_FILE,if=pflash,format=raw,unit=1,readonly=off \
-drive file=$UEFI_SHELL_ISO,format=raw,if=none,media=cdrom,id=drive-virtio-disk1,readonly=on \
-device virtio-blk-pci,scsi=off,drive=drive-virtio-disk1,id=virtio-disk1,bootindex=1 \
-boot menu=on,splash-time=3000,strict=on \
-serial stdio
