Page 1 of 1

[Solved] Using API to create / manage vm's

Posted: 20. Jul 2009, 16:53
by fred-dd
Hi @all,

I have some question about using the API. Like the topic describes, I want to create and manage vm's with the API. Creating a VM should not be a problem, but I don't find a way to attach cdrom image to a VM. I had search in API documentation and also google don't help much. In the API get methods or readonly attributes are described but I found nothing to set, same problem at network interfaces and serial ports.
Maybe a solution can be: to prepare an description xml file and load them with IVirtualBox::openMachine. Could work but I think is not the best way.
So my question is, is there a way to do what I want to do directly with the API?


Thanks for Help

Re: Using API to create / manage vm's

Posted: 24. Jul 2009, 01:23
by Perryg
Not sure. I do know that VBox uses VBoxManage to make the calls. See section Chapter 8. VBoxManage reference of the users guide.

Re: Using API to create / manage vm's

Posted: 29. Jul 2009, 02:41
by JshWright
In order to change/control a VM, you need to open a session.

If you're looking to change the settings of a VM, you'll need to use IVirtualBox::openSession to get a session for that VM. If you are trying to control a VM that's already running you'll need to use IVirtualBox::openExistingSession. In either case, you'll need to get a session object to pass to either method. You get that from ISession.

Once you have the session object, you can get the associated machine (be sure to use ISession::machine to get the mutable VM object), and then you can use IMachine::DVDDrive.

~JW

Re: Using API to create / manage vm's

Posted: 29. Jul 2009, 14:20
by fred-dd
Thank you very much, this was the point. You had helped me find the right way. I hadn't think enough object orientated, read only object means not object attributes are read only :oops: