FUCKKKK
This commit is contained in:
+19
-5
@@ -2,13 +2,14 @@
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
set "SCRIPT_DIR=%~dp0"
|
||||
set "IMG=%SCRIPT_DIR%deshab.img"
|
||||
set "IMG=%SCRIPT_DIR%deshab-dev.img"
|
||||
set "SATA_IMG=%SCRIPT_DIR%..\.build_tmp\sata_fat32_dsk.img"
|
||||
set "NVME_IMG=%SCRIPT_DIR%..\.build_tmp\nvme_test.img"
|
||||
|
||||
if not exist "%IMG%" (
|
||||
echo [qemu] Image not found: %IMG%
|
||||
echo [qemu] Run ..\build.bat first.
|
||||
echo [qemu] Run ..\build.bat first -- default builds both dev and release.
|
||||
echo [qemu] Or build dev only: build.bat -Variant dev
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
@@ -74,10 +75,14 @@ if "%LINUX_ENABLED%"=="1" (
|
||||
if "%QEMU_ACCEL%"=="whpx" (
|
||||
echo [qemu] WARNING: WHPX does not support nested VMX
|
||||
echo [qemu] Linux guest will NOT run under WHPX; VMX CPUID flag disabled
|
||||
echo [qemu] Use QEMU_ACCEL=tcg or run on real hardware for VMX support
|
||||
echo [qemu] For VSCode integration path ^(Linux guest + virtio-gpu + VSCode^):
|
||||
echo [qemu] Use WSL2 + KVM instead — run ISO\run_qemu_kvm.sh from WSL2 shell
|
||||
echo [qemu] Requires Windows 11 Pro/Enterprise ^(nested VMX^) or native Linux host
|
||||
echo [qemu] Or set QEMU_ACCEL=tcg for full software emulation ^(also no VMX^)
|
||||
) else if "%QEMU_ACCEL%"=="tcg" (
|
||||
echo [qemu] WARNING: TCG does not support VMX
|
||||
echo [qemu] Linux guest will NOT run under TCG
|
||||
echo [qemu] For VSCode integration path, use WSL2 + KVM ^(run ISO\run_qemu_kvm.sh^)
|
||||
) else (
|
||||
echo [qemu] VMX may be available for Linux guest
|
||||
)
|
||||
@@ -99,12 +104,21 @@ if exist "%USB_IMG%" (
|
||||
set "USB_OPTS=-device qemu-xhci,id=xhci0 -drive id=usb0,if=none,file=%USB_IMG%,format=raw -device usb-storage,bus=xhci0.0,drive=usb0"
|
||||
)
|
||||
|
||||
REM ===== Boot disk attach =====
|
||||
REM Main disk must use explicit virtio-blk-pci + bootindex=1: with plain
|
||||
REM "-drive if=virtio", OVMF only auto-creates a boot entry when virtio-blk
|
||||
REM lands on PCI slot 0x3 (no other PCI devices). Adding NVMe/USB/e1000 moves
|
||||
REM it to 0x4/0x5 and OVMF boot enumeration silently drops the ESP, falling
|
||||
REM back to EFI Internal Shell even though BOOTX64.EFI is present and valid.
|
||||
REM bootindex=1 injects the fw_cfg bootorder entry so OVMF always picks it.
|
||||
set "OSDISK_OPTS=-drive if=none,id=osdisk,format=raw,file="%IMG%" -device virtio-blk-pci,drive=osdisk,bootindex=1"
|
||||
|
||||
if exist "%SATA_IMG%" (
|
||||
echo [qemu] SATA: %SATA_IMG%
|
||||
"%QEMU%" -accel %QEMU_ACCEL% -machine q35 -m 2G -cpu %QEMU_CPU% -serial stdio -drive if=pflash,format=raw,readonly=on,file="%OVMF%" -drive format=raw,file="%IMG%",if=virtio -drive id=sata0,format=raw,file="%SATA_IMG%",if=none -device ide-hd,drive=sata0,bus=ide.0 %NVME_OPTS% %USB_OPTS% -netdev user,id=net0 -device e1000,netdev=net0,mac=52:54:00:12:34:56 -boot menu=on
|
||||
"%QEMU%" -accel %QEMU_ACCEL% -machine q35 -m 2G -cpu %QEMU_CPU% -serial stdio -drive if=pflash,format=raw,readonly=on,file="%OVMF%" %OSDISK_OPTS% -drive id=sata0,format=raw,file="%SATA_IMG%",if=none -device ide-hd,drive=sata0,bus=ide.0 %NVME_OPTS% %USB_OPTS% -netdev user,id=net0 -device e1000,netdev=net0,mac=52:54:00:12:34:56 -boot menu=on
|
||||
) else (
|
||||
echo [qemu] SATA image not found, booting without block device
|
||||
"%QEMU%" -accel %QEMU_ACCEL% -machine q35 -m 2G -cpu %QEMU_CPU% -serial stdio -drive if=pflash,format=raw,readonly=on,file="%OVMF%" -drive format=raw,file="%IMG%",if=virtio %NVME_OPTS% %USB_OPTS% -netdev user,id=net0 -device e1000,netdev=net0 -boot menu=on
|
||||
"%QEMU%" -accel %QEMU_ACCEL% -machine q35 -m 2G -cpu %QEMU_CPU% -serial stdio -drive if=pflash,format=raw,readonly=on,file="%OVMF%" %OSDISK_OPTS% %NVME_OPTS% %USB_OPTS% -netdev user,id=net0 -device e1000,netdev=net0 -boot menu=on
|
||||
)
|
||||
|
||||
endlocal
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
#!/usr/bin/env bash
|
||||
# Deshab QEMU launcher for WSL2/Linux hosts with KVM acceleration.
|
||||
#
|
||||
# VSCode integration requires nested VMX (Linux 6.6 guest runs inside UTSM's
|
||||
# VMX root). WHPX (Windows) and TCG both lack nested VMX, so the Linux guest
|
||||
# cannot start under them. Use this script from a WSL2 shell or a native Linux
|
||||
# host that exposes /dev/kvm with VMX-enabled nested virtualization.
|
||||
#
|
||||
# Prereqs:
|
||||
# - WSL2 (Windows 11 Pro/Enterprise for nested VMX; Home edition lacks it)
|
||||
# + `wsl --install` + ensure kernel supports nested virt
|
||||
# + /dev/kvm exists and is readable/writable
|
||||
# - Or native Linux host with KVM
|
||||
# - qemu-system-x86_64 in PATH
|
||||
# - OVMF firmware at one of the paths probed below
|
||||
#
|
||||
# Usage:
|
||||
# ./run_qemu_kvm.sh # default: -m 4G -smp 2, accel kvm
|
||||
# QEMU_MEM=6G ./run_qemu_kvm.sh # override memory
|
||||
# QEMU_SMP=4 ./run_qemu_kvm.sh # override vcpu count
|
||||
# QEMU_ACCEL=tcg ./run_qemu_kvm.sh # force TCG fallback (no nested VMX)
|
||||
#
|
||||
# See ISO/run_qemu.bat for Windows host fallback (WHPX/TCG, no Linux guest).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
IMG="$SCRIPT_DIR/deshab-dev.img"
|
||||
SATA_IMG="$SCRIPT_DIR/../.build_tmp/sata_fat32_dsk.img"
|
||||
NVME_IMG="$SCRIPT_DIR/../.build_tmp/nvme_test.img"
|
||||
USB_IMG="$SCRIPT_DIR/../.build_tmp/usb_test.img"
|
||||
|
||||
if [[ ! -f "$IMG" ]]; then
|
||||
echo "[qemu] Image not found: $IMG"
|
||||
echo "[qemu] Run build.bat first (default builds both dev and release),"
|
||||
echo "[qemu] or build dev only: build.bat -Variant dev"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Locate qemu-system-x86_64
|
||||
QEMU="${QEMU_BIN:-}"
|
||||
if [[ -z "$QEMU" ]]; then
|
||||
if command -v qemu-system-x86_64 >/dev/null 2>&1; then
|
||||
QEMU="$(command -v qemu-system-x86_64)"
|
||||
fi
|
||||
fi
|
||||
if [[ -z "$QEMU" ]]; then
|
||||
echo "[qemu] qemu-system-x86_64 was not found."
|
||||
echo "[qemu] Install QEMU: apt install qemu-system-x86 (Debian/Ubuntu)"
|
||||
echo "[qemu] or pacman -S qemu-system-x86 (Arch/WSL2)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Locate OVMF firmware
|
||||
OVMF=""
|
||||
for p in \
|
||||
/usr/share/OVMF/OVMF_CODE.fd \
|
||||
/usr/share/edk2/ovmf/OVMF_CODE.fd \
|
||||
/usr/share/ovmf/OVMF.fd \
|
||||
/usr/share/qemu/OVMF.fd \
|
||||
/usr/share/qemu-efi/QEMU_UEFI_CODE.fd ; do
|
||||
if [[ -f "$p" ]]; then OVMF="$p"; break; fi
|
||||
done
|
||||
if [[ -z "$OVMF" ]]; then
|
||||
echo "[qemu] OVMF firmware was not found."
|
||||
echo "[qemu] Install ovmf: apt install ovmf (Debian/Ubuntu) or pacman -S edk2-ovmf (Arch)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Accelerator selection: KVM preferred for nested VMX (Linux guest).
|
||||
# Override with QEMU_ACCEL=tcg to fall back to TCG (no nested VMX, Linux guest
|
||||
# will skip VMX init gracefully).
|
||||
ACCEL="${QEMU_ACCEL:-kvm}"
|
||||
CPU="host"
|
||||
if [[ "$ACCEL" == "kvm" ]]; then
|
||||
if [[ ! -e /dev/kvm ]]; then
|
||||
echo "[qemu] WARNING: /dev/kvm not found, KVM acceleration unavailable."
|
||||
echo "[qemu] - On WSL2: ensure Windows 11 Pro/Enterprise (nested VMX needs it),"
|
||||
echo "[qemu] and run 'wsl --update' + enable 'nestedVirtualization' in .wslconfig."
|
||||
echo "[qemu] - On Linux: ensure kvm module is loaded and /dev/kvm permissions OK."
|
||||
echo "[qemu] Falling back to TCG (Linux guest will NOT run without nested VMX)."
|
||||
ACCEL="tcg"
|
||||
fi
|
||||
fi
|
||||
if [[ "$ACCEL" == "tcg" ]]; then
|
||||
CPU="qemu64,-vmx" # disable VMX CPUID under TCG (no nested virt support)
|
||||
fi
|
||||
|
||||
# Memory and CPU topology: VSCode + Electron + GUI stack needs >= 4GB.
|
||||
MEM="${QEMU_MEM:-4G}"
|
||||
SMP="${QEMU_SMP:-2}"
|
||||
|
||||
# Detect whether Linux compat layer is enabled (bzImage module present in IMG).
|
||||
LINUX_ENABLED=0
|
||||
if grep -q 'module_path: boot():/boot/linux-bzImage' \
|
||||
"$SCRIPT_DIR/../SYSTEM/limine/limine.conf" 2>/dev/null ; then
|
||||
# Check the line is uncommented (not prefixed with '#')
|
||||
if grep -E '^\s*module_path: boot\(\):/boot/linux-bzImage' \
|
||||
"$SCRIPT_DIR/../SYSTEM/limine/limine.conf" >/dev/null 2>&1 ; then
|
||||
LINUX_ENABLED=1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "[qemu] Using: $QEMU"
|
||||
echo "[qemu] UEFI: $OVMF"
|
||||
echo "[qemu] Image: $IMG"
|
||||
echo "[qemu] Accel: $ACCEL"
|
||||
echo "[qemu] CPU: $CPU"
|
||||
echo "[qemu] Mem: $MEM"
|
||||
echo "[qemu] SMP: $SMP"
|
||||
if [[ "$LINUX_ENABLED" == "1" ]]; then
|
||||
echo "[qemu] Linux compat: ENABLED (modules present)"
|
||||
if [[ "$ACCEL" == "kvm" ]]; then
|
||||
echo "[qemu] KVM nested VMX: ready for Linux guest (VSCode integration path)"
|
||||
else
|
||||
echo "[qemu] WARNING: $ACCEL does not support nested VMX."
|
||||
echo "[qemu] Linux guest will NOT run; UTSM will skip VMX init."
|
||||
fi
|
||||
else
|
||||
echo "[qemu] Linux compat: disabled (build via CODE/linux/build.sh to enable)"
|
||||
fi
|
||||
|
||||
# Optional NVMe test disk
|
||||
NVME_OPTS=""
|
||||
if [[ -f "$NVME_IMG" ]]; then
|
||||
echo "[qemu] NVMe: $NVME_IMG"
|
||||
NVME_OPTS="-drive if=none,id=nvme0,file=$NVME_IMG,format=raw -device nvme,drive=nvme0,serial=deadbeef"
|
||||
fi
|
||||
|
||||
# Optional USB xHCI test disk
|
||||
USB_OPTS=""
|
||||
if [[ -f "$USB_IMG" ]]; then
|
||||
echo "[qemu] USB: $USB_IMG"
|
||||
USB_OPTS="-device qemu-xhci,id=xhci0 -drive id=usb0,if=none,file=$USB_IMG,format=raw -device usb-storage,bus=xhci0.0,drive=usb0"
|
||||
fi
|
||||
|
||||
# Optional SATA FAT32 disk (AHCI test)
|
||||
if [[ -f "$SATA_IMG" ]]; then
|
||||
echo "[qemu] SATA: $SATA_IMG"
|
||||
SATA_OPTS="-drive id=sata0,format=raw,file=$SATA_IMG,if=none -device ide-hd,drive=sata0,bus=ide.0"
|
||||
else
|
||||
echo "[qemu] SATA image not found, booting without block device"
|
||||
SATA_OPTS=""
|
||||
fi
|
||||
|
||||
exec "$QEMU" \
|
||||
-accel "$ACCEL" \
|
||||
-machine q35 \
|
||||
-m "$MEM" \
|
||||
-smp "$SMP" \
|
||||
-cpu "$CPU" \
|
||||
-serial stdio \
|
||||
-drive if=pflash,format=raw,readonly=on,file="$OVMF" \
|
||||
-drive format=raw,file="$IMG",if=virtio \
|
||||
$SATA_OPTS \
|
||||
$NVME_OPTS \
|
||||
$USB_OPTS \
|
||||
-netdev user,id=net0 \
|
||||
-device e1000,netdev=net0,mac=52:54:00:12:34:56 \
|
||||
-boot menu=on
|
||||
Reference in New Issue
Block a user