<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Traiano,<br>
<div class="moz-cite-prefix">On 11.05.2014 19:29, Traiano Welcome
wrote:<br>
</div>
<blockquote
cite="mid:CAFKCRVLWWu8Fy65MuCj5Kw1zodeEPpjUTqK477-0qFqdx0iPpQ@mail.gmail.com"
type="cite">
<div dir="ltr">Hi All
<div><br>
</div>
<div>I'm starting out to use the virtualbox C API, my objective
is to carry out the following sequence of simple operations to
automate the deployment of VMs on VirtualBox:</div>
</div>
</blockquote>
First of all - do you really really have a strict requirement that
you absolutely must use C? The C API needs a lot more effort than
using C++, simply because both COM and XPCOM are geared towards C++.
Effectively it's an attempt at wrapping the C++ functionality behind
C compatible functions, leaving the burden of doing the "object
orientation" by hand, e.g. by always passing the "this" pointer
explicitly.<br>
<br>
So... if you can, by any means go for C++. Even with our
long-standing todo to make what we internally call "COM/XPCOM glue"
externally available (it isn't today, so it's not possible to easily
write one piece of code which works both with COM and XPCOM, unlike
what we do internally in VirtualBox), C++ is a lot easier to use.
Long term (or short to medium term if someone helps with making the
COM/XPCOM glue part of the SDK) it will be possible to write API
clients just how we write them in the VirtualBox tree - totally
identical code on Windows and elsewhere.<br>
<blockquote
cite="mid:CAFKCRVLWWu8Fy65MuCj5Kw1zodeEPpjUTqK477-0qFqdx0iPpQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>1. Create and Launch a VM</div>
<div>2. Create a virtual disk and attach it to the VM</div>
<div>3. Detach a virtual disk from the VMr</div>
<div>4. Shut the VM down</div>
</div>
</blockquote>
The usual "why don't you provide code which does my work?" request,
which we don't take too seriously. After all the C API sample is
carefully written to cover the vital areas of a medium scale client,
which needs to do good error checking, event handling and the like.
If you ignore the rather significant effort for handling events (in
two flavors) then the sample is very straightforward: it dumps some
interesting global properties, enumerates all VMs, shows some
details about them, asks which one to start, starts the one the user
selected and then terminates.<br>
<br>
I think this qualifies as simple :)<br>
<blockquote
cite="mid:CAFKCRVLWWu8Fy65MuCj5Kw1zodeEPpjUTqK477-0qFqdx0iPpQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>I'm working through the single example C program supplied
with the VirtualBox SDK, however, I find it's quite a complex
piece of work, and I'd appreciate it if there were smaller
more digestable examples for doing limited sing-purpose
operations like those listed above?</div>
</div>
</blockquote>
There are no smaller examples, and one of the reasons is that the
VirtualBox team does NOT use the C API. It's just one of the
language bindings we offer, without an explicit recommendation.<br>
<br>
Either way, what you're asking for isn't truly smaller than the
existing samples, as you can see from my quick code summary of
tstCAPIGlue.c above.<br>
<blockquote
cite="mid:CAFKCRVLWWu8Fy65MuCj5Kw1zodeEPpjUTqK477-0qFqdx0iPpQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>Any pointers to working examples of C code would be much
appreciated!</div>
</div>
</blockquote>
Sorry, nothing like this in the VirtualBox sources. The original
reason for creating the C API was that the libvirt folks are totally
allergic against C++, and what we're recommending as proper C API
use is these days rather different to the "XPCOM only" hack we did 5
years ago and they keep maintaining the ancient coding style.<br>
<br>
Klaus<br>
<blockquote
cite="mid:CAFKCRVLWWu8Fy65MuCj5Kw1zodeEPpjUTqK477-0qFqdx0iPpQ@mail.gmail.com"
type="cite">
<div class="moz-signature">
<div>Thanks in advance!</div>
<div>Traiano</div>
<!-- This signature was generated by the MyDesktop Oracle Business Signature utility version 4.2 -->
</div>
</blockquote>
</body>
</html>