Skip to content

Commit

Permalink
scripts: Add test-in-svsm.sh helper script
Browse files Browse the repository at this point in the history
Instead of having the full QEMU command line in the Makefile, extract
the test-run into a separate script.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
  • Loading branch information
joergroedel committed Oct 23, 2023
1 parent 0d423f7 commit aba18a1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 22 deletions.
24 changes: 2 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,8 @@ all: stage1/kernel.elf svsm.bin
test:
cargo test --target=x86_64-unknown-linux-gnu

test-in-svsm: stage1/test-kernel.elf svsm.bin
ifndef QEMU
echo "Set QEMU environment variable to QEMU installation path" && exit 1
endif
ifndef OVMF
echo "Set OVMFenvironment variable to a folder containing OVMF_CODE.fd and OVMF_VARS.fd" && exit 1
endif
$(QEMU)/qemu-system-x86_64 \
-enable-kvm \
-cpu EPYC-v4 \
-machine q35,confidential-guest-support=sev0,memory-backend=ram1,kvm-type=protected \
-object memory-backend-memfd-private,id=ram1,size=1G,share=true \
-object sev-snp-guest,id=sev0,cbitpos=$(C_BIT_POS),reduced-phys-bits=1,svsm=on \
-smp 8 \
-no-reboot \
-drive if=pflash,format=raw,unit=0,file=$(OVMF)/OVMF_CODE.fd,readonly=on \
-drive if=pflash,format=raw,unit=1,file=$(OVMF)/OVMF_VARS.fd,snapshot=on \
-drive if=pflash,format=raw,unit=2,file=./svsm.bin,readonly=on \
-nographic \
-monitor none \
-serial stdio \
-device isa-debug-exit,iobase=0xf4,iosize=0x04 || true
test-in-svsm: utils/cbit stage1/test-kernel.elf svsm.bin
./scripts/test-in-svsm.sh

utils/gen_meta: utils/gen_meta.c
cc -O3 -Wall -o $@ $<
Expand Down
34 changes: 34 additions & 0 deletions scripts/test-in-svsm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
#

set -e

if [ "$QEMU" == "" ]; then
echo "Set QEMU environment variable to QEMU installation path" && exit 1
fi
if [ "$OVMF_PATH" == "" ]; then
echo "Set OVMF_PATH environment variable to a folder containing OVMF_CODE.fd and OVMF_VARS.fd" && exit 1
fi
if [ "$SUDO" != "" ]; then
SUDO_CMD="sudo"
else
SUDO_CMD=""
fi

C_BIT_POS=`utils/cbit`

$SUDO_CMD $QEMU \
-enable-kvm \
-cpu EPYC-v4 \
-machine q35,confidential-guest-support=sev0,memory-backend=ram1,kvm-type=protected \
-object memory-backend-memfd-private,id=ram1,size=1G,share=true \
-object sev-snp-guest,id=sev0,cbitpos=$C_BIT_POS,reduced-phys-bits=1,svsm=on \
-smp 8 \
-no-reboot \
-drive if=pflash,format=raw,unit=0,file=$OVMF_PATH/OVMF_CODE.fd,readonly=on \
-drive if=pflash,format=raw,unit=1,file=$OVMF_PATH/OVMF_VARS.fd,snapshot=on \
-drive if=pflash,format=raw,unit=2,file=./svsm.bin,readonly=on \
-nographic \
-monitor none \
-serial stdio \
-device isa-debug-exit,iobase=0xf4,iosize=0x04 || true

0 comments on commit aba18a1

Please sign in to comment.