5411e51be46a41d25066c06e1ab59c4fe12a650c
[mirror/dsa-puppet.git] / modules / ganeti2 / files / qemu-system-aarch64-wrapper
1 #!/bin/bash
2
3 ##
4 ## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
5 ## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
6 ##
7
8 ##
9 ## Wrapper to call qemu-system-aarch64 from Ganeti, removing all x86/PCI
10 ## assumptions.
11 ##
12
13 # With qemu-system-aarch64 the machine should be defined even for simple
14 # commands like querying the list of devices.
15 args=("-machine")
16 args+=("virt,gic-version=3")
17
18 # We want to always enable KVM. Contrary to what the Ganeti's documentation
19 # says, enabling kvm_flag is not enough.
20 args+=("-enable-kvm")
21
22 while [ "$1" ]; do
23     case "$1" in
24         -machine|-M)
25             # Ignore the machine argument (it is already defined above),
26             # except when querying the list of machines
27             if [ "$2" = "?" ] ; then
28                 args+=("-M")
29                 args+=("?")
30             fi
31             shift
32             ;;
33         *)
34             # Replace PCI devices by their bus agnostic variant, and drop
35             # all the PCI related options
36             args+=("$(echo $1 | sed -e 's/virtio-\(\w\+\)-pci/virtio-\1-device/' -e 's/,bus=[^,]\+,addr=[^,]\+//')")
37             ;;
38     esac
39     shift
40 done
41
42 exec /usr/bin/qemu-system-aarch64 "${args[@]}"