Files
common/start_qemu.sh
Miguel Bernal Marin 9008cbccba start_qemu.sh: enable OVMF CODE and VARS usage
Currently, we use the traditional BIOS flag "-bios" to specify the OVMF
firmware device file. Ken proposes changing to pflash type BIOS and separate
BIOS code and variable.

-drive file=OVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on \
-drive file=OVMF_VARS.fd,if=pflash,format=raw,unit=1 \

Ken has following reasons:
  1. -bios can only support single flash binary, but the actual BIOS binary
      is consisted by many parts like SEC, PEI(Boot Block), DXE(Main Block)
      and Variable area as non-volatile storage for BIOS settings. During
      OMVF booting, a file called NvVars.bin will be created at
      <Disk>/<ESP Partition>/NvVars.bin for BIOS variable storage.
      This will pollute original Clearlinux-xxx.img.

  2. In future, we can add secure signed SEC BIOS part to enable full
      secure boot for Clear Linux via pflash.

  3. Some version of open stack, it requires separate Var Store NV instead
      of OVMF.fd. Ken meet with this issue recently. So if can show the separate
      pflash BIOS file via start_qemu.sh as example.

Suggested-by: "Lu, Ken" <ken.lu@intel.com>
2018-10-25 16:44:58 -05:00

67 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
#
# start_qemu.sh
#
# Copyright (c) 2016-2017 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
if [ -z "$1" ]; then
IMAGE=clear.img
else
IMAGE="$1"
shift
fi
if [[ "$IMAGE" =~ .xz$ ]]; then
>&2 echo "File \"$IMAGE\" is still xz compressed. Uncompress it first with \"unxz\""
exit 1
fi
if [ ! -f "$IMAGE" ]; then
>&2 echo "Can't find image file \"$IMAGE\""
exit 1
fi
rm -f debug.log
# 10/25/2018: keep back compatibility for a while
UEFI_BIOS="-bios OVMF.fd"
if [ -f OVMF_VARS.fd -a -f OVMF_CODE.fd ]; then
UEFI_BIOS=" -drive file=OVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on "
UEFI_BIOS+=" -drive file=OVMF_VARS.fd,if=pflash,format=raw,unit=1 "
fi
VMN=${VMN:=1}
qemu-system-x86_64 \
-enable-kvm \
${UEFI_BIOS} \
-smp sockets=1,cpus=4,cores=2 -cpu host \
-m 1024 \
-vga none -nographic \
-drive file="$IMAGE",if=virtio,aio=threads,format=raw \
-netdev user,id=mynet0,hostfwd=tcp::${VMN}0022-:22,hostfwd=tcp::${VMN}2375-:2375 \
-device virtio-net-pci,netdev=mynet0 \
-device virtio-rng-pci \
-debugcon file:debug.log -global isa-debugcon.iobase=0x402 $@