Function vboxhelper::get_pid[][src]

pub fn get_pid(vid: &VmId) -> Result<u32, Error>
Expand description

Get the process id of the guest virtual machine.

If the virtual machine doesn’t exist or isn’t running this function will return Error::InvalidState.

The PID is determined by searching for a “Process ID:” string in the virtual machine’s log (no, I’m not kidding, it really does). If this entry can not be found in the log the function will return Error::Missing. Note that this doesn’t necessarily mean that something is wrong; it can simply mean that VirtualBox hasn’t had time to write the process id log entry yet, though empirically it would seem that it writes it pretty soon into the startup process. It is recommended that the application wait a few seconds between start of the virtual machine and calling this function, and also that the call be retried (with a delay between call) if Error::Missing is returned.

Use try_get_pid() to wrap some retry logic around this function.