executable_qemu-freebsd.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env bash
  2. # Run qemu-system-x86_64 with KVM and bridge
  3. # Copyright © 2019, 2020 Oleg Pykhalov <go.wigust@gmail.com>
  4. # Released under the GNU GPLv3 or any later version.
  5. # Make sure /etc/qemu/bridge.conf contains ‘allow br0’.
  6. # -machine type=pc,accel=kvm
  7. # -drive file=ubuntu.iso,format=raw,aio=native,cache=none
  8. #
  9. #-M q35 \
  10. #
  11. # -net nic,model=virtio -net user,hostfwd=tcp::2222-:22 \
  12. # -virtfs local,path="/srv/share",security_model=none,mount_tag="TAG_share" \
  13. #
  14. # exec qemu-system-x86_64 \
  15. # -smp 2 \
  16. # -m 4096 \
  17. # -enable-kvm \
  18. # -M q35 \
  19. # -net nic -net bridge,br=br0 \
  20. # $@
  21. #
  22. # -usb \
  23. # -device usb-host,hostbus=1,hostaddr=11 \
  24. # https://superuser.com/questions/132322/how-to-increase-the-visualized-screen-resolution-on-qemu-kvm
  25. # You can toggle fullscreen with Ctrl + Alt + F, or by passing -full-screen.
  26. # https://wiki.archlinux.org/index.php/QEMU#Creating_bridge_manually
  27. printf -v macaddr "52:54:%02x:%02x:%02x:%02x" $(( RANDOM & 0xff)) $(( RANDOM & 0xff )) $(( RANDOM & 0xff)) $(( RANDOM & 0xff ))
  28. qemu-system-x86_64 \
  29. -smp cores=4,threads=1 \
  30. -m 4096 \
  31. -enable-kvm \
  32. -cpu host \
  33. -daemonize \
  34. -net nic,model=virtio,macaddr="$macaddr" -net bridge,br=br0 \
  35. -vga virtio \
  36. -full-screen \
  37. -vnc :3 \
  38. -hda "${hda:-/home/oleg/vm/freebsd-12.qcow2}" \
  39. "$@"