#!/sbin/openrc-run

extra_commands="status"

depend() {
        need xenstored
        after xend xenconsoled
        before xendomains
}

is_running() {
        false
}

start() {
        if [ "${DEVICES}" != "" ]; then
                attached=$(xl pci-assignable-list)
                for x in ${DEVICES}; do
                        if echo "$attached" | grep -qsw "$x"; then
                          echo "PCI device $x already added - skipping"
                        else
                          echo "Adding PCI device $x to Xen"
                          xl pci-assignable-add $x
                        fi
                done
        else
                echo "DEVICES in /etc/conf.d/xen-pci is empty"
        fi
}

stop() {
	# do nothing devices may be in use
	true
}

status() {
        true
}
