Page 1 of 1

machine.launchVMProcess keeps session locked

PostPosted: 17. Apr 2013, 15:07
by PauloVJ
Hello everybody,

I'm building a script to start/stop/backup virtual machines using python but I stumbled in an issue with ISession.
When starting and unlocking the machine I cannot get another lock later, saying the machine is already locked.

I'm using the following code:
Code: Select all   Expand viewCollapse view
progress = machine.launchVMProcess(session, "headless", None)
progress.waitForCompletion(-1)
log("Started '%s'" % machine.name)
time.sleep(1)
session.unlockMachine()

Am I doing this wrong?
Thanks

Re: machine.launchVMProcess keeps session locked

PostPosted: 17. Apr 2013, 15:23
by noteirak
Moving to Virtualbox API

Re: machine.launchVMProcess keeps session locked

PostPosted: 17. Apr 2013, 15:49
by noteirak
launchVMProcess will lock the machine itself, as described in the SDK/API, so you don't need to unlock any session.
As for trying to get a lock later on, again as described in the SDK/API, you can only get a shared lock since the vboxheadless process has already a write lock on the VM.

Re: machine.launchVMProcess keeps session locked

PostPosted: 17. Apr 2013, 15:49
by PauloVJ
Thanks, somehow I missed this board.
noteirak wrote:Moving to Virtualbox API

Re: machine.launchVMProcess keeps session locked

PostPosted: 17. Apr 2013, 17:27
by PauloVJ
noteirak wrote:launchVMProcess will lock the machine itself, as described in the SDK/API, so you don't need to unlock any session.
As for trying to get a lock later on, again as described in the SDK/API, you can only get a shared lock since the vboxheadless process has already a write lock on the VM.

Thanks for the help. Changing the lock type worked.
As for the the session.unlockMachine it is needed as I'm looping through all the machines and the session is reused.

Re: machine.launchVMProcess keeps session locked

PostPosted: 17. Apr 2013, 19:26
by noteirak
If you don't do anything else except starting the VM with headless, you don't need the unlockMachine().
Only if you perform other tasks on it later but then you should only try to unlock if required.