Skip to content

Commit

Permalink
Pass arch to the qemu wrapper script.
Browse files Browse the repository at this point in the history
   * Since we are using the same same qemu wrapper script (module_wrapper script)
     pass the architecture to it.  The wrapper in main repo will invoke
     the right qemu binary based on the architecture.

   * Kernel args have spaces in betwen. To keep it simple pass kernel args
     separately to the wrapper script and before invoking the qemu binary
     pass each of the needed args.
  • Loading branch information
sudhakar-mamillapalli committed Jun 4, 2024
1 parent 8da20b5 commit 75375ab
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions bazel/linux/qemu.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ test -n "$QEMU_BINARY" || {{
}}
if [[ "$ARCH" == "x86" ]]; then
if [ -n "$ROOTFS" ]; then
QEMU_FLAGS+=("-drive" "file=$ROOTFS,if=virtio,cache=none")
else
Expand All @@ -63,8 +62,6 @@ if [[ "$ARCH" == "x86" ]]; then
test -z "$KERNEL" || QEMU_FLAGS+=("-kernel" "$KERNEL")
test -z "$SINGLE" || KERNEL_FLAGS+=("init=/bin/sh")
QEMU_FLAGS+=("-append" "${{KERNEL_FLAGS[*]}} ${{KERNEL_OPTS[*]}}")
fi
if [[ "$ARCH" == "aarch64" ]] ; then
Expand All @@ -79,22 +76,21 @@ if [[ "$ARCH" == "aarch64" ]] ; then
echo "QEMU_FLAGS: $QEMU_FLAGS"
fi
WRAPPER_OPTS+="arch=$ARCH"
QEMU_FLAGS+=("${{EMULATOR_OPTS[@]}}")
if [ ${{#WRAPPER_OPTS[@]}} -ne 0 ]; then
WRAPPER_OPTS=('--' "${{WRAPPER_OPTS[@]}}")
fi
# Pass qemu/kernel/wrapper opts as three separate args to Qemu binary.
echo 1>&2 '$' "$QEMU_BINARY" "${{QEMU_FLAGS[@]}}" "${{WRAPPER_OPTS[@]}}"
if [ -z "$INTERACTIVE" -a -z "$SINGLE" ]; then
"$QEMU_BINARY" "${{QEMU_FLAGS[@]}}" "${{WRAPPER_OPTS[@]}}" </dev/null | tee "$OUTPUT_FILE"
"$QEMU_BINARY" "${{QEMU_FLAGS[*]}}" "${{KERNEL_FLAGS[*]}}" "${{WRAPPER_OPTS[*]}}" </dev/null | tee "$OUTPUT_FILE"
else
if [[ "$ARCH" == "aarch64" ]]; then
CMD="$QEMU_BINARY ${{QEMU_FLAGS[@]}} ${{WRAPPER_OPTS[@]}}"
$CMD
else
"$QEMU_BINARY" "${{QEMU_FLAGS[@]}}" "${{WRAPPER_OPTS[@]}}"
fi
"$QEMU_BINARY" "${{QEMU_FLAGS[*]}}" "${{KERNEL_FLAGS[*]}}" "${{WRAPPER_OPTS[*]}}"
fi
"""
qemu_search = ctx.attr.qemu_search
Expand All @@ -106,6 +102,7 @@ fi
qemu_flags = ctx.attr.qemu_defaults + ctx.attr.qemu_flags

if "aarch64" in ctx.attr.archs:
# no cmdline kernel flags for aarch64 qemu. All embeded in the fit image for now
arch = "aarch64"
kernel_flags = []
else:
Expand Down

0 comments on commit 75375ab

Please sign in to comment.