#!/bin/bash

OP=$2
SUBOP=$3

VOLS=$(cat /dev/stdin | xmlstarlet sel -t -m "/domain/devices/disk/source" -v @dev -v @file -n | grep '/')

if [ $OP == "start" ] && [ $SUBOP == "begin" ]; then
    for VOL in $VOLS;do
        chcon -t virt_image_t $VOL
    done
fi

exit 0

