From 3321e5c466f3d57c2c35085a3f57773d22902564 Mon Sep 17 00:00:00 2001 From: mantrakp04 Date: Thu, 19 Mar 2026 12:52:41 -0700 Subject: [PATCH] Update QEMU emulator scripts to improve KVM detection and service status reporting - Modified `build-image.sh` and `run-emulator.sh` to check for write permissions on `/dev/kvm` instead of existence, enhancing compatibility with various environments. - Added status tracking for services in `run-emulator.sh`, allowing for better error handling and reporting during emulator status checks. These changes enhance the reliability and usability of the QEMU emulator setup. --- docker/local-emulator/qemu/build-image.sh | 4 ++-- docker/local-emulator/qemu/run-emulator.sh | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docker/local-emulator/qemu/build-image.sh b/docker/local-emulator/qemu/build-image.sh index feca447fa..302403bf0 100755 --- a/docker/local-emulator/qemu/build-image.sh +++ b/docker/local-emulator/qemu/build-image.sh @@ -91,7 +91,7 @@ qemu_cmd_prefix_for_arch() { if [ "$HOST_ARCH" = "arm64" ]; then case "$HOST_OS" in darwin) accel="hvf" ;; - linux) [ -e /dev/kvm ] && accel="kvm" ;; + linux) [ -w /dev/kvm ] && accel="kvm" ;; esac fi local firmware @@ -104,7 +104,7 @@ qemu_cmd_prefix_for_arch() { if [ "$HOST_ARCH" = "amd64" ]; then case "$HOST_OS" in darwin) accel="hvf" ;; - linux) [ -e /dev/kvm ] && accel="kvm" ;; + linux) [ -w /dev/kvm ] && accel="kvm" ;; esac else cpu="qemu64" diff --git a/docker/local-emulator/qemu/run-emulator.sh b/docker/local-emulator/qemu/run-emulator.sh index 58902363c..24461976b 100755 --- a/docker/local-emulator/qemu/run-emulator.sh +++ b/docker/local-emulator/qemu/run-emulator.sh @@ -38,7 +38,7 @@ select_accelerator() { fi ;; linux) - if [ -e /dev/kvm ]; then + if [ -w /dev/kvm ]; then accel="kvm" fi ;; @@ -327,6 +327,8 @@ cmd_reset() { log "Emulator state reset. Next start will be a fresh boot." } +STATUS_FAILED=0 + print_service_status() { local name="$1" local port="$2" @@ -337,15 +339,18 @@ print_service_status() { echo -e " ${GREEN}●${NC} $name (:$port)" else echo -e " ${RED}●${NC} $name (:$port)" + STATUS_FAILED=1 fi } cmd_status() { + STATUS_FAILED=0 echo "VM:" if is_running; then echo -e " ${GREEN}●${NC} emulator" else echo -e " ${RED}●${NC} emulator" + STATUS_FAILED=1 fi echo "" echo "Services:" @@ -357,6 +362,7 @@ cmd_status() { print_service_status "MinIO" "${PORT_PREFIX}21" http /minio/health/live print_service_status "QStash" "${PORT_PREFIX}25" http / 401 print_service_status "ClickHouse" "${PORT_PREFIX}36" http /ping + exit "$STATUS_FAILED" } cmd_bench() {