rc.d/vboxheadless doesn't show running VMs
Miroslav Lachman
000.fbsd at quip.cz
Mon Jun 25 09:08:29 UTC 2012
Hi,
I am using VirtualBox-OSE and phpVirtualBox. If I use "Save the machine
state" from phpVirtualBox and then "Start", the state of the VM is not
recognized by rc script vboxheadless:
# service vboxheadless status
Machine Status
------------------------- ------------
FreeBSD_one Powered Off
FreeBSD_two Powered Off
FreeBSD_three Powered Off
FreeBSD_four Powered Off
FreeBSD_five Powered Off
FreeBSD_six Powered Off
SmartOs_live Powered Off
But the VM FreeBSD_four is still running:
# /usr/local/bin/VBoxManage showvminfo FreeBSD_four | grep -i state
State: running (since 2012-06-20T21:30:56.211000000)
# /usr/local/bin/VBoxManage list runningvms
"FreeBSD_four" {14d0f837-bd84-432a-8a8b-ee48b247d3ef}
The FreeBSD_four VM is really running, I can log in to it by ssh.
One problem I found is different PID of running process and in PID file:
# ps auxwww | grep -i vboxheadless
root 61699 200.0 8.6 2228216 2157712 ?? I Wed11PM 10707:27.35
/usr/local/lib/virtualbox/VBoxHeadless --comment FreeBSD_four --startvm
14d0f837-bd84-432a-8a8b-ee48b247d3ef --vrde config
# cat /var/run/vboxheadless_FreeBSD_four.pid
61275
rc script contains this check:
/usr/bin/su ${vmuser} -c "/usr/local/bin/VBoxManage showvminfo
'${vmname}' >/dev/null" 2>/dev/null
if [ $? != 0 ]; then
/usr/bin/printf "%20s %s\n" "${vmname}" "Unknown Machine"
elif [ -n "${pid}" ]; then
/usr/bin/printf "%25s %s\n" "${vmname}" "Running"
else
/usr/bin/printf "%25s %s\n" "${vmname}" "Powered Off"
fi
Is it really right way to check it? Why not use something, that checks
real state of the VM reported by
VBoxManage showvminfo FreeBSD_four | grep 'State:'
This is on FreeBSD 8.3-RELEASE amd64 GENERIC with
virtualbox-ose-4.1.16_1 and phpvirtualbox-4.1.7
Miroslav Lachman
More information about the freebsd-emulation
mailing list