You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
987 B
Bash
47 lines
987 B
Bash
3 years ago
|
#!/bin/bash
|
||
|
|
||
|
# This is my QEMU starting script, copied over and over.
|
||
|
|
||
|
set -euo pipefail
|
||
|
|
||
|
# KNOWN BUG: We cannot override options from command line
|
||
|
# -> Easy fix would be to disallow spaces OR single quotes in options, but IMHO not worth
|
||
|
|
||
|
CONFIG='
|
||
|
|
||
|
# Basics:
|
||
|
name {{ c.name }}
|
||
|
m 20M
|
||
|
{# enable-kvm #}
|
||
|
|
||
|
# Boot drive (BIOS)
|
||
|
drive media=disk,file=./disk.img,format=raw
|
||
|
|
||
|
# Monitor on dedicated socket
|
||
|
monitor unix:./monitor.sock,server,nowait
|
||
|
|
||
|
spice unix=on,addr=./spice.sock,disable-copy-paste=on,seamless-migration=off,disable-ticketing=on
|
||
|
display none # Already handled by SPICE
|
||
|
|
||
|
# NIC: attach to bridges:
|
||
|
{% for br in c.bridges %}
|
||
|
nic bridge,br={{ br.name }},model=virtio-net-pci,mac=52:54:00:17:{{ '%02x%02x' % (c.num, br.num) }}
|
||
|
{% endfor %}
|
||
|
'
|
||
|
|
||
|
|
||
|
strip() {
|
||
|
sed -e '
|
||
|
s/^[ ]*//
|
||
|
s/[ ]*$//
|
||
|
|
||
|
s/[ ]*#.*$//
|
||
|
|
||
|
/^$/d
|
||
|
|
||
|
'
|
||
|
}
|
||
|
|
||
|
# Now QEMU is in foreground
|
||
|
strip <<<"$CONFIG" | while read option params; do echo "-$option"; test -n "$params" && echo "$params"; done | xargs qemu-system-x86_64 "$@"
|