blob: a208a3d2a48170c1adb3d8c97f0a5c80d9043b4c [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]}")" && pwd)"/lib/image_build_vars.sh
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" \
-o "${ZIRCON_BUILD_DIR}" \
-a "${FUCHSIA_ARCH}" \
-q "${qemu_dir}" \
-G 3 \
-x "${FUCHSIA_BUILD_DIR}/${IMAGE_BOOT_RAM}" \
-d \
-D "${qimg}" \
--diskfmt="qcow2" \
"$@"