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
creating a VM using the Virtualbox API
-
chrisbenninger
- Posts: 2
- Joined: 9. Aug 2012, 17:11
- Primary OS: Debian other
- VBox Version: OSE Debian
- Guest OSses: WInXP
Re: creating a VM using the Virtualbox API
Hi,
I'm having the exact same issue. Have you found a solution?
I'm having the exact same issue. Have you found a solution?
-
chrisbenninger
- Posts: 2
- Joined: 9. Aug 2012, 17:11
- Primary OS: Debian other
- VBox Version: OSE Debian
- Guest OSses: WInXP
Re: creating a VM using the Virtualbox API
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.
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.
-
BobKubista
- Posts: 5
- Joined: 27. Jul 2012, 13:47
Re: creating a VM using the Virtualbox API
Thanks, I found that as well.