random scripts I use
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
1.6KB

  1. #!/usr/bin/env fish
  2. function vm-qemu -d "Frontend to QEMU"
  3. # Args
  4. argparse \
  5. --name "vm-qemu" \
  6. --min-args 1 \
  7. 'V/version=' \
  8. 'i/install' \
  9. -- \
  10. $argv
  11. or exit 1
  12. set cfg $argv[1]
  13. set -e argv[1]
  14. # Config
  15. source $_agw_dir_rc/virtual-machines/QEMU/$cfg
  16. # Devices
  17. test "$_vga"
  18. and set vga $_vga
  19. or set vga vmware
  20. test "$_soundhw"
  21. and set soundhw $_soundhw
  22. or set soundhw hda
  23. for dev in $_devs
  24. set -a _args --device $dev
  25. end
  26. switch $soundhw
  27. case "hda"
  28. set -a _args --device intel-hda --device hda-duplex
  29. case "ac97"
  30. set -a _args --device AC97
  31. end
  32. # Machine
  33. test "$_cpu"
  34. and set cpu $_cpu
  35. or set cpu host
  36. if test "$_arch" = "i386" || test "$_arch" = "x86_64"
  37. set -p _args \
  38. --machine accel=kvm \
  39. --usb
  40. end
  41. # Versioning
  42. test "$_flag_version"
  43. and set ver $_flag_version
  44. or set ver $_ver
  45. # Disk Media
  46. set image "/media/store/vm/$cfg/image$ver"
  47. set boot_order c
  48. # Install Media
  49. set media "/media/store/osmedia"
  50. set install (string replace "_ver_" "$ver" "$_install")
  51. set boot (string replace "_ver_" "$ver" "$_boot")
  52. if test "$_flag_install"
  53. set boot_order d
  54. set -p _args --drive file="$media/$install",media=cdrom,readonly
  55. if test "$boot"
  56. set boot_order a
  57. set -p _args --drive file="$media/$boot",format=raw,if=floppy,readonly
  58. end
  59. end
  60. # Run!
  61. set -a _args $argv
  62. env QEMU_AUDIO_DRV=pa "qemu-system-$_arch" \
  63. --boot order="$boot_order" \
  64. --cpu "$cpu" \
  65. --display sdl,gl=on \
  66. --drive file="$image",format=qcow2,media=disk \
  67. --monitor stdio \
  68. --vga "$vga" \
  69. -m "$_mem" \
  70. $_args
  71. end
  72. complete -c vm-qemu -xa "(ls $_agw_dir_rc/virtual-machines/QEMU)"
  73. ## EOF