Saturday, 31 August 2013

virsh directive to disconnect hypervisor

virsh directive to disconnect hypervisor

What I have tried is below :
#!/bin/bash
read -p "Enter the hypervisor to connect to :" hyp
echo "Connecting to the hypervisor $hyp"
if virsh connect $hyp
then
{
read -p "Enter the domain to start : " dom
if virsh start $dom
then
{
echo "successfully starting $dom"
sleep 35 #Giving enough time for the domain to boot
virsh list
echo "Pinging the domain $dom (Count : 5)"
ping -c 5 $dom
virsh shutdown $dom
sleep 30 #Giving enough time for the domain to shutdown
}
else
echo "No such domain like $sys"
fi
virsh quit #I thought i would disconnect the hypervisor here
}
else
{
echo "No such hypervisor like $hyp"
}
fi
I have saved the above script as virshfe and ran it. Worked fine! My input
for the $hyp (The hypervisor) was qemu::///system and for $dom (domain)
was server1.example.com But as the script spawns a new bash shell, I
expected that the hypervisor connected to the virsh will also be closed as
the script end but this was not the case. Even after the script ends the
hypervisor seems to be connected so that if i issue a command like
virsh start server1.example.com
now, the domain is started. So I guess even if I quit the virsh, it is by
default connected to the hypervisor of the physcial host.
Is there a virsh directive to disconnect a hypervisor?

No comments:

Post a Comment