machine.launchVMProcess keeps session locked

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
PauloVJ
Posts: 3
Joined: 17. Apr 2013, 15:03

machine.launchVMProcess keeps session locked

Post 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

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
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: machine.launchVMProcess keeps session locked

Post by noteirak »

Moving to Virtualbox API
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: machine.launchVMProcess keeps session locked

Post 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.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
PauloVJ
Posts: 3
Joined: 17. Apr 2013, 15:03

Re: machine.launchVMProcess keeps session locked

Post by PauloVJ »

Thanks, somehow I missed this board.
noteirak wrote:Moving to Virtualbox API
PauloVJ
Posts: 3
Joined: 17. Apr 2013, 15:03

Re: machine.launchVMProcess keeps session locked

Post 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.
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: machine.launchVMProcess keeps session locked

Post 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.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Post Reply