creating a VM using the Virtualbox API

This is for discussing general topics about how to use VirtualBox.
Post Reply
BobKubista
Posts: 5
Joined: 27. Jul 2012, 13:47

creating a VM using the Virtualbox API

Post 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
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

Post by chrisbenninger »

Hi,

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

Post 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.
BobKubista
Posts: 5
Joined: 27. Jul 2012, 13:47

Re: creating a VM using the Virtualbox API

Post by BobKubista »

Thanks, I found that as well.
Post Reply