[vbox-dev] The given session is busy

Klaus Espenlaub klaus.espenlaub at oracle.com
Fri Sep 9 17:42:27 GMT 2011


On 03.09.2011 14:57, Barash, Danny wrote:
> I believe that the reason the machine is locked is because you are
> already locking it at
>
> /"//IProgress progress = machine.launchVMProcess(session, "gui", "");"/

Exactly. The code below makes no sense. You use the session to start a 
VM (which implicitly locks the session according to the API 
documentation), and when the VM is running the code locks it again 
(which fails). The remaining code would change the configured RAM size 
while the VM is running. PCs can't do that :)

Klaus

>
> //
>
> //
>
> Please refer to the SDK ref for more information.
>
> Regards,
>
> Danny.
>
> *From:*vbox-dev-bounces at virtualbox.org
> [mailto:vbox-dev-bounces at virtualbox.org] *On Behalf Of *Rafael Braga
> *Sent:* Thursday, September 01, 2011 21:49
> *To:* vbox-dev at virtualbox.org
> *Subject:* [vbox-dev] The given session is busy
>
> Hello,I am beginner in virtualbox java API and now I need
> change the memory size of a vm. I am using the following code:
>
> public void setMemorySize() {
> VirtualBoxManager mgr = VirtualBoxManager.createInstance(null);
> ISession session = mgr.getSessionObject();
> IVirtualBox vbox = mgr.getVBox();
>
> IMachine machine = vbox.getMachines().get(1);
> IProgress progress = machine.launchVMProcess(session, "gui", "");
> progress.waitForCompletion(-1);
> machine.lockMachine(session, LockType.Write); // machine is now locked
> for writing
> IMachine mutable = session.getMachine();
> // obtain the mutable machine copy
> mutable.setMemorySize((long) 1024);
> mutable.saveSettings();
> // write settings to XML
> session.unlockMachine();
> }
>
> But, returns the following error:
>
> Exception in thread "main" org.virtualbox_4_1.VBoxException: The
> function "lockMachine" returned an error condition: "The given session
> is busy" (0x80bb0007)
> at org.virtualbox_4_1.IMachine.lockMachine(IMachine.java:798)
> at teste.elasticidade.IniciaVM.setMemorySize(IniciaVM.java:51)
> at teste.elasticidade.IniciaVM.main(IniciaVM.java:37)
>
>
> what maybe happening?
>
> thanks a lot.
>
> --
> Rafael Braga
>
> ---------------------------------------------------------------------
> Intel Israel (74) Limited
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
>
>
> _______________________________________________
> vbox-dev mailing list
> vbox-dev at virtualbox.org
> http://vbox.innotek.de/mailman/listinfo/vbox-dev




More information about the vbox-dev mailing list