Add a wrapper to call qemu-system-aarch64 from ganeti
authorAurelien Jarno <aurelien@aurel32.net>
Tue, 8 Aug 2017 22:04:37 +0000 (00:04 +0200)
committerAurelien Jarno <aurelien@aurel32.net>
Tue, 8 Aug 2017 22:09:15 +0000 (00:09 +0200)
... until things get integrated upstream.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
modules/ganeti2/files/qemu-system-aarch64-wrapper [new file with mode: 0755]
modules/ganeti2/manifests/init.pp

diff --git a/modules/ganeti2/files/qemu-system-aarch64-wrapper b/modules/ganeti2/files/qemu-system-aarch64-wrapper
new file mode 100755 (executable)
index 0000000..1ad0d67
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+##
+## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
+## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
+##
+
+##
+## Wrapper to call qemu-system-aarch64 from Ganeti, removing all x86/PCI
+## assumptions.
+##
+
+# With qemu-system-aarch64 the machine should be defined even for simple
+# commands like querying the list of devices.
+args=("-machine")
+args+=("virt")
+
+# We want to always enable KVM. Contrary to what the Ganeti's documentation
+# says, enabling kvm_flag is not enough.
+args+=("-enable-kvm")
+
+while [ "$1" ]; do
+    case "$1" in
+        -machine|-M)
+            # Ignore the machine argument (it is already defined above),
+            # except when querying the list of machines
+            if [ "$2" = "?" ] ; then
+                args+=("-M")
+                args+=("?")
+            fi
+            shift
+            ;;
+        *)
+            # Replace PCI devices by their bus agnostic variant, and drop
+            # all the PCI related options
+            args+=("$(echo $1 | sed -e 's/virtio-\(\w\+\)-pci/virtio-\1-device/' -e 's/,bus=[^,]\+,addr=[^,]\+//')")
+            ;;
+    esac
+    shift
+done
+
+exec /usr/bin/qemu-system-aarch64 "${args[@]}"
index cb486df..2d80c9d 100644 (file)
@@ -23,4 +23,11 @@ class ganeti2 {
                source => 'puppet:///modules/ganeti2/cleanup-watcher-pause-file',
                mode    => '0555',
        }
+
+       if $::debarchitecture == 'arm64' {
+               file { '/usr/local/bin/qemu-system-aarch64-wrapper':
+                       source => 'puppet:///modules/ganeti2/qemu-system-aarch64-wrapper',
+                       mode   => '0755',
+               }
+       }
 }