#!/bin/sh

DIR="/etc/libvirt/hooks/qemu.d/"

# Domain xml is passed as stdin to the script, supply the same for sub-scripts
XML=$(mktemp)
cat - > $XML

if [ -d $DIR ]; then
  for SCRIPT in $(find $DIR -type f -executable); do
    $SCRIPT $@ < $XML
    if [ $? -ne 0 ]; then
      rm $XML
      exit 1
    fi
  done
fi

rm $XML
