From 1dc40655dffcc07ca34907b6d36063d8dbe7d279 Mon Sep 17 00:00:00 2001 From: Guofang Date: Mon, 2 Nov 2026 10:05:55 +0800 Subject: [PATCH] Add --window option to build-windows-base.sh Show the guest in a QEMU window instead of the VNC display. Co-Authored-By: Claude Sonnet 5.5 --- build-windows-base.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/build-windows-base.sh b/build-windows-base.sh index e3ad824..3722a15 100755 --- a/build-windows-base.sh +++ b/build-windows-base.sh @@ -19,7 +19,7 @@ # SSH_PRIVATE_KEY_FILE for this script). # # Usage: build-windows-base.sh [--force] [--no-sysprep] [--keep-work] [--compress] -# [--ssh-port PORT] [OUTPUT.qcow2] +# [--window] [--ssh-port PORT] [OUTPUT.qcow2] # OUTPUT defaults to the path that "download-images.sh --print-path windows11" # prints, which is where run-windows11.py looks for the base image. set -euo pipefail @@ -32,7 +32,7 @@ downloader="${images_dir}/download-images.sh" usage() { cat <&2; exit 2 ;; @@ -151,11 +155,21 @@ wait_for() { printf 'SSH %s 22\n' "$ssh_port" >"${work}/forwards.conf" step "Installing Windows 11 from the ISO (unattended; takes a while)" +display_option=(--vnc=127.0.0.1:90) +if ((window)); then + [[ -n "${DISPLAY:-}${WAYLAND_DISPLAY:-}" || "$(uname -s)" == Darwin ]] \ + || die "--window needs a desktop session (DISPLAY or WAYLAND_DISPLAY is not set)." + display_option=() +fi WIN11_VM_FORWARDS="${work}/forwards.conf" "$launcher" \ - --daemon --vnc=127.0.0.1:90 --install-from-iso --arch "$arch" --state-dir "$work" + --daemon "${display_option[@]}" --install-from-iso --arch "$arch" --state-dir "$work" step "Waiting for the guest to finish its first-logon setup (SSH answers)" -note "Screen: VNC 127.0.0.1:5990; console log: ${work}/console.log" +if ((window)); then + note "Screen: QEMU window; console log: ${work}/console.log" +else + note "Screen: VNC 127.0.0.1:5990; console log: ${work}/console.log" +fi if ! wait_for "${BASE_BUILD_TIMEOUT:-5400}" guest_ssh 'echo ready' >/dev/null 2>&1; then die "SSH did not answer in time; inspect the guest over VNC." fi