blob: b5ef78db17dc99693d67579707e86c7dc3efdf15 [file] [log] [blame]
#!/bin/bash
# Copyright 2017 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
### start fuchsia in qemu with a FVM disk
set -e
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/image_build_vars.sh || exit $?
source "${FUCHSIA_DIR}/buildtools/vars.sh"
qemu_dir="${BUILDTOOLS_QEMU_DIR}/bin"
# Construction of a qcow image prevents qemu from writing back to the
# build-produced image file, which could cause timestamp issues with that file.
qcowdir="$(mktemp -d)"
if [[ ! -d "${qcowdir}" ]]; then
echo >&2 "Failed to create temporary directory"
exit 1
fi
qimg="${qcowdir}/fuchsia.qcow2"
trap 'rm "${qimg}" && rmdir "${qcowdir}"' EXIT
"${qemu_dir}/qemu-img" create -f qcow2 -b "${FUCHSIA_BUILD_DIR}/${IMAGE_FVM_RAW}" \
"${qimg}"
"${FUCHSIA_DIR}/zircon/scripts/run-zircon" \
-a "${FUCHSIA_ARCH}" \
-q "${qemu_dir}" \
-G 3 \
-t "${FUCHSIA_BUILD_DIR}/${IMAGE_QEMU_KERNEL_RAW}" \
-z "${FUCHSIA_BUILD_DIR}/${IMAGE_ZIRCONA_ZBI}" \
-d \
-D "${qimg}" \
--diskfmt="qcow2" \
"$@"