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.
This commit is contained in:
mantrakp04 2026-03-19 12:52:41 -07:00
parent 5d98b44c34
commit 3321e5c466
2 changed files with 9 additions and 3 deletions

View File

@ -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"

View File

@ -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() {