#!/bin/bash

vmName=$1
vmConfig=/etc/xen/auto/$1.cfg
targetHostName=$2

echo $vmName
echo $vmConfig
echo $targetHostName

if xm migrate --live $vmName $targetHostName ; then
if xm delete $vmName ; then
if (scp $vmConfig root@$targetHostName:$vmConfig ; rm $vmConfig) ; then
ssh $targetHostName xm new $vmConfig
fi
fi
fi
	
