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

This is for discussing general topics about how to use VirtualBox.
Post Reply
fred-dd
Posts: 2
Joined: 20. Jul 2009, 16:20
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux

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

Post 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
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Using API to create / manage vm's

Post 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.
JshWright
Volunteer
Posts: 119
Joined: 13. Sep 2007, 00:33
Primary OS: Debian Lenny
VBox Version: OSE self-compiled
Guest OSses: Many...

Re: Using API to create / manage vm's

Post 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
Join us in the VirtualBox IRC channel: #vbox on FreeNode
http://www.virtualbox.org/wiki/IRC
fred-dd
Posts: 2
Joined: 20. Jul 2009, 16:20
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux

Re: Using API to create / manage vm's

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