Advertisement
zefie

QEmu Windows Helper (qemu-vm.bat)

Oct 26th, 2019
632
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 3.02 KB | None | 0 0
  1. @echo off
  2. Setlocal EnableDelayedExpansion
  3. SET GTK_CSD=0
  4. SET qemu_path=%~dp0
  5.  
  6. IF "%qemu_exec%"=="" ( SET "qemu_exec=!qemu_path!qemu-system-x86_64.exe" )
  7. IF "%qemu_cpu%"=="" ( SET "qemu_cpu=kvm64" )
  8. IF "%qemu_ram%"=="" ( SET "qemu_ram=256" )
  9. IF "%qemu_accel%"=="" ( SET "qemu_accel=whpx" )
  10. IF "%qemu_cores%"=="" ( SET "qemu_cores=1" )
  11.  
  12. SET "qemu_opts=-accel !qemu_accel! -cpu !qemu_cpu! -m !qemu_ram! -smp %qemu_cores%"
  13. SET "qemu_opts=!qemu_opts! -device pci-bridge,id=pci.2,chassis_nr=2,bus=pci.0,addr=0x1f"
  14. SET "qemu_opts=!qemu_opts! -device pci-bridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e"
  15. SET "qemu_opts=!qemu_opts! -device piix3-usb-uhci,id=uhci,bus=pci.0,addr=0x1.0x2"
  16. SET "qemu_opts=!qemu_opts! -device usb-tablet,id=tablet,bus=uhci.0,port=1"
  17. SET "qemu_opts=!qemu_opts! -device VGA,id=vga,bus=pci.0,addr=0x2"
  18. SET "qemu_opts=!qemu_opts! -device virtio-scsi-pci,id=scsi0"
  19.    
  20. IF NOT "%qemu_serialport%"=="" (
  21.     SET "qemu_opts=!qemu_opts! -serial %qemu_serialport%"
  22. )
  23.    
  24. IF NOT "%qemu_isofile%"=="" (
  25.     IF "%qemu_bootindexcd%"=="" ( SET "qemu_bootindexcd=100" )
  26.     SET "qemu_opts=!qemu_opts! -drive file=%qemu_isofile%,if=none,id=idecd0,media=cdrom,aio=threads"
  27.     SET "qemu_opts=!qemu_opts! -device ide-cd,bus=ide.1,unit=0,drive=idecd0,id=idecd0.0,bootindex=!qemu_bootindexcd!"
  28. )
  29.    
  30. IF NOT "%qemu_disk1%"=="" (
  31.     IF "%qemu_bootindexdisk1%"=="" ( SET "qemu_bootindexdisk1=200" )
  32.     IF "%qemu_disk1options%"=="" ( SET "qemu_disk1options=cache=writeback,aio=native" )
  33.     IF "%qemu_disk1format%"=="" (
  34.         FOR %%i IN ("%qemu_disk1%") DO (
  35.             SET "qemu_disk1format=%%~xi"
  36.             SET "qemu_disk1format=!qemu_disk1format:.=!"
  37.         )
  38.     )
  39.     SET "qemu_opts=!qemu_opts! -drive file="%qemu_disk1%",if=none,format=!qemu_disk1format!,id=scsidisk0,!qemu_disk1options!"
  40.     SET "qemu_opts=!qemu_opts! -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=scsidisk0,id=scsidisk0.0,bootindex=!qemu_bootindexdisk1!"
  41. )
  42.  
  43. IF NOT "%qemu_disk2%"=="" (
  44.     IF "%qemu_bootindexdisk2%"=="" ( SET "qemu_bootindexdisk2=300" )
  45.     IF "%qemu_disk2options%"=="" ( SET "qemu_disk2options=cache=writeback,aio=native" )
  46.     IF "%qemu_disk2format%"=="" (
  47.         FOR %%i IN ("%qemu_disk2%") DO (
  48.             SET "qemu_disk2format=%%~xi"
  49.             SET "qemu_disk2format=!qemu_disk2format:.=!"
  50.         )
  51.     )
  52.     SET "qemu_opts=!qemu_opts! -drive file="%qemu_disk2%",if=none,format=!qemu_disk2format!,id=scsidisk1,!qemu_disk2options!"
  53.     SET "qemu_opts=!qemu_opts! -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=1,drive=scsidisk1,id=scsidisk1.0,bootindex=!qemu_bootindexdisk2!"
  54. )
  55.  
  56. IF NOT "%qemu_ifname%"=="" (
  57.     IF "%qemu_bootindexlan%"=="" ( SET "qemu_bootindexlan=400" )
  58.     IF "%qemu_macaddr%"=="" ( call "!qemu_path!qemu-gen-mac.bat" )
  59.     SET "qemu_opts=!qemu_opts! -netdev tap,id=wininet0,ifname=%qemu_ifname%"
  60.     SET "qemu_opts=!qemu_opts! -device virtio-net-pci,mac=%qemu_macaddr%,netdev=wininet0,id=wininet0.0,bus=pci.0,addr=0x12,id=net0,bootindex=!qemu_bootindexlan!"
  61. )
  62.  
  63. IF NOT "%qemu_vmname%"=="" (
  64.     TITLE QEmu Virtual Machine: %qemu_vmname%
  65. )
  66.  
  67. !qemu_exec! !qemu_opts! %*
  68. call S:\bin\qemu\qemu-resetvar.bat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement