update
This commit is contained in:
@@ -48,7 +48,25 @@ else
|
||||
echo "KVM not available, using software emulation (slower)"
|
||||
fi
|
||||
|
||||
# Start QEMU with multiple displays (3 total) for multi-monitor testing
|
||||
# Cleanup function
|
||||
cleanup() {
|
||||
echo ""
|
||||
echo "Shutting down..."
|
||||
if [ -n "$VIEWER_PID" ] && kill -0 "$VIEWER_PID" 2>/dev/null; then
|
||||
kill "$VIEWER_PID" 2>/dev/null || true
|
||||
fi
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
PID=$(cat "$PID_FILE")
|
||||
if kill -0 "$PID" 2>/dev/null; then
|
||||
kill "$PID" 2>/dev/null || true
|
||||
fi
|
||||
rm -f "$PID_FILE"
|
||||
fi
|
||||
echo "Done"
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
# Start QEMU with virtio-gpu multi-head (3 outputs)
|
||||
> "$SERIAL_LOG" # Clear old log
|
||||
qemu-system-x86_64 \
|
||||
$KVM_OPTS \
|
||||
@@ -57,26 +75,81 @@ qemu-system-x86_64 \
|
||||
-bios /usr/share/qemu/OVMF.fd \
|
||||
-drive file="$ISO_PATH",media=cdrom \
|
||||
-drive file="$DISK_PATH",format=qcow2,if=virtio \
|
||||
-device virtio-gpu-pci,id=video0 \
|
||||
-device virtio-gpu-pci,id=video1 \
|
||||
-device virtio-gpu-pci,id=video2 \
|
||||
-device virtio-vga,max_outputs=3 \
|
||||
-display none \
|
||||
-spice port=5930,disable-ticketing=on \
|
||||
-device virtio-serial-pci \
|
||||
-chardev spicevmc,id=vdagent,name=vdagent \
|
||||
-device virtserialport,chardev=vdagent,name=com.redhat.spice.0 \
|
||||
-serial unix:"$SERIAL_SOCK",server,nowait \
|
||||
-monitor unix:"$MONITOR_SOCK",server,nowait \
|
||||
-nic user,model=virtio-net-pci,hostfwd=tcp::3006-:3006,hostfwd=tcp::2222-:22 \
|
||||
-pidfile "$PID_FILE" &
|
||||
|
||||
QEMU_PID=$!
|
||||
|
||||
echo ""
|
||||
sleep 1
|
||||
echo "=== EcoOS Test VM Started ==="
|
||||
echo "PID: $(cat $PID_FILE 2>/dev/null || echo 'running')"
|
||||
echo "SPICE: spicy -h localhost -p 5930"
|
||||
echo "Serial Log: $SERIAL_LOG"
|
||||
echo "QEMU PID: $QEMU_PID"
|
||||
echo "Management UI: http://localhost:3006"
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " pnpm run test:screenshot - Take screenshot"
|
||||
echo " pnpm run test:stop - Stop VM"
|
||||
echo " tail -f $SERIAL_LOG - Watch serial console"
|
||||
echo " socat - UNIX-CONNECT:$SERIAL_SOCK - Interactive serial"
|
||||
|
||||
# Wait for QEMU to start and SPICE to be ready
|
||||
echo "Waiting for SPICE server..."
|
||||
sleep 3
|
||||
|
||||
# Check if remote-viewer is available
|
||||
if ! command -v remote-viewer &> /dev/null; then
|
||||
echo "WARNING: remote-viewer not installed"
|
||||
echo "Install with: sudo apt install virt-viewer"
|
||||
echo ""
|
||||
echo "Running without display viewer. Press Ctrl-C to stop."
|
||||
wait $QEMU_PID
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Detect DISPLAY if not set
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
# Try to find an active X display
|
||||
if [ -S /tmp/.X11-unix/X0 ]; then
|
||||
export DISPLAY=:0
|
||||
elif [ -S /tmp/.X11-unix/X1 ]; then
|
||||
export DISPLAY=:1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Detect WAYLAND_DISPLAY if not set
|
||||
if [ -z "$WAYLAND_DISPLAY" ] && [ -z "$DISPLAY" ]; then
|
||||
# Try common Wayland sockets
|
||||
if [ -S "$XDG_RUNTIME_DIR/wayland-0" ]; then
|
||||
export WAYLAND_DISPLAY=wayland-0
|
||||
elif [ -S "/run/user/$(id -u)/wayland-0" ]; then
|
||||
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
|
||||
export WAYLAND_DISPLAY=wayland-0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Launch remote-viewer - use Xvfb if no display available
|
||||
if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then
|
||||
echo "No display found, using Xvfb for headless SPICE client..."
|
||||
# Use Xvfb with large virtual screen to support 3 monitors (5760x1080 = 3x1920x1080)
|
||||
xvfb-run -a -s "-screen 0 5760x1080x24" remote-viewer spice://localhost:5930 &
|
||||
VIEWER_PID=$!
|
||||
echo "remote-viewer running headlessly under Xvfb (PID: $VIEWER_PID)"
|
||||
else
|
||||
echo "Launching remote-viewer (DISPLAY=$DISPLAY, WAYLAND_DISPLAY=$WAYLAND_DISPLAY)..."
|
||||
remote-viewer spice://localhost:5930 &
|
||||
VIEWER_PID=$!
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "=== Press Ctrl-C to stop ==="
|
||||
echo ""
|
||||
echo "Tips:"
|
||||
echo " - View > Displays > Enable Display 2/3 for multi-monitor"
|
||||
echo " - pnpm run test:screenshot - Take screenshot"
|
||||
echo " - http://localhost:3006 - Management UI"
|
||||
echo ""
|
||||
|
||||
# Wait for either process to exit
|
||||
wait $QEMU_PID 2>/dev/null || true
|
||||
|
||||
Reference in New Issue
Block a user