From bc614fd233768137c118dfcfa74fb121fb48c7d1 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 20 Oct 2024 16:20:12 +0200 Subject: [PATCH] feat: Use q35 machine type for Windows XP (#823) --- Dockerfile | 2 +- src/define.sh | 34 ++++++++++++++++------------------ src/install.sh | 11 +++++++++++ src/samba.sh | 12 ++---------- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index 22a73af..61b4567 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM scratch AS build-amd64 -COPY --from=qemux/qemu-docker:6.05 / / +COPY --from=qemux/qemu-docker:6.06 / / ARG VERSION_ARG="0.0" ARG DEBCONF_NOWARNINGS="yes" diff --git a/src/define.sh b/src/define.sh index e496be5..271f38c 100644 --- a/src/define.sh +++ b/src/define.sh @@ -2106,39 +2106,37 @@ setMachine() { local dir="$3" local desc="$4" - case "${id,,}" in - "win9"* | "win2k"* ) - MACHINE="pc-i440fx-2.4" ;; - "winxp"* | "win2003"* | "winvistax86"* | "win7x86"* ) - MACHINE="pc-q35-2.10" ;; - esac - - case "${id,,}" in - "win9"* | "win2k"* | "winxp"* | "win2003"* ) - BOOT_MODE="windows_legacy" ;; - "winvista"* | "win7"* | "win2008"* ) - BOOT_MODE="windows_legacy" ;; - esac - case "${id,,}" in "win9"* ) - DISK_TYPE="auto" ETFS="[BOOT]/Boot-1.44M.img" ;; "win2k"* ) - DISK_TYPE="auto" ETFS="[BOOT]/Boot-NoEmul.img" ;; "winxp"* ) - DISK_TYPE="blk" if ! prepareXP "$iso" "$dir" "$desc"; then error "Failed to prepare $desc ISO!" && return 1 fi ;; "win2003"* ) - DISK_TYPE="blk" if ! prepare2k3 "$iso" "$dir" "$desc"; then error "Failed to prepare $desc ISO!" && return 1 fi ;; esac + case "${id,,}" in + "win9"* | "win2k"* ) + USB="None" + DISK_TYPE="auto" + MACHINE="pc-i440fx-2.4" + BOOT_MODE="windows_legacy" ;; + "winxp"* | "win2003"* ) + USB="None" + DISK_TYPE="blk" + BOOT_MODE="windows_legacy" + # Prevent bluescreen if 64 bit PCI hole size is >2G. + ARGS="-global q35-pcihost.x-pci-hole64-fix=false" ;; + "winvista"* | "win7"* | "win2008"* ) + BOOT_MODE="windows_legacy" ;; + esac + return 0 } diff --git a/src/install.sh b/src/install.sh index 3170833..b03f55a 100644 --- a/src/install.sh +++ b/src/install.sh @@ -120,6 +120,7 @@ finishInstall() { rm -f "$STORAGE/windows.old" rm -f "$STORAGE/windows.vga" + rm -f "$STORAGE/windows.args" rm -f "$STORAGE/windows.base" rm -f "$STORAGE/windows.boot" rm -f "$STORAGE/windows.mode" @@ -156,6 +157,11 @@ finishInstall() { fi fi + if [ -n "${ARGS:-}" ]; then + ARGUMENTS="$ARGS ${ARGUMENTS:-}" + echo "$ARGS" > "$STORAGE/windows.args" + fi + if [ -n "${DISK_TYPE:-}" ] && [[ "${DISK_TYPE:-}" != "scsi" ]]; then echo "$DISK_TYPE" > "$STORAGE/windows.type" fi @@ -965,6 +971,11 @@ bootWindows() { rm -rf "$TMP" + if [ -f "$STORAGE/windows.args" ]; then + ARGS=$(<"$STORAGE/windows.args") + ARGUMENTS="$ARGS ${ARGUMENTS:-}" + fi + if [ -s "$STORAGE/windows.type" ] && [ -f "$STORAGE/windows.type" ]; then [ -z "${DISK_TYPE:-}" ] && DISK_TYPE=$(<"$STORAGE/windows.type") fi diff --git a/src/samba.sh b/src/samba.sh index 498194f..3137d05 100644 --- a/src/samba.sh +++ b/src/samba.sh @@ -94,16 +94,8 @@ if ! smbd; then smbd -i --debug-stdout || true fi -legacy="" - -if [ -f "$STORAGE/windows.old" ]; then - MT=$(<"$STORAGE/windows.old") - [[ "${MT,,}" == "pc-q35-2"* ]] && legacy="y" - [[ "${MT,,}" == "pc-i440fx-2"* ]] && legacy="y" -fi - -if [ -n "$legacy" ]; then - # Enable NetBIOS on Windows XP and lower +if [[ "${BOOT_MODE:-}" == "windows_legacy" ]]; then + # Enable NetBIOS on Windows 7 and lower if ! nmbd; then error "NetBIOS daemon failed to start!" nmbd -i --debug-stdout || true