From 75375ab97f9d971f516999f4c391c043fc5eb247 Mon Sep 17 00:00:00 2001 From: sudhakar Date: Fri, 31 May 2024 19:19:15 +0000 Subject: [PATCH] Pass arch to the qemu wrapper script. * 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. --- bazel/linux/qemu.bzl | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/bazel/linux/qemu.bzl b/bazel/linux/qemu.bzl index a927151f..1a7a0845 100644 --- a/bazel/linux/qemu.bzl +++ b/bazel/linux/qemu.bzl @@ -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 @@ -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 @@ -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[@]}}"