You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.4 KiB
49 lines
1.4 KiB
#!/bin/sh
|
|
# Copyright 2022 Northern.tech AS
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
set -e
|
|
|
|
if [ -z "$DISK_IMG" ]; then
|
|
echo "ERROR: DISK_IMG is not set"
|
|
exit 1
|
|
fi
|
|
|
|
# Look for OVMF_CODE.fd in /usr/share
|
|
ovmf_file=$(find /usr/share -type f -and -name OVMF_CODE.fd 2>/dev/null | head -1)
|
|
if [ -z "${ovmf_file}" ]; then
|
|
echo "ERROR: could not find OVMF file"
|
|
exit 1
|
|
fi
|
|
|
|
qemu-system-x86_64 \
|
|
-enable-kvm \
|
|
-nographic \
|
|
-m 512 \
|
|
-net user,hostfwd=tcp::8822-:22 \
|
|
-net nic,macaddr=52:54:00$(od -txC -An -N3 /dev/urandom|tr \ :) \
|
|
-drive file=${ovmf_file},if=pflash,format=raw,unit=0,readonly=on \
|
|
-drive file="$(dirname "$0")/../../tests/uefi-nvram/OVMF_VARS.fd",if=pflash,format=raw,unit=1,readonly=on \
|
|
-drive format=raw,file=${DISK_IMG} &
|
|
|
|
qemu_pid=$!
|
|
|
|
trap qemu_cleanup HUP KILL TERM
|
|
|
|
qemu_cleanup() {
|
|
kill -s TERM $qemu_pid
|
|
}
|
|
|
|
echo "QEMU started with PID $qemu_pid"
|
|
wait $qemu_pid
|
|
|