#!/bin/bash

#qemu-system-x86_64 -boot d -cdrom ./out/melawy-linux-2023.10.02-x86_64.iso -usb -vga virtio -display spice-app -full-screen -net nic -net user -m 8192 -smbios type=0,uefi=on -smp cpus=4 -enable-kvm -bios /usr/share/ovmf/x64/OVMF.fd

numberofcores=$(grep -c ^processor /proc/cpuinfo)
virt_cpu=$(( $numberofcores/2 ))

cp -av -- '/usr/share/edk2-ovmf/x64/OVMF_VARS.fd' "./out/"

qemu-system-x86_64 \
-boot order=d,menu=on,reboot-timeout=5000 \
-cdrom ./out/melawy-linux-2023.10.03-x86_64.iso \
-smbios type=0,uefi=on \
-smp cpus=$virt_cpu \
-m "size=3072,slots=0,maxmem=$((3072*1024*1024))" \
-usb \
-k en-us \
-name archiso,process=archiso_0 \
-display spice-app \
-vga virtio \
-audiodev pipewire,id=snd0 \
-device ich9-intel-hda \
-device hda-output,audiodev=snd0 \
-device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0,hostfwd=tcp::60022-:22 \
-machine type=q35,smm=on,accel=kvm,usb=on,pcspk-audiodev=snd0 \
-global ICH9-LPC.disable_s3=1 \
-enable-kvm \
-drive "if=pflash,format=raw,unit=0,file=/usr/share/edk2-ovmf/x64/OVMF_CODE.fd,read-only=on" \
-drive "if=pflash,format=raw,unit=1,file=./out/OVMF_VARS.fd" \
-global "driver=cfi.pflash01,property=secure,value=off" \
-serial stdio

# -m 8192 \
# -display sdl,gl=on,show-cursor=on,window-close=on \
# -full-screen \
# -audiodev pa,id=snd0 \
