Press a key automatically at the Windows ISO boot prompt

bootmgr waits for a key ("Press any key to boot from CD or DVD...") and
gives up after a few seconds. For ISO installs, a detached helper now taps
the space bar through the QEMU monitor for the first 30 s. Also update the
vm-images submodule for the new --window option.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
GuofangandClaude Sonnet 5.5 committed 2026-11-02 10:05:55 +08:00
1 parent 2a8d5a1bed
commit b149dd4bc3
2 files changed
+27 -1

No files matched your search

+26
View File
@@ -486,6 +486,32 @@ print("Account: guofang / password; " + "; ".join(
f"{forward.label}: 0.0.0.0:{forward.host_port}" for forward in forwards), f"{forward.label}: 0.0.0.0:{forward.host_port}" for forward in forwards),
flush=True) flush=True)
if installing_from_iso and not install_from_img:
# The Windows ISO boots through bootmgr, which waits for a key ("Press any
# key to boot from CD or DVD...") and gives up after a few seconds. Nobody
# is there to press it, so a detached helper taps the space bar through the
# QEMU monitor for the first 30 s. It exits by itself; later key presses
# are harmless because Setup is unattended.
key_script = (
"import socket, sys, time\n"
"path = sys.argv[1]\n"
"end = time.time() + 30\n"
"while time.time() < end:\n"
" try:\n"
" s = socket.socket(socket.AF_UNIX)\n"
" s.connect(path)\n"
" break\n"
" except OSError:\n"
" time.sleep(0.5)\n"
"else:\n"
" sys.exit(0)\n"
"while time.time() < end:\n"
" s.sendall(b'sendkey spc\\n')\n"
" time.sleep(1)\n")
subprocess.Popen([sys.executable, "-c", key_script, str(monitor_socket)],
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, start_new_session=True)
if daemonize: if daemonize:
log_file.write_text("") log_file.write_text("")
qemu_args += ["-serial", f"file:{log_file}", "-daemonize", "-pidfile", str(pid_file)] qemu_args += ["-serial", f"file:{log_file}", "-daemonize", "-pidfile", str(pid_file)]