machine.launchVMProcess keeps session locked

Discussion about using the VirtualBox API, Tutorials, Samples.

machine.launchVMProcess keeps session locked

Postby PauloVJ » 17. Apr 2013, 15:07

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
PauloVJ
 
Posts: 3
Joined: 17. Apr 2013, 15:03

Re: machine.launchVMProcess keeps session locked

Postby noteirak » 17. Apr 2013, 15:23

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

Re: machine.launchVMProcess keeps session locked

Postby noteirak » 17. Apr 2013, 15:49

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://kamax.io/hbox/
Manage your VirtualBox infrastructure the free way!
noteirak
Site Moderator
 
Posts: 5198
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7

Re: machine.launchVMProcess keeps session locked

Postby PauloVJ » 17. Apr 2013, 15:49

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

Postby PauloVJ » 17. Apr 2013, 17:27

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.
PauloVJ
 
Posts: 3
Joined: 17. Apr 2013, 15:03

Re: machine.launchVMProcess keeps session locked

Postby noteirak » 17. Apr 2013, 19:26

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://kamax.io/hbox/
Manage your VirtualBox infrastructure the free way!
noteirak
Site Moderator
 
Posts: 5198
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7


Return to The VirtualBox API

Who is online

Users browsing this forum: No registered users and 3 guests