start-freebsd-qemu.cmd 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. @echo off
  2. chcp 65001
  3. REM
  4. REM This script is used to run a Windows x64 VM on QEMU that is hosted by a Windows x64 host system
  5. REM The Host system is a PC with x64 CPU.
  6. REM
  7. set EXECUTABLE="C:\Program Files\qemu\qemu-system-x86_64.exe"
  8. set MACHINE=-m 2G -smp cores=2,threads=1 -name FreeBSD -no-reboot -parallel none -serial none -monitor stdio
  9. REM No acceleration
  10. REM generic cpu emulation.
  11. REM to find out which CPU types are supported by the QEMU version on your system, then run:
  12. REM qemu-system-x86_64.exe -cpu help
  13. REM the see if your host system CPU is listed
  14. REM
  15. set CPU=-machine q35,accel=tcg,hpet=off -cpu qemu64,kvm=off,-smap,-smep
  16. REM Enables x64 UEFI-BIOS that will be used by QEMU :
  17. set BIOS=-drive if=pflash,format=raw,unit=0,file="c:\Program Files\qemu\share\edk2-x86_64-code.fd",readonly=on -drive if=pflash,format=raw,unit=1,file="D:\temp\qemu\FreeBSD\edk2-i386-vars.fd"
  18. REM Use regular GFX simulation
  19. : set GFX=-device ramfb -device VGA
  20. set GFX=-vga qxl -display gtk
  21. set USB_CTRL=-device usb-ehci,id=usbctrl
  22. set KEYB_MOUSE=-device usb-kbd -device usb-tablet
  23. REM # The following line enable the full-speed HD controller (requires separate driver)
  24. REM # Following line uses the AHCI controller for the Virtual Hard Disk:
  25. rem set DRIVE0=-device ahci,id=ahci -device ide-hd,drive=disk,bus=ahci.0
  26. REM
  27. REM This will set the Windows VM x64 disk image that will be launched by QEMU
  28. REM The disk image is in the qcow2 format accepted by QEMU.
  29. REM You get the .qcow2 image, once you get the VHDX Windows VM x64 image
  30. REM and apply the script to inject the virtio x64 drivers and then run the
  31. REM the QEMU tool to convert the .VHDX image to .qcow2 format
  32. REM i.e.
  33. REM qemu-img convert -c -p -O qcow2 Windows_VM_VHDX_with_injected_drivers_file.vhdx file.qcow2
  34. REM file : points to the specified qcow2 image path.
  35. REM
  36. rem set DISK0=-drive id=disk,file="D:\temp\qemu\FreeBSD\FreeBSD-13.2-RELEASE-amd64.qcow2",if=none
  37. set DISK0=-hda "D:\temp\qemu\FreeBSD\FreeBSD-13.2-RELEASE-amd64-mini-memstick.img" -boot a
  38. rem set DISK1=-drive id=flash,if=floppy,format=raw,file="D:\temp\qemu\FreeBSD\FreeBSD-13.2-RELEASE-amd64-mini-memstick.img"
  39. REM
  40. REM for kdnet on, then best option:
  41. REM NETWORK0="-netdev user,id=net0,hostfwd=tcp::53389-:3389,hostfwd=tcp::50001-:50001 -device virtio-net,netdev=net0,disable-legacy=on"
  42. REM
  43. set NETHOST=-netdev user,id=net0,hostfwd=tcp::3589-:3389
  44. set NETGUEST=-device e1000,netdev=net0
  45. REM Audio
  46. set AUDIO=-audiodev sdl,id=snd0
  47. REM RTC
  48. set RTC=-rtc base=localtime,clock=host,driftfix=none
  49. REM Random Number Generator
  50. rem set RNG=-object rng-random,id=rng0,filename=/dev/urandom -device virtio-rng-pci,rng=rng0
  51. REM # The following line should enable the Daemon (instead of interactive)
  52. set DEAMON=-daemonize"
  53. %EXECUTABLE% %MACHINE% %CPU% %BIOS% %GFX% %USB_CTRL% %KEYB_MOUSE% %DRIVE0% %DISK1% %DISK0% %NETHOST% %NETGUEST% %AUDIO% %RTC%