#!/bin/bash # Persistent VM launch — starts swtpm first, waits for socket, then QEMU # VNC only, no SPICE (POC configuration) VMROOT=/home/aivanov/quickemu-win11-arm-lea SWTPM_SOCK="$VMROOT/windows-11-arm-lea.swtpm-sock" /usr/bin/swtpm socket \ --ctrl type=unixio,path="$SWTPM_SOCK" \ --terminate \ --tpmstate dir="$VMROOT" \ --tpm2 & # Wait for swtpm socket (up to 10s) for _i in $(seq 1 100); do if [ -S "$SWTPM_SOCK" ]; then break; fi sleep 0.1 done if [ ! -S "$SWTPM_SOCK" ]; then echo "ERROR: swtpm socket not ready after 10s" exit 1 fi exec /usr/bin/qemu-system-aarch64 \ -name windows-11-arm-lea \ -machine virt,highmem=on,pflash0=rom,pflash1=efivars,accel=kvm \ -global kvm-pit.lost_tick_policy=discard \ -cpu host \ -smp cores=8,threads=1,sockets=1 \ -m 8G \ -device virtio-balloon \ -pidfile "$VMROOT/windows-11-arm-lea.pid" \ -rtc base=utc,clock=host \ -device ramfb \ -vga none \ -device virtio-gpu-pci,id=video0,xres=1280,yres=800 \ -display none \ -vnc 127.0.0.1:2,password=on \ -device virtio-serial-pci \ -chardev socket,id=agent0,path="$VMROOT/windows-11-arm-lea-agent.sock",server=on,wait=off \ -device virtserialport,chardev=agent0,name=org.qemu.guest_agent.0 \ -device virtio-rng-pci,rng=rng0 \ -object rng-random,id=rng0,filename=/dev/urandom \ -device qemu-xhci,id=input \ -device usb-kbd,bus=input.0 \ -k fr \ -device usb-tablet,bus=input.0 \ -device virtio-net-pci,netdev=nic \ -netdev user,hostname=windows-11-arm-lea,hostfwd=tcp::22220-:22,id=nic \ -blockdev node-name=rom,driver=file,filename=/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd,read-only=true \ -blockdev node-name=efivars,driver=file,filename="$VMROOT/OVMF_VARS.fd" \ -device virtio-scsi-pci,id=scsi0 \ -device scsi-hd,drive=SystemDisk,bus=scsi0.0,bootindex=2 \ -drive id=SystemDisk,if=none,format=qcow2,file="$VMROOT/disk.qcow2",discard=unmap,detect-zeroes=unmap,cache=writeback,aio=threads \ -chardev socket,id=chrtpm,path="$SWTPM_SOCK" \ -tpmdev emulator,id=tpm0,chardev=chrtpm \ -device tpm-tis-device,tpmdev=tpm0 \ -monitor unix:"$VMROOT/windows-11-arm-lea-monitor.socket",server,nowait \ -serial unix:"$VMROOT/windows-11-arm-lea-serial.socket",server,nowait \ 2>"$VMROOT/qemu.log"