[vbox-dev] The given session is busy

Rafael Braga rafaeltelematica at gmail.com
Thu Sep 1 18:48:32 GMT 2011


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 may be happening?

thanks a lot.

-- 
Rafael Braga <http://www.linkedin.com/myprofile?trk=hb_tab_pro>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20110901/00a632b5/attachment.html>


More information about the vbox-dev mailing list