Created at:

VirtualBox notes


When you lost connection to a machine that is still locked to the dead session

I've opened a remote ssh session with X forwarding and opened a virtual machine with VBoxManage::

    $ VBoxManage startvm 'Debian Master'

After some time, the dynamic IP address of the host machine changed, then I lost the connection to the virtual machine. I reconnected to the host again and tried to start it again, but received an error::

    $ VBoxManage startvm 'Debian Master'
    VBoxHeadless: error: The machine 'Debian Master' is already locked for a session (or being unlocked)
    VBoxHeadless: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component Machine, interface IMachine, callee nsISupports
    Context: "LockMachine(session, LockType_Write)" at line 817 of file VBoxHeadless.cpp

Trying to stop it hanged the command.  So, I had to search for a process that
still had the control over the virtual machine::

    $ ps ax | grep -i virtualbox
     2067 ?        S      9:23 /usr/lib/virtualbox/VBoxXPCOMIPCD
     2072 ?        Sl    29:57 /usr/lib/virtualbox/VBoxSVC --auto-shutdown
    14215 ?        Sl     0:40 /usr/lib/virtualbox/VirtualBox /vms/node002.ova
    18722 ?        SLl   78:13 /usr/lib/virtualbox/VirtualBox --comment Windows --startvm 0ac2589a-cdfd-424a-b908-63512238f7d9 --no-startvm-errormsgbox
    27227 ?        Sl     2:07 /usr/lib/virtualbox/VirtualBox --comment Debian Master --startvm efc1d9f1-2aec-4fbe-aaa3-fd62ca578ab0 --no-startvm-errormsgbox
    27983 pts/3    S+     0:00 grep -i virtualbox

See that it is the process 27227. After killing it I could start the virtual machine again.