#!/bin/bash
RET=0

for RVM in $(virsh  list  | awk '$0  ~/instance/ { print  $2 }')
do
  LOSTVM=$( timeout 10 virsh qemu-monitor-command $RVM --pretty  '{"execute":"query-kvm"}')
  if [ $? -ne 0 ]
  then
    echo -n "${RVM} is  lost"
    RET=2
  fi
done

if [ "${RET}" -le "0" ]
then
    echo "OK"
fi

exit ${RET}
