-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_final_efi.sh
executable file
·54 lines (46 loc) · 1.25 KB
/
test_final_efi.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
SSHPORT=2222
SSH_ICPCADMIN_KEY="files/secrets/icpcadmin@contestmanager"
PIDFILE="tmp/qemu.pid"
SNAPSHOT="-snapshot"
ALIVE=0
BASEIMG="*_image-amd64.img"
function launchssh() {
echo "Launching ssh session"
ssh -o BatchMode=yes -o IdentitiesOnly=yes -o ConnectTimeout=1 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null icpcadmin@localhost -i $SSH_ICPCADMIN_KEY -p$SSHPORT
}
function cleanup() {
echo "Forcing shutdown(poweroff)"
kill "$(cat $PIDFILE)"
rm -f $PIDFILE
}
set -x
qemu-system-x86_64 -machine q35 -smp 2 -m 4096 --enable-kvm \
-hda output/$BASEIMG \
-global driver=cfi.pflash01,property=secure,value=on \
-drive if=pflash,format=raw,unit=0,file=efi/OVMF_CODE.fd,readonly=on \
-drive if=pflash,format=raw,unit=1,file=efi/OVMF_VARS.fd \
-net user,hostfwd=tcp::$SSHPORT-:22 -net nic \
--daemonize --pidfile $PIDFILE \
$SNAPSHOT \
-vnc :0 -vga qxl -spice port=5901,disable-ticketing \
-usbdevice tablet
set +x
CMD=1
while [ $CMD != 0 ]; do
echo "Select an action"
echo " 1. Launch SSH Session"
echo " 0. Halt VM"
read -p "Action(Default 1): " CMD
CMD=${CMD:-1}
case $CMD in
0) break ;;
1) launchssh ;;
*) launchssh ;;
esac
done
echo
echo
read -p "Press enter to halt"
cleanup
exit 0