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.

91 lines
1.6 KiB

#!/usr/bin/env fish
function vm-qemu -d "Frontend to QEMU"
# Args
argparse \
--name "vm-qemu" \
--min-args 1 \
'V/version=' \
'i/install' \
-- \
or exit 1
set cfg $argv[1]
set -e argv[1]
# Config
source $_agw_dir_rc/virtual-machines/QEMU/$cfg
# Devices
test "$_vga"
and set vga $_vga
or set vga vmware
test "$_soundhw"
and set soundhw $_soundhw
or set soundhw hda
for dev in $_devs
set -a _args --device $dev
switch $soundhw
case "hda"
set -a _args --device intel-hda --device hda-duplex
case "ac97"
set -a _args --device AC97
# Machine
test "$_cpu"
and set cpu $_cpu
or set cpu host
if test "$_arch" = "i386" || test "$_arch" = "x86_64"
set -p _args \
--machine accel=kvm \
# Versioning
test "$_flag_version"
and set ver $_flag_version
or set ver $_ver
# Disk Media
set image "/media/store/vm/$cfg/image$ver"
set boot_order c
# Install Media
set media "/media/store/osmedia"
set install (string replace "_ver_" "$ver" "$_install")
set boot (string replace "_ver_" "$ver" "$_boot")
if test "$_flag_install"
set boot_order d
set -p _args --drive file="$media/$install",media=cdrom,readonly
if test "$boot"
set boot_order a
set -p _args --drive file="$media/$boot",format=raw,if=floppy,readonly
# Run!
set -a _args $argv
env QEMU_AUDIO_DRV=pa "qemu-system-$_arch" \
--boot order="$boot_order" \
--cpu "$cpu" \
--display sdl,gl=on \
--drive file="$image",format=qcow2,media=disk \
--monitor stdio \
--vga "$vga" \
-m "$_mem" \
complete -c vm-qemu -xa "(ls $_agw_dir_rc/virtual-machines/QEMU)"
## EOF