Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Added BSD support for qemu script #583

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions build_library/qemu_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ VM_MEMORY=
VM_CDROM=
VM_PFLASH_RO=
VM_PFLASH_RW=
VM_NCPUS="`grep -c ^processor /proc/cpuinfo`"
VM_NCPUS="`grep -c ^processor /proc/cpuinfo 2>/dev/null`"
BSD=
if [ -z "${VM_NCPUS}" ]; then
# BSD support
VM_NCPUS="`sysctl -n hw.ncpu`"
BSD=true
fi
SSH_PORT=2222
SSH_KEYS=""
CONFIG_FILE=""
Expand Down Expand Up @@ -44,6 +50,11 @@ check_conflict() {
fi
}

die() {
echo "$@"
exit 1
}

while [ $# -ge 1 ]; do
case "$1" in
-u|-user-data)
Expand Down Expand Up @@ -99,7 +110,7 @@ write_ssh_keys() {


if [ -z "${CONFIG_IMAGE}" ]; then
CONFIG_DRIVE=$(mktemp -t -d coreos-configdrive.XXXXXXXXXX)
CONFIG_DRIVE=$(mktemp -d -t coreos-configdrive.XXXXXXXXXX)
if [ $? -ne 0 ] || [ ! -d "$CONFIG_DRIVE" ]; then
echo "$0: mktemp -d failed!" >&2
exit 1
Expand Down Expand Up @@ -139,8 +150,13 @@ if [ "${SAFE_ARGS}" -eq 1 ]; then
else
case "${VM_BOARD}" in
amd64-usr)
# Emulate the host CPU closely in both features and cores.
set -- -machine accel=kvm -cpu host -smp "${VM_NCPUS}" "$@" ;;
if [ -z "${BSD}" ]; then
# Emulate the host CPU closely in both features and cores.
set -- -machine accel=kvm -cpu host -smp "${VM_NCPUS}" "$@"
else
set -- -smp "${VM_NCPUS}" "$@"
fi
;;
arm64-usr)
#FIXME(andrejro): tune the smp parameter
set -- -machine virt -cpu cortex-a57 -machine type=virt -smp 1 "$@" ;;
Expand All @@ -149,10 +165,16 @@ else
fi

# ${CONFIG_DRIVE} or ${CONFIG_IMAGE} will be mounted in CoreOS as /media/configdrive
if [ -n "${CONFIG_DRIVE}" ]; then
if [ -n "${CONFIG_DRIVE}" ] && [ -z "${BSD}" ]; then
set -- \
-fsdev local,id=conf,security_model=none,readonly,path="${CONFIG_DRIVE}" \
-device virtio-9p-pci,fsdev=conf,mount_tag=config-2 "$@"
elif [ -n "${CONFIG_DRIVE}" ] && [ -n "${BSD}" ]; then
if ! which mkisofs >/dev/null; then
die "Plesae install 'cdrtools'"
fi
mkisofs -input-charset utf-8 -R -V config-2 -o "${CONFIG_DRIVE}/configdrive.iso" "${CONFIG_DRIVE}"
set -- -drive if=virtio,file="${CONFIG_DRIVE}/configdrive.iso" "$@"
fi

if [ -n "${CONFIG_IMAGE}" ]; then
Expand Down