Add dummy xen network interface to AppVM

I’ve ended up doing it like this in dom0:

sudo mkdir /etc/libvirt/hooks/
sudo nano /etc/libvirt/hooks/libxl

Paste this script inside:

#!/bin/bash
guest_name="$1"
libvirt_operation="$2"
timeout=60

if [ "$guest_name" = "myvmname" ] && [ "$libvirt_operation" = "started" ]; then
    (
        exec 0</dev/null
        exec 1>/dev/null
        exec 2>/dev/null
        for i in $(seq 1 $timeout);
        do
            if qvm-ls --running $guest_name | grep -q Running; then
                xl network-attach $guest_name mac=xx:xx:xx:xx:xx:xx
                break
            fi
            sleep 1
        done
    ) & disown
fi

Then add execute permission:

sudo chmod +x /etc/libvirt/hooks/libxl

Reboot.