vboxmanage: wait for shutdown

Discussions related to using VirtualBox on Linux hosts.

vboxmanage: wait for shutdown

Postby jedix » 23. Jul 2012, 17:05

Hello,

currently I'm trying to control my virtual machins with vboxmanage. However, at one point the program does not do what I expected:

Let's say my vm is named "test-vm".

After this:
Code: Select all   Expand viewCollapse view
vboxmanage startvm test-vm

the vm is listed under
Code: Select all   Expand viewCollapse view
vboxmanage list runningvms


And immediately after this:
Code: Select all   Expand viewCollapse view
vboxmanage controlvm test-vm poweroff

it is not.

But (while the vm is running):
Code: Select all   Expand viewCollapse view
vboxmanage controlvm test-vm poweroff && vboxmanage unregistervm test-vm --delete

does not work:

Code: Select all   Expand viewCollapse view
VBoxManage: error: Cannot unregister the machine 'test-vm' while it is locked
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component Machine, interface IMachine, callee nsISupports
Context: "Unregister(fDelete ? (CleanupMode_T)CleanupMode_DetachAllReturnHardDisksOnly : (CleanupMode_T)CleanupMode_DetachAllReturnNone, ComSafeArrayAsOutParam(aMedia))" at line 160 of file VBoxManageMisc.cpp


How can I check, if a machine is locked? The machine is not listed as "running" and
Code: Select all   Expand viewCollapse view
vboxmanage showvminfo test-vm --machinereadable

says
Code: Select all   Expand viewCollapse view
VMState="poweroff"


If I wait 0.5 seconds between shutdown and unregister, everything works. But that is on my machine... and I'd rather not wait 5 seconds only to be safe.

Any suggestions?
jedix
 
Posts: 2
Joined: 23. Jul 2012, 16:53

Re: vboxmanage: wait for shutdown

Postby Perryg » 23. Jul 2012, 17:10

If I wait 0.5 seconds between shutdown and unregister, everything works. But that is on my machine... and I'd rather not wait 5 seconds only to be safe.
The PID will not be released until the machine is completely powered down, and even then might take a few seconds to release. Not sure you can do anything except put a wait state in your shutdown script if using a script or wait the 0.5 seconds to issue the unregister command.
Perryg
Site Moderator
 
Posts: 34373
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: vboxmanage: wait for shutdown

Postby jedix » 23. Jul 2012, 17:13

Thanks for the quick reply.

Is there maybe a way to check, if the PID is released or not?
jedix
 
Posts: 2
Joined: 23. Jul 2012, 16:53

Re: vboxmanage: wait for shutdown

Postby Perryg » 23. Jul 2012, 17:29

You can look in /tmp/.vbox....
Perryg
Site Moderator
 
Posts: 34373
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX


Return to VirtualBox on Linux Hosts

Who is online

Users browsing this forum: Google [Bot] and 12 guests