Page 1 of 1

creating a VM using the Virtualbox API

Posted: 27. Jul 2012, 13:51
by BobKubista
Hello everyone,

I am trying to create a new Vitrual machine using the java api. I would like to make it work on a windows machine to create a linux machine. I can create a VM, a storage controller and a (normal) harddisk, but I cannot seem to be able to attach the harddisk to the VM. I get the same problem trying to attach a DVD device. I keep getting that the machine is not mutable (state is powered off) This is with a registered machine.

What steps do I need to do to attach the devices to the VM?

Thanks

Re: creating a VM using the Virtualbox API

Posted: 9. Aug 2012, 17:11
by chrisbenninger
Hi,

I'm having the exact same issue. Have you found a solution?

Re: creating a VM using the Virtualbox API

Posted: 10. Aug 2012, 17:19
by chrisbenninger
Turns out I was using the API incorrectly.

Once you've created a new VM with machine=createMachine(...), you have a non-mutable reference to that VM. From there, you need to create a new session using manager.getSessionObject(), lock the machine with machine.lockMachine(session,...), use the session to get a mutable reference to the machine mutableMachine=session.getMachine() and then use that reference for all the rest of your stuff.

Re: creating a VM using the Virtualbox API

Posted: 13. Aug 2012, 12:42
by BobKubista
Thanks, I found that as well.