VirtualBox

source: vbox/trunk/doc/manual/en_US/SDKRef.xml@ 81940

Last change on this file since 81940 was 81421, checked in by vboxsync, 5 years ago

bugref:9589. OCI: user is able to pass several SSH keys during instance creation.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 281.9 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"[
4<!ENTITY % all.entities SYSTEM "all-entities.ent">
5%all.entities;
6]>
7
8<book>
9 <bookinfo>
10 <title>&VBOX_PRODUCT;</title>
11
12 <subtitle>Programming Guide and Reference</subtitle>
13
14 <edition>Version &VBOX_VERSION_STRING;</edition>
15
16 <corpauthor>&VBOX_VENDOR;</corpauthor>
17
18 <address>http://www.virtualbox.org</address>
19
20 <copyright>
21 <year>2004-&VBOX_C_YEAR;</year>
22
23 <holder>&VBOX_VENDOR;</holder>
24 </copyright>
25 </bookinfo>
26
27 <chapter>
28 <title>Introduction</title>
29
30 <para>VirtualBox comes with comprehensive support for third-party
31 developers. This Software Development Kit (SDK) contains all the
32 documentation and interface files that are needed to write code that
33 interacts with VirtualBox.</para>
34
35 <sect1>
36 <title>Modularity: the building blocks of VirtualBox</title>
37
38 <para>VirtualBox is cleanly separated into several layers, which can be
39 visualized like in the picture below:</para>
40
41 <mediaobject>
42 <imageobject>
43 <imagedata align="center" fileref="images/vbox-components.png"
44 width="12cm"/>
45 </imageobject>
46 </mediaobject>
47
48 <para>The orange area represents code that runs in kernel mode, the blue
49 area represents userspace code.</para>
50
51 <para>At the bottom of the stack resides the hypervisor -- the core of
52 the virtualization engine, controlling execution of the virtual machines
53 and making sure they do not conflict with each other or whatever the
54 host computer is doing otherwise.</para>
55
56 <para>On top of the hypervisor, additional internal modules provide
57 extra functionality. For example, the RDP server, which can deliver the
58 graphical output of a VM remotely to an RDP client, is a separate module
59 that is only loosely tacked into the virtual graphics device. Live
60 Migration and Resource Monitor are additional modules currently in the
61 process of being added to VirtualBox.</para>
62
63 <para>What is primarily of interest for purposes of the SDK is the API
64 layer block that sits on top of all the previously mentioned blocks.
65 This API, which we call the <emphasis role="bold">"Main API"</emphasis>,
66 exposes the entire feature set of the virtualization engine below. It is
67 completely documented in this SDK Reference -- see <xref
68 linkend="sdkref_classes"/> and <xref linkend="sdkref_enums"/> -- and
69 available to anyone who wishes to control VirtualBox programmatically.
70 We chose the name "Main API" to differentiate it from other programming
71 interfaces of VirtualBox that may be publicly accessible.</para>
72
73 <para>With the Main API, you can create, configure, start, stop and
74 delete virtual machines, retrieve performance statistics about running
75 VMs, configure the VirtualBox installation in general, and more. In
76 fact, internally, the front-end programs
77 <computeroutput>VirtualBox</computeroutput> and
78 <computeroutput>VBoxManage</computeroutput> use nothing but this API as
79 well -- there are no hidden backdoors into the virtualization engine for
80 our own front-ends. This ensures the entire Main API is both
81 well-documented and well-tested. (The same applies to
82 <computeroutput>VBoxHeadless</computeroutput>, which is not shown in the
83 image.)</para>
84 </sect1>
85
86 <sect1 id="webservice-or-com">
87 <title>Two guises of the same "Main API": the web service or
88 COM/XPCOM</title>
89
90 <para>There are several ways in which the Main API can be called by
91 other code:<orderedlist>
92 <listitem>
93 <para>VirtualBox comes with a <emphasis role="bold">web
94 service</emphasis> that maps nearly the entire Main API. The web
95 service ships in a stand-alone executable
96 (<computeroutput>vboxwebsrv</computeroutput>) that, when running,
97 acts as an HTTP server, accepts SOAP connections and processes
98 them.</para>
99
100 <para>Since the entire web service API is publicly described in a
101 web service description file (in WSDL format), you can write
102 client programs that call the web service in any language with a
103 toolkit that understands WSDL. These days, that includes most
104 programming languages that are available: Java, C++, .NET, PHP,
105 Python, Perl and probably many more.</para>
106
107 <para>All of this is explained in detail in subsequent chapters of
108 this book.</para>
109
110 <para>There are two ways in which you can write client code that
111 uses the web service:<orderedlist>
112 <listitem>
113 <para>For Java as well as Python, the SDK contains
114 easy-to-use classes that allow you to use the web service in
115 an object-oriented, straightforward manner. We shall refer
116 to this as the <emphasis role="bold">"object-oriented web
117 service (OOWS)"</emphasis>.</para>
118
119 <para>The OO bindings for Java are described in <xref
120 linkend="javaapi"/>, those for Python in <xref
121 linkend="glue-python-ws"/>.</para>
122 </listitem>
123
124 <listitem>
125 <para>Alternatively, you can use the web service directly,
126 without the object-oriented client layer. We shall refer to
127 this as the <emphasis role="bold">"raw web
128 service"</emphasis>.</para>
129
130 <para>You will then have neither native object orientation
131 nor full type safety, since web services are neither
132 object-oriented nor stateful. However, in this way, you can
133 write client code even in languages for which we do not ship
134 object-oriented client code; all you need is a programming
135 language with a toolkit that can parse WSDL and generate
136 client wrapper code from it.</para>
137
138 <para>We describe this further in <xref
139 linkend="raw-webservice"/>, with samples for Java and
140 Perl.</para>
141 </listitem>
142 </orderedlist></para>
143 </listitem>
144
145 <listitem>
146 <para>Internally, for portability and easier maintenance, the Main
147 API is implemented using the <emphasis role="bold">Component
148 Object Model (COM), </emphasis> an interprocess mechanism for
149 software components originally introduced by Microsoft for
150 Microsoft Windows. On a Windows host, VirtualBox will use
151 Microsoft COM; on other hosts where COM is not present, it ships
152 with XPCOM, a free software implementation of COM originally
153 created by the Mozilla project for their browsers.</para>
154
155 <para>So, if you are familiar with COM and the C++ programming
156 language (or with any other programming language that can handle
157 COM/XPCOM objects, such as Java, Visual Basic or C#), then you can
158 use the COM/XPCOM API directly. VirtualBox comes with all
159 necessary files and documentation to build fully functional COM
160 applications. For an introduction, please see <xref
161 linkend="api_com"/> below.</para>
162
163 <para>The VirtualBox front-ends (the graphical user interfaces as
164 well as the command line), which are all written in C++, use
165 COM/XPCOM to call the Main API. Technically, the web service is
166 another front-end to this COM API, mapping almost all of it to
167 SOAP clients.</para>
168 </listitem>
169 </orderedlist></para>
170
171 <para>If you wonder which way to choose, here are a few
172 comparisons:<table>
173 <title>Comparison web service vs. COM/XPCOM</title>
174
175 <tgroup cols="2">
176 <tbody>
177 <row>
178 <entry><emphasis role="bold">Web service</emphasis></entry>
179
180 <entry><emphasis role="bold">COM/XPCOM</emphasis></entry>
181 </row>
182
183 <row>
184 <entry><emphasis role="bold">Pro:</emphasis> Easy to use with
185 Java and Python with the object-oriented web service;
186 extensive support even with other languages (C++, .NET, PHP,
187 Perl and others)</entry>
188
189 <entry><emphasis role="bold">Con:</emphasis> Usable from
190 languages where COM bridge available (most languages on
191 Windows platform, Python and C++ on other hosts)</entry>
192 </row>
193
194 <row>
195 <entry><emphasis role="bold">Pro:</emphasis> Client can be on
196 remote machine</entry>
197
198 <entry><emphasis role="bold">Con: </emphasis>Client must be on
199 the same host where virtual machine is executed</entry>
200 </row>
201
202 <row>
203 <entry><emphasis role="bold">Con: </emphasis>Significant
204 overhead due to XML marshalling over the wire for each method
205 call</entry>
206
207 <entry><emphasis role="bold">Pro: </emphasis>Relatively low
208 invocation overhead</entry>
209 </row>
210 </tbody>
211 </tgroup>
212 </table></para>
213
214 <para>In the following chapters, we will describe the different ways in
215 which to program VirtualBox, starting with the method that is easiest to
216 use and then increase complexity as we go along.</para>
217 </sect1>
218
219 <sect1 id="api_soap_intro">
220 <title>About web services in general</title>
221
222 <para>Web services are a particular type of programming interface.
223 Whereas, with "normal" programming, a program calls an application
224 programming interface (API) defined by another program or the operating
225 system and both sides of the interface have to agree on the calling
226 convention and, in most cases, use the same programming language, web
227 services use Internet standards such as HTTP and XML to
228 communicate.<footnote>
229 <para>In some ways, web services promise to deliver the same thing
230 as CORBA and DCOM did years ago. However, while these previous
231 technologies relied on specific binary protocols and thus proved to
232 be difficult to use between diverging platforms, web services
233 circumvent these incompatibilities by using text-only standards like
234 HTTP and XML. On the downside (and, one could say, typical of things
235 related to XML), a lot of standards are involved before a web
236 service can be implemented. Many of the standards invented around
237 XML are used one way or another. As a result, web services are slow
238 and verbose, and the details can be incredibly messy. The relevant
239 standards here are called SOAP and WSDL, where SOAP describes the
240 format of the messages that are exchanged (an XML document wrapped
241 in an HTTP header), and WSDL is an XML format that describes a
242 complete API provided by a web service. WSDL in turn uses XML Schema
243 to describe types, which is not exactly terse either. However, as
244 you will see from the samples provided in this chapter, the
245 VirtualBox web service shields you from these details and is easy to
246 use.</para>
247 </footnote></para>
248
249 <para>In order to successfully use a web service, a number of things are
250 required -- primarily, a web service accepting connections; service
251 descriptions; and then a client that connects to that web service. The
252 connections are governed by the SOAP standard, which describes how
253 messages are to be exchanged between a service and its clients; the
254 service descriptions are governed by WSDL.</para>
255
256 <para>In the case of VirtualBox, this translates into the following
257 three components:<orderedlist>
258 <listitem>
259 <para>The VirtualBox web service (the "server"): this is the
260 <computeroutput>vboxwebsrv</computeroutput> executable shipped
261 with VirtualBox. Once you start this executable (which acts as a
262 HTTP server on a specific TCP/IP port), clients can connect to the
263 web service and thus control a VirtualBox installation.</para>
264 </listitem>
265
266 <listitem>
267 <para>VirtualBox also comes with WSDL files that describe the
268 services provided by the web service. You can find these files in
269 the <computeroutput>sdk/bindings/webservice/</computeroutput>
270 directory. These files are understood by the web service toolkits
271 that are shipped with most programming languages and enable you to
272 easily access a web service even if you don't use our
273 object-oriented client layers. VirtualBox is shipped with
274 pregenerated web service glue code for several languages (Python,
275 Perl, Java).</para>
276 </listitem>
277
278 <listitem>
279 <para>A client that connects to the web service in order to
280 control the VirtualBox installation.</para>
281
282 <para>Unless you play with some of the samples shipped with
283 VirtualBox, this needs to be written by you.</para>
284 </listitem>
285 </orderedlist></para>
286 </sect1>
287
288 <sect1 id="runvboxwebsrv">
289 <title>Running the web service</title>
290
291 <para>The web service ships in an stand-alone executable,
292 <computeroutput>vboxwebsrv</computeroutput>, that, when running, acts as
293 a HTTP server, accepts SOAP connections and processes them -- remotely
294 or from the same machine.<note>
295 <para>The web service executable is not contained with the
296 VirtualBox SDK, but instead ships with the standard VirtualBox
297 binary package for your specific platform. Since the SDK contains
298 only platform-independent text files and documentation, the binaries
299 are instead shipped with the platform-specific packages. For this
300 reason the information how to run it as a service is included in the
301 VirtualBox documentation.</para>
302 </note></para>
303
304 <para>The <computeroutput>vboxwebsrv</computeroutput> program, which
305 implements the web service, is a text-mode (console) program which,
306 after being started, simply runs until it is interrupted with Ctrl-C or
307 a kill command.</para>
308
309 <para>Once the web service is started, it acts as a front-end to the
310 VirtualBox installation of the user account that it is running under. In
311 other words, if the web service is run under the user account of
312 <computeroutput>user1</computeroutput>, it will see and manipulate the
313 virtual machines and other data represented by the VirtualBox data of
314 that user (for example, on a Linux machine, under
315 <computeroutput>/home/user1/.config/VirtualBox</computeroutput>; see the
316 VirtualBox User Manual for details on where this data is stored).</para>
317
318 <sect2 id="vboxwebsrv-ref">
319 <title>Command line options of vboxwebsrv</title>
320
321 <para>The web service supports the following command line
322 options:</para>
323
324 <itemizedlist>
325 <listitem>
326 <para><computeroutput>--help</computeroutput> (or
327 <computeroutput>-h</computeroutput>): print a brief summary of
328 command line options.</para>
329 </listitem>
330
331 <listitem>
332 <para><computeroutput>--background</computeroutput> (or
333 <computeroutput>-b</computeroutput>): run the web service as a
334 background daemon. This option is not supported on Windows
335 hosts.</para>
336 </listitem>
337
338 <listitem>
339 <para><computeroutput>--host</computeroutput> (or
340 <computeroutput>-H</computeroutput>): This specifies the host to
341 bind to and defaults to "localhost".</para>
342 </listitem>
343
344 <listitem>
345 <para><computeroutput>--port</computeroutput> (or
346 <computeroutput>-p</computeroutput>): This specifies which port to
347 bind to on the host and defaults to 18083.</para>
348 </listitem>
349
350 <listitem>
351 <para><computeroutput>--ssl</computeroutput> (or
352 <computeroutput>-s</computeroutput>): This enables SSL
353 support.</para>
354 </listitem>
355
356 <listitem>
357 <para><computeroutput>--keyfile</computeroutput> (or
358 <computeroutput>-K</computeroutput>): This specifies the file name
359 containing the server private key and the certificate. This is a
360 mandatory parameter if SSL is enabled.</para>
361 </listitem>
362
363 <listitem>
364 <para><computeroutput>--passwordfile</computeroutput> (or
365 <computeroutput>-a</computeroutput>): This specifies the file name
366 containing the password for the server private key. If unspecified
367 or an empty string is specified this is interpreted as an empty
368 password (i.e. the private key is not protected by a password). If
369 the file name <computeroutput>-</computeroutput> is specified then
370 then the password is read from the standard input stream, otherwise
371 from the specified file. The user is responsible for appropriate
372 access rights to protect the confidential password.</para>
373 </listitem>
374
375 <listitem>
376 <para><computeroutput>--cacert</computeroutput> (or
377 <computeroutput>-c</computeroutput>): This specifies the file name
378 containing the CA certificate appropriate for the server
379 certificate.</para>
380 </listitem>
381
382 <listitem>
383 <para><computeroutput>--capath</computeroutput> (or
384 <computeroutput>-C</computeroutput>): This specifies the directory
385 containing several CA certificates appropriate for the server
386 certificate.</para>
387 </listitem>
388
389 <listitem>
390 <para><computeroutput>--dhfile</computeroutput> (or
391 <computeroutput>-D</computeroutput>): This specifies the file name
392 containing the DH key. Alternatively it can contain the number of
393 bits of the DH key to generate. If left empty, RSA is used.</para>
394 </listitem>
395
396 <listitem>
397 <para><computeroutput>--randfile</computeroutput> (or
398 <computeroutput>-r</computeroutput>): This specifies the file name
399 containing the seed for the random number generator. If left empty,
400 an operating system specific source of the seed.</para>
401 </listitem>
402
403 <listitem>
404 <para><computeroutput>--timeout</computeroutput> (or
405 <computeroutput>-t</computeroutput>): This specifies the session
406 timeout, in seconds, and defaults to 300 (five minutes). A web
407 service client that has logged on but makes no calls to the web
408 service will automatically be disconnected after the number of
409 seconds specified here, as if it had called the
410 <computeroutput>IWebSessionManager::logoff()</computeroutput>
411 method provided by the web service itself.</para>
412
413 <para>It is normally vital that each web service client call this
414 method, as the web service can accumulate large amounts of memory
415 when running, especially if a web service client does not properly
416 release managed object references. As a result, this timeout value
417 should not be set too high, especially on machines with a high
418 load on the web service, or the web service may eventually deny
419 service.</para>
420 </listitem>
421
422 <listitem>
423 <para><computeroutput>--check-interval</computeroutput> (or
424 <computeroutput>-i</computeroutput>): This specifies the interval
425 in which the web service checks for timed-out clients, in seconds,
426 and defaults to 5. This normally does not need to be
427 changed.</para>
428 </listitem>
429
430 <listitem>
431 <para><computeroutput>--threads</computeroutput> (or
432 <computeroutput>-T</computeroutput>): This specifies the maximum
433 number or worker threads, and defaults to 100. This normally does
434 not need to be changed.</para>
435 </listitem>
436
437 <listitem>
438 <para><computeroutput>--keepalive</computeroutput> (or
439 <computeroutput>-k</computeroutput>): This specifies the maximum
440 number of requests which can be sent in one web service connection,
441 and defaults to 100. This normally does not need to be
442 changed.</para>
443 </listitem>
444
445 <listitem>
446 <para><computeroutput>--authentication</computeroutput> (or
447 <computeroutput>-A</computeroutput>): This specifies the desired
448 web service authentication method. If the parameter is not
449 specified or the empty string is specified it does not change the
450 authentication method, otherwise it is set to the specified value.
451 Using this parameter is a good measure against accidental
452 misconfiguration, as the web service ensures periodically that it
453 isn't changed.</para>
454 </listitem>
455
456 <listitem>
457 <para><computeroutput>--verbose</computeroutput> (or
458 <computeroutput>-v</computeroutput>): Normally, the web service
459 outputs only brief messages to the console each time a request is
460 served. With this option, the web service prints much more detailed
461 data about every request and the COM methods that those requests
462 are mapped to internally, which can be useful for debugging client
463 programs.</para>
464 </listitem>
465
466 <listitem>
467 <para><computeroutput>--pidfile</computeroutput> (or
468 <computeroutput>-P</computeroutput>): Name of the PID file which is
469 created when the daemon was started.</para>
470 </listitem>
471
472 <listitem>
473 <para><computeroutput>--logfile</computeroutput> (or
474 <computeroutput>-F</computeroutput>)
475 <computeroutput>&lt;file&gt;</computeroutput>: If this is
476 specified, the web service not only prints its output to the
477 console, but also writes it to the specified file. The file is
478 created if it does not exist; if it does exist, new output is
479 appended to it. This is useful if you run the web service
480 unattended and need to debug problems after they have
481 occurred.</para>
482 </listitem>
483
484 <listitem>
485 <para><computeroutput>--logrotate</computeroutput> (or
486 <computeroutput>-R</computeroutput>): Number of old log files to
487 keep, defaults to 10. Log rotation is disabled if set to 0.</para>
488 </listitem>
489
490 <listitem>
491 <para><computeroutput>--logsize</computeroutput> (or
492 <computeroutput>-S</computeroutput>): Maximum size of log file in
493 bytes, defaults to 100MB. Log rotation is triggered if the file
494 grows beyond this limit.</para>
495 </listitem>
496
497 <listitem>
498 <para><computeroutput>--loginterval</computeroutput> (or
499 <computeroutput>-I</computeroutput>): Maximum time interval to be
500 put in a log file before rotation is triggered, in seconds, and
501 defaults to one day.</para>
502 </listitem>
503 </itemizedlist>
504 </sect2>
505
506 <sect2 id="websrv_authenticate">
507 <title>Authenticating at web service logon</title>
508
509 <para>As opposed to the COM/XPCOM variant of the Main API, a client
510 that wants to use the web service must first log on by calling the
511 <link linkend="IWebsessionManager__logon">IWebsessionManager::logon()</link>
512 API that is specific to the
513 web service. Logon is necessary for the web service to be stateful;
514 internally, it maintains a session for each client that connects to
515 it.</para>
516
517 <para>The <computeroutput>IWebsessionManager::logon()</computeroutput>
518 API takes a user name and a password as arguments, which the web
519 service then passes to a customizable authentication plugin that
520 performs the actual authentication.</para>
521
522 <para>For testing purposes, it is recommended that you first disable
523 authentication with this command:
524 <screen>VBoxManage setproperty websrvauthlibrary null</screen></para>
525
526 <para><warning>
527 <para>This will cause all logons to succeed, regardless of user
528 name or password. This should of course not be used in a
529 production environment.</para>
530 </warning>Generally, the mechanism by which clients are
531 authenticated is configurable by way of the
532 <computeroutput>VBoxManage</computeroutput> command:</para>
533
534 <para><screen>VBoxManage setproperty websrvauthlibrary default|null|&lt;library&gt;</screen></para>
535
536 <para>This way you can specify any shared object/dynamic link module
537 that conforms with the specifications for VirtualBox external
538 authentication modules as laid out in section <emphasis
539 role="bold">VRDE authentication</emphasis> of the VirtualBox User
540 Manual; the web service uses the same kind of modules as the
541 VirtualBox VRDE server. For technical details on VirtualBox external
542 authentication modules see <xref linkend="vbox-auth"/></para>
543
544 <para>By default, after installation, the web service uses the
545 VBoxAuth module that ships with VirtualBox. This module uses PAM on
546 Linux hosts to authenticate users. Any valid username/password
547 combination is accepted, it does not have to be the username and
548 password of the user running the web service daemon. Unless
549 <computeroutput>vboxwebsrv</computeroutput> runs as root, PAM
550 authentication can fail, because sometimes the file
551 <computeroutput>/etc/shadow</computeroutput>, which is used by PAM, is
552 not readable. On most Linux distribution PAM uses a suid root helper
553 internally, so make sure you test this before deploying it. One can
554 override this behavior by setting the environment variable
555 <computeroutput>VBOX_PAM_ALLOW_INACTIVE</computeroutput> which will
556 suppress failures when unable to read the shadow password file. Please
557 use this variable carefully, and only if you fully understand what
558 you're doing.</para>
559 </sect2>
560 </sect1>
561 </chapter>
562
563 <chapter>
564 <title>Environment-specific notes</title>
565
566 <para>The Main API described in <xref linkend="sdkref_classes"/> and
567 <xref linkend="sdkref_enums"/> is mostly identical in all the supported
568 programming environments which have been briefly mentioned in the
569 introduction of this book. As a result, the Main API's general concepts
570 described in <xref linkend="concepts"/> are the same whether you use the
571 object-oriented web service (OOWS) for JAX-WS or a raw web service
572 connection via, say, Perl, or whether you use C++ COM bindings.</para>
573
574 <para>Some things are different depending on your environment, however.
575 These differences are explained in this chapter.</para>
576
577 <sect1 id="glue">
578 <title>Using the object-oriented web service (OOWS)</title>
579
580 <para>As explained in <xref linkend="webservice-or-com"/>, VirtualBox
581 ships with client-side libraries for Java, Python and PHP that allow you
582 to use the VirtualBox web service in an intuitive, object-oriented way.
583 These libraries shield you from the client-side complications of managed
584 object references and other implementation details that come with the
585 VirtualBox web service. (If you are interested in these complications,
586 have a look at <xref linkend="raw-webservice"/>).</para>
587
588 <para>We recommend that you start your experiments with the VirtualBox
589 web service by using our object-oriented client libraries for JAX-WS, a
590 web service toolkit for Java, which enables you to write code to
591 interact with VirtualBox in the simplest manner possible.</para>
592
593 <para>As "interfaces", "attributes" and "methods" are COM concepts,
594 please read the documentation in <xref linkend="sdkref_classes"/> and
595 <xref linkend="sdkref_enums"/> with the following notes in mind.</para>
596
597 <para>The OOWS bindings attempt to map the Main API as closely as
598 possible to the Java, Python and PHP languages. In other words, objects
599 are objects, interfaces become classes, and you can call methods on
600 objects as you would on local objects.</para>
601
602 <para>The main difference remains with attributes: to read an attribute,
603 call a "getXXX" method, with "XXX" being the attribute name with a
604 capitalized first letter. So when the Main API Reference says that
605 <computeroutput>IMachine</computeroutput> has a "name" attribute (see
606 <link linkend="IMachine__name">IMachine::name</link>), call
607 <computeroutput>getName()</computeroutput> on an IMachine object to
608 obtain a machine's name. Unless the attribute is marked as read-only in
609 the documentation, there will also be a corresponding "set"
610 method.</para>
611
612 <sect2 id="glue-jax-ws">
613 <title>The object-oriented web service for JAX-WS</title>
614
615 <para>JAX-WS is a powerful toolkit by Sun Microsystems to build both
616 server and client code with Java. It is part of Java 6 (JDK 1.6), but
617 can also be obtained separately for Java 5 (JDK 1.5). The VirtualBox
618 SDK comes with precompiled OOWS bindings working with both Java 5 and
619 6.</para>
620
621 <para>The following sections explain how to get the JAX-WS sample code
622 running and explain a few common practices when using the JAX-WS
623 object-oriented web service.</para>
624
625 <sect3>
626 <title>Preparations</title>
627
628 <para>Since JAX-WS is already integrated into Java 6, no additional
629 preparations are needed for Java 6.</para>
630
631 <para>If you are using Java 5 (JDK 1.5.x), you will first need to
632 download and install an external JAX-WS implementation, as Java 5
633 does not support JAX-WS out of the box; for example, you can
634 download one from here: <ulink
635 url="https://jax-ws.dev.java.net/2.1.4/JAXWS2.1.4-20080502.jar">https://jax-ws.dev.java.net/2.1.4/JAXWS2.1.4-20080502.jar</ulink>.
636 Then perform the installation (<computeroutput>java -jar
637 JAXWS2.1.4-20080502.jar</computeroutput>).</para>
638 </sect3>
639
640 <sect3>
641 <title>Getting started: running the sample code</title>
642
643 <para>To run the OOWS for JAX-WS samples that we ship with the SDK,
644 perform the following steps: <orderedlist>
645 <listitem>
646 <para>Open a terminal and change to the directory where the
647 JAX-WS samples reside.<footnote>
648 <para>In
649 <computeroutput>sdk/bindings/glue/java/</computeroutput>.</para>
650 </footnote> Examine the header of
651 <computeroutput>Makefile</computeroutput> to see if the
652 supplied variables (Java compiler, Java executable) and a few
653 other details match your system settings.</para>
654 </listitem>
655
656 <listitem>
657 <para>To start the VirtualBox web service, open a second
658 terminal and change to the directory where the VirtualBox
659 executables are located. Then type:
660 <screen>./vboxwebsrv -v</screen></para>
661
662 <para>The web service now waits for connections and will run
663 until you press Ctrl+C in this second terminal. The -v
664 argument causes it to log all connections to the terminal.
665 (See <xref linkend="runvboxwebsrv"/> for details on how
666 to run the web service.)</para>
667 </listitem>
668
669 <listitem>
670 <para>Back in the first terminal and still in the samples
671 directory, to start a simple client example just type:
672 <screen>make run16</screen></para>
673
674 <para>if you're on a Java 6 system; on a Java 5 system, run
675 <computeroutput>make run15</computeroutput> instead.</para>
676
677 <para>This should work on all Unix-like systems such as Linux
678 and Solaris. For Windows systems, use commands similar to what
679 is used in the Makefile.</para>
680
681 <para>This will compile the
682 <computeroutput>clienttest.java</computeroutput> code on the
683 first call and then execute the resulting
684 <computeroutput>clienttest</computeroutput> class to show the
685 locally installed VMs (see below).</para>
686 </listitem>
687 </orderedlist></para>
688
689 <para>The <computeroutput>clienttest</computeroutput> sample
690 imitates a few typical command line tasks that
691 <computeroutput>VBoxManage</computeroutput>, VirtualBox's regular
692 command-line front-end, would provide (see the VirtualBox User
693 Manual for details). In particular, you can run:<itemizedlist>
694 <listitem>
695 <para><computeroutput>java clienttest show
696 vms</computeroutput>: show the virtual machines that are
697 registered locally.</para>
698 </listitem>
699
700 <listitem>
701 <para><computeroutput>java clienttest list
702 hostinfo</computeroutput>: show various information about the
703 host this VirtualBox installation runs on.</para>
704 </listitem>
705
706 <listitem>
707 <para><computeroutput>java clienttest startvm
708 &lt;vmname|uuid&gt;</computeroutput>: start the given virtual
709 machine.</para>
710 </listitem>
711 </itemizedlist></para>
712
713 <para>The <computeroutput>clienttest.java</computeroutput> sample
714 code illustrates common basic practices how to use the VirtualBox
715 OOWS for JAX-WS, which we will explain in more detail in the
716 following chapters.</para>
717 </sect3>
718
719 <sect3>
720 <title>Logging on to the web service</title>
721
722 <para>Before a web service client can do anything useful, two
723 objects need to be created, as can be seen in the
724 <computeroutput>clienttest</computeroutput> constructor:<orderedlist>
725 <listitem>
726 <para>An instance of
727 <link linkend="IWebsessionManager">IWebsessionManager</link>,
728 which is an interface provided by the web service to manage
729 "web sessions" -- that is, stateful connections to the web
730 service with persistent objects upon which methods can be
731 invoked.</para>
732
733 <para>In the OOWS for JAX-WS, the IWebsessionManager class
734 must be constructed explicitly, and a URL must be provided in
735 the constructor that specifies where the web service (the
736 server) awaits connections. The code in
737 <computeroutput>clienttest.java</computeroutput> connects to
738 "http://localhost:18083/", which is the default.</para>
739
740 <para>The port number, by default 18083, must match the port
741 number given to the
742 <computeroutput>vboxwebsrv</computeroutput> command line; see
743 <xref linkend="vboxwebsrv-ref"/>.</para>
744 </listitem>
745
746 <listitem>
747 <para>After that, the code calls
748 <link linkend="IWebsessionManager__logon">IWebsessionManager::logon()</link>,
749 which is the first call that actually communicates with the
750 server. This authenticates the client with the web service and
751 returns an instance of
752 <link linkend="IVirtualBox">IVirtualBox</link>,
753 the most fundamental interface of the VirtualBox web service,
754 from which all other functionality can be derived.</para>
755
756 <para>If logon doesn't work, please take another look at <xref
757 linkend="websrv_authenticate"/>.</para>
758 </listitem>
759 </orderedlist></para>
760 </sect3>
761
762 <sect3>
763 <title>Object management</title>
764
765 <para>The current OOWS for JAX-WS has certain memory management
766 related limitations. When you no longer need an object, call its
767 <link linkend="IManagedObjectRef__release">IManagedObjectRef::release()</link>
768 method explicitly, which
769 frees appropriate managed reference, as is required by the raw
770 web service; see <xref linkend="managed-object-references"/> for
771 details. This limitation may be reconsidered in a future version of
772 the VirtualBox SDK.</para>
773 </sect3>
774 </sect2>
775
776 <sect2 id="glue-python-ws">
777 <title>The object-oriented web service for Python</title>
778
779 <para>VirtualBox comes with two flavors of a Python API: one for web
780 service, discussed here, and one for the COM/XPCOM API discussed in
781 <xref linkend="pycom"/>. The client code is mostly similar, except
782 for the initialization part, so it is up to the application developer
783 to choose the appropriate technology. Moreover, a common Python glue
784 layer exists, abstracting out concrete platform access details, see
785 <xref linkend="glue-python"/>.</para>
786
787 <para>The minimum supported Python version is 2.6.</para>
788
789 <para>As indicated in <xref linkend="webservice-or-com"/>, the
790 COM/XPCOM API gives better performance without the SOAP overhead, and
791 does not require a web server to be running. On the other hand, the
792 COM/XPCOM Python API requires a suitable Python bridge for your Python
793 installation (VirtualBox ships the most important ones for each
794 platform<footnote>
795 <para>On On Mac OS X only the Python versions bundled with the OS
796 are officially supported. This means 2.6 and 2.7 for 10.9 and later.</para>
797 </footnote>). On Windows, you can use the Main API from Python if the
798 Win32 extensions package for Python<footnote>
799 <para>See <ulink
800 url="http://sourceforge.net/project/showfiles.php?group_id=78018">http://sourceforge.net/project/showfiles.php?group_id=78018</ulink>.</para>
801 </footnote> is installed. Versions of Python Win32 extensions earlier
802 than 2.16 are known to have bugs, leading to issues with VirtualBox
803 Python bindings, so please make sure to use latest available Python
804 and Win32 extensions.</para>
805
806 <para>The VirtualBox OOWS for Python relies on the Python ZSI SOAP
807 implementation (see <ulink
808 url="http://pywebsvcs.sourceforge.net/zsi.html">http://pywebsvcs.sourceforge.net/zsi.html</ulink>),
809 which you will need to install locally before trying the examples.
810 Most Linux distributions come with package for ZSI, such as
811 <computeroutput>python-zsi</computeroutput> in Ubuntu.</para>
812
813 <para>To get started, open a terminal and change to the
814 <computeroutput>bindings/glue/python/sample</computeroutput>
815 directory, which contains an example of a simple interactive shell
816 able to control a VirtualBox instance. The shell is written using the
817 API layer, thereby hiding different implementation details, so it is
818 actually an example of code share among XPCOM, MSCOM and web services.
819 If you are interested in how to interact with the web services layer
820 directly, have a look at
821 <computeroutput>install/vboxapi/__init__.py</computeroutput> which
822 contains the glue layer for all target platforms (i.e. XPCOM, MSCOM
823 and web services).</para>
824
825 <para>To start the shell, perform the following commands:
826 <screen>/opt/VirtualBox/vboxwebsrv -t 0
827 # start web service with object autocollection disabled
828export VBOX_PROGRAM_PATH=/opt/VirtualBox
829 # your VirtualBox installation directory
830export VBOX_SDK_PATH=/home/youruser/vbox-sdk
831 # where you've extracted the SDK
832./vboxshell.py -w </screen>
833 See <xref linkend="vboxshell"/> for more
834 details on the shell's functionality. For you, as a VirtualBox
835 application developer, the vboxshell sample could be interesting as an
836 example of how to write code targeting both local and remote cases
837 (COM/XPCOM and SOAP). The common part of the shell is the same -- the
838 only difference is how it interacts with the invocation layer. You can
839 use the <computeroutput>connect</computeroutput> shell command to
840 connect to remote VirtualBox servers; in this case you can skip
841 starting the local web server.</para>
842 </sect2>
843
844 <sect2>
845 <title>The object-oriented web service for PHP</title>
846
847 <para>VirtualBox also comes with object-oriented web service (OOWS)
848 wrappers for PHP5. These wrappers rely on the PHP SOAP
849 Extension<footnote>
850 <para>See
851 <ulink url="https://www.php.net/soap">https://www.php.net/soap</ulink>.</para>
852 </footnote>, which can be installed by configuring PHP with
853 <computeroutput>--enable-soap</computeroutput>.</para>
854 </sect2>
855 </sect1>
856
857 <sect1 id="raw-webservice">
858 <title>Using the raw web service with any language</title>
859
860 <para>The following examples show you how to use the raw web service,
861 without the object-oriented client-side code that was described in the
862 previous chapter.</para>
863
864 <para>Generally, when reading the documentation in <xref
865 linkend="sdkref_classes"/> and <xref linkend="sdkref_enums"/>, due to
866 the limitations of SOAP and WSDL lined out in <xref
867 linkend="rawws-conventions"/>, please have the following notes in
868 mind:</para>
869
870 <para><orderedlist>
871 <listitem>
872 <para>Any COM method call becomes a <emphasis role="bold">plain
873 function call</emphasis> in the raw web service, with the object
874 as an additional first parameter (before the "real" parameters
875 listed in the documentation). So when the documentation says that
876 the <computeroutput>IVirtualBox</computeroutput> interface
877 supports the <computeroutput>createMachine()</computeroutput>
878 method (see
879 <link linkend="IVirtualBox__createMachine">IVirtualBox::createMachine()</link>),
880 the web service operation is
881 <computeroutput>IVirtualBox_createMachine(...)</computeroutput>,
882 and a managed object reference to an
883 <computeroutput>IVirtualBox</computeroutput> object must be passed
884 as the first argument.</para>
885 </listitem>
886
887 <listitem>
888 <para>For <emphasis role="bold">attributes</emphasis> in
889 interfaces, there will be at least one "get" function; there will
890 also be a "set" function, unless the attribute is "readonly". The
891 attribute name will be appended to the "get" or "set" prefix, with
892 a capitalized first letter. So, the "version" readonly attribute
893 of the <computeroutput>IVirtualBox</computeroutput> interface can
894 be retrieved by calling
895 <computeroutput>IVirtualBox_getVersion(vbox)</computeroutput>,
896 with <computeroutput>vbox</computeroutput> being the VirtualBox
897 object.</para>
898 </listitem>
899
900 <listitem>
901 <para>Whenever the API documentation says that a method (or an
902 attribute getter) returns an <emphasis
903 role="bold">object</emphasis>, it will returned a managed object
904 reference in the web service instead. As said above, managed
905 object references should be released if the web service client
906 does not log off again immediately!</para>
907 </listitem>
908 </orderedlist></para>
909
910 <para></para>
911
912 <sect2 id="webservice-java-sample">
913 <title>Raw web service example for Java with Axis</title>
914
915 <para>Axis is an older web service toolkit created by the Apache
916 foundation. If your distribution does not have it installed, you can
917 get a binary from <ulink
918 url="http://www.apache.org">http://www.apache.org</ulink>. The
919 following examples assume that you have Axis 1.4 installed.</para>
920
921 <para>The VirtualBox SDK ships with an example for Axis that, again,
922 is called <computeroutput>clienttest.java</computeroutput> and that
923 imitates a few of the commands of
924 <computeroutput>VBoxManage</computeroutput> over the wire.</para>
925
926 <para>Then perform the following steps:<orderedlist>
927 <listitem>
928 <para>Create a working directory somewhere. Under your
929 VirtualBox installation directory, find the
930 <computeroutput>sdk/webservice/samples/java/axis/</computeroutput>
931 directory and copy the file
932 <computeroutput>clienttest.java</computeroutput> to your working
933 directory.</para>
934 </listitem>
935
936 <listitem>
937 <para>Open a terminal in your working directory. Execute the
938 following command:
939 <screen>java org.apache.axis.wsdl.WSDL2Java /path/to/vboxwebService.wsdl</screen></para>
940
941 <para>The <computeroutput>vboxwebService.wsdl</computeroutput>
942 file should be located in the
943 <computeroutput>sdk/webservice/</computeroutput>
944 directory.</para>
945
946 <para>If this fails, your Apache Axis may not be located on your
947 system classpath, and you may have to adjust the CLASSPATH
948 environment variable. Something like this:
949 <screen>export CLASSPATH="/path-to-axis-1_4/lib/*":$CLASSPATH</screen></para>
950
951 <para>Use the directory where the Axis JAR files are located.
952 Mind the quotes so that your shell passes the "*" character to
953 the java executable without expanding. Alternatively, add a
954 corresponding <computeroutput>-classpath</computeroutput>
955 argument to the "java" call above.</para>
956
957 <para>If the command executes successfully, you should see an
958 "org" directory with subdirectories containing Java source files
959 in your working directory. These classes represent the
960 interfaces that the VirtualBox web service offers, as described
961 by the WSDL file.</para>
962
963 <para>This is the bit that makes using web services so
964 attractive to client developers: if a language's toolkit
965 understands WSDL, it can generate large amounts of support code
966 automatically. Clients can then easily use this support code and
967 can be done with just a few lines of code.</para>
968 </listitem>
969
970 <listitem>
971 <para>Next, compile the
972 <computeroutput>clienttest.java</computeroutput>
973 source:<screen>javac clienttest.java </screen></para>
974
975 <para>This should yield a "clienttest.class" file.</para>
976 </listitem>
977
978 <listitem>
979 <para>To start the VirtualBox web service, open a second
980 terminal and change to the directory where the VirtualBox
981 executables are located. Then type:
982 <screen>./vboxwebsrv -v</screen></para>
983
984 <para>The web service now waits for connections and will run
985 until you press Ctrl+C in this second terminal. The -v argument
986 causes it to log all connections to the terminal. (See <xref
987 linkend="runvboxwebsrv"/> for details on how to run the
988 web service.)</para>
989 </listitem>
990
991 <listitem>
992 <para>Back in the original terminal where you compiled the Java
993 source, run the resulting binary, which will then connect to the
994 web service:<screen>java clienttest</screen></para>
995
996 <para>The client sample will connect to the web service (on
997 localhost, but the code could be changed to connect remotely if
998 the web service was running on a different machine) and make a
999 number of method calls. It will output the version number of
1000 your VirtualBox installation and a list of all virtual machines
1001 that are currently registered (with a bit of seemingly random
1002 data, which will be explained later).</para>
1003 </listitem>
1004 </orderedlist></para>
1005 </sect2>
1006
1007 <sect2 id="raw-webservice-perl">
1008 <title>Raw web service example for Perl</title>
1009
1010 <para>We also ship a small sample for Perl. It uses the SOAP::Lite
1011 perl module to communicate with the VirtualBox web service.</para>
1012
1013 <para>The
1014 <computeroutput>sdk/bindings/webservice/perl/lib/</computeroutput>
1015 directory contains a pre-generated Perl module that allows for
1016 communicating with the web service from Perl. You can generate such a
1017 module yourself using the "stubmaker" tool that comes with SOAP::Lite,
1018 but since that tool is slow as well as sometimes unreliable, we are
1019 shipping a working module with the SDK for your convenience.</para>
1020
1021 <para>Perform the following steps:<orderedlist>
1022 <listitem>
1023 <para>If SOAP::Lite is not yet installed on your system, you
1024 will need to install the package first. On Debian-based systems,
1025 the package is called
1026 <computeroutput>libsoap-lite-perl</computeroutput>; on Gentoo,
1027 it's <computeroutput>dev-perl/SOAP-Lite</computeroutput>.</para>
1028 </listitem>
1029
1030 <listitem>
1031 <para>Open a terminal in the
1032 <computeroutput>sdk/bindings/webservice/perl/samples/</computeroutput>
1033 directory.</para>
1034 </listitem>
1035
1036 <listitem>
1037 <para>To start the VirtualBox web service, open a second
1038 terminal and change to the directory where the VirtualBox
1039 executables are located. Then type:
1040 <screen>./vboxwebsrv -v</screen></para>
1041
1042 <para>The web service now waits for connections and will run
1043 until you press Ctrl+C in this second terminal. The -v argument
1044 causes it to log all connections to the terminal. (See <xref
1045 linkend="runvboxwebsrv"/> for details on how to run the
1046 web service.)</para>
1047 </listitem>
1048
1049 <listitem>
1050 <para>In the first terminal with the Perl sample, run the
1051 clienttest.pl script:
1052 <screen>perl -I ../lib clienttest.pl</screen></para>
1053 </listitem>
1054 </orderedlist></para>
1055 </sect2>
1056
1057 <sect2>
1058 <title>Programming considerations for the raw web service</title>
1059
1060 <para>If you use the raw web service, you need to keep a number of
1061 things in mind, or you will sooner or later run into issues that are
1062 not immediately obvious. By contrast, the object-oriented client-side
1063 libraries described in <xref linkend="glue"/> take care of these
1064 things automatically and thus greatly simplify using the web
1065 service.</para>
1066
1067 <sect3 id="rawws-conventions">
1068 <title>Fundamental conventions</title>
1069
1070 <para>If you are familiar with other web services, you may find the
1071 VirtualBox web service to behave a bit differently to accommodate
1072 for the fact that VirtualBox web service more or less maps the
1073 VirtualBox Main COM API. The following main differences had to be
1074 taken care of:<itemizedlist>
1075 <listitem>
1076 <para>Web services, as expressed by WSDL, are not
1077 object-oriented. Even worse, they are normally stateless (or,
1078 in web services terminology, "loosely coupled"). Web service
1079 operations are entirely procedural, and one cannot normally
1080 make assumptions about the state of a web service between
1081 function calls.</para>
1082
1083 <para>In particular, this normally means that you cannot work
1084 on objects in one method call that were created by another
1085 call.</para>
1086 </listitem>
1087
1088 <listitem>
1089 <para>By contrast, the VirtualBox Main API, being expressed in
1090 COM, is object-oriented and works entirely on objects, which
1091 are grouped into public interfaces, which in turn have
1092 attributes and methods associated with them.</para>
1093 </listitem>
1094 </itemizedlist> For the VirtualBox web service, this results in
1095 three fundamental conventions:<orderedlist>
1096 <listitem>
1097 <para>All <emphasis role="bold">function names</emphasis> in
1098 the VirtualBox web service consist of an interface name and a
1099 method name, joined together by an underscore. This is because
1100 there are only functions ("operations") in WSDL, but no
1101 classes, interfaces, or methods.</para>
1102
1103 <para>In addition, all calls to the VirtualBox web service
1104 (except for logon, see below) take a <emphasis
1105 role="bold">managed object reference</emphasis> as the first
1106 argument, representing the object upon which the underlying
1107 method is invoked. (Managed object references are explained in
1108 detail below; see <xref
1109 linkend="managed-object-references"/>.)</para>
1110
1111 <para>So, when one would normally code, in the pseudo-code of
1112 an object-oriented language, to invoke a method upon an
1113 object:<screen>IMachine machine;
1114result = machine.getName();</screen></para>
1115
1116 <para>In the VirtualBox web service, this looks something like
1117 this (again, pseudo-code):<screen>IMachineRef machine;
1118result = IMachine_getName(machine);</screen></para>
1119 </listitem>
1120
1121 <listitem>
1122 <para>To make the web service stateful, and objects persistent
1123 between method calls, the VirtualBox web service introduces a
1124 <emphasis role="bold">session manager</emphasis> (by way of the
1125 <link linkend="IWebsessionManager">IWebsessionManager</link>
1126 interface), which manages object references. Any client wishing
1127 to interact with the web service must first log on to the
1128 session manager and in turn receives a managed object reference
1129 to an object that supports the
1130 <link linkend="IVirtualBox">IVirtualBox</link>
1131 interface (the basic interface in the Main API).</para>
1132 </listitem>
1133 </orderedlist></para>
1134
1135 <para>In other words, as opposed to other web services, <emphasis
1136 role="bold">the VirtualBox web service is both object-oriented and
1137 stateful.</emphasis></para>
1138 </sect3>
1139
1140 <sect3>
1141 <title>Example: A typical web service client session</title>
1142
1143 <para>A typical short web service session to retrieve the version
1144 number of the VirtualBox web service (to be precise, the underlying
1145 Main API version number) looks like this:<orderedlist>
1146 <listitem>
1147 <para>A client logs on to the web service by calling
1148 <link linkend="IWebsessionManager__logon">IWebsessionManager::logon()</link>
1149 with a valid user name and password. See
1150 <xref linkend="websrv_authenticate"/>
1151 for details about how authentication works.</para>
1152 </listitem>
1153
1154 <listitem>
1155 <para>On the server side,
1156 <computeroutput>vboxwebsrv</computeroutput> creates a session,
1157 which persists until the client calls
1158 <link linkend="IWebsessionManager__logoff">IWebsessionManager::logoff()</link>
1159 or the session times out after a configurable period of
1160 inactivity (see <xref linkend="vboxwebsrv-ref"/>).</para>
1161
1162 <para>For the new session, the web service creates an instance
1163 of <link linkend="IVirtualBox">IVirtualBox</link>.
1164 This interface is the most central one in the Main API and
1165 allows access to all other interfaces, either through
1166 attributes or method calls. For example, IVirtualBox contains
1167 a list of all virtual machines that are currently registered
1168 (as they would be listed on the left side of the VirtualBox
1169 main program).</para>
1170
1171 <para>The web service then creates a managed object reference
1172 for this instance of IVirtualBox and returns it to the calling
1173 client, which receives it as the return value of the logon
1174 call. Something like this:</para>
1175
1176 <screen>string oVirtualBox;
1177oVirtualBox = webservice.IWebsessionManager_logon("user", "pass");</screen>
1178
1179 <para>(The managed object reference "oVirtualBox" is just a
1180 string consisting of digits and dashes. However, it is a
1181 string with a meaning and will be checked by the web service.
1182 For details, see below. As hinted above,
1183 <link linkend="IWebsessionManager__logon">IWebsessionManager::logon()</link>
1184 is the <emphasis>only</emphasis> operation provided by the web
1185 service which does not take a managed object reference as the
1186 first argument!)</para>
1187 </listitem>
1188
1189 <listitem>
1190 <para>The VirtualBox Main API documentation says that the
1191 <computeroutput>IVirtualBox</computeroutput> interface has a
1192 <link linkend="IVirtualBox__version">version</link>
1193 attribute, which is a string. For each attribute, there is a
1194 "get" and a "set" method in COM, which maps to according
1195 operations in the web service. So, to retrieve the "version"
1196 attribute of this <computeroutput>IVirtualBox</computeroutput>
1197 object, the web service client does this:
1198 <screen>string version;
1199version = webservice.IVirtualBox_getVersion(oVirtualBox);
1200
1201print version;</screen></para>
1202
1203 <para>And it will print
1204 "&VBOX_VERSION_MAJOR;.&VBOX_VERSION_MINOR;.&VBOX_VERSION_BUILD;".</para>
1205 </listitem>
1206
1207 <listitem>
1208 <para>The web service client calls
1209 <link linkend="IWebsessionManager__logoff">IWebsessionManager::logoff()</link>
1210 with the VirtualBox managed object reference. This will clean
1211 up all allocated resources.</para>
1212 </listitem>
1213 </orderedlist></para>
1214 </sect3>
1215
1216 <sect3 id="managed-object-references">
1217 <title>Managed object references</title>
1218
1219 <para>To a web service client, a managed object reference looks like
1220 a string: two 64-bit hex numbers separated by a dash. This string,
1221 however, represents a COM object that "lives" in the web service
1222 process. The two 64-bit numbers encoded in the managed object
1223 reference represent a session ID (which is the same for all objects
1224 in the same web service session, i.e. for all objects after one
1225 logon) and a unique object ID within that session.</para>
1226
1227 <para>Managed object references are created in two
1228 situations:<orderedlist>
1229 <listitem>
1230 <para>When a client logs on, by calling
1231 <link linkend="IWebsessionManager__logon">IWebsessionManager::logon()</link>.</para>
1232
1233 <para>Upon logon, the websession manager creates one instance
1234 of <link linkend="IVirtualBox">IVirtualBox</link>,
1235 which can be used for directly performing calls to its
1236 methods, or used as a parameter for calling some methods of
1237 <link linkend="IWebsessionManager">IWebsessionManager</link>.
1238 Creating Main API session objects is performed using
1239 <link linkend="IWebsessionManager__getSessionObject">IWebsessionManager::getSessionObject()</link>.</para>
1240
1241 <para>(Technically, there is always only one
1242 <link linkend="IVirtualBox">IVirtualBox</link> object, which
1243 is shared between all websessions and clients, as it is a COM
1244 singleton. However, each session receives its own managed
1245 object reference to it.)</para>
1246 </listitem>
1247
1248 <listitem>
1249 <para>Whenever a web service clients invokes an operation
1250 whose COM implementation creates COM objects.</para>
1251
1252 <para>For example,
1253 <link linkend="IVirtualBox__createMachine">IVirtualBox::createMachine()</link>
1254 creates a new instance of
1255 <link linkend="IMachine">IMachine</link>;
1256 the COM object returned by the COM method call is then wrapped
1257 into a managed object reference by the web server, and this
1258 reference is returned to the web service client.</para>
1259 </listitem>
1260 </orderedlist></para>
1261
1262 <para>Internally, in the web service process, each managed object
1263 reference is simply a small data structure, containing a COM pointer
1264 to the "real" COM object, the web session ID and the object ID. This
1265 structure is allocated on creation and stored efficiently in hashes,
1266 so that the web service can look up the COM object quickly whenever
1267 a web service client wishes to make a method call. The random
1268 session ID also ensures that one web service client cannot intercept
1269 the objects of another.</para>
1270
1271 <para>Managed object references are not destroyed automatically and
1272 must be released by explicitly calling
1273 <link linkend="IManagedObjectRef__release">IManagedObjectRef::release()</link>.
1274 This is important, as
1275 otherwise hundreds or thousands of managed object references (and
1276 corresponding COM objects, which can consume much more memory!) can
1277 pile up in the web service process and eventually cause it to deny
1278 service.</para>
1279
1280 <para>To reiterate: The underlying COM object, which the reference
1281 points to, is only freed if the managed object reference is
1282 released. It is therefore vital that web service clients properly
1283 clean up after the managed object references that are returned to
1284 them.</para>
1285
1286 <para>When a web service client calls
1287 <link linkend="IWebsessionManager__logoff">IWebsessionManager::logoff()</link>,
1288 all managed object references created during the session are
1289 automatically freed. For short-lived sessions that do not create a
1290 lot of objects, logging off may therefore be sufficient, although it
1291 is certainly not "best practice".</para>
1292 </sect3>
1293
1294 <sect3>
1295 <title>Some more detail about web service operation</title>
1296
1297 <sect4 id="soap">
1298 <title>SOAP messages</title>
1299
1300 <para>Whenever a client makes a call to a web service, this
1301 involves a complicated procedure internally. These calls are
1302 remote procedure calls. Each such procedure call typically
1303 consists of two "message" being passed, where each message is a
1304 plain-text HTTP request with a standard HTTP header and a special
1305 XML document following. This XML document encodes the name of the
1306 procedure to call and the argument names and values passed to
1307 it.</para>
1308
1309 <para>To give you an idea of what such a message looks like,
1310 assuming that a web service provides a procedure called
1311 "SayHello", which takes a string "name" as an argument and returns
1312 "Hello" with a space and that name appended, the request message
1313 could look like this:</para>
1314
1315 <para><screen>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
1316&lt;SOAP-ENV:Envelope
1317 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
1318 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
1319 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1320 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
1321 xmlns:test="http://test/"&gt;
1322&lt;SOAP-ENV:Body&gt;
1323 &lt;test:SayHello&gt;
1324 &lt;name&gt;Peter&lt;/name&gt;
1325 &lt;/test:SayHello&gt;
1326 &lt;/SOAP-ENV:Body&gt;
1327&lt;/SOAP-ENV:Envelope&gt;</screen>A similar message -- the "response" message
1328 -- would be sent back from the web service to the client,
1329 containing the return value "Hello Peter".</para>
1330
1331 <para>Most programming languages provide automatic support to
1332 generate such messages whenever code in that programming language
1333 makes such a request. In other words, these programming languages
1334 allow for writing something like this (in pseudo-C++ code):</para>
1335
1336 <para><screen>webServiceClass service("localhost", 18083); // server and port
1337string result = service.SayHello("Peter"); // invoke remote procedure</screen>
1338 and would, for these two pseudo-lines, automatically perform these
1339 steps:</para>
1340
1341 <para><orderedlist>
1342 <listitem>
1343 <para>prepare a connection to a web service running on port
1344 18083 of "localhost";</para>
1345 </listitem>
1346
1347 <listitem>
1348 <para>for the <computeroutput>SayHello()</computeroutput>
1349 function of the web service, generate a SOAP message like in
1350 the above example by encoding all arguments of the remote
1351 procedure call (which could involve all kinds of type
1352 conversions and complex marshalling for arrays and
1353 structures);</para>
1354 </listitem>
1355
1356 <listitem>
1357 <para>connect to the web service via HTTP and send that
1358 message;</para>
1359 </listitem>
1360
1361 <listitem>
1362 <para>wait for the web service to send a response
1363 message;</para>
1364 </listitem>
1365
1366 <listitem>
1367 <para>decode that response message and put the return value
1368 of the remote procedure into the "result" variable.</para>
1369 </listitem>
1370 </orderedlist></para>
1371 </sect4>
1372
1373 <sect4 id="wsdl">
1374 <title>Service descriptions in WSDL</title>
1375
1376 <para>In the above explanations about SOAP, it was left open how
1377 the programming language learns about how to translate function
1378 calls in its own syntax into proper SOAP messages. In other words,
1379 the programming language needs to know what operations the web
1380 service supports and what types of arguments are required for the
1381 operation's data in order to be able to properly serialize and
1382 deserialize the data to and from the web service. For example, if
1383 a web service operation expects a number in "double" floating
1384 point format for a particular parameter, the programming language
1385 cannot send to it a string instead.</para>
1386
1387 <para>For this, the Web Service Definition Language (WSDL) was
1388 invented, another XML substandard that describes exactly what
1389 operations the web service supports and, for each operation, which
1390 parameters and types are needed with each request and response
1391 message. WSDL descriptions can be incredibly verbose, and one of
1392 the few good things that can be said about this standard is that
1393 it is indeed supported by most programming languages.</para>
1394
1395 <para>So, if it is said that a programming language "supports" web
1396 services, this typically means that a programming language has
1397 support for parsing WSDL files and somehow integrating the remote
1398 procedure calls into the native language syntax -- for example,
1399 like in the Java sample shown in <xref
1400 linkend="webservice-java-sample"/>.</para>
1401
1402 <para>For details about how programming languages support web
1403 services, please refer to the documentation that comes with the
1404 individual languages. Here are a few pointers:</para>
1405
1406 <orderedlist>
1407 <listitem>
1408 <para>For <emphasis role="bold">C++, </emphasis> among many
1409 others, the gSOAP toolkit is a good option. Parts of gSOAP are
1410 also used in VirtualBox to implement the VirtualBox web
1411 service.</para>
1412 </listitem>
1413
1414 <listitem>
1415 <para>For <emphasis role="bold">Java, </emphasis> there are
1416 several implementations already described in this document
1417 (see <xref linkend="glue-jax-ws"/> and <xref
1418 linkend="webservice-java-sample"/>).</para>
1419 </listitem>
1420
1421 <listitem>
1422 <para><emphasis role="bold">Perl</emphasis> supports WSDL via
1423 the SOAP::Lite package. This in turn comes with a tool called
1424 <computeroutput>stubmaker.pl</computeroutput> that allows you
1425 to turn any WSDL file into a Perl package that you can import.
1426 (You can also import any WSDL file "live" by having it parsed
1427 every time the script runs, but that can take a while.) You
1428 can then code (again, assuming the above example):
1429 <screen>my $result = servicename-&gt;sayHello("Peter");</screen>
1430 </para>
1431
1432 <para>A sample that uses SOAP::Lite was described in <xref
1433 linkend="raw-webservice-perl"/>.</para>
1434 </listitem>
1435 </orderedlist>
1436 </sect4>
1437 </sect3>
1438 </sect2>
1439 </sect1>
1440
1441 <sect1 id="api_com">
1442 <title>Using COM/XPCOM directly</title>
1443
1444 <para>If you do not require <emphasis>remote</emphasis> procedure calls
1445 such as those offered by the VirtualBox web service, and if you know
1446 Python or C++ as well as COM, you might find it preferable to program
1447 VirtualBox's Main API directly via COM.</para>
1448
1449 <para>COM stands for "Component Object Model" and is a standard
1450 originally introduced by Microsoft in the 1990s for Microsoft Windows.
1451 It allows for organizing software in an object-oriented way and across
1452 processes; code in one process may access objects that live in another
1453 process.</para>
1454
1455 <para>COM has several advantages: it is language-neutral, meaning that
1456 even though all of VirtualBox is internally written in C++, programs
1457 written in other languages could communicate with it. COM also cleanly
1458 separates interface from implementation, so that external programs need
1459 not know anything about the messy and complicated details of VirtualBox
1460 internals.</para>
1461
1462 <para>On a Windows host, all parts of VirtualBox will use the COM
1463 functionality that is native to Windows. On other hosts (including
1464 Linux), VirtualBox comes with a built-in implementation of XPCOM, as
1465 originally created by the Mozilla project, which we have enhanced to
1466 support interprocess communication on a level comparable to Microsoft
1467 COM. Internally, VirtualBox has an abstraction layer that allows the
1468 same VirtualBox code to work both with native COM as well as our XPCOM
1469 implementation.</para>
1470
1471 <sect2 id="pycom">
1472 <title>Python COM API</title>
1473
1474 <para>On Windows, Python scripts can use COM and VirtualBox interfaces
1475 to control almost all aspects of virtual machine execution. As an
1476 example, use the following commands to instantiate the VirtualBox
1477 object and start a VM: <screen>
1478 vbox = win32com.client.Dispatch("VirtualBox.VirtualBox")
1479 session = win32com.client.Dispatch("VirtualBox.Session")
1480 mach = vbox.findMachine("uuid or name of machine to start")
1481 progress = mach.launchVMProcess(session, "gui", "")
1482 progress.waitForCompletion(-1)
1483 </screen> Also, see
1484 <computeroutput>/bindings/glue/python/samples/vboxshell.py</computeroutput>
1485 for more advanced usage scenarious. However, unless you have specific
1486 requirements, we strongly recommend to use the generic glue layer
1487 described in the next section to access MS COM objects.</para>
1488 </sect2>
1489
1490 <sect2 id="glue-python">
1491 <title>Common Python bindings layer</title>
1492
1493 <para>As different wrappers ultimately provide access to the same
1494 underlying API, and to simplify porting and development of Python
1495 application using the VirtualBox Main API, we developed a common glue
1496 layer that abstracts out most platform-specific details from the
1497 application and allows the developer to focus on application logic.
1498 The VirtualBox installer automatically sets up this glue layer for the
1499 system default Python install. See below for details on how to set up
1500 the glue layer if you want to use a different Python
1501 installation.</para>
1502
1503 <para>The minimum supported Python version is 2.6.</para>
1504
1505 <para>In this layer, the class
1506 <computeroutput>VirtualBoxManager</computeroutput> hides most
1507 platform-specific details. It can be used to access both the local
1508 (COM) and the web service based API. The following code can be used by
1509 an application to use the glue layer.</para>
1510
1511 <screen># This code assumes vboxapi.py from VirtualBox distribution
1512# being in PYTHONPATH, or installed system-wide
1513from vboxapi import VirtualBoxManager
1514
1515# This code initializes VirtualBox manager with default style
1516# and parameters
1517virtualBoxManager = VirtualBoxManager(None, None)
1518
1519# Alternatively, one can be more verbose, and initialize
1520# glue with web service backend, and provide authentication
1521# information
1522virtualBoxManager = VirtualBoxManager("WEBSERVICE",
1523 {'url':'http://myhost.com::18083/',
1524 'user':'me',
1525 'password':'secret'}) </screen>
1526
1527 <para>We supply the <computeroutput>VirtualBoxManager</computeroutput>
1528 constructor with 2 arguments: style and parameters. Style defines
1529 which bindings style to use (could be "MSCOM", "XPCOM" or
1530 "WEBSERVICE"), and if set to <computeroutput>None</computeroutput>
1531 defaults to usable platform bindings (MS COM on Windows, XPCOM on
1532 other platforms). The second argument defines parameters, passed to
1533 the platform-specific module, as we do in the second example, where we
1534 pass username and password to be used to authenticate against the web
1535 service.</para>
1536
1537 <para>After obtaining the
1538 <computeroutput>VirtualBoxManager</computeroutput> instance, one can
1539 perform operations on the IVirtualBox class. For example, the
1540 following code will a start virtual machine by name or ID:</para>
1541
1542 <screen>from vboxapi import VirtualBoxManager
1543mgr = VirtualBoxManager(None, None)
1544vbox = mgr.getVirtualBox()
1545name = "Linux"
1546mach = vbox.findMachine(name)
1547session = mgr.getSessionObject(vbox)
1548progress = mach.launchVMProcess(session, "gui", "")
1549progress.waitForCompletion(-1)
1550mgr.closeMachineSession(session)
1551 </screen>
1552 <para>
1553 Following code will print all registered machines and their log
1554 folders
1555 </para>
1556 <screen>from vboxapi import VirtualBoxManager
1557mgr = VirtualBoxManager(None, None)
1558vbox = mgr.getVirtualBox()
1559
1560for m in mgr.getArray(vbox, 'machines'):
1561 print "Machine '%s' logs in '%s'" %(m.name, m.logFolder)
1562 </screen>
1563
1564 <para>Code above demonstrates cross-platform access to array properties
1565 (certain limitations prevent one from using
1566 <computeroutput>vbox.machines</computeroutput> to access a list of
1567 available virtual machines in case of XPCOM), and a mechanism of
1568 uniform session creation and closing
1569 (<computeroutput>mgr.getSessionObject()</computeroutput>).</para>
1570
1571 <para>In case you want to use the glue layer with a different Python
1572 installation, use these steps in a shell to add the necessary
1573 files:</para>
1574
1575 <screen> # cd VBOX_INSTALL_PATH/sdk/installer
1576 # PYTHON vboxapisetup.py install</screen>
1577 </sect2>
1578
1579 <sect2 id="cppcom">
1580 <title>C++ COM API</title>
1581
1582 <para>C++ is the language that VirtualBox itself is written in, so C++
1583 is the most direct way to use the Main API -- but it is not
1584 necessarily the easiest, as using COM and XPCOM has its own set of
1585 complications.</para>
1586
1587 <para>VirtualBox ships with sample programs that demonstrate how to
1588 use the Main API to implement a number of tasks on your host platform.
1589 These samples can be found in the
1590 <computeroutput>/bindings/xpcom/samples</computeroutput> directory for
1591 Linux, Mac OS X and Solaris and
1592 <computeroutput>/bindings/mscom/samples</computeroutput> for Windows.
1593 The two samples are actually different, because the one for Windows
1594 uses native COM, whereas the other uses our XPCOM implementation, as
1595 described above.</para>
1596
1597 <para>Since COM and XPCOM are conceptually very similar but vary in
1598 the implementation details, we have created a "glue" layer that
1599 shields COM client code from these differences. All VirtualBox uses is
1600 this glue layer, so the same code written once works on both Windows
1601 hosts (with native COM) as well as on other hosts (with our XPCOM
1602 implementation). It is recommended to always use this glue code
1603 instead of using the COM and XPCOM APIs directly, as it is very easy
1604 to make your code completely independent from the platform it is
1605 running on.<!-- A third sample,
1606 <computeroutput>tstVBoxAPIGlue.cpp</computeroutput>, illustrates how to
1607 use the glue layer.
1608--></para>
1609
1610 <para>In order to encapsulate platform differences between Microsoft
1611 COM and XPCOM, the following items should be kept in mind when using
1612 the glue layer:</para>
1613
1614 <para><orderedlist>
1615 <listitem>
1616 <para><emphasis role="bold">Attribute getters and
1617 setters.</emphasis> COM has the notion of "attributes" in
1618 interfaces, which roughly compare to C++ member variables in
1619 classes. The difference is that for each attribute declared in
1620 an interface, COM automatically provides a "get" method to
1621 return the attribute's value. Unless the attribute has been
1622 marked as "readonly", a "set" attribute is also provided.</para>
1623
1624 <para>To illustrate, the IVirtualBox interface has a "version"
1625 attribute, which is read-only and of the "wstring" type (the
1626 standard string type in COM). As a result, you can call the
1627 "get" method for this attribute to retrieve the version number
1628 of VirtualBox.</para>
1629
1630 <para>Unfortunately, the implementation differs between COM and
1631 XPCOM. Microsoft COM names the "get" method like this:
1632 <computeroutput>get_Attribute()</computeroutput>, whereas XPCOM
1633 uses this syntax:
1634 <computeroutput>GetAttribute()</computeroutput> (and accordingly
1635 for "set" methods). To hide these differences, the VirtualBox
1636 glue code provides the
1637 <computeroutput>COMGETTER(attrib)</computeroutput> and
1638 <computeroutput>COMSETTER(attrib)</computeroutput> macros. So,
1639 <computeroutput>COMGETTER(version)()</computeroutput> (note, two
1640 pairs of brackets) expands to
1641 <computeroutput>get_Version()</computeroutput> on Windows and
1642 <computeroutput>GetVersion()</computeroutput> on other
1643 platforms.</para>
1644 </listitem>
1645
1646 <listitem>
1647 <para><emphasis role="bold">Unicode conversions.</emphasis>
1648 While the rest of the modern world has pretty much settled on
1649 encoding strings in UTF-8, COM, unfortunately, uses UCS-16
1650 encoding. This requires a lot of conversions, in particular
1651 between the VirtualBox Main API and the Qt GUI, which, like the
1652 rest of Qt, likes to use UTF-8.</para>
1653
1654 <para>To facilitate these conversions, VirtualBox provides the
1655 <computeroutput>com::Bstr</computeroutput> and
1656 <computeroutput>com::Utf8Str</computeroutput> classes, which
1657 support all kinds of conversions back and forth.</para>
1658 </listitem>
1659
1660 <listitem>
1661 <para><emphasis role="bold">COM autopointers.</emphasis>
1662 Possibly the greatest pain of using COM -- reference counting --
1663 is alleviated by the
1664 <computeroutput>ComPtr&lt;&gt;</computeroutput> template
1665 provided by the <computeroutput>ptr.h</computeroutput> file in
1666 the glue layer.</para>
1667 </listitem>
1668 </orderedlist></para>
1669 </sect2>
1670
1671 <sect2 id="event-queue">
1672 <title>Event queue processing</title>
1673
1674 <para>Both VirtualBox client programs and frontends should
1675 periodically perform processing of the main event queue, and do that
1676 on the application's main thread. In case of a typical GUI Windows/Mac
1677 OS application this happens automatically in the GUI's dispatch loop.
1678 However, for CLI only application, the appropriate actions have to be
1679 taken. For C++ applications, the VirtualBox SDK provided glue method
1680 <screen>
1681 int EventQueue::processEventQueue(uint32_t cMsTimeout)
1682 </screen> can be used for both blocking and non-blocking operations.
1683 For the Python bindings, a common layer provides the method <screen>
1684 VirtualBoxManager.waitForEvents(ms)
1685 </screen> with similar semantics.</para>
1686
1687 <para>Things get somewhat more complicated for situations where an
1688 application using VirtualBox cannot directly control the main event
1689 loop and the main event queue is separated from the event queue of the
1690 programming librarly (for example in case of Qt on Unix platforms). In
1691 such a case, the application developer is advised to use a
1692 platform/toolkit specific event injection mechanism to force event
1693 queue checks either based on periodical timer events delivered to the
1694 main thread, or by using custom platform messages to notify the main
1695 thread when events are available. See the VBoxSDL and Qt (VirtualBox)
1696 frontends as examples.</para>
1697 </sect2>
1698
1699 <sect2 id="vbcom">
1700 <title>Visual Basic and Visual Basic Script (VBS) on Windows
1701 hosts</title>
1702
1703 <para>On Windows hosts, one can control some of the VirtualBox Main
1704 API functionality from VBS scripts, and pretty much everything from
1705 Visual Basic programs.<footnote>
1706 <para>The difference results from the way VBS treats COM
1707 safearrays, which are used to keep lists in the Main API. VBS
1708 expects every array element to be a
1709 <computeroutput>VARIANT</computeroutput>, which is too strict a
1710 limitation for any high performance API. We may lift this
1711 restriction for interface APIs in a future version, or
1712 alternatively provide conversion APIs.</para>
1713 </footnote></para>
1714
1715 <para>VBS is scripting language available in any recent Windows
1716 environment. As an example, the following VBS code will print
1717 VirtualBox version: <screen>
1718 set vb = CreateObject("VirtualBox.VirtualBox")
1719 Wscript.Echo "VirtualBox version " &amp; vb.version
1720 </screen> See
1721 <computeroutput>bindings/mscom/vbs/sample/vboxinfo.vbs</computeroutput>
1722 for the complete sample.</para>
1723
1724 <para>Visual Basic is a popular high level language capable of
1725 accessing COM objects. The following VB code will iterate over all
1726 available virtual machines:<screen>
1727 Dim vb As VirtualBox.IVirtualBox
1728
1729 vb = CreateObject("VirtualBox.VirtualBox")
1730 machines = ""
1731 For Each m In vb.Machines
1732 m = m &amp; " " &amp; m.Name
1733 Next
1734 </screen> See
1735 <computeroutput>bindings/mscom/vb/sample/vboxinfo.vb</computeroutput>
1736 for the complete sample.</para>
1737 </sect2>
1738
1739 <sect2 id="cbinding">
1740 <title>C binding to VirtualBox API</title>
1741
1742 <para>The VirtualBox API originally is designed as object oriented,
1743 using XPCOM or COM as the middleware, which translates natively to C++.
1744 This means that in order to use it from C there needs to be some
1745 helper code to bridge the language differences and reduce the
1746 differences between platforms.</para>
1747
1748 <sect3 id="capi_glue">
1749 <title>Cross-platform C binding to VirtualBox API</title>
1750
1751 <para>Starting with version 4.3, VirtualBox offers a C binding
1752 which allows using the same C client sources for all platforms,
1753 covering Windows, Linux, Mac OS X and Solaris. It is the
1754 preferred way to write API clients, even though the old style
1755 is still available.</para>
1756
1757 </sect3>
1758
1759 <sect3 id="c-gettingstarted">
1760 <title>Getting started</title>
1761
1762 <para>The following sections describe how to use the VirtualBox API
1763 in a C program. The necessary files are included in the SDK, in the
1764 directories <computeroutput>sdk/bindings/c/include</computeroutput>
1765 and <computeroutput>sdk/bindings/c/glue</computeroutput>.</para>
1766
1767 <para>As part of the SDK, a sample program
1768 <computeroutput>tstCAPIGlue.c</computeroutput> is provided in the
1769 directory <computeroutput>sdk/bindings/c/samples</computeroutput>
1770 which demonstrates
1771 using the C binding to initialize the API, get handles for
1772 VirtualBox and Session objects, make calls to list and start virtual
1773 machines, monitor events, and uninitialize resources when done. The
1774 sample program is trying to illustrate all relevant concepts, so it
1775 is a great source of detail information. Among many other generally
1776 useful code sequences it contains a function which shows how to
1777 retrieve error details in C code if they are available from the API
1778 call.</para>
1779
1780 <para>The sample program <computeroutput>tstCAPIGlue</computeroutput>
1781 can be built using the provided
1782 <computeroutput>Makefile</computeroutput> and can be run without
1783 arguments.</para>
1784
1785 <para>It uses the VBoxCAPIGlue library (source code is in directory
1786 <computeroutput>sdk/bindings/c/glue</computeroutput>, to be used in
1787 your API client code) to open the C binding layer during runtime,
1788 which is preferred to other means as it isolates the code which
1789 locates the necessary dynamic library, using a known working way
1790 which works on all platforms. If you encounter problems with this
1791 glue code in <computeroutput>VBoxCAPIGlue.c</computeroutput>, let the
1792 VirtualBox developers know, rather than inventing incompatible
1793 solutions.</para>
1794
1795 <para>The following sections document the important concepts needed
1796 to correctly use the C binding, as it is vital for developing API
1797 client code which manages memory correctly, updates the reference
1798 counters correctly, avoiding crashes and memory leaks. Often API
1799 clients need to handle events, so the C API specifics are also
1800 described below.</para>
1801 </sect3>
1802
1803 <sect3 id="c-initialization">
1804 <title>VirtualBox C API initialization</title>
1805
1806 <para>Just like in C++, the API and the underlying middleware needs
1807 to be initialized before it can be used. The
1808 <computeroutput>VBoxCAPI_v4_3.h</computeroutput> header provides the
1809 interface to the C binding, but you can alternatively and more
1810 conveniently also include
1811 <computeroutput>VBoxCAPIGlue.h</computeroutput>,
1812 as this avoids the VirtualBox version dependent header file name and
1813 makes sure the global variable <code>g_pVBoxFuncs</code> contains a
1814 pointer to the structure which contains the helper function pointers.
1815 Here's how to initialize the C API:<screen>#include "VBoxCAPIGlue.h"
1816...
1817IVirtualBoxClient *vboxclient = NULL;
1818IVirtualBox *vbox = NULL;
1819ISession *session = NULL;
1820HRESULT rc;
1821ULONG revision;
1822
1823/*
1824 * VBoxCGlueInit() loads the necessary dynamic library, handles errors
1825 * (producing an error message hinting what went wrong) and gives you
1826 * the pointer to the function table (g_pVBoxFuncs).
1827 *
1828 * Once you get the function table, then how and which functions
1829 * to use is explained below.
1830 *
1831 * g_pVBoxFuncs-&gt;pfnClientInitialize does all the necessary startup
1832 * action and provides us with pointers to an IVirtualBoxClient instance.
1833 * It should be matched by a call to g_pVBoxFuncs-&gt;pfnClientUninitialize()
1834 * when done.
1835 */
1836
1837if (VBoxCGlueInit())
1838{
1839 fprintf(stderr, "s: FATAL: VBoxCGlueInit failed: %s\n",
1840 argv[0], g_szVBoxErrMsg);
1841 return EXIT_FAILURE;
1842}
1843
1844g_pVBoxFuncs-&gt;pfnClientInitialize(NULL, &amp;vboxclient);
1845if (!vboxclient)
1846{
1847 fprintf(stderr, "%s: FATAL: could not get VirtualBoxClient reference\n",
1848 argv[0]);
1849 return EXIT_FAILURE;
1850}</screen></para>
1851
1852 <para>If <computeroutput>vboxclient</computeroutput> is still
1853 <computeroutput>NULL</computeroutput> this means the initializationi
1854 failed and the VirtualBox C API cannot be used.</para>
1855
1856 <para>It is possible to write C applications using multiple threads
1857 which all use the VirtualBox API, as long as you're initializing
1858 the C API in each thread which your application creates. This is done
1859 with <code>g_pVBoxFuncs->pfnClientThreadInitialize()</code> and
1860 likewise before the thread is terminated the API must be
1861 uninitialized with
1862 <code>g_pVBoxFuncs->pfnClientThreadUninitialize()</code>. You don't
1863 have to use these functions in worker threads created by COM/XPCOM
1864 (which you might observe if your code uses active event handling),
1865 everything is initialized correctly already. On Windows the C
1866 bindings create a marshaller which supports a wide range of COM
1867 threading models, from STA to MTA, so you don't have to worry about
1868 these details unless you plan to use active event handlers. See
1869 the sample code how to get this to work reliably (in other words
1870 think twice if passive event handling isn't the better solution after
1871 you looked at the sample code).</para>
1872 </sect3>
1873
1874 <sect3 id="c-invocation">
1875 <title>C API attribute and method invocation</title>
1876
1877 <para>Method invocation is straightforward. It looks pretty much
1878 like the C++ way, by using a macro which internally accesses the
1879 vtable, and additionally needs to be passed a pointer to the objecti
1880 as the first argument to serve as the
1881 <computeroutput>this</computeroutput> pointer.</para>
1882
1883 <para>Using the C binding, all method invocations return a numeric
1884 result code of type <code>HRESULT</code> (with a few exceptions
1885 which normally are not relevant).</para>
1886
1887 <para>If an interface is specified as returning an object, a pointer
1888 to a pointer to the appropriate object must be passed as the last
1889 argument. The method will then store an object pointer in that
1890 location.</para>
1891
1892 <para>Likewise, attributes (properties) can be queried or set using
1893 method invocations, using specially named methods. For each
1894 attribute there exists a getter method, the name of which is composed
1895 of <computeroutput>get_</computeroutput> followed by the capitalized
1896 attribute name. Unless the attribute is read-only, an analogous
1897 <computeroutput>set_</computeroutput> method exists. Let's apply
1898 these rules to get the <computeroutput>IVirtualBox</computeroutput>
1899 reference, an <computeroutput>ISession</computeroutput> instance
1900 reference and read the
1901 <link linkend="IVirtualBox__revision">IVirtualBox::revision</link>
1902 attribute:
1903 <screen>rc = IVirtualBoxClient_get_VirtualBox(vboxclient, &amp;vbox);
1904if (FAILED(rc) || !vbox)
1905{
1906 PrintErrorInfo(argv[0], "FATAL: could not get VirtualBox reference", rc);
1907 return EXIT_FAILURE;
1908}
1909rc = IVirtualBoxClient_get_Session(vboxclient, &amp;session);
1910if (FAILED(rc) || !session)
1911{
1912 PrintErrorInfo(argv[0], "FATAL: could not get Session reference", rc);
1913 return EXIT_FAILURE;
1914}
1915
1916rc = IVirtualBox_get_Revision(vbox, &amp;revision);
1917if (SUCCEEDED(rc))
1918{
1919 printf("Revision: %u\n", revision);
1920}</screen></para>
1921
1922 <para>The convenience macros for calling a method are named by
1923 prepending the method name with the interface name (using
1924 <code>_</code>as the separator).</para>
1925
1926 <para>So far only attribute getters were illustrated, but generic
1927 method calls are straightforward, too:
1928 <screen>IMachine *machine = NULL;
1929BSTR vmname = ...;
1930...
1931/*
1932 * Calling IMachine::findMachine(...)
1933 */
1934rc = IVirtualBox_FindMachine(vbox, vmname, &amp;machine);</screen></para>
1935
1936 <para>As a more complicated example of a method invocation, let's
1937 call
1938 <link linkend="IMachine__launchVMProcess">IMachine::launchVMProcess</link>
1939 which returns an IProgress object. Note again that the method name is
1940 capitalized:
1941 <screen>IProgress *progress;
1942...
1943rc = IMachine_LaunchVMProcess(
1944 machine, /* this */
1945 session, /* arg 1 */
1946 sessionType, /* arg 2 */
1947 env, /* arg 3 */
1948 &amp;progress /* Out */
1949);</screen></para>
1950
1951 <para>All objects with their methods and attributes are documented
1952 in <xref linkend="sdkref_classes"/>.</para>
1953 </sect3>
1954
1955 <sect3 id="c-string-handling">
1956 <title>String handling</title>
1957
1958 <para>When dealing with strings you have to be aware of a string's
1959 encoding and ownership.</para>
1960
1961 <para>Internally, the API uses UTF-16 encoded strings. A set of
1962 conversion functions is provided to convert other encodings to and
1963 from UTF-16. The type of a UTF-16 character is
1964 <computeroutput>BSTR</computeroutput> (or its constant counterpart
1965 <computeroutput>CBSTR</computeroutput>), which is an array type,
1966 represented by a pointer to the start of the zero-terminated string.
1967 There are functions for converting between UTF-8 and UTF-16 strings
1968 available through <code>g_pVBoxFuncs</code>:
1969 <screen>int (*pfnUtf16ToUtf8)(CBSTR pwszString, char **ppszString);
1970int (*pfnUtf8ToUtf16)(const char *pszString, BSTR *ppwszString);</screen></para>
1971
1972 <para>The ownership of a string determines who is responsible for
1973 releasing resources associated with the string. Whenever the API
1974 creates a string (essentially for output parameters), ownership is
1975 transferred to the caller. To avoid resource leaks, the caller
1976 should release resources once the string is no longer needed.
1977 There are plenty of examples in the sample code.</para>
1978 </sect3>
1979
1980 <sect3 id="c-safearray">
1981 <title>Array handling</title>
1982
1983 <para>Arrays are handled somewhat similarly to strings, with the
1984 additional information of the number of elements in the array. The
1985 exact details of string passing depends on the platform middleware
1986 (COM/XPCOM), and therefore the C binding offers helper functions to
1987 gloss over these differences.</para>
1988
1989 <para>Passing arrays as input parameters to API methods is usually
1990 done by the following sequence, calling a hypothetical
1991 <code>IArrayDemo_PassArray</code> API method:
1992 <screen>static const ULONG aElements[] = { 1, 2, 3, 4 };
1993ULONG cElements = sizeof(aElements) / sizeof(aElements[0]);
1994SAFEARRAY *psa = NULL;
1995psa = g_pVBoxFuncs->pfnSafeArrayCreateVector(VT_I4, 0, cElements);
1996g_pVBoxFuncs->pfnSafeArrayCopyInParamHelper(psa, aElements, sizeof(aElements));
1997IArrayDemo_PassArray(pThis, ComSafeArrayAsInParam(psa));
1998g_pVBoxFuncs->pfnSafeArrayDestroy(psa);</screen></para>
1999
2000 <para>Likewise, getting arrays results from output parameters is done
2001 using helper functions which manage memory allocations as part of
2002 their other functionality:
2003 <screen>SAFEARRAY *psa = g_pVBoxFuncs->pfnSafeArrayOutParamAlloc();
2004ULONG *pData;
2005ULONG cElements;
2006IArrayDemo_ReturnArray(pThis, ComSafeArrayAsOutTypeParam(psa, ULONG));
2007g_pVBoxFuncs->pfnSafeArrayCopyOutParamHelper((void **)&amp;pData, &amp;cElements, VT_I4, psa);
2008g_pVBoxFuncs->pfnSafeArrayDestroy(psa);</screen></para>
2009
2010 <para>This covers the necessary functionality for all array element
2011 types except interface references. These need special helpers to
2012 manage the reference counting correctly. The following code snippet
2013 gets the list of VMs, and passes the first IMachine reference to
2014 another API function (assuming that there is at least one element
2015 in the array, to simplify the example):
2016 <screen>SAFEARRAY psa = g_pVBoxFuncs->pfnSafeArrayOutParamAlloc();
2017IMachine **machines = NULL;
2018ULONG machineCnt = 0;
2019ULONG i;
2020IVirtualBox_get_Machines(virtualBox, ComSafeArrayAsOutIfaceParam(machinesSA, IMachine *));
2021g_pVBoxFuncs->pfnSafeArrayCopyOutIfaceParamHelper((IUnknown ***)&amp;machines, &amp;machineCnt, machinesSA);
2022g_pVBoxFuncs->pfnSafeArrayDestroy(machinesSA);
2023/* Now "machines" contains the IMachine references, and machineCnt the
2024 * number of elements in the array. */
2025...
2026SAFEARRAY *psa = g_pVBoxFuncs->pfnSafeArrayCreateVector(VT_IUNKNOWN, 0, 1);
2027g_pVBoxFuncs->pfnSafeArrayCopyInParamHelper(psa, (void *)&amp;machines[0], sizeof(machines[0]));
2028IVirtualBox_GetMachineStates(ComSafeArrayAsInParam(psa), ...);
2029...
2030g_pVBoxFuncs->pfnSafeArrayDestroy(psa);
2031for (i = 0; i &lt; machineCnt; ++i)
2032{
2033 IMachine *machine = machines[i];
2034 IMachine_Release(machine);
2035}
2036free(machines);</screen></para>
2037
2038 <para>Handling output parameters needs more special effort than
2039 input parameters, thus only for the former there are special helpers,
2040 and the latter is handled through the generic array support.</para>
2041 </sect3>
2042
2043 <sect3 id="c-eventhandling">
2044 <title>Event handling</title>
2045
2046 <para>The VirtualBox API offers two types of event handling, active
2047 and passive, and consequently there is support for both with the
2048 C API binding. Active event handling (based on asynchronous
2049 callback invocation for event delivery) is more difficult, as it
2050 requires the construction of valid C++ objects in C, which is
2051 inherently platform and compiler dependent. Passive event handling
2052 is much simpler, it relies on an event loop, fetching events and
2053 triggering the necessary handlers explicitly in the API client code.
2054 Both approaches depend on an event loop to make sure that events
2055 get delivered in a timely manner, with differences what exactly needs
2056 to be done.</para>
2057
2058 <para>The C API sample contains code for both event handling styles,
2059 and one has to modify the appropriate <code>#define</code> to select
2060 which style is actually used by the compiled program. It allows a
2061 good comparison between the two variants, and the code sequences are
2062 probably worth reusing without much change in other API clients
2063 with only minor adaptions.</para>
2064
2065 <para>Active event handling needs to ensure that the following helper
2066 function is called frequently enough in the primary thread:
2067 <screen>g_pVBoxFuncs->pfnProcessEventQueue(cTimeoutMS);</screen></para>
2068
2069 <para>The actual event handler implementation is quite tedious, as
2070 it has to implement a complete API interface. Especially on Windows
2071 it is a lot of work to implement the complicated
2072 <code>IDispatch</code> interface, requiring to load COM type
2073 information and using it in the <code>IDispatch</code> method
2074 implementation. Overall this is quite tedious compared to passive
2075 event handling.</para>
2076
2077 <para>Passive event handling uses a similar event loop structure,
2078 which requires calling the following function in a loop, and
2079 processing the returned event appropriately:
2080 <screen>rc = IEventSource_GetEvent(pEventSource, pListener, cTimeoutMS, &amp;pEvent);</screen></para>
2081
2082 <para>After processing the event it needs to be marked as processed
2083 with the following method call:
2084 <screen>rc = IEventSource_EventProcessed(pEventSource, pListener, pEvent);</screen></para>
2085
2086 <para>This is vital for vetoable events, as they would be stuck
2087 otherwise, waiting whether the veto comes or not. It does not do any
2088 harm for other event types, and in the end is cheaper than checking
2089 if the event at hand is vetoable or not.</para>
2090
2091 <para>The general event handling concepts are described in the API
2092 specification (see <xref linkend="events"/>), including how to
2093 aggregate multiple event sources for processing in one event loop.
2094 As mentioned, the sample illustrates the practical aspects of how to
2095 use both types of event handling, active and passive, from a C
2096 application. Additional hints are in the comments documenting
2097 the helper methods in
2098 <computeroutput>VBoxCAPI_v4_3.h</computeroutput>. The code complexity
2099 of active event handling (and its inherenly platform/compiler
2100 specific aspects) should be motivation to use passive event handling
2101 whereever possible.</para>
2102 </sect3>
2103
2104 <sect3 id="c-uninitialization">
2105 <title>C API uninitialization</title>
2106
2107 <para>Uninitialization is performed by
2108 <computeroutput>g_pVBoxFuncs-&gt;pfnClientUninitialize().</computeroutput>
2109 If your program can exit from more than one place, it is a good idea
2110 to install this function as an exit handler with Standard C's
2111 <computeroutput>atexit()</computeroutput> just after calling
2112 <computeroutput>g_pVBoxFuncs-&gt;pfnClientInitialize()</computeroutput>
2113 , e.g. <screen>#include &lt;stdlib.h&gt;
2114#include &lt;stdio.h&gt;
2115
2116...
2117
2118/*
2119 * Make sure g_pVBoxFuncs-&gt;pfnClientUninitialize() is called at exit, no
2120 * matter if we return from the initial call to main or call exit()
2121 * somewhere else. Note that atexit registered functions are not
2122 * called upon abnormal termination, i.e. when calling abort() or
2123 * signal().
2124 */
2125
2126if (atexit(g_pVBoxFuncs-&gt;pfnClientUninitialize()) != 0) {
2127 fprintf(stderr, "failed to register g_pVBoxFuncs-&gt;pfnClientUninitialize()\n");
2128 exit(EXIT_FAILURE);
2129}</screen></para>
2130
2131 <para>Another idea would be to write your own <computeroutput>void
2132 myexit(int status)</computeroutput> function, calling
2133 <computeroutput>g_pVBoxFuncs-&gt;pfnClientUninitialize()</computeroutput>
2134 followed by the real <computeroutput>exit()</computeroutput>, and
2135 use it instead of <computeroutput>exit()</computeroutput> throughout
2136 your program and at the end of
2137 <computeroutput>main.</computeroutput></para>
2138
2139 <para>If you expect the program to be terminated by a signal (e.g.
2140 user types CTRL-C sending SIGINT) you might want to install a signal
2141 handler setting a flag noting that a signal was sent and then
2142 calling
2143 <computeroutput>g_pVBoxFuncs-&gt;pfnClientUninitialize()</computeroutput>
2144 later on, <emphasis>not</emphasis> from the handler itself.</para>
2145
2146 <para>That said, if a client program forgets to call
2147 <computeroutput>g_pVBoxFuncs-&gt;pfnClientUninitialize()</computeroutput>
2148 before it terminates, there is a mechanism in place which will
2149 eventually release references held by the client. On Windows it can
2150 take quite a while, in the order of 6-7 minutes.</para>
2151 </sect3>
2152
2153 <sect3 id="c-linking">
2154 <title>Compiling and linking</title>
2155
2156 <para>A program using the C binding has to open the library during
2157 runtime using the help of glue code provided and as shown in the
2158 example <computeroutput>tstCAPIGlue.c</computeroutput>.
2159 Compilation and linking can be achieved with a makefile fragment
2160 similar to:<screen># Where is the SDK directory?
2161PATH_SDK = ../../..
2162CAPI_INC = -I$(PATH_SDK)/bindings/c/include
2163ifeq ($(BUILD_PLATFORM),win)
2164PLATFORM_INC = -I$(PATH_SDK)/bindings/mscom/include
2165PLATFORM_LIB = $(PATH_SDK)/bindings/mscom/lib
2166else
2167PLATFORM_INC = -I$(PATH_SDK)/bindings/xpcom/include
2168PLATFORM_LIB = $(PATH_SDK)/bindings/xpcom/lib
2169endif
2170GLUE_DIR = $(PATH_SDK)/bindings/c/glue
2171GLUE_INC = -I$(GLUE_DIR)
2172
2173# Compile Glue Library
2174VBoxCAPIGlue.o: $(GLUE_DIR)/VBoxCAPIGlue.c
2175 $(CC) $(CFLAGS) $(CAPI_INC) $(PLATFORM_INC) $(GLUE_INC) -o $@ -c $&lt;
2176
2177# Compile interface ID list
2178VirtualBox_i.o: $(PLATFORM_LIB)/VirtualBox_i.c
2179 $(CC) $(CFLAGS) $(CAPI_INC) $(PLATFORM_INC) $(GLUE_INC) -o $@ -c $&lt;
2180
2181# Compile program code
2182program.o: program.c
2183 $(CC) $(CFLAGS) $(CAPI_INC) $(PLATFORM_INC) $(GLUE_INC) -o $@ -c $&lt;
2184
2185# Link program.
2186program: program.o VBoxCAPICGlue.o VirtualBox_i.o
2187 $(CC) -o $@ $^ -ldl -lpthread</screen></para>
2188 </sect3>
2189
2190 <sect3 id="capi_conversion">
2191 <title>Conversion of code using legacy C binding</title>
2192
2193 <para>This section aims to make the task of converting code using
2194 the legacy C binding to the new style a breeze, by pointing out some
2195 key steps.</para>
2196
2197 <para>One necessary change is adjusting your Makefile to reflect the
2198 different include paths. See above. There are now 3 relevant include
2199 directories, and most of it is pointing to the C binding directory.
2200 The XPCOM include directory is still relevant for platforms where
2201 the XPCOM middleware is used, but most of the include files live
2202 elsewhere now, so it's good to have it last. Additionally the
2203 <computeroutput>VirtualBox_i.c</computeroutput> file needs to be
2204 compiled and linked to the program, it contains the IIDs relevant
2205 for the VirtualBox API, making sure they are not replicated endlessly
2206 if the code refers to them frequently.</para>
2207
2208 <para>The C API client code should include
2209 <computeroutput>VBoxCAPIGlue.h</computeroutput> instead of
2210 <computeroutput>VBoxXPCOMCGlue.h</computeroutput> or
2211 <computeroutput>VBoxCAPI_v4_3.h</computeroutput>, as this makes sure
2212 the correct macros and internal translations are selected.</para>
2213
2214 <para>All API method calls (anything mentioning <code>vtbl</code>)
2215 should be rewritten using the convenience macros for calling methods,
2216 as these hide the internal details, are generally easier to use and
2217 shorter to type. You should remove as many as possible
2218 <code>(nsISupports **)</code> or similar typecasts, as the new style
2219 should use the correct type in most places, increasing the type
2220 safety in case of an error in the source code.</para>
2221
2222 <para>To gloss over the platform differences, API client code should
2223 no longer rely on XPCOM specific interface names such as
2224 <code>nsISupports</code>, <code>nsIException</code> and
2225 <code>nsIEventQueue</code>, and replace them by the platform
2226 independent interface names <code>IUnknown</code> and
2227 <code>IErrorInfo</code> for the first two respectively. Event queue
2228 handling should be replaced by using the platform independent way
2229 described in <xref linkend="c-eventhandling"/>.</para>
2230
2231 <para>Finally adjust the string and array handling to use the new
2232 helpers, as these make sure the code works without changes with
2233 both COM and XPCOM, which are significantly different in this area.
2234 The code should be double checked if it uses the correct way to
2235 manage memory, and is freeing it only after the last use.</para>
2236 </sect3>
2237
2238 <sect3 id="xpcom_cbinding">
2239 <title>Legacy C binding to VirtualBox API for XPCOM</title>
2240
2241 <note>
2242 <para>This section applies to Linux, Mac OS X and Solaris
2243 hosts only and describes deprecated use of the API from C.</para>
2244 </note>
2245
2246 <para>Starting with version 2.2, VirtualBox offers a C binding for
2247 its API which works only on platforms using XPCOM. Refer to the
2248 old SDK documentation (included in the SDK packages for version 4.3.6
2249 or earlier), it still applies unchanged. The fundamental concepts are
2250 similar (but the syntactical details are quite different) to the
2251 newer cross-platform C binding which should be used for all new code,
2252 as the support for the old C binding will go away in a major release
2253 after version 4.3.</para>
2254 </sect3>
2255 </sect2>
2256 </sect1>
2257 </chapter>
2258
2259 <chapter id="concepts">
2260 <title>Basic VirtualBox concepts; some examples</title>
2261
2262 <para>The following explains some basic VirtualBox concepts such as the
2263 VirtualBox object, sessions and how virtual machines are manipulated and
2264 launched using the Main API. The coding examples use a pseudo-code style
2265 closely related to the object-oriented web service (OOWS) for JAX-WS.
2266 Depending on which environment you are using, you will need to adjust the
2267 examples.</para>
2268
2269 <sect1>
2270 <title>Obtaining basic machine information. Reading attributes</title>
2271
2272 <para>Any program using the Main API will first need access to the
2273 global VirtualBox object (see
2274 <link linkend="IVirtualBox">IVirtualBox</link>), from which all other
2275 functionality of the API is derived. With the OOWS for JAX-WS, this is
2276 returned from the
2277 <link linkend="IWebsessionManager__logon">IWebsessionManager::logon()</link>
2278 call.</para>
2279
2280 <para>To enumerate virtual machines, one would look at the "machines"
2281 array attribute in the VirtualBox object (see
2282 <link linkend="IVirtualBox__machines">IVirtualBox::machines</link>).
2283 This array contains all virtual machines currently registered with the
2284 host, each of them being an instance of
2285 <link linkend="IMachine">IMachine</link>.
2286 From each such instance, one can query additional information, such as
2287 the UUID, the name, memory, operating system and more by looking at the
2288 attributes; see the attributes list in
2289 <link linkend="IMachine">IMachine</link> documentation.</para>
2290
2291 <para>As mentioned in the preceding chapters, depending on your
2292 programming environment, attributes are mapped to corresponding "get"
2293 and (if the attribute is not read-only) "set" methods. So when the
2294 documentation says that IMachine has a
2295 "<link linkend="IMachine__name">name</link>" attribute, this means you
2296 need to code something
2297 like the following to get the machine's name:
2298 <screen>IMachine machine = ...;
2299String name = machine.getName();</screen>
2300 Boolean attribute getters can sometimes be called
2301 <computeroutput>isAttribute()</computeroutput> due to JAX-WS naming
2302 conventions.</para>
2303 </sect1>
2304
2305 <sect1>
2306 <title>Changing machine settings: Sessions</title>
2307
2308 <para>As said in the previous section, to read a machine's attribute,
2309 one invokes the corresponding "get" method. One would think that to
2310 change settings of a machine, it would suffice to call the corresponding
2311 "set" method -- for example, to set a VM's memory to 1024 MB, one would
2312 call <computeroutput>setMemorySize(1024)</computeroutput>. Try that, and
2313 you will get an error: "The machine is not mutable."</para>
2314
2315 <para>So unfortunately, things are not that easy. VirtualBox is a
2316 complicated environment in which multiple processes compete for possibly
2317 the same resources, especially machine settings. As a result, machines
2318 must be "locked" before they can either be modified or started. This is
2319 to prevent multiple processes from making conflicting changes to a
2320 machine: it should, for example, not be allowed to change the memory
2321 size of a virtual machine while it is running. (You can't add more
2322 memory to a real computer while it is running either, at least not to an
2323 ordinary PC.) Also, two processes must not change settings at the same
2324 time, or start a machine at the same time.</para>
2325
2326 <para>These requirements are implemented in the Main API by way of
2327 "sessions", in particular, the <link linkend="ISession">ISession</link>
2328 interface. Each process which talks to
2329 VirtualBox needs its own instance of ISession. In the web service, you
2330 can request the creation of such an object by calling
2331 <link linkend="IWebsessionManager__getSessionObject">IWebsessionManager::getSessionObject()</link>.
2332 More complex management tasks might need multiple instances of ISession,
2333 and each call returns a new one.</para>
2334
2335 <para>This session object must then be used like a mutex semaphore in
2336 common programming environments. Before you can change machine settings,
2337 you must write-lock the machine by calling
2338 <link linkend="IMachine__lockMachine">IMachine::lockMachine()</link>
2339 with your process's session object.</para>
2340
2341 <para>After the machine has been locked, the
2342 <link linkend="ISession__machine">ISession::machine</link> attribute
2343 contains a copy of the original IMachine object upon which the session
2344 was opened, but this copy is "mutable": you can invoke "set" methods on
2345 it.</para>
2346
2347 <para>When done making the changes to the machine, you must call
2348 <link linkend="IMachine__saveSettings">IMachine::saveSettings()</link>,
2349 which will copy the changes you have made from your "mutable" machine
2350 back to the real machine and write them out to the machine settings XML
2351 file. This will make your changes permanent.</para>
2352
2353 <para>Finally, it is important to always unlock the machine again, by
2354 calling
2355 <link linkend="ISession__unlockMachine">ISession::unlockMachine()</link>.
2356 Otherwise, when the calling process end, the machine will receive the
2357 "aborted" state, which can lead to loss of data.</para>
2358
2359 <para>So, as an example, the sequence to change a machine's memory to
2360 1024 MB is something like this:<screen>IWebsessionManager mgr ...;
2361IVirtualBox vbox = mgr.logon(user, pass);
2362...
2363IMachine machine = ...; // read-only machine
2364ISession session = mgr.getSessionObject();
2365machine.lockMachine(session, LockType.Write); // machine is now locked for writing
2366IMachine mutable = session.getMachine(); // obtain the mutable machine copy
2367mutable.setMemorySize(1024);
2368mutable.saveSettings(); // write settings to XML
2369session.unlockMachine();</screen></para>
2370 </sect1>
2371
2372 <sect1>
2373 <title>Launching virtual machines</title>
2374
2375 <para>To launch a virtual machine, you call
2376 <link linkend="IMachine__launchVMProcess">IMachine::launchVMProcess()</link>.
2377 In doing so, the caller instructs the VirtualBox engine to start a new
2378 process with the virtual machine in it, since to the host, each virtual
2379 machine looks like single process, even if it has hundreds of its own
2380 processes inside. (This new VM process in turn obtains a write lock on
2381 the machine, as described above, to prevent conflicting changes from
2382 other processes; this is why opening another session will fail while the
2383 VM is running.)</para>
2384
2385 <para>Starting a machine looks something like this:
2386 <screen>IWebsessionManager mgr ...;
2387IVirtualBox vbox = mgr.logon(user, pass);
2388...
2389IMachine machine = ...; // read-only machine
2390ISession session = mgr.getSessionObject();
2391IProgress prog = machine.launchVMProcess(session,
2392 "gui", // session type
2393 ""); // possibly environment setting
2394prog.waitForCompletion(10000); // give the process 10 secs
2395if (prog.getResultCode() != 0) // check success
2396 System.out.println("Cannot launch VM!")</screen></para>
2397
2398 <para>The caller's session object can then be used as a sort of remote
2399 control to the VM process that was launched. It contains a "console"
2400 object (see <link linkend="ISession__console">ISession::console</link>)
2401 with which the VM can be paused,
2402 stopped, snapshotted or other things.</para>
2403 </sect1>
2404
2405 <sect1 id="events">
2406 <title>VirtualBox events</title>
2407
2408 <para>In VirtualBox, "events" provide a uniform mechanism to register
2409 for and consume specific events. A VirtualBox client can register an
2410 "event listener" (represented by the
2411 <link linkend="IEventListener">IEventListener</link> interface), which
2412 will then get notified by the server when an event (represented by the
2413 <link linkend="IEvent">IEvent</link> interface) happens.</para>
2414
2415 <para>The IEvent interface is an abstract parent interface for all
2416 events that can occur in VirtualBox. The actual events that the server
2417 sends out are then of one of the specific subclasses, for example
2418 <link linkend="IMachineStateChangedEvent">IMachineStateChangedEvent</link>
2419 or
2420 <link linkend="IMediumChangedEvent">IMediumChangedEvent</link>.</para>
2421
2422 <para>As an example, the VirtualBox GUI waits for machine events and can
2423 thus update its display when the machine state changes or machine
2424 settings are modified, even if this happens in another client. This is
2425 how the GUI can automatically refresh its display even if you manipulate
2426 a machine from another client, for example, from VBoxManage.</para>
2427
2428 <para>To register an event listener to listen to events, use code like
2429 this:<screen>EventSource es = console.getEventSource();
2430IEventListener listener = es.createListener();
2431VBoxEventType aTypes[] = (VBoxEventType.OnMachineStateChanged);
2432 // list of event types to listen for
2433es.registerListener(listener, aTypes, false /* active */);
2434 // register passive listener
2435IEvent ev = es.getEvent(listener, 1000);
2436 // wait up to one second for event to happen
2437if (ev != null)
2438{
2439 // downcast to specific event interface (in this case we have only registered
2440 // for one type, otherwise IEvent::type would tell us)
2441 IMachineStateChangedEvent mcse = IMachineStateChangedEvent.queryInterface(ev);
2442 ... // inspect and do something
2443 es.eventProcessed(listener, ev);
2444}
2445...
2446es.unregisterListener(listener); </screen></para>
2447
2448 <para>A graphical user interface would probably best start its own
2449 thread to wait for events and then process these in a loop.</para>
2450
2451 <para>The events mechanism was introduced with VirtualBox 3.3 and
2452 replaces various callback interfaces which were called for each event in
2453 the interface. The callback mechanism was not compatible with scripting
2454 languages, local Java bindings and remote web services as they do not
2455 support callbacks. The new mechanism with events and event listeners
2456 works with all of these.</para>
2457
2458 <para>To simplify developement of application using events, concept of
2459 event aggregator was introduced. Essentially it's mechanism to aggregate
2460 multiple event sources into single one, and then work with this single
2461 aggregated event source instead of original sources. As an example, one
2462 can evaluate demo recorder in VirtualBox Python shell, shipped with SDK
2463 - it records mouse and keyboard events, represented as separate event
2464 sources. Code is essentially like this:<screen>
2465 listener = console.eventSource.createListener()
2466 agg = console.eventSource.createAggregator([console.keyboard.eventSource, console.mouse.eventSource])
2467 agg.registerListener(listener, [ctx['global'].constants.VBoxEventType_Any], False)
2468 registered = True
2469 end = time.time() + dur
2470 while time.time() &lt; end:
2471 ev = agg.getEvent(listener, 1000)
2472 processEent(ev)
2473 agg.unregisterListener(listener)</screen> Without using aggregators
2474 consumer have to poll on both sources, or start multiple threads to
2475 block on those sources.</para>
2476 </sect1>
2477 </chapter>
2478
2479 <chapter id="vboxshell">
2480 <title>The VirtualBox shell</title>
2481
2482 <para>VirtualBox comes with an extensible shell, which allows you to
2483 control your virtual machines from the command line. It is also a
2484 nontrivial example of how to use the VirtualBox APIs from Python, for all
2485 three COM/XPCOM/WS styles of the API.</para>
2486
2487 <para>You can easily extend this shell with your own commands. Create a
2488 subdirectory named
2489 <computeroutput>.config/VirtualBox/shexts</computeroutput> below your home
2490 directory (respectively <computeroutput>.VirtualBox/shexts</computeroutput>
2491 on a Windows system and
2492 <computeroutput>Library/VirtualBox/shexts</computeroutput> on OS X) and put
2493 a Python file implementing your shell extension commands in this directory.
2494 This file must contain an array named
2495 <computeroutput>commands</computeroutput> containing your command
2496 definitions: <screen>
2497 commands = {
2498 'cmd1': ['Command cmd1 help', cmd1],
2499 'cmd2': ['Command cmd2 help', cmd2]
2500 }
2501 </screen> For example, to create a command for creating hard drive
2502 images, the following code can be used: <screen>
2503 def createHdd(ctx,args):
2504 # Show some meaningful error message on wrong input
2505 if (len(args) &lt; 3):
2506 print "usage: createHdd sizeM location type"
2507 return 0
2508
2509 # Get arguments
2510 size = int(args[1])
2511 loc = args[2]
2512 if len(args) &gt; 3:
2513 format = args[3]
2514 else:
2515 # And provide some meaningful defaults
2516 format = "vdi"
2517
2518 # Call VirtualBox API, using context's fields
2519 hdd = ctx['vb'].createMedium(format, loc, ctx['global'].constants.AccessMode_ReadWrite, \
2520 ctx['global'].constants.DeviceType_HardDisk)
2521 # Access constants using ctx['global'].constants
2522 progress = hdd.createBaseStorage(size, (ctx['global'].constants.MediumVariant_Standard, ))
2523 # use standard progress bar mechanism
2524 ctx['progressBar'](progress)
2525
2526
2527 # Report errors
2528 if not hdd.id:
2529 print "cannot create disk (file %s exist?)" %(loc)
2530 return 0
2531
2532 # Give user some feedback on success too
2533 print "created HDD with id: %s" %(hdd.id)
2534
2535 # 0 means continue execution, other values mean exit from the interpreter
2536 return 0
2537
2538 commands = {
2539 'myCreateHDD': ['Create virtual HDD, createHdd size location type', createHdd]
2540 }
2541 </screen> Just store the above text in the file
2542 <computeroutput>createHdd</computeroutput> (or any other meaningful name)
2543 in <computeroutput>.config/VirtualBox/shexts/</computeroutput>. Start the
2544 VirtualBox shell, or just issue the
2545 <computeroutput>reloadExts</computeroutput> command, if the shell is
2546 already running. Your new command will now be available.</para>
2547 </chapter>
2548
2549 <xi:include href="SDKRef_apiref.xml" xpointer="xpointer(/book/*)"
2550 xmlns:xi="http://www.w3.org/2001/XInclude" />
2551
2552 <chapter id="cloud">
2553 <title>Working with the Cloud</title>
2554
2555 <para>VirtualBox supports and goes towards the Oracle tendencies like "move to the Cloud".</para>
2556
2557 <sect1>
2558 <title>OCI features</title>
2559 <para>VirtualBox supports the Oracle Cloud Infrastructure (OCI). See the interfaces:
2560 <link linkend="ICloudClient">ICloudClient</link>,
2561 <link linkend="ICloudProvider">ICloudProvider</link>,
2562 <link linkend="ICloudProfile">ICloudProfile</link>,
2563 <link linkend="ICloudProviderManager">ICloudProviderManager</link>.
2564 </para>
2565 <para>Each cloud interface has own implementation to support OCI features. There are everal functions in the implementation
2566 which should be explained in details because OCI requires some special data or settings.
2567 </para>
2568 <para>
2569 Also see the enumeration <link linkend="VirtualSystemDescriptionType">VirtualSystemDescriptionType</link> for the possible values.
2570 </para>
2571 </sect1>
2572
2573 <sect1>
2574 <title>Function ICloudClient::exportVM</title>
2575 <para>
2576 See the <link linkend="ICloudClient__exportVM">ICloudClient::exportVM</link>.
2577 The function exports an existing virtual machine into OCI. The final result of this operation is creation a custom image
2578 from the bootable image of VM. The Id of created image is returned in the parameter "description" (which is
2579 <link linkend="IVirtualSystemDescription">IVirtualSystemDescription</link>) as an entry with the type
2580 VirtualSystemDescriptionType::CloudImageId. The standard steps here are:
2581 <itemizedlist>
2582 <listitem>
2583 <para>Upload VBox image to OCI Object Storage.</para>
2584 </listitem>
2585 <listitem>
2586 <para>Create OCI custom image from the uploaded object.</para>
2587 </listitem>
2588 </itemizedlist>
2589 Parameter "description" must contain all information and settings needed for creation a custom image in OCI.
2590 At least next entries must be presented there before the call:
2591 <itemizedlist>
2592 <listitem>
2593 <para>VirtualSystemDescriptionType::Name - Name of new instance in OCI.</para>
2594 </listitem>
2595 <listitem>
2596 <para>VirtualSystemDescriptionType::HardDiskImage - The local path or id of bootable VM image.</para>
2597 </listitem>
2598 <listitem>
2599 <para>VirtualSystemDescriptionType::CloudBucket - A cloud bucket name where the exported image is uploaded.</para>
2600 </listitem>
2601 <listitem>
2602 <para>VirtualSystemDescriptionType::CloudImageDisplayName - A name which is assigned to a new custom image in the OCI.</para>
2603 </listitem>
2604 <listitem>
2605 <para>VirtualSystemDescriptionType::CloudKeepObject - Whether keep or delete an uploaded object after its usage.</para>
2606 </listitem>
2607 <listitem>
2608 <para>VirtualSystemDescriptionType::CloudLaunchInstance - Whether launch or not a new instance.</para>
2609 </listitem>
2610 </itemizedlist>
2611 </para>
2612 </sect1>
2613
2614 <sect1>
2615 <title>Function ICloudClient::launchVM</title>
2616 <para>
2617 See the <link linkend="ICloudClient__launchVM">ICloudClient::launchVM</link>.
2618 The function launches a new instance in OCI with a bootable volume previously created from a custom image in OCI or
2619 as the source may be used an existing bootable volume which shouldn't be attached to any instance.
2620 For launching instance from a custom image use the parameter VirtualSystemDescriptionType::CloudImageId.
2621 For launching instance from a bootable volume use the parameter VirtualSystemDescriptionType::CloudBootVolumeId.
2622 Only one of them must be presented otherwise the error will occur.
2623 The final result of this operation is a running instance. The id of created instance is returned
2624 in the parameter "description" (which is <link linkend="IVirtualSystemDescription">IVirtualSystemDescription</link>)
2625 as an entry with the type VirtualSystemDescriptionType::CloudInstanceId. Parameter "description" must contain all information
2626 and settings needed for creation a new instance in OCI. At least next entries must be presented there before the call:
2627 <itemizedlist>
2628 <listitem>
2629 <para>VirtualSystemDescriptionType::Name - Name of new instance in OCI.</para>
2630 </listitem>
2631 <listitem>
2632 <para>VirtualSystemDescriptionType::CloudOCISubnet - OCID of existing subnet in OCI which will be used by the instance.</para>
2633 </listitem>
2634 <listitem>
2635 <para>
2636 Use VirtualSystemDescriptionType::CloudImageId - OCID of custom image used as a bootable image for the instance
2637 or
2638 VirtualSystemDescriptionType::CloudBootVolumeId - OCID of existing and non-attached bootable volume used as a bootable volume for the instance.
2639 </para>
2640 </listitem>
2641 <listitem>
2642 <para>Add VirtualSystemDescriptionType::CloudBootDiskSize - The size of instance bootable volume in GB,
2643 If you use VirtualSystemDescriptionType::CloudImageId.</para>
2644 </listitem>
2645 <listitem>
2646 <para>VirtualSystemDescriptionType::CloudInstanceShape - The shape of instance according to OCI documentation,
2647 defines the number of CPUs and RAM memory.</para>
2648 </listitem>
2649 <listitem>
2650 <para>VirtualSystemDescriptionType::CloudLaunchInstance - Whether launch or not a new instance.</para>
2651 </listitem>
2652 <listitem>
2653 <para>VirtualSystemDescriptionType::CloudDomain - Availability domain in OCI where new instance is created.</para>
2654 </listitem>
2655 <listitem>
2656 <para>VirtualSystemDescriptionType::CloudPublicIP - Whether the instance will have a public IP or not.</para>
2657 </listitem>
2658 <listitem>
2659 <para>VirtualSystemDescriptionType::CloudPublicSSHKey - Public SSH key which is used to connect to an instance via SSH.
2660 It may be one or more records with the type VirtualSystemDescriptionType::CloudPublicSSHKey in the VirtualSystemDescription.
2661 But at least one should be presented otherwise user won't be able to connect to the instance via SSH.
2662 </para>
2663 </listitem>
2664 </itemizedlist>
2665 </para>
2666 </sect1>
2667
2668 <sect1>
2669 <title>Function ICloudClient::getInstanceInfo</title>
2670 <para>
2671 See the <link linkend="ICloudClient__getInstanceInfo">ICloudClient::getInstanceInfo</link>.
2672 The function takes an instance id (parameter "uid"), finds the requested instance in OCI and gets back information
2673 about the found instance in the parameter "description" (which is <link linkend="IVirtualSystemDescription">IVirtualSystemDescription</link>)
2674 The entries with next types will be presented in the object:
2675 <itemizedlist>
2676 <listitem>
2677 <para>VirtualSystemDescriptionType::Name - Displayed name of the instance.</para>
2678 </listitem>
2679 <listitem>
2680 <para>VirtualSystemDescriptionType::CloudDomain - Availability domain in OCI.</para>
2681 </listitem>
2682 <listitem>
2683 <para>VirtualSystemDescriptionType::CloudImageId - Name of custom image used for creation this instance.</para>
2684 </listitem>
2685 <listitem>
2686 <para>VirtualSystemDescriptionType::CloudInstanceId - The OCID of the instance.</para>
2687 </listitem>
2688 <listitem>
2689 <para>VirtualSystemDescriptionType::OS - Guest OS type of the instance.</para>
2690 </listitem>
2691 <listitem>
2692 <para>VirtualSystemDescriptionType::CloudBootDiskSize - Size of instance bootable image.</para>
2693 </listitem>
2694 <listitem>
2695 <para>VirtualSystemDescriptionType::CloudInstanceState - The instance state according to OCI documentation.</para>
2696 </listitem>
2697 <listitem>
2698 <para>VirtualSystemDescriptionType::CloudInstanceShape - The instance shape according to OCI documentation</para>
2699 </listitem>
2700 <listitem>
2701 <para>VirtualSystemDescriptionType::Memory - RAM memory in GB allocated for the instance.</para>
2702 </listitem>
2703 <listitem>
2704 <para>VirtualSystemDescriptionType::CPU - Number of virtual CPUs allocated for the instance.</para>
2705 </listitem>
2706 </itemizedlist>
2707 </para>
2708 </sect1>
2709
2710 <sect1>
2711 <title>Function ICloudClient::importInstance</title>
2712 <para>
2713 See the <link linkend="ICloudClient__importInstance">ICloudClient::importInstance</link>.
2714 The API function imports an existing instance from the OCI to the local host.
2715 The standard steps here are:
2716 <itemizedlist>
2717 <listitem>
2718 <para>Create a custom image from an existing OCI instance.</para>
2719 </listitem>
2720 <listitem>
2721 <para>Export the custom image to OCI object (the object is created in the OCI Object Storage).</para>
2722 </listitem>
2723 <listitem>
2724 <para>Download the OCI object to the local host.</para>
2725 </listitem>
2726 </itemizedlist>
2727 As the result of operation user will have a file with the suffix ".oci" on the local host. This file is a TAR archive which
2728 contains a bootable instance image in QCOW2 format and a JSON file with some metadata related to
2729 the imported instance. The function takes the parameter "description"
2730 (which is <link linkend="IVirtualSystemDescription">IVirtualSystemDescription</link>)
2731 Parameter "description" must contain all information and settings needed for successful operation result.
2732 At least next entries must be presented there before the call:
2733 <itemizedlist>
2734 <listitem>
2735 <para>VirtualSystemDescriptionType::Name is used for the several purposes:
2736 <itemizedlist>
2737 <listitem>
2738 <para>As a custom image name. A custom image is created from an instance.</para>
2739 </listitem>
2740 <listitem>
2741 <para>As OCI object name. An object is a file in OCI Object Storage. The object is created from the custom image.</para>
2742 </listitem>
2743 <listitem>
2744 <para>Name of imported instance on the local host. Because the result of import is a file, the file will have this
2745 name and extension ".oci".</para>
2746 </listitem>
2747 </itemizedlist>
2748 </para>
2749 </listitem>
2750 <listitem>
2751 <para>VirtualSystemDescriptionType::CloudInstanceId - The OCID of the existing instance.</para>
2752 </listitem>
2753 <listitem>
2754 <para>VirtualSystemDescriptionType::CloudBucket - a cloud bucket name in OCI Object Storage where created an OCI object
2755 from a custom image.
2756 </para>
2757 </listitem>
2758 </itemizedlist>
2759 </para>
2760 </sect1>
2761
2762 </chapter>
2763
2764 <chapter id="hgcm">
2765 <title>Host-Guest Communication Manager</title>
2766
2767 <para>The VirtualBox Host-Guest Communication Manager (HGCM) allows a
2768 guest application or a guest driver to call a host shared library. The
2769 following features of VirtualBox are implemented using HGCM: <itemizedlist>
2770 <listitem>
2771 <para>Shared Folders</para>
2772 </listitem>
2773
2774 <listitem>
2775 <para>Shared Clipboard</para>
2776 </listitem>
2777
2778 <listitem>
2779 <para>Guest configuration interface</para>
2780 </listitem>
2781 </itemizedlist></para>
2782
2783 <para>The shared library contains a so called HGCM service. The guest HGCM
2784 clients establish connections to the service to call it. When calling a
2785 HGCM service the client supplies a function code and a number of
2786 parameters for the function.</para>
2787
2788 <sect1>
2789 <title>Virtual hardware implementation</title>
2790
2791 <para>HGCM uses the VMM virtual PCI device to exchange data between the
2792 guest and the host. The guest always acts as an initiator of requests. A
2793 request is constructed in the guest physical memory, which must be
2794 locked by the guest. The physical address is passed to the VMM device
2795 using a 32-bit <computeroutput>out edx, eax</computeroutput>
2796 instruction. The physical memory must be allocated below 4GB by 64-bit
2797 guests.</para>
2798
2799 <para>The host parses the request header and data and queues the request
2800 for a host HGCM service. The guest continues execution and usually waits
2801 on a HGCM event semaphore.</para>
2802
2803 <para>When the request has been processed by the HGCM service, the VMM
2804 device sets the completion flag in the request header, sets the HGCM
2805 event and raises an IRQ for the guest. The IRQ handler signals the HGCM
2806 event semaphore and all HGCM callers check the completion flag in the
2807 corresponding request header. If the flag is set, the request is
2808 considered completed.</para>
2809 </sect1>
2810
2811 <sect1>
2812 <title>Protocol specification</title>
2813
2814 <para>The HGCM protocol definitions are contained in the
2815 <computeroutput>VBox/VBoxGuest.h</computeroutput></para>
2816
2817 <sect2>
2818 <title>Request header</title>
2819
2820 <para>HGCM request structures contains a generic header
2821 (VMMDevHGCMRequestHeader): <table>
2822 <title>HGCM Request Generic Header</title>
2823
2824 <tgroup cols="2">
2825 <tbody>
2826 <row>
2827 <entry><emphasis role="bold">Name</emphasis></entry>
2828
2829 <entry><emphasis role="bold">Description</emphasis></entry>
2830 </row>
2831
2832 <row>
2833 <entry>size</entry>
2834
2835 <entry>Size of the entire request.</entry>
2836 </row>
2837
2838 <row>
2839 <entry>version</entry>
2840
2841 <entry>Version of the header, must be set to
2842 <computeroutput>0x10001</computeroutput>.</entry>
2843 </row>
2844
2845 <row>
2846 <entry>type</entry>
2847
2848 <entry>Type of the request.</entry>
2849 </row>
2850
2851 <row>
2852 <entry>rc</entry>
2853
2854 <entry>HGCM return code, which will be set by the VMM
2855 device.</entry>
2856 </row>
2857
2858 <row>
2859 <entry>reserved1</entry>
2860
2861 <entry>A reserved field 1.</entry>
2862 </row>
2863
2864 <row>
2865 <entry>reserved2</entry>
2866
2867 <entry>A reserved field 2.</entry>
2868 </row>
2869
2870 <row>
2871 <entry>flags</entry>
2872
2873 <entry>HGCM flags, set by the VMM device.</entry>
2874 </row>
2875
2876 <row>
2877 <entry>result</entry>
2878
2879 <entry>The HGCM result code, set by the VMM device.</entry>
2880 </row>
2881 </tbody>
2882 </tgroup>
2883 </table> <note>
2884 <itemizedlist>
2885 <listitem>
2886 <para>All fields are 32-bit.</para>
2887 </listitem>
2888
2889 <listitem>
2890 <para>Fields from <computeroutput>size</computeroutput> to
2891 <computeroutput>reserved2</computeroutput> are a standard VMM
2892 device request header, which is used for other interfaces as
2893 well.</para>
2894 </listitem>
2895 </itemizedlist>
2896 </note></para>
2897
2898 <para>The <emphasis role="bold">type</emphasis> field indicates the
2899 type of the HGCM request: <table>
2900 <title>Request Types</title>
2901
2902 <tgroup cols="2">
2903 <tbody>
2904 <row>
2905 <entry><emphasis role="bold">Name (decimal
2906 value)</emphasis></entry>
2907
2908 <entry><emphasis role="bold">Description</emphasis></entry>
2909 </row>
2910
2911 <row>
2912 <entry>VMMDevReq_HGCMConnect
2913 (<computeroutput>60</computeroutput>)</entry>
2914
2915 <entry>Connect to a HGCM service.</entry>
2916 </row>
2917
2918 <row>
2919 <entry>VMMDevReq_HGCMDisconnect
2920 (<computeroutput>61</computeroutput>)</entry>
2921
2922 <entry>Disconnect from the service.</entry>
2923 </row>
2924
2925 <row>
2926 <entry>VMMDevReq_HGCMCall32
2927 (<computeroutput>62</computeroutput>)</entry>
2928
2929 <entry>Call a HGCM function using the 32-bit
2930 interface.</entry>
2931 </row>
2932
2933 <row>
2934 <entry>VMMDevReq_HGCMCall64
2935 (<computeroutput>63</computeroutput>)</entry>
2936
2937 <entry>Call a HGCM function using the 64-bit
2938 interface.</entry>
2939 </row>
2940
2941 <row>
2942 <entry>VMMDevReq_HGCMCancel
2943 (<computeroutput>64</computeroutput>)</entry>
2944
2945 <entry>Cancel a HGCM request currently being processed by a
2946 host HGCM service.</entry>
2947 </row>
2948 </tbody>
2949 </tgroup>
2950 </table></para>
2951
2952 <para>The <emphasis role="bold">flags</emphasis> field may contain:
2953 <table>
2954 <title>Flags</title>
2955
2956 <tgroup cols="2">
2957 <tbody>
2958 <row>
2959 <entry><emphasis role="bold">Name (hexadecimal
2960 value)</emphasis></entry>
2961
2962 <entry><emphasis role="bold">Description</emphasis></entry>
2963 </row>
2964
2965 <row>
2966 <entry>VBOX_HGCM_REQ_DONE
2967 (<computeroutput>0x00000001</computeroutput>)</entry>
2968
2969 <entry>The request has been processed by the host
2970 service.</entry>
2971 </row>
2972
2973 <row>
2974 <entry>VBOX_HGCM_REQ_CANCELLED
2975 (<computeroutput>0x00000002</computeroutput>)</entry>
2976
2977 <entry>This request was cancelled.</entry>
2978 </row>
2979 </tbody>
2980 </tgroup>
2981 </table></para>
2982 </sect2>
2983
2984 <sect2>
2985 <title>Connect</title>
2986
2987 <para>The connection request must be issued by the guest HGCM client
2988 before it can call the HGCM service (VMMDevHGCMConnect): <table>
2989 <title>Connect request</title>
2990
2991 <tgroup cols="2">
2992 <tbody>
2993 <row>
2994 <entry><emphasis role="bold">Name</emphasis></entry>
2995
2996 <entry><emphasis role="bold">Description</emphasis></entry>
2997 </row>
2998
2999 <row>
3000 <entry>header</entry>
3001
3002 <entry>The generic HGCM request header with type equal to
3003 VMMDevReq_HGCMConnect
3004 (<computeroutput>60</computeroutput>).</entry>
3005 </row>
3006
3007 <row>
3008 <entry>type</entry>
3009
3010 <entry>The type of the service location information (32
3011 bit).</entry>
3012 </row>
3013
3014 <row>
3015 <entry>location</entry>
3016
3017 <entry>The service location information (128 bytes).</entry>
3018 </row>
3019
3020 <row>
3021 <entry>clientId</entry>
3022
3023 <entry>The client identifier assigned to the connecting
3024 client by the HGCM subsystem (32-bit).</entry>
3025 </row>
3026 </tbody>
3027 </tgroup>
3028 </table> The <emphasis role="bold">type</emphasis> field tells the
3029 HGCM how to look for the requested service: <table>
3030 <title>Location Information Types</title>
3031
3032 <tgroup cols="2">
3033 <tbody>
3034 <row>
3035 <entry><emphasis role="bold">Name (hexadecimal
3036 value)</emphasis></entry>
3037
3038 <entry><emphasis role="bold">Description</emphasis></entry>
3039 </row>
3040
3041 <row>
3042 <entry>VMMDevHGCMLoc_LocalHost
3043 (<computeroutput>0x1</computeroutput>)</entry>
3044
3045 <entry>The requested service is a shared library located on
3046 the host and the location information contains the library
3047 name.</entry>
3048 </row>
3049
3050 <row>
3051 <entry>VMMDevHGCMLoc_LocalHost_Existing
3052 (<computeroutput>0x2</computeroutput>)</entry>
3053
3054 <entry>The requested service is a preloaded one and the
3055 location information contains the service name.</entry>
3056 </row>
3057 </tbody>
3058 </tgroup>
3059 </table> <note>
3060 <para>Currently preloaded HGCM services are hard-coded in
3061 VirtualBox: <itemizedlist>
3062 <listitem>
3063 <para>VBoxSharedFolders</para>
3064 </listitem>
3065
3066 <listitem>
3067 <para>VBoxSharedClipboard</para>
3068 </listitem>
3069
3070 <listitem>
3071 <para>VBoxGuestPropSvc</para>
3072 </listitem>
3073
3074 <listitem>
3075 <para>VBoxSharedOpenGL</para>
3076 </listitem>
3077 </itemizedlist></para>
3078 </note> There is no difference between both types of HGCM services,
3079 only the location mechanism is different.</para>
3080
3081 <para>The client identifier is returned by the host and must be used
3082 in all subsequent requests by the client.</para>
3083 </sect2>
3084
3085 <sect2>
3086 <title>Disconnect</title>
3087
3088 <para>This request disconnects the client and makes the client
3089 identifier invalid (VMMDevHGCMDisconnect): <table>
3090 <title>Disconnect request</title>
3091
3092 <tgroup cols="2">
3093 <tbody>
3094 <row>
3095 <entry><emphasis role="bold">Name</emphasis></entry>
3096
3097 <entry><emphasis role="bold">Description</emphasis></entry>
3098 </row>
3099
3100 <row>
3101 <entry>header</entry>
3102
3103 <entry>The generic HGCM request header with type equal to
3104 VMMDevReq_HGCMDisconnect
3105 (<computeroutput>61</computeroutput>).</entry>
3106 </row>
3107
3108 <row>
3109 <entry>clientId</entry>
3110
3111 <entry>The client identifier previously returned by the
3112 connect request (32-bit).</entry>
3113 </row>
3114 </tbody>
3115 </tgroup>
3116 </table></para>
3117 </sect2>
3118
3119 <sect2>
3120 <title>Call32 and Call64</title>
3121
3122 <para>Calls the HGCM service entry point (VMMDevHGCMCall) using 32-bit
3123 or 64-bit addresses: <table>
3124 <title>Call request</title>
3125
3126 <tgroup cols="2">
3127 <tbody>
3128 <row>
3129 <entry><emphasis role="bold">Name</emphasis></entry>
3130
3131 <entry><emphasis role="bold">Description</emphasis></entry>
3132 </row>
3133
3134 <row>
3135 <entry>header</entry>
3136
3137 <entry>The generic HGCM request header with type equal to
3138 either VMMDevReq_HGCMCall32
3139 (<computeroutput>62</computeroutput>) or
3140 VMMDevReq_HGCMCall64
3141 (<computeroutput>63</computeroutput>).</entry>
3142 </row>
3143
3144 <row>
3145 <entry>clientId</entry>
3146
3147 <entry>The client identifier previously returned by the
3148 connect request (32-bit).</entry>
3149 </row>
3150
3151 <row>
3152 <entry>function</entry>
3153
3154 <entry>The function code to be processed by the service (32
3155 bit).</entry>
3156 </row>
3157
3158 <row>
3159 <entry>cParms</entry>
3160
3161 <entry>The number of following parameters (32-bit). This
3162 value is 0 if the function requires no parameters.</entry>
3163 </row>
3164
3165 <row>
3166 <entry>parms</entry>
3167
3168 <entry>An array of parameter description structures
3169 (HGCMFunctionParameter32 or
3170 HGCMFunctionParameter64).</entry>
3171 </row>
3172 </tbody>
3173 </tgroup>
3174 </table></para>
3175
3176 <para>The 32-bit parameter description (HGCMFunctionParameter32)
3177 consists of 32-bit type field and 8 bytes of an opaque value, so 12
3178 bytes in total. The 64-bit variant (HGCMFunctionParameter64) consists
3179 of the type and 12 bytes of a value, so 16 bytes in total.</para>
3180
3181 <para><table>
3182 <title>Parameter types</title>
3183
3184 <tgroup cols="2">
3185 <tbody>
3186 <row>
3187 <entry><emphasis role="bold">Type</emphasis></entry>
3188
3189 <entry><emphasis role="bold">Format of the
3190 value</emphasis></entry>
3191 </row>
3192
3193 <row>
3194 <entry>VMMDevHGCMParmType_32bit (1)</entry>
3195
3196 <entry>A 32-bit value.</entry>
3197 </row>
3198
3199 <row>
3200 <entry>VMMDevHGCMParmType_64bit (2)</entry>
3201
3202 <entry>A 64-bit value.</entry>
3203 </row>
3204
3205 <row>
3206 <entry>VMMDevHGCMParmType_PhysAddr (3)</entry>
3207
3208 <entry>A 32-bit size followed by a 32-bit or 64-bit guest
3209 physical address.</entry>
3210 </row>
3211
3212 <row>
3213 <entry>VMMDevHGCMParmType_LinAddr (4)</entry>
3214
3215 <entry>A 32-bit size followed by a 32-bit or 64-bit guest
3216 linear address. The buffer is used both for guest to host
3217 and for host to guest data.</entry>
3218 </row>
3219
3220 <row>
3221 <entry>VMMDevHGCMParmType_LinAddr_In (5)</entry>
3222
3223 <entry>Same as VMMDevHGCMParmType_LinAddr but the buffer is
3224 used only for host to guest data.</entry>
3225 </row>
3226
3227 <row>
3228 <entry>VMMDevHGCMParmType_LinAddr_Out (6)</entry>
3229
3230 <entry>Same as VMMDevHGCMParmType_LinAddr but the buffer is
3231 used only for guest to host data.</entry>
3232 </row>
3233
3234 <row>
3235 <entry>VMMDevHGCMParmType_LinAddr_Locked (7)</entry>
3236
3237 <entry>Same as VMMDevHGCMParmType_LinAddr but the buffer is
3238 already locked by the guest.</entry>
3239 </row>
3240
3241 <row>
3242 <entry>VMMDevHGCMParmType_LinAddr_Locked_In (1)</entry>
3243
3244 <entry>Same as VMMDevHGCMParmType_LinAddr_In but the buffer
3245 is already locked by the guest.</entry>
3246 </row>
3247
3248 <row>
3249 <entry>VMMDevHGCMParmType_LinAddr_Locked_Out (1)</entry>
3250
3251 <entry>Same as VMMDevHGCMParmType_LinAddr_Out but the buffer
3252 is already locked by the guest.</entry>
3253 </row>
3254 </tbody>
3255 </tgroup>
3256 </table></para>
3257
3258 <para>The</para>
3259 </sect2>
3260
3261 <sect2>
3262 <title>Cancel</title>
3263
3264 <para>This request cancels a call request (VMMDevHGCMCancel): <table>
3265 <title>Cancel request</title>
3266
3267 <tgroup cols="2">
3268 <tbody>
3269 <row>
3270 <entry><emphasis role="bold">Name</emphasis></entry>
3271
3272 <entry><emphasis role="bold">Description</emphasis></entry>
3273 </row>
3274
3275 <row>
3276 <entry>header</entry>
3277
3278 <entry>The generic HGCM request header with type equal to
3279 VMMDevReq_HGCMCancel
3280 (<computeroutput>64</computeroutput>).</entry>
3281 </row>
3282 </tbody>
3283 </tgroup>
3284 </table></para>
3285 </sect2>
3286 </sect1>
3287
3288 <sect1>
3289 <title>Guest software interface</title>
3290
3291 <para>The guest HGCM clients can call HGCM services from both drivers
3292 and applications.</para>
3293
3294 <sect2>
3295 <title>The guest driver interface</title>
3296
3297 <para>The driver interface is implemented in the VirtualBox guest
3298 additions driver (VBoxGuest), which works with the VMM virtual device.
3299 Drivers must use the VBox Guest Library (VBGL), which provides an API
3300 for HGCM clients (<computeroutput>VBox/VBoxGuestLib.h</computeroutput>
3301 and <computeroutput>VBox/VBoxGuest.h</computeroutput>).</para>
3302
3303 <para><screen>
3304DECLR0VBGL(int) VbglR0HGCMConnect(VBGLHGCMHANDLE *pHandle, const char *pszServiceName, HGCMCLIENTID *pidClient);
3305 </screen> Connects to the service: <screen>
3306 VBoxGuestHGCMConnectInfo data;
3307
3308 memset(&amp;data, sizeof(VBoxGuestHGCMConnectInfo));
3309
3310 data.result = VINF_SUCCESS;
3311 data.Loc.type = VMMDevHGCMLoc_LocalHost_Existing;
3312 strcpy (data.Loc.u.host.achName, "VBoxSharedFolders");
3313
3314 rc = VbglHGCMConnect (&amp;handle, "VBoxSharedFolders"&amp;data);
3315
3316 if (RT_SUCCESS (rc))
3317 {
3318 rc = data.result;
3319 }
3320
3321 if (RT_SUCCESS (rc))
3322 {
3323 /* Get the assigned client identifier. */
3324 ulClientID = data.u32ClientID;
3325 }
3326 </screen></para>
3327
3328 <para><screen>
3329DECLVBGL(int) VbglHGCMDisconnect (VBGLHGCMHANDLE handle, VBoxGuestHGCMDisconnectInfo *pData);
3330 </screen> Disconnects from the service. <screen>
3331 VBoxGuestHGCMDisconnectInfo data;
3332
3333 RtlZeroMemory (&amp;data, sizeof (VBoxGuestHGCMDisconnectInfo));
3334
3335 data.result = VINF_SUCCESS;
3336 data.u32ClientID = ulClientID;
3337
3338 rc = VbglHGCMDisconnect (handle, &amp;data);
3339 </screen></para>
3340
3341 <para><screen>
3342DECLVBGL(int) VbglHGCMCall (VBGLHGCMHANDLE handle, VBoxGuestHGCMCallInfo *pData, uint32_t cbData);
3343 </screen> Calls a function in the service. <screen>
3344typedef struct _VBoxSFRead
3345{
3346 VBoxGuestHGCMCallInfo callInfo;
3347
3348 /** pointer, in: SHFLROOT
3349 * Root handle of the mapping which name is queried.
3350 */
3351 HGCMFunctionParameter root;
3352
3353 /** value64, in:
3354 * SHFLHANDLE of object to read from.
3355 */
3356 HGCMFunctionParameter handle;
3357
3358 /** value64, in:
3359 * Offset to read from.
3360 */
3361 HGCMFunctionParameter offset;
3362
3363 /** value64, in/out:
3364 * Bytes to read/How many were read.
3365 */
3366 HGCMFunctionParameter cb;
3367
3368 /** pointer, out:
3369 * Buffer to place data to.
3370 */
3371 HGCMFunctionParameter buffer;
3372
3373} VBoxSFRead;
3374
3375/** Number of parameters */
3376#define SHFL_CPARMS_READ (5)
3377
3378...
3379
3380 VBoxSFRead data;
3381
3382 /* The call information. */
3383 data.callInfo.result = VINF_SUCCESS; /* Will be returned by HGCM. */
3384 data.callInfo.u32ClientID = ulClientID; /* Client identifier. */
3385 data.callInfo.u32Function = SHFL_FN_READ; /* The function code. */
3386 data.callInfo.cParms = SHFL_CPARMS_READ; /* Number of parameters. */
3387
3388 /* Initialize parameters. */
3389 data.root.type = VMMDevHGCMParmType_32bit;
3390 data.root.u.value32 = pMap-&gt;root;
3391
3392 data.handle.type = VMMDevHGCMParmType_64bit;
3393 data.handle.u.value64 = hFile;
3394
3395 data.offset.type = VMMDevHGCMParmType_64bit;
3396 data.offset.u.value64 = offset;
3397
3398 data.cb.type = VMMDevHGCMParmType_32bit;
3399 data.cb.u.value32 = *pcbBuffer;
3400
3401 data.buffer.type = VMMDevHGCMParmType_LinAddr_Out;
3402 data.buffer.u.Pointer.size = *pcbBuffer;
3403 data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
3404
3405 rc = VbglHGCMCall (handle, &amp;data.callInfo, sizeof (data));
3406
3407 if (RT_SUCCESS (rc))
3408 {
3409 rc = data.callInfo.result;
3410 *pcbBuffer = data.cb.u.value32; /* This is returned by the HGCM service. */
3411 }
3412 </screen></para>
3413 </sect2>
3414
3415 <sect2>
3416 <title>Guest application interface</title>
3417
3418 <para>Applications call the VirtualBox Guest Additions driver to
3419 utilize the HGCM interface. There are IOCTL's which correspond to the
3420 <computeroutput>Vbgl*</computeroutput> functions: <itemizedlist>
3421 <listitem>
3422 <para><computeroutput>VBOXGUEST_IOCTL_HGCM_CONNECT</computeroutput></para>
3423 </listitem>
3424
3425 <listitem>
3426 <para><computeroutput>VBOXGUEST_IOCTL_HGCM_DISCONNECT</computeroutput></para>
3427 </listitem>
3428
3429 <listitem>
3430 <para><computeroutput>VBOXGUEST_IOCTL_HGCM_CALL</computeroutput></para>
3431 </listitem>
3432 </itemizedlist></para>
3433
3434 <para>These IOCTL's get the same input buffer as
3435 <computeroutput>VbglHGCM*</computeroutput> functions and the output
3436 buffer has the same format as the input buffer. The same address can
3437 be used as the input and output buffers.</para>
3438
3439 <para>For example see the guest part of shared clipboard, which runs
3440 as an application and uses the HGCM interface.</para>
3441 </sect2>
3442 </sect1>
3443
3444 <sect1>
3445 <title>HGCM Service Implementation</title>
3446
3447 <para>The HGCM service is a shared library with a specific set of entry
3448 points. The library must export the
3449 <computeroutput>VBoxHGCMSvcLoad</computeroutput> entry point: <screen>
3450extern "C" DECLCALLBACK(DECLEXPORT(int)) VBoxHGCMSvcLoad (VBOXHGCMSVCFNTABLE *ptable)
3451 </screen></para>
3452
3453 <para>The service must check the
3454 <computeroutput>ptable-&gt;cbSize</computeroutput> and
3455 <computeroutput>ptable-&gt;u32Version</computeroutput> fields of the
3456 input structure and fill the remaining fields with function pointers of
3457 entry points and the size of the required client buffer size.</para>
3458
3459 <para>The HGCM service gets a dedicated thread, which calls service
3460 entry points synchronously, that is the service will be called again
3461 only when a previous call has returned. However, the guest calls can be
3462 processed asynchronously. The service must call a completion callback
3463 when the operation is actually completed. The callback can be issued
3464 from another thread as well.</para>
3465
3466 <para>Service entry points are listed in the
3467 <computeroutput>VBox/hgcmsvc.h</computeroutput> in the
3468 <computeroutput>VBOXHGCMSVCFNTABLE</computeroutput> structure. <table>
3469 <title>Service entry points</title>
3470
3471 <tgroup cols="2">
3472 <tbody>
3473 <row>
3474 <entry><emphasis role="bold">Entry</emphasis></entry>
3475
3476 <entry><emphasis role="bold">Description</emphasis></entry>
3477 </row>
3478
3479 <row>
3480 <entry>pfnUnload</entry>
3481
3482 <entry>The service is being unloaded.</entry>
3483 </row>
3484
3485 <row>
3486 <entry>pfnConnect</entry>
3487
3488 <entry>A client <computeroutput>u32ClientID</computeroutput>
3489 is connected to the service. The
3490 <computeroutput>pvClient</computeroutput> parameter points to
3491 an allocated memory buffer which can be used by the service to
3492 store the client information.</entry>
3493 </row>
3494
3495 <row>
3496 <entry>pfnDisconnect</entry>
3497
3498 <entry>A client is being disconnected.</entry>
3499 </row>
3500
3501 <row>
3502 <entry>pfnCall</entry>
3503
3504 <entry>A guest client calls a service function. The
3505 <computeroutput>callHandle</computeroutput> must be used in
3506 the VBOXHGCMSVCHELPERS::pfnCallComplete callback when the call
3507 has been processed.</entry>
3508 </row>
3509
3510 <row>
3511 <entry>pfnHostCall</entry>
3512
3513 <entry>Called by the VirtualBox host components to perform
3514 functions which should be not accessible by the guest. Usually
3515 this entry point is used by VirtualBox to configure the
3516 service.</entry>
3517 </row>
3518
3519 <row>
3520 <entry>pfnSaveState</entry>
3521
3522 <entry>The VM state is being saved and the service must save
3523 relevant information using the SSM API
3524 (<computeroutput>VBox/ssm.h</computeroutput>).</entry>
3525 </row>
3526
3527 <row>
3528 <entry>pfnLoadState</entry>
3529
3530 <entry>The VM is being restored from the saved state and the
3531 service must load the saved information and be able to
3532 continue operations from the saved state.</entry>
3533 </row>
3534 </tbody>
3535 </tgroup>
3536 </table></para>
3537 </sect1>
3538 </chapter>
3539
3540 <chapter id="rdpweb">
3541 <title>RDP Web Control</title>
3542
3543 <para>The VirtualBox <emphasis>RDP Web Control</emphasis> (RDPWeb)
3544 provides remote access to a running VM. RDPWeb is a RDP (Remote Desktop
3545 Protocol) client based on Flash technology and can be used from a Web
3546 browser with a Flash plugin.</para>
3547
3548 <sect1>
3549 <title>RDPWeb features</title>
3550
3551 <para>RDPWeb is embedded into a Web page and can connect to VRDP server
3552 in order to displays the VM screen and pass keyboard and mouse events to
3553 the VM.</para>
3554 </sect1>
3555
3556 <sect1>
3557 <title>RDPWeb reference</title>
3558
3559 <para>RDPWeb consists of two required components:<itemizedlist>
3560 <listitem>
3561 <para>Flash movie
3562 <computeroutput>RDPClientUI.swf</computeroutput></para>
3563 </listitem>
3564
3565 <listitem>
3566 <para>JavaScript helpers
3567 <computeroutput>webclient.js</computeroutput></para>
3568 </listitem>
3569 </itemizedlist></para>
3570
3571 <para>The VirtualBox SDK contains sample HTML code
3572 including:<itemizedlist>
3573 <listitem>
3574 <para>JavaScript library for embedding Flash content
3575 <computeroutput>SWFObject.js</computeroutput></para>
3576 </listitem>
3577
3578 <listitem>
3579 <para>Sample HTML page
3580 <computeroutput>webclient3.html</computeroutput></para>
3581 </listitem>
3582 </itemizedlist></para>
3583
3584 <sect2>
3585 <title>RDPWeb functions</title>
3586
3587 <para><computeroutput>RDPClientUI.swf</computeroutput> and
3588 <computeroutput>webclient.js</computeroutput> work with each other.
3589 JavaScript code is responsible for a proper SWF initialization,
3590 delivering mouse events to the SWF and processing resize requests from
3591 the SWF. On the other hand, the SWF contains a few JavaScript callable
3592 methods, which are used both from
3593 <computeroutput>webclient.js</computeroutput> and the user HTML
3594 page.</para>
3595
3596 <sect3>
3597 <title>JavaScript functions</title>
3598
3599 <para><computeroutput>webclient.js</computeroutput> contains helper
3600 functions. In the following table ElementId refers to an HTML
3601 element name or attribute, and Element to the HTML element itself.
3602 HTML code<programlisting>
3603 &lt;div id="FlashRDP"&gt;
3604 &lt;/div&gt;
3605</programlisting> would have ElementId equal to FlashRDP and Element equal to
3606 the div element.</para>
3607
3608 <para><itemizedlist>
3609 <listitem>
3610 <programlisting>RDPWebClient.embedSWF(SWFFileName, ElementId)</programlisting>
3611
3612 <para>Uses SWFObject library to replace the HTML element with
3613 the Flash movie.</para>
3614 </listitem>
3615
3616 <listitem>
3617 <programlisting>RDPWebClient.isRDPWebControlById(ElementId)</programlisting>
3618
3619 <para>Returns true if the given id refers to a RDPWeb Flash
3620 element.</para>
3621 </listitem>
3622
3623 <listitem>
3624 <programlisting>RDPWebClient.isRDPWebControlByElement(Element)</programlisting>
3625
3626 <para>Returns true if the given element is a RDPWeb Flash
3627 element.</para>
3628 </listitem>
3629
3630 <listitem>
3631 <programlisting>RDPWebClient.getFlashById(ElementId)</programlisting>
3632
3633 <para>Returns an element, which is referenced by the given id.
3634 This function will try to resolve any element, event if it is
3635 not a Flash movie.</para>
3636 </listitem>
3637 </itemizedlist></para>
3638 </sect3>
3639
3640 <sect3>
3641 <title>Flash methods callable from JavaScript</title>
3642
3643 <para><computeroutput>RDPWebClienUI.swf</computeroutput> methods can
3644 be called directly from JavaScript code on a HTML page.</para>
3645
3646 <itemizedlist>
3647 <listitem>
3648 <para>getProperty(Name)</para>
3649 </listitem>
3650
3651 <listitem>
3652 <para>setProperty(Name)</para>
3653 </listitem>
3654
3655 <listitem>
3656 <para>connect()</para>
3657 </listitem>
3658
3659 <listitem>
3660 <para>disconnect()</para>
3661 </listitem>
3662
3663 <listitem>
3664 <para>keyboardSendCAD()</para>
3665 </listitem>
3666 </itemizedlist>
3667 </sect3>
3668
3669 <sect3>
3670 <title>Flash JavaScript callbacks</title>
3671
3672 <para><computeroutput>RDPWebClienUI.swf</computeroutput> calls
3673 JavaScript functions provided by the HTML page.</para>
3674 </sect3>
3675 </sect2>
3676
3677 <sect2>
3678 <title>Embedding RDPWeb in an HTML page</title>
3679
3680 <para>It is necessary to include
3681 <computeroutput>webclient.js</computeroutput> helper script. If
3682 SWFObject library is used, the
3683 <computeroutput>swfobject.js</computeroutput> must be also included
3684 and RDPWeb flash content can be embedded to a Web page using dynamic
3685 HTML. The HTML must include a "placeholder", which consists of 2
3686 <computeroutput>div</computeroutput> elements.</para>
3687 </sect2>
3688 </sect1>
3689
3690 <sect1>
3691 <title>RDPWeb change log</title>
3692
3693 <sect2>
3694 <title>Version 1.2.28</title>
3695
3696 <itemizedlist>
3697 <listitem>
3698 <para><computeroutput>keyboardLayout</computeroutput>,
3699 <computeroutput>keyboardLayouts</computeroutput>,
3700 <computeroutput>UUID</computeroutput> properties.</para>
3701 </listitem>
3702
3703 <listitem>
3704 <para>Support for German keyboard layout on the client.</para>
3705 </listitem>
3706
3707 <listitem>
3708 <para>Rebranding to Oracle.</para>
3709 </listitem>
3710 </itemizedlist>
3711 </sect2>
3712
3713 <sect2>
3714 <title>Version 1.1.26</title>
3715
3716 <itemizedlist>
3717 <listitem>
3718 <para><computeroutput>webclient.js</computeroutput> is a part of
3719 the distribution package.</para>
3720 </listitem>
3721
3722 <listitem>
3723 <para><computeroutput>lastError</computeroutput> property.</para>
3724 </listitem>
3725
3726 <listitem>
3727 <para><computeroutput>keyboardSendScancodes</computeroutput> and
3728 <computeroutput>keyboardSendCAD</computeroutput> methods.</para>
3729 </listitem>
3730 </itemizedlist>
3731 </sect2>
3732
3733 <sect2>
3734 <title>Version 1.0.24</title>
3735
3736 <itemizedlist>
3737 <listitem>
3738 <para>Initial release.</para>
3739 </listitem>
3740 </itemizedlist>
3741 </sect2>
3742 </sect1>
3743 </chapter>
3744
3745 <chapter id="dnd">
3746 <title>Drag and Drop</title>
3747
3748 <para>Since VirtualBox 4.2 it's possible to transfer files from host to the
3749 Linux guests by dragging files, directories or text from the host into the
3750 guest's screen. This is called <emphasis>drag and drop
3751 (DnD)</emphasis>.</para>
3752
3753 <para>In version 5.0 support for Windows guests has been added, as well as
3754 the ability to transfer data the other way around, that is, from the guest
3755 to the host.</para>
3756
3757 <note><para>Currently only the VirtualBox Manager frontend supports drag and
3758 drop.</para></note>
3759
3760 <para>This chapter will show how to use the required interfaces provided
3761 by VirtualBox for adding drag and drop functionality to third-party
3762 frontends.</para>
3763
3764 <sect1>
3765 <title>Basic concepts</title>
3766
3767 <para>In order to use the interfaces provided by VirtualBox, some basic
3768 concepts needs to be understood first: To successfully initiate a
3769 drag and drop operation at least two sides needs to be involved, a
3770 <emphasis>source</emphasis> and a <emphasis>target</emphasis>:</para>
3771
3772 <para>The <emphasis>source</emphasis> is the side which provides the
3773 data, e.g. is the origin of data. This data can be stored within the
3774 source directly or can be retrieved on-demand by the source itself. Other
3775 interfaces don't care where the data from this source actually came
3776 from.</para>
3777
3778 <para>The <emphasis>target</emphasis> on the other hand is the side which
3779 provides the source a visual representation where the user can drop the
3780 data the source offers. This representation can be a window (or just a
3781 certain part of it), for example.</para>
3782
3783 <para>The source and the target have abstract interfaces called
3784 <link linkend="IDnDSource">IDnDSource</link> and
3785 <link linkend="IDnDTarget">IDnDTarget</link>. VirtualBox also
3786 provides implementations of both interfaces, called
3787 <link linkend="IGuestDnDSource">IGuestDnDSource</link> and
3788 <link linkend="IGuestDnDTarget">IGuestDnDTarget</link>. Both
3789 implementations are also used in the VirtualBox Manager frontend.</para>
3790 </sect1>
3791
3792 <sect1>
3793 <title>Supported formats</title>
3794
3795 <para>As the target needs to perform specific actions depending on the
3796 data the source provided, the target first needs to know what type of
3797 data it actually is going to retrieve. It might be that the source offers
3798 data the target cannot (or intentionally does not want to)
3799 support.</para>
3800
3801 <para>VirtualBox handles those data types by providing so-called
3802 <emphasis>MIME types</emphasis> -- these MIME types were originally
3803 defined in
3804 <ulink url="https://tools.ietf.org/html/rfc2046">RFC 2046</ulink> and
3805 are also called <emphasis>Content-types</emphasis>.
3806 <link linkend="IGuestDnDSource">IGuestDnDSource</link> and
3807 <link linkend="IGuestDnDTarget">IGuestDnDTarget</link> support
3808 the following MIME types by default:<itemizedlist>
3809 <listitem>
3810 <para><emphasis role="bold">text/uri-list</emphasis> - A list of
3811 URIs (Uniform Resource Identifier, see
3812 <ulink url="https://tools.ietf.org/html/rfc3986">RFC 3986</ulink>)
3813 pointing to the file and/or directory paths already transferred
3814 from the source to the target.</para>
3815 </listitem>
3816 <listitem>
3817 <para><emphasis role="bold">text/plain;charset=utf-8</emphasis> and
3818 <emphasis role="bold">UTF8_STRING</emphasis> - text in UTF-8
3819 format.</para>
3820 </listitem>
3821 <listitem>
3822 <para><emphasis role="bold">text/plain, TEXT</emphasis>
3823 and <emphasis role="bold">STRING</emphasis> - plain ASCII text,
3824 depending on the source's active ANSI page (if any).</para>
3825 </listitem>
3826 </itemizedlist>
3827 </para>
3828
3829 <para>If, for whatever reason, a certain default format should not be
3830 supported or a new format should be registered,
3831 <link linkend="IDnDSource">IDnDSource</link> and
3832 <link linkend="IDnDTarget">IDnDTarget</link> have methods derived from
3833 <link linkend="IDnDBase">IDnDBase</link> which provide adding,
3834 removing and enumerating specific formats.
3835 <note><para>Registering new or removing default formats on the guest side
3836 currently is not implemented.</para></note></para>
3837 </sect1>
3838
3839 </chapter>
3840
3841 <chapter id="vbox-auth">
3842 <title>VirtualBox external authentication modules</title>
3843
3844 <para>VirtualBox supports arbitrary external modules to perform
3845 authentication. The module is used when the authentication method is set
3846 to "external" for a particular VM VRDE access and the library was
3847 specified with <computeroutput>VBoxManage setproperty
3848 vrdeauthlibrary</computeroutput>. Web service also use the authentication
3849 module which was specified with <computeroutput>VBoxManage setproperty
3850 websrvauthlibrary</computeroutput>.</para>
3851
3852 <para>This library will be loaded by the VM or web service process on
3853 demand, i.e. when the first remote desktop connection is made by a client
3854 or when a client that wants to use the web service logs on.</para>
3855
3856 <para>External authentication is the most flexible as the external handler
3857 can both choose to grant access to everyone (like the "null"
3858 authentication method would) and delegate the request to the guest
3859 authentication component. When delegating the request to the guest
3860 component, the handler will still be called afterwards with the option to
3861 override the result.</para>
3862
3863 <para>An authentication library is required to implement exactly one entry
3864 point:</para>
3865
3866 <screen>#include "VBoxAuth.h"
3867
3868/**
3869 * Authentication library entry point.
3870 *
3871 * Parameters:
3872 *
3873 * szCaller The name of the component which calls the library (UTF8).
3874 * pUuid Pointer to the UUID of the accessed virtual machine. Can be NULL.
3875 * guestJudgement Result of the guest authentication.
3876 * szUser User name passed in by the client (UTF8).
3877 * szPassword Password passed in by the client (UTF8).
3878 * szDomain Domain passed in by the client (UTF8).
3879 * fLogon Boolean flag. Indicates whether the entry point is called
3880 * for a client logon or the client disconnect.
3881 * clientId Server side unique identifier of the client.
3882 *
3883 * Return code:
3884 *
3885 * AuthResultAccessDenied Client access has been denied.
3886 * AuthResultAccessGranted Client has the right to use the
3887 * virtual machine.
3888 * AuthResultDelegateToGuest Guest operating system must
3889 * authenticate the client and the
3890 * library must be called again with
3891 * the result of the guest
3892 * authentication.
3893 *
3894 * Note: When 'fLogon' is 0, only pszCaller, pUuid and clientId are valid and the return
3895 * code is ignored.
3896 */
3897AuthResult AUTHCALL AuthEntry(
3898 const char *szCaller,
3899 PAUTHUUID pUuid,
3900 AuthGuestJudgement guestJudgement,
3901 const char *szUser,
3902 const char *szPassword
3903 const char *szDomain
3904 int fLogon,
3905 unsigned clientId)
3906{
3907 /* Process request against your authentication source of choice. */
3908 // if (authSucceeded(...))
3909 // return AuthResultAccessGranted;
3910 return AuthResultAccessDenied;
3911}</screen>
3912
3913 <para>A note regarding the UUID implementation of the
3914 <computeroutput>pUuid</computeroutput> argument: VirtualBox uses a
3915 consistent binary representation of UUIDs on all platforms. For this
3916 reason the integer fields comprising the UUID are stored as little endian
3917 values. If you want to pass such UUIDs to code which assumes that the
3918 integer fields are big endian (often also called network byte order), you
3919 need to adjust the contents of the UUID to e.g. achieve the same string
3920 representation. The required changes are:<itemizedlist>
3921 <listitem>
3922 <para>reverse the order of byte 0, 1, 2 and 3</para>
3923 </listitem>
3924
3925 <listitem>
3926 <para>reverse the order of byte 4 and 5</para>
3927 </listitem>
3928
3929 <listitem>
3930 <para>reverse the order of byte 6 and 7.</para>
3931 </listitem>
3932 </itemizedlist>Using this conversion you will get identical results when
3933 converting the binary UUID to the string representation.</para>
3934
3935 <para>The <computeroutput>guestJudgement</computeroutput> argument
3936 contains information about the guest authentication status. For the first
3937 call, it is always set to
3938 <computeroutput>AuthGuestNotAsked</computeroutput>. In case the
3939 <computeroutput>AuthEntry</computeroutput> function returns
3940 <computeroutput>AuthResultDelegateToGuest</computeroutput>, a guest
3941 authentication will be attempted and another call to the
3942 <computeroutput>AuthEntry</computeroutput> is made with its result. This
3943 can be either granted / denied or no judgement (the guest component chose
3944 for whatever reason to not make a decision). In case there is a problem
3945 with the guest authentication module (e.g. the Additions are not installed
3946 or not running or the guest did not respond within a timeout), the "not
3947 reacted" status will be returned.</para>
3948 </chapter>
3949
3950 <chapter id="javaapi">
3951 <title>Using Java API</title>
3952
3953 <sect1>
3954 <title>Introduction</title>
3955
3956 <para>VirtualBox can be controlled by a Java API, both locally
3957 (COM/XPCOM) and from remote (SOAP) clients. As with the Python bindings,
3958 a generic glue layer tries to hide all platform differences, allowing
3959 for source and binary compatibility on different platforms.</para>
3960 </sect1>
3961
3962 <sect1>
3963 <title>Requirements</title>
3964
3965 <para>To use the Java bindings, there are certain requirements depending
3966 on the platform. First of all, you need JDK 1.5 (Java 5) or later. Also
3967 please make sure that the version of the VirtualBox API .jar file
3968 exactly matches the version of VirtualBox you use. To avoid confusion,
3969 the VirtualBox API provides versioning in the Java package name, e.g.
3970 the package is named <computeroutput>org.virtualbox_3_2</computeroutput>
3971 for VirtualBox version 3.2. <itemizedlist>
3972 <listitem>
3973 <para><emphasis role="bold">XPCOM</emphasis> - for all platforms,
3974 but Microsoft Windows. A Java bridge based on JavaXPCOM is shipped
3975 with VirtualBox. The classpath must contain
3976 <computeroutput>vboxjxpcom.jar</computeroutput> and the
3977 <computeroutput>vbox.home</computeroutput> property must be set to
3978 location where the VirtualBox binaries are. Please make sure that
3979 the JVM bitness matches bitness of VirtualBox you use as the XPCOM
3980 bridge relies on native libraries.</para>
3981
3982 <para>Start your application like this: <programlisting>
3983 java -cp vboxjxpcom.jar -Dvbox.home=/opt/virtualbox MyProgram
3984 </programlisting></para>
3985 </listitem>
3986
3987 <listitem>
3988 <para><emphasis role="bold">COM</emphasis> - for Microsoft
3989 Windows. We rely on <computeroutput>Jacob</computeroutput> - a
3990 generic Java to COM bridge - which has to be installed seperately.
3991 See <ulink
3992 url="http://sourceforge.net/projects/jacob-project/">http://sourceforge.net/projects/jacob-project/</ulink>
3993 for installation instructions. Also, the VirtualBox provided
3994 <computeroutput>vboxjmscom.jar</computeroutput> must be in the
3995 class path.</para>
3996
3997 <para>Start your application like this:
3998 <programlisting>java -cp vboxjmscom.jar;c:\jacob\jacob.jar -Djava.library.path=c:\jacob MyProgram</programlisting></para>
3999 </listitem>
4000
4001 <listitem>
4002 <para><emphasis role="bold">SOAP</emphasis> - all platforms. Java
4003 6 is required, as it comes with builtin support for SOAP via the
4004 JAX-WS library. Also, the VirtualBox provided
4005 <computeroutput>vbojws.jar</computeroutput> must be in the class
4006 path. In the SOAP case it's possible to create several
4007 VirtualBoxManager instances to communicate with multiple
4008 VirtualBox hosts.</para>
4009
4010 <para>Start your application like this: <programlisting>
4011 java -cp vboxjws.jar MyProgram
4012 </programlisting></para>
4013 </listitem>
4014 </itemizedlist></para>
4015
4016 <para>Exception handling is also generalized by the generic glue layer,
4017 so that all methods could throw
4018 <computeroutput>VBoxException</computeroutput> containing human-readable
4019 text message (see <computeroutput>getMessage()</computeroutput> method)
4020 along with wrapped original exception (see
4021 <computeroutput>getWrapped()</computeroutput> method).</para>
4022 </sect1>
4023
4024 <sect1>
4025 <title>Example</title>
4026
4027 <para>This example shows a simple use case of the Java API. Differences
4028 for SOAP vs. local version are minimal, and limited to the connection
4029 setup phase (see <computeroutput>ws</computeroutput> variable). In the
4030 SOAP case it's possible to create several VirtualBoxManager instances to
4031 communicate with multiple VirtualBox hosts. <programlisting>
4032 import org.virtualbox_4_3.*;
4033 ....
4034 VirtualBoxManager mgr = VirtualBoxManager.createInstance(null);
4035 boolean ws = false; // or true, if we need the SOAP version
4036 if (ws)
4037 {
4038 String url = "http://myhost:18034";
4039 String user = "test";
4040 String passwd = "test";
4041 mgr.connect(url, user, passwd);
4042 }
4043 IVirtualBox vbox = mgr.getVBox();
4044 System.out.println("VirtualBox version: " + vbox.getVersion() + "\n");
4045 // get first VM name
4046 String m = vbox.getMachines().get(0).getName();
4047 System.out.println("\nAttempting to start VM '" + m + "'");
4048 // start it
4049 mgr.startVm(m, null, 7000);
4050
4051 if (ws)
4052 mgr.disconnect();
4053
4054 mgr.cleanup();
4055 </programlisting> For more a complete example, see
4056 <computeroutput>TestVBox.java</computeroutput>, shipped with the
4057 SDK. It contains exception handling and error printing code, which
4058 is important for reliable larger scale projects.</para>
4059
4060 <para>It is good practice in long-running API clients to process the
4061 system events every now and then in the main thread (does not work
4062 in other threads). As a rule of thumb it makes sense to process them
4063 every few 100msec to every few seconds). This is done by
4064 calling<programlisting>
4065 mgr.waitForEvents(0);
4066 </programlisting>
4067 This avoids that a large number of system events accumulate, which can
4068 need a significant amount of memory, and as they also play a role in
4069 object cleanup it helps freeing additional memory in a timely manner
4070 which is used by the API implementation itself. Java's garbage collection
4071 approach already needs more memory due to the delayed freeing of memory
4072 used by no longer accessible objects, and not processing the system
4073 events exacerbates the memory usage. The
4074 <computeroutput>TestVBox.java</computeroutput> example code sprinkles
4075 such lines over the code to achieve the desired effect. In multi-threaded
4076 applications it can be called from the main thread periodically.
4077 Sometimes it's possible to use the non-zero timeout variant of the
4078 method, which then waits the specified number of milliseconds for
4079 events, processing them immediately as they arrive. It achieves better
4080 runtime behavior than separate sleeping/processing.</para>
4081 </sect1>
4082 </chapter>
4083
4084 <chapter>
4085 <title>License information</title>
4086
4087 <para>The sample code files shipped with the SDK are generally licensed
4088 liberally to make it easy for anyone to use this code for their own
4089 application code.</para>
4090
4091 <para>The Java files under
4092 <computeroutput>bindings/webservice/java/jax-ws/</computeroutput> (library
4093 files for the object-oriented web service) are, by contrast, licensed
4094 under the GNU Lesser General Public License (LGPL) V2.1.</para>
4095
4096 <para>See
4097 <computeroutput>sdk/bindings/webservice/java/jax-ws/src/COPYING.LIB</computeroutput>
4098 for the full text of the LGPL 2.1.</para>
4099
4100 <para>When in doubt, please refer to the individual source code files
4101 shipped with this SDK.</para>
4102 </chapter>
4103
4104 <chapter>
4105 <title>Main API change log</title>
4106
4107 <para>Generally, VirtualBox will maintain API compatibility within a major
4108 release; a major release occurs when the first or the second of the three
4109 version components of VirtualBox change (that is, in the x.y.z scheme, a
4110 major release is one where x or y change, but not when only z
4111 changes).</para>
4112
4113 <para>In other words, updates like those from 2.0.0 to 2.0.2 will not come
4114 with API breakages.</para>
4115
4116 <para>Migration between major releases most likely will lead to API
4117 breakage, so please make sure you updated code accordingly. The OOWS Java
4118 wrappers enforce that mechanism by putting VirtualBox classes into
4119 version-specific packages such as
4120 <computeroutput>org.virtualbox_2_2</computeroutput>. This approach allows
4121 for connecting to multiple VirtualBox versions simultaneously from the
4122 same Java application.</para>
4123
4124 <para>The following sections list incompatible changes that the Main API
4125 underwent since the original release of this SDK Reference with VirtualBox
4126 2.0. A change is deemed "incompatible" only if it breaks existing client
4127 code (e.g. changes in method parameter lists, renamed or removed
4128 interfaces and similar). In other words, the list does not contain new
4129 interfaces, methods or attributes or other changes that do not affect
4130 existing client code.</para>
4131
4132 <sect1>
4133 <title>Incompatible API changes with version 6.0</title>
4134
4135 <itemizedlist>
4136
4137 <listitem><para>Video recording APIs for were changed as follows:
4138 <itemizedlist>
4139 <listitem><para>All attributes which were living in <link linkend="IMachine">IMachine</link> before
4140 have been moved to an own, dedicated interface named <link linkend="IRecordingSettings">IRecordingSettings</link>.
4141 This new interface can be accessed via the new <link linkend="IMachine__recordingSettings">IMachine::recordingSettings</link>
4142 attribute. This should emphasize that recording is not limited to video capturing as such.</para>
4143 </listitem>
4144
4145 <listitem><para>For further flexibility all specific per-VM-screen settings have been moved to a new interface
4146 called <link linkend="IRecordingScreenSettings">IRecordingScreenSettings</link>. Such settings now exist per configured
4147 VM display and can be retrieved via the <link linkend="IRecordingSettings__screens">IRecordingSettings::screens</link>
4148 attribute or the <link linkend="IRecordingSettings__getScreenSettings">IRecordingSettings::getScreenSettings</link>
4149 method.
4150 <note><para>For now all screen settings will share the same settings, e.g. different settings on a per-screen basis
4151 is not implemented yet.</para></note>
4152 </para>
4153 </listitem>
4154
4155 <listitem><para>The event <computeroutput>IVideoCaptureChangedEvent</computeroutput> was renamed into
4156 <link linkend="IRecordingChangedEvent">IRecordingChangedEvent</link>.</para>
4157 </listitem>
4158
4159 </itemizedlist>
4160 </para></listitem>
4161
4162 <listitem><para>Guest Control APIs were changed as follows:
4163 <itemizedlist>
4164 <listitem><para><link linkend="IGuest__createSession">IGuest::createSession()</link>,
4165 <link linkend="IGuestSession__processCreate">IGuestSession::processCreate()</link>,
4166 <link linkend="IGuestSession__processCreateEx">IGuestSession::processCreateEx()</link>,
4167 <link linkend="IGuestSession__directoryOpen">IGuestSession::directoryOpen()</link> and
4168 <link linkend="IGuestSession__fileOpen">IGuestSession::fileOpen()</link> now will
4169 return the new error code VBOX_E_MAXIMUM_REACHED if the limit for the according object
4170 group has been reached.</para>
4171 </listitem>
4172
4173 <listitem><para>The enumerations FileOpenExFlags, FsObjMoveFlags and DirectoryCopyFlags have
4174 been renamed to <link linkend="FileOpenExFlag">FileOpenExFlag</link>,
4175 <link linkend="FsObjMoveFlag">FsObjMoveFlag</link> and <link linkend="DirectoryCopyFlag">DirectoryCopyFlag</link>
4176 accordingly to match the rest of the API.</para>
4177 </listitem>
4178
4179 <listitem>
4180 <para>The following methods have been implemented:
4181 <computeroutput>IGuestSession::directoryCopyFromGuest()</computeroutput> and
4182 <computeroutput>IGuestSession::directoryCopyToGuest()</computeroutput>.
4183 </para>
4184
4185 <para>The following attributes have been implemented:
4186 <computeroutput>IGuestFsObjInfo::accessTime</computeroutput>,
4187 <computeroutput>IGuestFsObjInfo::birthTime</computeroutput>,
4188 <computeroutput>IGuestFsObjInfo::changeTime</computeroutput> and
4189 <computeroutput>IGuestFsObjInfo::modificationTime</computeroutput>.
4190 </para>
4191
4192 </listitem>
4193 </itemizedlist>
4194 </para></listitem>
4195
4196 <listitem><para>The webservice version of the <link linkend="ISharedFolder">ISharedFolder</link>
4197 interface was changed from a struct to a managed object. This causes incompatiblities on the
4198 protocol level as the shared folder attributes are not returned in the responses of
4199 <link linkend="IVirtualBox__sharedFolders">IVirtualBox::getSharedFolders</link> and
4200 <link linkend="IMachine__sharedFolders">IMachine::getSharedFolders</link> anymore. They
4201 return object UUIDs instead which need be wrapped by stub objects. The change is not visible when
4202 using the appropriate client bindings from the most recent VirtualBox SDK.
4203 </para></listitem>
4204
4205 </itemizedlist>
4206
4207 </sect1>
4208
4209 <sect1>
4210 <title>Incompatible API changes with version 5.x</title>
4211
4212 <itemizedlist>
4213 <listitem><para>ProcessCreateFlag::NoProfile has been renamed to
4214 <link linkend="ProcessCreateFlag__Profile">ProcessCreateFlag::Profile</link>,
4215 whereas the semantics also has been changed: ProcessCreateFlag::NoProfile
4216 explicitly <emphasis role="bold">did not</emphasis> utilize the guest user's profile data,
4217 which in turn <link linkend="ProcessCreateFlag__Profile">ProcessCreateFlag::Profile</link>
4218 explicitly <emphasis role="bold">does now</emphasis>.</para>
4219 </listitem>
4220 </itemizedlist>
4221
4222 </sect1>
4223
4224 <sect1>
4225 <title>Incompatible API changes with version 5.0</title>
4226
4227 <itemizedlist>
4228 <listitem>
4229 <para>The methods for saving state, adopting a saved state file,
4230 discarding a saved state, taking a snapshot, restoring
4231 a snapshot and deleting a snapshot have been moved from
4232 <computeroutput>IConsole</computeroutput> to
4233 <computeroutput>IMachine</computeroutput>. This straightens out the
4234 logical placement of methods and was necessary to resolve a
4235 long-standing issue, preventing 32-bit API clients from invoking
4236 those operations in the case where no VM is running.
4237 <itemizedlist>
4238 <listitem><para><link linkend="IMachine__saveState">IMachine::saveState()</link>
4239 replaces
4240 <computeroutput>IConsole::saveState()</computeroutput></para>
4241 </listitem>
4242 <listitem>
4243 <para><link linkend="IMachine__adoptSavedState">IMachine::adoptSavedState()</link>
4244 replaces
4245 <computeroutput>IConsole::adoptSavedState()</computeroutput></para>
4246 </listitem>
4247 <listitem>
4248 <para><link linkend="IMachine__discardSavedState">IMachine::discardSavedState()</link>
4249 replaces
4250 <computeroutput>IConsole::discardSavedState()</computeroutput></para>
4251 </listitem>
4252 <listitem>
4253 <para><link linkend="IMachine__takeSnapshot">IMachine::takeSnapshot()</link>
4254 replaces
4255 <computeroutput>IConsole::takeSnapshot()</computeroutput></para>
4256 </listitem>
4257 <listitem>
4258 <para><link linkend="IMachine__deleteSnapshot">IMachine::deleteSnapshot()</link>
4259 replaces
4260 <computeroutput>IConsole::deleteSnapshot()</computeroutput></para>
4261 </listitem>
4262 <listitem>
4263 <para><link linkend="IMachine__deleteSnapshotAndAllChildren">IMachine::deleteSnapshotAndAllChildren()</link>
4264 replaces
4265 <computeroutput>IConsole::deleteSnapshotAndAllChildren()</computeroutput></para>
4266 </listitem>
4267 <listitem>
4268 <para><link linkend="IMachine__deleteSnapshotRange">IMachine::deleteSnapshotRange()</link>
4269 replaces
4270 <computeroutput>IConsole::deleteSnapshotRange()</computeroutput></para>
4271 </listitem>
4272 <listitem>
4273 <para><link linkend="IMachine__restoreSnapshot">IMachine::restoreSnapshot()</link>
4274 replaces
4275 <computeroutput>IConsole::restoreSnapshot()</computeroutput></para>
4276 </listitem>
4277 </itemizedlist>
4278 Small adjustments to the parameter lists have been made to reduce
4279 the number of API calls when taking online snapshots (no longer
4280 needs explicit pausing), and taking a snapshot also returns now
4281 the snapshot id (useful for finding the right snapshot if there
4282 are non-unique snapshot names).</para>
4283 </listitem>
4284
4285 <listitem>
4286 <para>Two new machine states have been introduced to allow proper
4287 distinction between saving state and taking a snapshot.
4288 <link linkend="MachineState__Saving">MachineState::Saving</link>
4289 now is used exclusively while the VM's state is being saved, without
4290 any overlaps with snapshot functionality. The new state
4291 <link linkend="MachineState__Snapshotting">MachineState::Snapshotting</link>
4292 is used when an offline snapshot is taken and likewise the new state
4293 <link linkend="MachineState__OnlineSnapshotting">MachineState::OnlineSnapshotting</link>
4294 is used when an online snapshot is taken.</para>
4295 </listitem>
4296
4297 <listitem>
4298 <para>A new event has been introduced, which signals when a snapshot
4299 has been restored:
4300 <link linkend="ISnapshotRestoredEvent">ISnapshotRestoredEvent</link>.
4301 Previously the event
4302 <link linkend="ISnapshotDeletedEvent">ISnapshotDeletedEvent</link>
4303 was signalled, which isn't logical (but could be distinguished from
4304 actual deletion by the fact that the snapshot was still
4305 there).</para>
4306 </listitem>
4307
4308 <listitem>
4309 <para>The method
4310 <link linkend="IVirtualBox__createMedium">IVirtualBox::createMedium()</link>
4311 replaces
4312 <computeroutput>VirtualBox::createHardDisk()</computeroutput>.
4313 Adjusting existing code needs adding two parameters with
4314 value <computeroutput>AccessMode_ReadWrite</computeroutput>
4315 and <computeroutput>DeviceType_HardDisk</computeroutput>
4316 respectively. The new method supports creating floppy and
4317 DVD images, and (less obviously) further API functionality
4318 such as cloning floppy images.</para>
4319 </listitem>
4320
4321 <listitem>
4322 <para>The method
4323 <link linkend="IMachine__getStorageControllerByInstance">IMachine::getStorageControllerByInstance()</link>
4324 now has an additional parameter (first parameter), for specifying the
4325 storage bus which the storage controller must be using. The method
4326 was not useful before, as the instance numbers are only unique for a
4327 specfic storage bus.</para>
4328 </listitem>
4329
4330 <listitem>
4331 <para>The attribute
4332 <computeroutput>IMachine::sessionType</computeroutput> has been
4333 renamed to
4334 <link linkend="IMachine__sessionName">IMachine::sessionName()</link>.
4335 This cleans up the confusing terminology (as the session type is
4336 something different).</para>
4337 </listitem>
4338
4339 <listitem>
4340 <para>The attribute
4341 <computeroutput>IMachine::guestPropertyNotificationPatterns</computeroutput>
4342 has been removed. In practice it was not usable because it is too
4343 global and didn't distinguish between API clients.</para>
4344 </listitem>
4345
4346 <listitem><para>Drag and drop APIs were changed as follows:<itemizedlist>
4347
4348 <listitem>
4349 <para>Methods for providing host to guest drag and drop
4350 functionality, such as
4351 <computeroutput>IGuest::dragHGEnter</computeroutput>,
4352 <computeroutput>IGuest::dragHGMove()</computeroutput>,
4353 <computeroutput>IGuest::dragHGLeave()</computeroutput>,
4354 <computeroutput>IGuest::dragHGDrop()</computeroutput> and
4355 <computeroutput>IGuest::dragHGPutData()</computeroutput>,
4356 have been moved to an abstract base class called
4357 <link linkend="IDnDTarget">IDnDTarget</link>.
4358 VirtualBox implements this base class in the
4359 <link linkend="IGuestDnDTarget">IGuestDnDTarget</link>
4360 interface. The implementation can be used by using the
4361 <link linkend="IGuest__dnDTarget">IGuest::dnDTarget()</link>
4362 method.</para>
4363 <para>Methods for providing guest to host drag and drop
4364 functionality, such as
4365 <computeroutput>IGuest::dragGHPending()</computeroutput>,
4366 <computeroutput>IGuest::dragGHDropped()</computeroutput> and
4367 <computeroutput>IGuest::dragGHGetData()</computeroutput>,
4368 have been moved to an abstract base class called
4369 <link linkend="IDnDSource">IDnDSource</link>.
4370 VirtualBox implements this base class in the
4371 <link linkend="IGuestDnDSource">IGuestDnDSource</link>
4372 interface. The implementation can be used by using the
4373 <link linkend="IGuest__dnDSource">IGuest::dnDSource()</link>
4374 method.</para>
4375 </listitem>
4376
4377 <listitem>
4378 <para>The <computeroutput>DragAndDropAction</computeroutput>
4379 enumeration has been renamed to
4380 <link linkend="DnDAction">DnDAction</link>.</para>
4381 </listitem>
4382
4383 <listitem>
4384 <para>The <computeroutput>DragAndDropMode</computeroutput>
4385 enumeration has been renamed to
4386 <link linkend="DnDMode">DnDMode</link>.</para>
4387 </listitem>
4388
4389 <listitem>
4390 <para>The attribute
4391 <computeroutput>IMachine::dragAndDropMode</computeroutput>
4392 has been renamed to
4393 <link linkend="IMachine__dnDMode">IMachine::dnDMode()</link>.</para>
4394 </listitem>
4395
4396 <listitem>
4397 <para>The event
4398 <computeroutput>IDragAndDropModeChangedEvent</computeroutput>
4399 has been renamed to
4400 <link linkend="IDnDModeChangedEvent">IDnDModeChangedEvent</link>.</para>
4401 </listitem>
4402
4403 </itemizedlist></para>
4404 </listitem>
4405
4406 <listitem><para>IDisplay and IFramebuffer interfaces were changed to
4407 allow IFramebuffer object to reside in a separate frontend
4408 process:<itemizedlist>
4409
4410 <listitem><para>
4411 IDisplay::ResizeCompleted() has been removed, because the
4412 IFramebuffer object does not provide the screen memory anymore.
4413 </para></listitem>
4414
4415 <listitem><para>
4416 IDisplay::SetFramebuffer() has been replaced with
4417 IDisplay::AttachFramebuffer() and IDisplay::DetachFramebuffer().
4418 </para></listitem>
4419
4420 <listitem><para>
4421 IDisplay::GetFramebuffer() has been replaced with
4422 IDisplay::QueryFramebuffer().
4423 </para></listitem>
4424
4425 <listitem><para>
4426 IDisplay::GetScreenResolution() has a new output parameter
4427 <computeroutput>guestMonitorStatus</computeroutput>
4428 which tells whether the monitor is enabled in the guest.
4429 </para></listitem>
4430
4431 <listitem><para>
4432 IDisplay::TakeScreenShot() and IDisplay::TakeScreenShotToArray()
4433 have a new parameter
4434 <computeroutput>bitmapFormat</computeroutput>. As a consequence of
4435 this, IDisplay::TakeScreenShotPNGToArray() has been removed.
4436 </para></listitem>
4437
4438 <listitem><para>
4439 IFramebuffer::RequestResize() has been replaced with
4440 IFramebuffer::NotifyChange().
4441 </para></listitem>
4442
4443 <listitem><para>
4444 IFramebuffer::NotifyUpdateImage() added to support IFramebuffer
4445 objects in a different process.
4446 </para></listitem>
4447
4448 <listitem><para>
4449 IFramebuffer::Lock(), IFramebuffer::Unlock(),
4450 IFramebuffer::Address(), IFramebuffer::UsesGuestVRAM() have been
4451 removed because the IFramebuffer object does not provide the screen
4452 memory anymore.
4453 </para></listitem>
4454
4455 </itemizedlist></para>
4456 </listitem>
4457
4458 <listitem><para>IGuestSession, IGuestFile and IGuestProcess interfaces
4459 were changed as follows:
4460 <itemizedlist>
4461 <listitem>
4462 <para>Replaced IGuestSession::directoryQueryInfo and
4463 IGuestSession::fileQueryInfo with a new
4464 <link linkend="IGuestSession__fsObjQueryInfo">IGuestSession::fsObjQueryInfo</link>
4465 method that works on any type of file system object.</para>
4466 </listitem>
4467 <listitem>
4468 <para>Replaced IGuestSession::fileRemove,
4469 IGuestSession::symlinkRemoveDirectory and
4470 IGuestSession::symlinkRemoveFile with a new
4471 <link linkend="IGuestSession__fsObjRemove">IGuestSession::fsObjRemove</link>
4472 method that works on any type of file system object except
4473 directories. (fileRemove also worked on any type of object
4474 too, though that was not the intent of the method.)</para>
4475 </listitem>
4476 <listitem>
4477 <para>Replaced IGuestSession::directoryRename and
4478 IGuestSession::directoryRename with a new
4479 <link linkend="IGuestSession__fsObjRename">IGuestSession::fsObjRename</link>
4480 method that works on any type of file system object.
4481 (directoryRename and fileRename may already have worked for
4482 any kind of object, but that was never the intent of the
4483 methods.)</para>
4484 </listitem>
4485 <listitem>
4486 <para>Replaced the unimplemented IGuestSession::directorySetACL
4487 and IGuestSession::fileSetACL with a new
4488 <link linkend="IGuestSession__fsObjSetACL">IGuestSession::fsObjSetACL</link>
4489 method that works on all type of file system object. Also
4490 added a UNIX-style mode parameter as an alternative to the
4491 ACL.</para>
4492 </listitem>
4493 <listitem>
4494 <para>Replaced IGuestSession::fileRemove,
4495 IGuestSession::symlinkRemoveDirectory and
4496 IGuestSession::symlinkRemoveFile with a new
4497 <link linkend="IGuestSession__fsObjRemove">IGuestSession::fsObjRemove</link>
4498 method that works on any type of file system object except
4499 directories (fileRemove also worked on any type of object,
4500 though that was not the intent of the method.)</para>
4501 </listitem>
4502 <listitem>
4503 <para>Renamed IGuestSession::copyTo to
4504 <link linkend="IGuestSession__fileCopyToGuest">IGuestSession::fileCopyToGuest</link>.</para>
4505 </listitem>
4506 <listitem>
4507 <para>Renamed IGuestSession::copyFrom to
4508 <link linkend="IGuestSession__fileCopyFromGuest">IGuestSession::fileCopyFromGuest</link>.</para>
4509 </listitem>
4510 <listitem>
4511 <para>Renamed the CopyFileFlag enum to
4512 <link linkend="FileCopyFlag">FileCopyFlag</link>.</para>
4513 </listitem>
4514 <listitem>
4515 <para>Renamed the IGuestSession::environment attribute to
4516 <link linkend="IGuestSession__environmentChanges">IGuestSession::environmentChanges</link>
4517 to better reflect what it does.</para>
4518 </listitem>
4519 <listitem>
4520 <para>Changed the
4521 <link linkend="IProcess__environment">IGuestProcess::environment</link>
4522 to a stub returning E_NOTIMPL since it wasn't doing what was
4523 advertised (returned changes, not the actual environment).</para>
4524 </listitem>
4525 <listitem>
4526 <para>Renamed IGuestSession::environmentSet to
4527 <link linkend="IGuestSession__environmentScheduleSet">IGuestSession::environmentScheduleSet</link>
4528 to better reflect what it does.</para>
4529 </listitem>
4530 <listitem>
4531 <para>Renamed IGuestSession::environmentUnset to
4532 <link linkend="IGuestSession__environmentScheduleUnset">IGuestSession::environmentScheduleUnset</link>
4533 to better reflect what it does.</para>
4534 </listitem>
4535 <listitem>
4536 <para>Removed IGuestSession::environmentGet it was only getting
4537 changes while giving the impression it was actual environment
4538 variables, and it did not represent scheduled unset
4539 operations.</para>
4540 </listitem>
4541 <listitem>
4542 <para>Removed IGuestSession::environmentClear as it duplicates
4543 assigning an empty array to the
4544 <link linkend="IGuestSession__environmentChanges">IGuestSession::environmentChanges</link>
4545 (formerly known as IGuestSession::environment).</para>
4546 </listitem>
4547 <listitem>
4548 <para>Changed the
4549 <link linkend="IGuestSession__processCreate">IGuestSession::processCreate</link>
4550 and
4551 <link linkend="IGuestSession__processCreateEx">IGuestSession::processCreateEx</link>
4552 methods to accept arguments starting with argument zero (argv[0])
4553 instead of argument one (argv[1]). (Not yet implemented on the
4554 guest additions side, so argv[0] will probably be ignored for a
4555 short while.)</para>
4556 </listitem>
4557
4558 <listitem>
4559 <para>Added a followSymlink parameter to the following methods:
4560 <itemizedlist>
4561 <listitem><para><link linkend="IGuestSession__directoryExists">IGuestSession::directoryExists</link></para></listitem>
4562 <listitem><para><link linkend="IGuestSession__fileExists">IGuestSession::fileExists</link></para></listitem>
4563 <listitem><para><link linkend="IGuestSession__fileQuerySize">IGuestSession::fileQuerySize</link></para></listitem>
4564 </itemizedlist></para>
4565 </listitem>
4566 <listitem>
4567 <para>The parameters to the
4568 <link linkend="IGuestSession__fileOpen">IGuestSession::fileOpen</link>
4569 and
4570 <link linkend="IGuestSession__fileOpenEx">IGuestSession::fileOpenEx</link>
4571 methods were altered:<itemizedlist>
4572 <listitem><para>The openMode string parameter was replaced by
4573 the enum
4574 <link linkend="FileAccessMode">FileAccessMode</link>
4575 and renamed to accessMode.</para></listitem>
4576 <listitem><para>The disposition string parameter was replaced
4577 by the enum
4578 <link linkend="FileOpenAction">FileOpenAction</link>
4579 and renamed to openAction.</para></listitem>
4580 <listitem><para>The unimplemented sharingMode string parameter
4581 was replaced by the enum
4582 <link linkend="FileSharingMode">FileSharingMode</link>
4583 (fileOpenEx only).</para></listitem>
4584 <listitem><para>Added a flags parameter taking a list of
4585 <link linkend="FileOpenExFlag">FileOpenExFlag</link> values
4586 (fileOpenEx only).</para></listitem>
4587 <listitem><para>Removed the offset parameter (fileOpenEx
4588 only).</para></listitem>
4589 </itemizedlist></para>
4590 </listitem>
4591
4592 <listitem>
4593 <para><link linkend="IFile__seek">IGuestFile::seek</link> now
4594 returns the new offset.</para>
4595 </listitem>
4596 <listitem>
4597 <para>Renamed the FileSeekType enum used by
4598 <link linkend="IFile__seek">IGuestFile::seek</link>
4599 to <link linkend="FileSeekOrigin">FileSeekOrigin</link> and
4600 added the missing End value and renaming the Set to
4601 Begin.</para>
4602 </listitem>
4603 <listitem>
4604 <para>Extended the unimplemented
4605 <link linkend="IFile__setACL">IGuestFile::setACL</link>
4606 method with a UNIX-style mode parameter as an alternative to
4607 the ACL.</para>
4608 </listitem>
4609 <listitem>
4610 <para>Renamed the IFile::openMode attribute to
4611 <link linkend="IFile__accessMode">IFile::accessMode</link>
4612 and change the type from string to
4613 <link linkend="FileAccessMode">FileAccessMode</link> to reflect
4614 the changes to the fileOpen methods.</para>
4615 </listitem>
4616 <listitem>
4617 <para>Renamed the IGuestFile::disposition attribute to
4618 <link linkend="IFile__openAction">IFile::openAction</link> and
4619 change the type from string to
4620 <link linkend="FileOpenAction">FileOpenAction</link> to reflect
4621 the changes to the fileOpen methods.</para>
4622 </listitem>
4623
4624 <!-- Non-incompatible things worth mentioning (stubbed methods/attrs aren't worth it). -->
4625 <listitem>
4626 <para>Added
4627 <link linkend="IGuestSession__pathStyle">IGuestSession::pathStyle</link>
4628 attribute.</para>
4629 </listitem>
4630 <listitem>
4631 <para>Added
4632 <link linkend="IGuestSession__fsObjExists">IGuestSession::fsObjExists</link>
4633 attribute.</para>
4634 </listitem>
4635
4636 </itemizedlist>
4637 </para>
4638 </listitem>
4639
4640 <listitem><para>
4641 IConsole::GetDeviceActivity() returns information about multiple
4642 devices.
4643 </para></listitem>
4644
4645 <listitem><para>
4646 IMachine::ReadSavedThumbnailToArray() has a new parameter
4647 <computeroutput>bitmapFormat</computeroutput>. As a consequence of
4648 this, IMachine::ReadSavedThumbnailPNGToArray() has been removed.
4649 </para></listitem>
4650
4651 <listitem><para>
4652 IMachine::QuerySavedScreenshotPNGSize() has been renamed to
4653 IMachine::QuerySavedScreenshotInfo() which also returns
4654 an array of available screenshot formats.
4655 </para></listitem>
4656
4657 <listitem><para>
4658 IMachine::ReadSavedScreenshotPNGToArray() has been renamed to
4659 IMachine::ReadSavedScreenshotToArray() which has a new parameter
4660 <computeroutput>bitmapFormat</computeroutput>.
4661 </para></listitem>
4662
4663 <listitem><para>
4664 IMachine::QuerySavedThumbnailSize() has been removed.
4665 </para></listitem>
4666
4667 <listitem>
4668 <para>The method
4669 <link linkend="IWebsessionManager__getSessionObject">IWebsessionManager::getSessionObject()</link>
4670 now returns a new <link linkend="ISession">ISession</link> instance
4671 for every invocation. This puts the behavior in line with other
4672 binding styles, which never forced the equivalent of establishing
4673 another connection and logging in again to get another
4674 instance.</para>
4675 </listitem>
4676 </itemizedlist>
4677 </sect1>
4678
4679 <sect1>
4680 <title>Incompatible API changes with version 4.3</title>
4681
4682 <itemizedlist>
4683 <listitem>
4684 <para>The explicit medium locking methods
4685 <link linkend="IMedium__lockRead">IMedium::lockRead()</link>
4686 and <link linkend="IMedium__lockWrite">IMedium::lockWrite()</link>
4687 have been redesigned. They return a lock token object reference
4688 now, and calling the
4689 <link linkend="IToken__abandon">IToken::abandon()</link> method (or
4690 letting the reference count to this object drop to 0) will unlock
4691 it. This eliminates the rather common problem that an API client
4692 crash left behind locks, and also improves the safety (API clients
4693 can't release locks they didn't obtain).</para>
4694 </listitem>
4695
4696 <listitem>
4697 <para>The parameter list of
4698 <link linkend="IAppliance__write">IAppliance::write()</link>
4699 has been changed slightly, to allow multiple flags to be
4700 passed.</para>
4701 </listitem>
4702
4703 <listitem>
4704 <para><computeroutput>IMachine::delete</computeroutput>
4705 has been renamed to
4706 <link linkend="IMachine__deleteConfig">IMachine::deleteConfig()</link>,
4707 to improve API client binding compatibility.</para>
4708 </listitem>
4709
4710 <listitem>
4711 <para><computeroutput>IMachine::export</computeroutput>
4712 has been renamed to
4713 <link linkend="IMachine__exportTo">IMachine::exportTo()</link>,
4714 to improve API client binding compatibility.</para>
4715 </listitem>
4716
4717 <listitem>
4718 <para>For
4719 <link linkend="IMachine__launchVMProcess">IMachine::launchVMProcess()</link>
4720 the meaning of the <computeroutput>type</computeroutput> parameter
4721 has changed slightly. Empty string now means that the per-VM or
4722 global default frontend is launched. Most callers of this method
4723 should use the empty string now, unless they really want to override
4724 the default and launch a particular frontend.</para>
4725 </listitem>
4726
4727 <listitem>
4728 <para>Medium management APIs were changed as follows:<itemizedlist>
4729
4730 <listitem>
4731 <para>The type of attribute
4732 <link linkend="IMedium__variant">IMedium::variant()</link>
4733 changed from <computeroutput>unsigned long</computeroutput>
4734 to <computeroutput>safe-array MediumVariant</computeroutput>.
4735 It is an array of flags instead of a set of flags which were
4736 stored inside one variable.
4737 </para>
4738 </listitem>
4739
4740 <listitem>
4741 <para>The parameter list for
4742 <link linkend="IMedium__cloneTo">IMedium::cloneTo()</link>
4743 was modified. The type of parameter variant was changed from
4744 unsigned long to safe-array MediumVariant.
4745 </para>
4746 </listitem>
4747
4748 <listitem>
4749 <para>The parameter list for
4750 <link linkend="IMedium__createBaseStorage">IMedium::createBaseStorage()</link>
4751 was modified. The type of parameter variant was changed from
4752 unsigned long to safe-array MediumVariant.
4753 </para>
4754 </listitem>
4755
4756 <listitem>
4757 <para>The parameter list for
4758 <link linkend="IMedium__createDiffStorage">IMedium::createDiffStorage()</link>
4759 was modified. The type of parameter variant was changed from
4760 unsigned long to safe-array MediumVariant.
4761 </para>
4762 </listitem>
4763
4764 <listitem>
4765 <para>The parameter list for
4766 <link linkend="IMedium__cloneToBase">IMedium::cloneToBase()</link>
4767 was modified. The type of parameter variant was changed from
4768 unsigned long to safe-array MediumVariant.
4769 </para>
4770 </listitem>
4771 </itemizedlist></para>
4772 </listitem>
4773
4774 <listitem>
4775 <para>The type of attribute
4776 <link linkend="IMediumFormat__capabilities">IMediumFormat::capabilities()</link>
4777 changed from <computeroutput>unsigned long</computeroutput> to
4778 <computeroutput>safe-array MediumFormatCapabilities</computeroutput>.
4779 It is an array of flags instead of a set of flags which were stored
4780 inside one variable.
4781 </para>
4782 </listitem>
4783
4784 <listitem>
4785 <para>The attribute
4786 <link linkend="IMedium__logicalSize">IMedium::logicalSize()</link>
4787 now returns the logical size of exactly this medium object (whether
4788 it is a base or diff image). The old behavior was no longer
4789 acceptable, as each image can have a different capacity.</para>
4790 </listitem>
4791
4792 <listitem>
4793 <para>Guest control APIs - such as
4794 <link linkend="IGuest">IGuest</link>,
4795 <link linkend="IGuestSession">IGuestSession</link>,
4796 <link linkend="IGuestProcess">IGuestProcess</link> and so on - now
4797 emit own events to provide clients much finer control and the ability
4798 to write own frontends for guest operations. The event
4799 <link linkend="IGuestSessionEvent">IGuestSessionEvent</link> acts as
4800 an abstract base class for all guest control events. Certain guest
4801 events contain a
4802 <link linkend="IVirtualBoxErrorInfo">IVirtualBoxErrorInfo</link>
4803 member to provide more information in case of an error happened on
4804 the guest side.</para>
4805 </listitem>
4806
4807 <listitem>
4808 <para>Guest control sessions on the guest started by
4809 <link linkend="IGuest__createSession">IGuest::createSession()</link>
4810 now are dedicated guest processes to provide more safety and
4811 performance for certain operations. Also, the
4812 <link linkend="IGuest__createSession">IGuest::createSession()</link>
4813 call does not wait for the guest session being created anymore due
4814 to the dedicated guest session processes just mentioned. This also
4815 will enable webservice clients to handle guest session creation
4816 more gracefully. To wait for a guest session being started, use the
4817 newly added attribute
4818 <link linkend="IGuestSession__status">IGuestSession::status()</link>
4819 to query the current guest session status.</para>
4820 </listitem>
4821
4822 <listitem>
4823 <para>The <link linkend="IGuestFile">IGuestFile</link>
4824 APIs are now implemented to provide native guest file access from
4825 the host.</para>
4826 </listitem>
4827
4828 <listitem>
4829 <para>The parameter list for
4830 <link linkend="IGuest__updateGuestAdditions">IMedium::updateGuestAdditions()</link>
4831 was modified. It now supports specifying optional command line
4832 arguments for the Guest Additions installer performing the actual
4833 update on the guest.
4834 </para>
4835 </listitem>
4836
4837 <listitem>
4838 <para>A new event
4839 <link linkend="IGuestUserStateChangedEvent">IGuestUserStateChangedEvent</link>
4840 was introduced to provide guest user status updates to the host via
4841 event listeners. To use this event there needs to be at least the 4.3
4842 Guest Additions installed on the guest. At the moment only the states
4843 "Idle" and "InUse" of the
4844 <link linkend="GuestUserState">GuestUserState</link> enumeration arei
4845 supported on Windows guests, starting at Windows 2000 SP2.</para>
4846 </listitem>
4847
4848 <listitem>
4849 <para>
4850 The attribute
4851 <link linkend="IGuestSession__protocolVersion">IGuestSession::protocolVersion</link>
4852 was added to provide a convenient way to lookup the guest session's
4853 protocol version it uses to communicate with the installed Guest
4854 Additions on the guest. Older Guest Additions will set the protocol
4855 version to 1, whereas Guest Additions 4.3 will set the protocol
4856 version to 2. This might change in the future as new features
4857 arise.</para>
4858 </listitem>
4859
4860 <listitem>
4861 <para><computeroutput>IDisplay::getScreenResolution</computeroutput>
4862 has been extended to return the display position in the guest.</para>
4863 </listitem>
4864
4865 <listitem>
4866 <para>
4867 The <link linkend="IUSBController">IUSBController</link>
4868 class is not a singleton of
4869 <link linkend="IMachine">IMachine</link> anymore but
4870 <link linkend="IMachine">IMachine</link> contains a list of USB
4871 controllers present in the VM. The USB device filter handling was
4872 moved to
4873 <link linkend="IUSBDeviceFilters">IUSBDeviceFilters</link>.
4874 </para>
4875 </listitem>
4876 </itemizedlist>
4877 </sect1>
4878
4879 <sect1>
4880 <title>Incompatible API changes with version 4.2</title>
4881
4882 <itemizedlist>
4883 <listitem>
4884 <para>Guest control APIs for executing guest processes, working with
4885 guest files or directories have been moved to the newly introduced
4886 <link linkend="IGuestSession">IGuestSession</link> interface which
4887 can be created by calling
4888 <link linkend="IGuest__createSession">IGuest::createSession()</link>.</para>
4889
4890 <para>A guest session will act as a
4891 guest user's impersonation so that the guest credentials only have to
4892 be provided when creating a new guest session. There can be up to 32
4893 guest sessions at once per VM, each session serving up to 2048 guest
4894 processes running or files opened.</para>
4895
4896 <para>Instead of working with process or directory handles before
4897 version 4.2, there now are the dedicated interfaces
4898 <link linkend="IGuestProcess">IGuestProcess</link>,
4899 <link linkend="IGuestDirectory">IGuestDirectory</link> and
4900 <link linkend="IGuestFile">IGuestFile</link>. To retrieve more
4901 information of a file system object the new interface
4902 <link linkend="IGuestFsObjInfo">IGuestFsObjInfo</link> has been
4903 introduced.</para>
4904
4905 <para>Even though the guest control API was changed it is backwards
4906 compatible so that it can be used with older installed Guest
4907 Additions. However, to use upcoming features like process termination
4908 or waiting for input / output new Guest Additions must be installed
4909 when these features got implemented.</para>
4910
4911 <para>The following limitations apply:
4912 <itemizedlist>
4913 <listitem><para>The <link linkend="IGuestFile">IGuestFile</link>
4914 interface is not fully implemented yet.</para>
4915 </listitem>
4916 <listitem><para>The symbolic link APIs
4917 <link linkend="IGuestSession__symlinkCreate">IGuestSession::symlinkCreate()</link>,
4918 <link linkend="IGuestSession__symlinkExists">IGuestSession::symlinkExists()</link>,
4919 <link linkend="IGuestSession__symlinkRead">IGuestSession::symlinkRead()</link>,
4920 IGuestSession::symlinkRemoveDirectory() and
4921 IGuestSession::symlinkRemoveFile() are not
4922 implemented yet.</para>
4923 </listitem>
4924 <listitem><para>The directory APIs
4925 <link linkend="IGuestSession__directoryRemove">IGuestSession::directoryRemove()</link>,
4926 <link linkend="IGuestSession__directoryRemoveRecursive">IGuestSession::directoryRemoveRecursive()</link>,
4927 IGuestSession::directoryRename() and
4928 IGuestSession::directorySetACL() are not
4929 implemented yet.</para>
4930 </listitem>
4931 <listitem><para>The temporary file creation API
4932 <link linkend="IGuestSession__fileCreateTemp">IGuestSession::fileCreateTemp()</link>
4933 is not implemented yet.</para>
4934 </listitem>
4935 <listitem><para>Guest process termination via
4936 <link linkend="IProcess__terminate">IProcess::terminate()</link>
4937 is not implemented yet.</para>
4938 </listitem>
4939 <listitem><para>Waiting for guest process output via
4940 <link linkend="ProcessWaitForFlag__StdOut">ProcessWaitForFlag::StdOut</link>
4941 and
4942 <link linkend="ProcessWaitForFlag__StdErr">ProcessWaitForFlag::StdErr</link>
4943 is not implemented yet.</para>
4944 <para>To wait for process output,
4945 <link linkend="IProcess__read">IProcess::read()</link> with
4946 appropriate flags still can be used to periodically check for
4947 new output data to arrive. Note that
4948 <link linkend="ProcessCreateFlag__WaitForStdOut">ProcessCreateFlag::WaitForStdOut</link>
4949 and / or
4950 <link linkend="ProcessCreateFlag__WaitForStdErr">ProcessCreateFlag::WaitForStdErr</link>
4951 need to be specified when creating a guest process via
4952 <link linkend="IGuestSession__processCreate">IGuestSession::processCreate()</link>
4953 or
4954 <link linkend="IGuestSession__processCreateEx">IGuestSession::processCreateEx()</link>.</para>
4955 </listitem>
4956 <listitem>
4957 <para>ACL (Access Control List) handling in general is not
4958 implemented yet.</para>
4959 </listitem>
4960 </itemizedlist>
4961 </para>
4962 </listitem>
4963
4964 <listitem>
4965 <para>The <link linkend="LockType">LockType</link>
4966 enumeration now has an additional value
4967 <computeroutput>VM</computeroutput> which tells
4968 <link linkend="IMachine__lockMachine">IMachine::lockMachine()</link>
4969 to create a full-blown object structure for running a VM. This was
4970 the previous behavior with <computeroutput>Write</computeroutput>,
4971 which now only creates the minimal object structure to save time and
4972 resources (at the moment the Console object is still created, but all
4973 sub-objects such as Display, Keyboard, Mouse, Guest are not.</para>
4974 </listitem>
4975
4976 <listitem>
4977 <para>Machines can be put in groups (actually an array of groups).
4978 The primary group affects the default placement of files belonging
4979 to a VM.
4980 <link linkend="IVirtualBox__createMachine">IVirtualBox::createMachine()</link>
4981 and
4982 <link linkend="IVirtualBox__composeMachineFilename">IVirtualBox::composeMachineFilename()</link>
4983 have been adjusted accordingly, the former taking an array of groups
4984 as an additional parameter and the latter taking a group as an
4985 additional parameter. The create option handling has been changed for
4986 those two methods, too.</para>
4987 </listitem>
4988
4989 <listitem>
4990 <para>The method IVirtualBox::findMedium() has been removed, since
4991 it provides a subset of the functionality of
4992 <link linkend="IVirtualBox__openMedium">IVirtualBox::openMedium()</link>.</para>
4993 </listitem>
4994
4995 <listitem>
4996 <para>The use of acronyms in API enumeration, interface, attribute
4997 and method names has been made much more consistent, previously they
4998 sometimes were lowercase and sometimes mixed case. They are now
4999 consistently all caps:<table>
5000 <title>Renamed identifiers in VirtualBox 4.2</title>
5001
5002 <tgroup cols="2" style="verywide">
5003 <tbody>
5004 <row>
5005 <entry><emphasis role="bold">Old name</emphasis></entry>
5006
5007 <entry><emphasis role="bold">New name</emphasis></entry>
5008 </row>
5009 <row>
5010 <entry>PointingHidType</entry>
5011 <entry><link linkend="PointingHIDType">PointingHIDType</link></entry>
5012 </row>
5013 <row>
5014 <entry>KeyboardHidType</entry>
5015 <entry><link linkend="KeyboardHIDType">KeyboardHIDType</link></entry>
5016 </row>
5017 <row>
5018 <entry>IPciAddress</entry>
5019 <entry><link linkend="IPCIAddress">IPCIAddress</link></entry>
5020 </row>
5021 <row>
5022 <entry>IPciDeviceAttachment</entry>
5023 <entry><link linkend="IPCIDeviceAttachment">IPCIDeviceAttachment</link></entry>
5024 </row>
5025 <row>
5026 <entry>IMachine::pointingHidType</entry>
5027 <entry><link linkend="IMachine__pointingHIDType">IMachine::pointingHIDType</link></entry>
5028 </row>
5029 <row>
5030 <entry>IMachine::keyboardHidType</entry>
5031 <entry><link linkend="IMachine__keyboardHIDType">IMachine::keyboardHIDType</link></entry>
5032 </row>
5033 <row>
5034 <entry>IMachine::hpetEnabled</entry>
5035 <entry><link linkend="IMachine__HPETEnabled">IMachine::HPETEnabled</link></entry>
5036 </row>
5037 <row>
5038 <entry>IMachine::sessionPid</entry>
5039 <entry><link linkend="IMachine__sessionPID">IMachine::sessionPID</link></entry>
5040 </row>
5041 <row>
5042 <entry>IMachine::ioCacheEnabled</entry>
5043 <entry><link linkend="IMachine__IOCacheEnabled">IMachine::IOCacheEnabled</link></entry>
5044 </row>
5045 <row>
5046 <entry>IMachine::ioCacheSize</entry>
5047 <entry><link linkend="IMachine__IOCacheSize">IMachine::IOCacheSize</link></entry>
5048 </row>
5049 <row>
5050 <entry>IMachine::pciDeviceAssignments</entry>
5051 <entry><link linkend="IMachine__PCIDeviceAssignments">IMachine::PCIDeviceAssignments</link></entry>
5052 </row>
5053 <row>
5054 <entry>IMachine::attachHostPciDevice()</entry>
5055 <entry><link linkend="IMachine__attachHostPCIDevice">IMachine::attachHostPCIDevice</link></entry>
5056 </row>
5057 <row>
5058 <entry>IMachine::detachHostPciDevice()</entry>
5059 <entry><link linkend="IMachine__detachHostPCIDevice">IMachine::detachHostPCIDevice()</link></entry>
5060 </row>
5061 <row>
5062 <entry>IConsole::attachedPciDevices</entry>
5063 <entry><link linkend="IConsole__attachedPCIDevices">IConsole::attachedPCIDevices</link></entry>
5064 </row>
5065 <row>
5066 <entry>IHostNetworkInterface::dhcpEnabled</entry>
5067 <entry><link linkend="IHostNetworkInterface__DHCPEnabled">IHostNetworkInterface::DHCPEnabled</link></entry>
5068 </row>
5069 <row>
5070 <entry>IHostNetworkInterface::enableStaticIpConfig()</entry>
5071 <entry><link linkend="IHostNetworkInterface__enableStaticIPConfig">IHostNetworkInterface::enableStaticIPConfig()</link></entry>
5072 </row>
5073 <row>
5074 <entry>IHostNetworkInterface::enableStaticIpConfigV6()</entry>
5075 <entry><link linkend="IHostNetworkInterface__enableStaticIPConfigV6">IHostNetworkInterface::enableStaticIPConfigV6()</link></entry>
5076 </row>
5077 <row>
5078 <entry>IHostNetworkInterface::enableDynamicIpConfig()</entry>
5079 <entry><link linkend="IHostNetworkInterface__enableDynamicIPConfig">IHostNetworkInterface::enableDynamicIPConfig()</link></entry>
5080 </row>
5081 <row>
5082 <entry>IHostNetworkInterface::dhcpRediscover()</entry>
5083 <entry><link linkend="IHostNetworkInterface__DHCPRediscover">IHostNetworkInterface::DHCPRediscover()</link></entry>
5084 </row>
5085 <row>
5086 <entry>IHost::Acceleration3DAvailable</entry>
5087 <entry><link linkend="IHost__acceleration3DAvailable">IHost::acceleration3DAvailable</link></entry>
5088 </row>
5089 <row>
5090 <entry>IGuestOSType::recommendedPae</entry>
5091 <entry><link linkend="IGuestOSType__recommendedPAE">IGuestOSType::recommendedPAE</link></entry>
5092 </row>
5093 <row>
5094 <entry>IGuestOSType::recommendedDvdStorageController</entry>
5095 <entry><link linkend="IGuestOSType__recommendedDVDStorageController">IGuestOSType::recommendedDVDStorageController</link></entry>
5096 </row>
5097 <row>
5098 <entry>IGuestOSType::recommendedDvdStorageBus</entry>
5099 <entry><link linkend="IGuestOSType__recommendedDVDStorageBus">IGuestOSType::recommendedDVDStorageBus</link></entry>
5100 </row>
5101 <row>
5102 <entry>IGuestOSType::recommendedHdStorageController</entry>
5103 <entry><link linkend="IGuestOSType__recommendedHDStorageController">IGuestOSType::recommendedHDStorageController</link></entry>
5104 </row>
5105 <row>
5106 <entry>IGuestOSType::recommendedHdStorageBus</entry>
5107 <entry><link linkend="IGuestOSType__recommendedHDStorageBus">IGuestOSType::recommendedHDStorageBus</link></entry>
5108 </row>
5109 <row>
5110 <entry>IGuestOSType::recommendedUsbHid</entry>
5111 <entry><link linkend="IGuestOSType__recommendedUSBHID">IGuestOSType::recommendedUSBHID</link></entry>
5112 </row>
5113 <row>
5114 <entry>IGuestOSType::recommendedHpet</entry>
5115 <entry><link linkend="IGuestOSType__recommendedHPET">IGuestOSType::recommendedHPET</link></entry>
5116 </row>
5117 <row>
5118 <entry>IGuestOSType::recommendedUsbTablet</entry>
5119 <entry><link linkend="IGuestOSType__recommendedUSBTablet">IGuestOSType::recommendedUSBTablet</link></entry>
5120 </row>
5121 <row>
5122 <entry>IGuestOSType::recommendedRtcUseUtc</entry>
5123 <entry><link linkend="IGuestOSType__recommendedRTCUseUTC">IGuestOSType::recommendedRTCUseUTC</link></entry>
5124 </row>
5125 <row>
5126 <entry>IGuestOSType::recommendedUsb</entry>
5127 <entry><link linkend="IGuestOSType__recommendedUSB">IGuestOSType::recommendedUSB</link></entry>
5128 </row>
5129 <row>
5130 <entry>INetworkAdapter::natDriver</entry>
5131 <entry><link linkend="INetworkAdapter__NATEngine">INetworkAdapter::NATEngine</link></entry>
5132 </row>
5133 <row>
5134 <entry>IUSBController::enabledEhci</entry>
5135 <entry>IUSBController::enabledEHCI"</entry>
5136 </row>
5137 <row>
5138 <entry>INATEngine::tftpPrefix</entry>
5139 <entry><link linkend="INATEngine__TFTPPrefix">INATEngine::TFTPPrefix</link></entry>
5140 </row>
5141 <row>
5142 <entry>INATEngine::tftpBootFile</entry>
5143 <entry><link linkend="INATEngine__TFTPBootFile">INATEngine::TFTPBootFile</link></entry>
5144 </row>
5145 <row>
5146 <entry>INATEngine::tftpNextServer</entry>
5147 <entry><link linkend="INATEngine__TFTPNextServer">INATEngine::TFTPNextServer</link></entry>
5148 </row>
5149 <row>
5150 <entry>INATEngine::dnsPassDomain</entry>
5151 <entry><link linkend="INATEngine__DNSPassDomain">INATEngine::DNSPassDomain</link></entry>
5152 </row>
5153 <row>
5154 <entry>INATEngine::dnsProxy</entry>
5155 <entry><link linkend="INATEngine__DNSProxy">INATEngine::DNSProxy</link></entry>
5156 </row>
5157 <row>
5158 <entry>INATEngine::dnsUseHostResolver</entry>
5159 <entry><link linkend="INATEngine__DNSUseHostResolver">INATEngine::DNSUseHostResolver</link></entry>
5160 </row>
5161 <row>
5162 <entry>VBoxEventType::OnHostPciDevicePlug</entry>
5163 <entry><link linkend="VBoxEventType__OnHostPCIDevicePlug">VBoxEventType::OnHostPCIDevicePlug</link></entry>
5164 </row>
5165 <row>
5166 <entry>ICPUChangedEvent::cpu</entry>
5167 <entry><link linkend="ICPUChangedEvent__CPU">ICPUChangedEvent::CPU</link></entry>
5168 </row>
5169 <row>
5170 <entry>INATRedirectEvent::hostIp</entry>
5171 <entry><link linkend="INATRedirectEvent__hostIP">INATRedirectEvent::hostIP</link></entry>
5172 </row>
5173 <row>
5174 <entry>INATRedirectEvent::guestIp</entry>
5175 <entry><link linkend="INATRedirectEvent__guestIP">INATRedirectEvent::guestIP</link></entry>
5176 </row>
5177 <row>
5178 <entry>IHostPciDevicePlugEvent</entry>
5179 <entry><link linkend="IHostPCIDevicePlugEvent">IHostPCIDevicePlugEvent</link></entry>
5180 </row>
5181 </tbody>
5182 </tgroup></table></para>
5183 </listitem>
5184 </itemizedlist>
5185 </sect1>
5186
5187 <sect1>
5188 <title>Incompatible API changes with version 4.1</title>
5189
5190 <itemizedlist>
5191 <listitem>
5192 <para>The method
5193 <link linkend="IAppliance__importMachines">IAppliance::importMachines()</link>
5194 has one more parameter now, which allows to configure the import
5195 process in more detail.
5196 </para>
5197 </listitem>
5198
5199 <listitem>
5200 <para>The method
5201 <link linkend="IVirtualBox__openMedium">IVirtualBox::openMedium()</link>
5202 has one more parameter now, which allows resolving duplicate medium
5203 UUIDs without the need for external tools.</para>
5204 </listitem>
5205
5206 <listitem>
5207 <para>The <link linkend="INetworkAdapter">INetworkAdapter</link>
5208 interface has been cleaned up. The various methods to activate an
5209 attachment type have been replaced by the
5210 <link linkend="INetworkAdapter__attachmentType">INetworkAdapter::attachmentType</link>
5211 setter.</para>
5212 <para>Additionally each attachment mode now has its own attribute,
5213 which means that host only networks no longer share the settings with
5214 bridged interfaces.</para>
5215 <para>To allow introducing new network attachment implementations
5216 without making API changes, the concept of a generic network
5217 attachment driver has been introduced, which is configurable through
5218 key/value properties.</para>
5219 </listitem>
5220
5221 <listitem>
5222 <para>This version introduces the guest facilities concept. A guest
5223 facility either represents a module or feature the guest is running
5224 or offering, which is defined by
5225 <link linkend="AdditionsFacilityType">AdditionsFacilityType</link>.
5226 Each facility is member of a
5227 <link linkend="AdditionsFacilityClass">AdditionsFacilityClass</link>
5228 and has a current status indicated by
5229 <link linkend="AdditionsFacilityStatus">AdditionsFacilityStatus</link>,
5230 together with a timestamp (in ms) of the last status update.</para>
5231 <para>To address the above concept, the following changes were made:
5232 <itemizedlist>
5233 <listitem>
5234 <para>
5235 In the <link linkend="IGuest">IGuest</link> interface, the
5236 following were removed:
5237 <itemizedlist>
5238 <listitem>
5239 <para>the
5240 <computeroutput>supportsSeamless</computeroutput>
5241 attribute;</para>
5242 </listitem>
5243 <listitem>
5244 <para>the
5245 <computeroutput>supportsGraphics</computeroutput>
5246 attribute;</para>
5247 </listitem>
5248 </itemizedlist>
5249 </para>
5250 </listitem>
5251 <listitem>
5252 <para>
5253 The function
5254 <link linkend="IGuest__getFacilityStatus">IGuest::getFacilityStatus()</link>
5255 was added. It quickly provides a facility's status without
5256 the need to get the facility collection with
5257 <link linkend="IGuest__facilities">IGuest::facilities</link>.
5258 </para>
5259 </listitem>
5260 <listitem>
5261 <para>
5262 The attribute
5263 <link linkend="IGuest__facilities">IGuest::facilities</link>
5264 was added to provide an easy to access collection of all
5265 currently known guest facilities, that is, it contains all
5266 facilies where at least one status update was made since the
5267 guest was started.
5268 </para>
5269 </listitem>
5270 <listitem>
5271 <para>
5272 The interface
5273 <link linkend="IAdditionsFacility">IAdditionsFacility</link>
5274 was added to represent a single facility returned by
5275 <link linkend="IGuest__facilities">IGuest::facilities</link>.
5276 </para>
5277 </listitem>
5278 <listitem>
5279 <para>
5280 <link linkend="AdditionsFacilityStatus">AdditionsFacilityStatus</link>
5281 was added to represent a facility's overall status.
5282 </para>
5283 </listitem>
5284 <listitem>
5285 <para>
5286 <link linkend="AdditionsFacilityType">AdditionsFacilityType</link> and
5287 <link linkend="AdditionsFacilityClass">AdditionsFacilityClass</link> were
5288 added to represent the facility's type and class.
5289 </para>
5290 </listitem>
5291 </itemizedlist>
5292 </para>
5293 </listitem>
5294 </itemizedlist>
5295 </sect1>
5296
5297 <sect1>
5298 <title>Incompatible API changes with version 4.0</title>
5299
5300 <itemizedlist>
5301 <listitem>
5302 <para>A new Java glue layer replacing the previous OOWS JAX-WS
5303 bindings was introduced. The new library allows for uniform code
5304 targeting both local (COM/XPCOM) and remote (SOAP) transports. Now,
5305 instead of <computeroutput>IWebsessionManager</computeroutput>, the
5306 new class <computeroutput>VirtualBoxManager</computeroutput> must be
5307 used. See <xref linkend="javaapi"/> for details.</para>
5308 </listitem>
5309
5310 <listitem>
5311 <para>The confusingly named and impractical session APIs were
5312 changed. In existing client code, the following changes need to be
5313 made:<itemizedlist>
5314 <listitem>
5315 <para>Replace any
5316 <computeroutput>IVirtualBox::openSession(uuidMachine,
5317 ...)</computeroutput> API call with the machine's
5318 <link linkend="IMachine__lockMachine">IMachine::lockMachine()</link>
5319 call and a
5320 <computeroutput>LockType.Write</computeroutput> argument. The
5321 functionality is unchanged, but instead of "opening a direct
5322 session on a machine" all documentation now refers to
5323 "obtaining a write lock on a machine for the client
5324 session".</para>
5325 </listitem>
5326
5327 <listitem>
5328 <para>Similarly, replace any
5329 <computeroutput>IVirtualBox::openExistingSession(uuidMachine,
5330 ...)</computeroutput> call with the machine's
5331 <link linkend="IMachine__lockMachine">IMachine::lockMachine()</link>
5332 call and a <computeroutput>LockType.Shared</computeroutput>
5333 argument. Whereas it was previously impossible to connect a
5334 client session to a running VM process in a race-free manner,
5335 the new API will atomically either write-lock the machine for
5336 the current session or establish a remote link to an existing
5337 session. Existing client code which tried calling both
5338 <computeroutput>openSession()</computeroutput> and
5339 <computeroutput>openExistingSession()</computeroutput> can now
5340 use this one call instead.</para>
5341 </listitem>
5342
5343 <listitem>
5344 <para>Third, replace any
5345 <computeroutput>IVirtualBox::openRemoteSession(uuidMachine,
5346 ...)</computeroutput> call with the machine's
5347 <link linkend="IMachine__launchVMProcess">IMachine::launchVMProcess()</link>
5348 call. The functionality is unchanged.</para>
5349 </listitem>
5350
5351 <listitem>
5352 <para>The <link linkend="SessionState">SessionState</link> enum
5353 was adjusted accordingly: "Open" is now "Locked", "Closed" is
5354 now "Unlocked", "Closing" is now "Unlocking".</para>
5355 </listitem>
5356 </itemizedlist></para>
5357 </listitem>
5358
5359 <listitem>
5360 <para>Virtual machines created with VirtualBox 4.0 or later no
5361 longer register their media in the global media registry in the
5362 <computeroutput>VirtualBox.xml</computeroutput> file. Instead, such
5363 machines list all their media in their own machine XML files. As a
5364 result, a number of media-related APIs had to be modified again.
5365 <itemizedlist>
5366 <listitem>
5367 <para>Neither
5368 <computeroutput>IVirtualBox::createHardDisk()</computeroutput>
5369 nor
5370 <link linkend="IVirtualBox__openMedium">IVirtualBox::openMedium()</link>
5371 register media automatically any more.</para>
5372 </listitem>
5373
5374 <listitem>
5375 <para><link linkend="IMachine__attachDevice">IMachine::attachDevice()</link>
5376 and
5377 <link linkend="IMachine__mountMedium">IMachine::mountMedium()</link>
5378 now take an IMedium object instead of a UUID as an argument. It
5379 is these two calls which add media to a registry now (either a
5380 machine registry for machines created with VirtualBox 4.0 or
5381 later or the global registry otherwise). As a consequence, if a
5382 medium is opened but never attached to a machine, it is no
5383 longer added to any registry any more.</para>
5384 </listitem>
5385
5386 <listitem>
5387 <para>To reduce code duplication, the APIs
5388 IVirtualBox::findHardDisk(), getHardDisk(), findDVDImage(),
5389 getDVDImage(), findFloppyImage() and getFloppyImage() have all
5390 been merged into IVirtualBox::findMedium(), and
5391 IVirtualBox::openHardDisk(), openDVDImage() and
5392 openFloppyImage() have all been merged into
5393 <link linkend="IVirtualBox__openMedium">IVirtualBox::openMedium()</link>.</para>
5394 </listitem>
5395
5396 <listitem>
5397 <para>The rare use case of changing the UUID and parent UUID
5398 of a medium previously handled by
5399 <computeroutput>openHardDisk()</computeroutput> is now in a
5400 separate IMedium::setIDs method.</para>
5401 </listitem>
5402
5403 <listitem>
5404 <para><computeroutput>ISystemProperties::get/setDefaultHardDiskFolder()</computeroutput>
5405 have been removed since disk images are now by default placed
5406 in each machine's folder.</para>
5407 </listitem>
5408
5409 <listitem>
5410 <para>The
5411 <link linkend="ISystemProperties__infoVDSize">ISystemProperties::infoVDSize</link>
5412 attribute replaces the
5413 <computeroutput>getMaxVDISize()</computeroutput>
5414 API call; this now uses bytes instead of megabytes.</para>
5415 </listitem>
5416 </itemizedlist></para>
5417 </listitem>
5418
5419 <listitem>
5420 <para>Machine management APIs were enhanced as follows:<itemizedlist>
5421 <listitem>
5422 <para><link linkend="IVirtualBox__createMachine">IVirtualBox::createMachine()</link>
5423 is no longer restricted to creating machines in the default
5424 "Machines" folder, but can now create machines at arbitrary
5425 locations. For this to work, the parameter list had to be
5426 changed.</para>
5427 </listitem>
5428
5429 <listitem>
5430 <para>The long-deprecated
5431 <computeroutput>IVirtualBox::createLegacyMachine()</computeroutput>
5432 API has been removed.</para>
5433 </listitem>
5434
5435 <listitem>
5436 <para>To reduce code duplication and for consistency with the
5437 aforementioned media APIs,
5438 <computeroutput>IVirtualBox::getMachine()</computeroutput> has
5439 been merged with
5440 <link linkend="IVirtualBox__findMachine">IVirtualBox::findMachine()</link>,
5441 and
5442 <computeroutput>IMachine::getSnapshot()</computeroutput> has
5443 been merged with
5444 <link linkend="IMachine__findSnapshot">IMachine::findSnapshot()</link>.</para>
5445 </listitem>
5446
5447 <listitem>
5448 <para><computeroutput>IVirtualBox::unregisterMachine()</computeroutput>
5449 was replaced with
5450 <link linkend="IMachine__unregister">IMachine::unregister()</link>
5451 with additional functionality for cleaning up machine
5452 files.</para>
5453 </listitem>
5454
5455 <listitem>
5456 <para><computeroutput>IMachine::deleteSettings</computeroutput>
5457 has been replaced by IMachine::delete, which allows specifying
5458 which disk images are to be deleted as part of the deletion,
5459 and because it can take a while it also returns a
5460 <computeroutput>IProgress</computeroutput> object reference,
5461 so that the completion of the asynchronous activities can be
5462 monitored.</para>
5463 </listitem>
5464
5465 <listitem>
5466 <para><computeroutput>IConsole::forgetSavedState</computeroutput>
5467 has been renamed to
5468 <computeroutput>IConsole::discardSavedState()</computeroutput>.</para>
5469 </listitem>
5470 </itemizedlist></para>
5471 </listitem>
5472
5473 <listitem>
5474 <para>All event callbacks APIs were replaced with a new, generic
5475 event mechanism that can be used both locally (COM, XPCOM) and
5476 remotely (web services). Also, the new mechanism is usable from
5477 scripting languages and a local Java. See
5478 <link linkend="IEvent">events</link> for details. The new concept
5479 will require changes to all clients that used event callbacks.</para>
5480 </listitem>
5481
5482 <listitem>
5483 <para><computeroutput>additionsActive()</computeroutput> was replaced
5484 with
5485 <link linkend="IGuest__additionsRunLevel">additionsRunLevel()</link>
5486 and
5487 <link linkend="IGuest__getAdditionsStatus">getAdditionsStatus()</link>
5488 in order to support a more detailed status of the current Guest
5489 Additions loading/readiness state.
5490 <link linkend="IGuest__additionsVersion">IGuest::additionsVersion()</link>
5491 no longer returns the Guest Additions interface version but the
5492 installed Guest Additions version and revision in form of
5493 <computeroutput>3.3.0r12345</computeroutput>.</para>
5494 </listitem>
5495
5496 <listitem>
5497 <para>To address shared folders auto-mounting support, the following
5498 APIs were extended to require an additional
5499 <computeroutput>automount</computeroutput> parameter: <itemizedlist>
5500 <listitem>
5501 <para><link linkend="IVirtualBox__createSharedFolder">IVirtualBox::createSharedFolder()</link></para>
5502 </listitem>
5503
5504 <listitem>
5505 <para><link linkend="IMachine__createSharedFolder">IMachine::createSharedFolder()</link></para>
5506 </listitem>
5507
5508 <listitem>
5509 <para><link linkend="IConsole__createSharedFolder">IConsole::createSharedFolder()</link></para>
5510 </listitem>
5511 </itemizedlist> Also, a new property named
5512 <computeroutput>autoMount</computeroutput> was added to the
5513 <link linkend="ISharedFolder">ISharedFolder</link>
5514 interface.</para>
5515 </listitem>
5516
5517 <listitem>
5518 <para>The appliance (OVF) APIs were enhanced as
5519 follows:<itemizedlist>
5520 <listitem>
5521 <para><computeroutput>IMachine::export</computeroutput>
5522 received an extra parameter
5523 <computeroutput>location</computeroutput>, which is used to
5524 decide for the disk naming.</para>
5525 </listitem>
5526
5527 <listitem>
5528 <para><link linkend="IAppliance__write">IAppliance::write()</link>
5529 received an extra parameter
5530 <computeroutput>manifest</computeroutput>, which can suppress
5531 creating the manifest file on export.</para>
5532 </listitem>
5533
5534 <listitem>
5535 <para><link linkend="IVFSExplorer__entryList">IVFSExplorer::entryList()</link>
5536 received two extra parameters
5537 <computeroutput>sizes</computeroutput> and
5538 <computeroutput>modes</computeroutput>, which contains the
5539 sizes (in bytes) and the file access modes (in octal form) of
5540 the returned files.</para>
5541 </listitem>
5542 </itemizedlist></para>
5543 </listitem>
5544
5545 <listitem>
5546 <para>Support for remote desktop access to virtual machines has been
5547 cleaned up to allow third party implementations of the remote
5548 desktop server. This is called the VirtualBox Remote Desktop
5549 Extension (VRDE) and can be added to VirtualBox by installing the
5550 corresponding extension package; see the VirtualBox User Manual for
5551 details.</para>
5552
5553 <para>The following API changes were made to support the VRDE
5554 interface: <itemizedlist>
5555 <listitem>
5556 <para><computeroutput>IVRDPServer</computeroutput> has been
5557 renamed to
5558 <link linkend="IVRDEServer">IVRDEServer</link>.</para>
5559 </listitem>
5560
5561 <listitem>
5562 <para><computeroutput>IRemoteDisplayInfo</computeroutput> has
5563 been renamed to
5564 <link linkend="IVRDEServerInfo">IVRDEServerInfo</link>.</para>
5565 </listitem>
5566
5567 <listitem>
5568 <para><link linkend="IMachine__VRDEServer">IMachine::VRDEServer</link>
5569 replaces
5570 <computeroutput>VRDPServer.</computeroutput></para>
5571 </listitem>
5572
5573 <listitem>
5574 <para><link linkend="IConsole__VRDEServerInfo">IConsole::VRDEServerInfo</link>
5575 replaces
5576 <computeroutput>RemoteDisplayInfo</computeroutput>.</para>
5577 </listitem>
5578
5579 <listitem>
5580 <para><link linkend="ISystemProperties__VRDEAuthLibrary">ISystemProperties::VRDEAuthLibrary</link>
5581 replaces
5582 <computeroutput>RemoteDisplayAuthLibrary</computeroutput>.</para>
5583 </listitem>
5584
5585 <listitem>
5586 <para>The following methods have been implemented in
5587 <computeroutput>IVRDEServer</computeroutput> to support
5588 generic VRDE properties: <itemizedlist>
5589 <listitem>
5590 <para><link linkend="IVRDEServer__setVRDEProperty">IVRDEServer::setVRDEProperty</link></para>
5591 </listitem>
5592
5593 <listitem>
5594 <para><link linkend="IVRDEServer__getVRDEProperty">IVRDEServer::getVRDEProperty</link></para>
5595 </listitem>
5596
5597 <listitem>
5598 <para><link linkend="IVRDEServer__VRDEProperties">IVRDEServer::VRDEProperties</link></para>
5599 </listitem>
5600 </itemizedlist></para>
5601
5602 <para>A few implementation-specific attributes of the old
5603 <computeroutput>IVRDPServer</computeroutput> interface have
5604 been removed and replaced with properties: <itemizedlist>
5605 <listitem>
5606 <para><computeroutput>IVRDPServer::Ports</computeroutput>
5607 has been replaced with the
5608 <computeroutput>"TCP/Ports"</computeroutput> property.
5609 The property value is a string, which contains a
5610 comma-separated list of ports or ranges of ports. Use a
5611 dash between two port numbers to specify a range.
5612 Example:
5613 <computeroutput>"5000,5010-5012"</computeroutput></para>
5614 </listitem>
5615
5616 <listitem>
5617 <para><computeroutput>IVRDPServer::NetAddress</computeroutput>
5618 has been replaced with the
5619 <computeroutput>"TCP/Address"</computeroutput> property.
5620 The property value is an IP address string. Example:
5621 <computeroutput>"127.0.0.1"</computeroutput></para>
5622 </listitem>
5623
5624 <listitem>
5625 <para><computeroutput>IVRDPServer::VideoChannel</computeroutput>
5626 has been replaced with the
5627 <computeroutput>"VideoChannel/Enabled"</computeroutput>
5628 property. The property value is either
5629 <computeroutput>"true"</computeroutput> or
5630 <computeroutput>"false"</computeroutput></para>
5631 </listitem>
5632
5633 <listitem>
5634 <para><computeroutput>IVRDPServer::VideoChannelQuality</computeroutput>
5635 has been replaced with the
5636 <computeroutput>"VideoChannel/Quality"</computeroutput>
5637 property. The property value is a string which contain a
5638 decimal number in range 10..100. Invalid values are
5639 ignored and the quality is set to the default value 75.
5640 Example: <computeroutput>"50"</computeroutput></para>
5641 </listitem>
5642 </itemizedlist></para>
5643 </listitem>
5644 </itemizedlist></para>
5645 </listitem>
5646
5647 <listitem>
5648 <para>The VirtualBox external authentication module interface has
5649 been updated and made more generic. Because of that,
5650 <computeroutput>VRDPAuthType</computeroutput> enumeration has been
5651 renamed to <link linkend="AuthType">AuthType</link>.</para>
5652 </listitem>
5653 </itemizedlist>
5654 </sect1>
5655
5656 <sect1>
5657 <title>Incompatible API changes with version 3.2</title>
5658
5659 <itemizedlist>
5660 <listitem>
5661 <para>The following interfaces were renamed for consistency:
5662 <itemizedlist>
5663 <listitem>
5664 <para>IMachine::getCpuProperty() is now
5665 <link linkend="IMachine__getCPUProperty">IMachine::getCPUProperty()</link>;</para>
5666 </listitem>
5667
5668 <listitem>
5669 <para>IMachine::setCpuProperty() is now
5670 <link linkend="IMachine__setCPUProperty">IMachine::setCPUProperty()</link>;</para>
5671 </listitem>
5672
5673 <listitem>
5674 <para>IMachine::getCpuIdLeaf() is now
5675 <link linkend="IMachine__getCPUIDLeaf">IMachine::getCPUIDLeaf()</link>;</para>
5676 </listitem>
5677
5678 <listitem>
5679 <para>IMachine::setCpuIdLeaf() is now
5680 <link linkend="IMachine__setCPUIDLeaf">IMachine::setCPUIDLeaf()</link>;</para>
5681 </listitem>
5682
5683 <listitem>
5684 <para>IMachine::removeCpuIdLeaf() is now
5685 <link linkend="IMachine__removeCPUIDLeaf">IMachine::removeCPUIDLeaf()</link>;</para>
5686 </listitem>
5687
5688 <listitem>
5689 <para>IMachine::removeAllCpuIdLeafs() is now
5690 <link linkend="IMachine__removeAllCPUIDLeaves">IMachine::removeAllCPUIDLeaves()</link>;</para>
5691 </listitem>
5692
5693 <listitem>
5694 <para>the CpuPropertyType enum is now
5695 <link linkend="CPUPropertyType">CPUPropertyType</link>.</para>
5696 </listitem>
5697
5698 <listitem>
5699 <para>IVirtualBoxCallback::onSnapshotDiscarded() is now
5700 IVirtualBoxCallback::onSnapshotDeleted.</para>
5701 </listitem>
5702 </itemizedlist></para>
5703 </listitem>
5704
5705 <listitem>
5706 <para>When creating a VM configuration with
5707 <link linkend="IVirtualBox__createMachine">IVirtualBox::createMachine()</link>
5708 it is now possible to ignore existing configuration files which would
5709 previously have caused a failure. For this the
5710 <computeroutput>override</computeroutput> parameter was added.</para>
5711 </listitem>
5712
5713 <listitem>
5714 <para>Deleting snapshots via
5715 <computeroutput>IConsole::deleteSnapshot()</computeroutput> is now
5716 possible while the associated VM is running in almost all cases.
5717 The API is unchanged, but client code that verifies machine states
5718 to determine whether snapshots can be deleted may need to be
5719 adjusted.</para>
5720 </listitem>
5721
5722 <listitem>
5723 <para>The IoBackendType enumeration was replaced with a boolean flag
5724 (see
5725 <link linkend="IStorageController__useHostIOCache">IStorageController::useHostIOCache</link>).</para>
5726 </listitem>
5727
5728 <listitem>
5729 <para>To address multi-monitor support, the following APIs were
5730 extended to require an additional
5731 <computeroutput>screenId</computeroutput> parameter: <itemizedlist>
5732 <listitem>
5733 <para>IMachine::querySavedThumbnailSize()</para>
5734 </listitem>
5735
5736 <listitem>
5737 <para><link linkend="IMachine__readSavedThumbnailToArray">IMachine::readSavedThumbnailToArray()</link></para>
5738 </listitem>
5739
5740 <listitem>
5741 <para><link linkend="IMachine__querySavedScreenshotInfo">IMachine::querySavedScreenshotPNGSize()</link></para>
5742 </listitem>
5743
5744 <listitem>
5745 <para><link linkend="IMachine__readSavedScreenshotToArray">IMachine::readSavedScreenshotPNGToArray()</link></para>
5746 </listitem>
5747 </itemizedlist></para>
5748 </listitem>
5749
5750 <listitem>
5751 <para>The <computeroutput>shape</computeroutput> parameter of
5752 IConsoleCallback::onMousePointerShapeChange was changed from a
5753 implementation-specific pointer to a safearray, enabling scripting
5754 languages to process pointer shapes.</para>
5755 </listitem>
5756 </itemizedlist>
5757 </sect1>
5758
5759 <sect1>
5760 <title>Incompatible API changes with version 3.1</title>
5761
5762 <itemizedlist>
5763 <listitem>
5764 <para>Due to the new flexibility in medium attachments that was
5765 introduced with version 3.1 (in particular, full flexibility with
5766 attaching CD/DVD drives to arbitrary controllers), we seized the
5767 opportunity to rework all interfaces dealing with storage media to
5768 make the API more flexible as well as logical. The
5769 <link linkend="IStorageController">IStorageController</link>,
5770 <link linkend="IMedium">IMedium</link>,
5771 <link linkend="IMediumAttachment">IMediumAttachment</link> and
5772 <link linkend="IMachine">IMachine</link> interfaces were
5773 affected the most. Existing code using them to configure storage and
5774 media needs to be carefully checked.</para>
5775
5776 <para>All media (hard disks, floppies and CDs/DVDs) are now
5777 uniformly handled through the <link linkend="IMedium">IMedium</link>
5778 interface. The device-specific interfaces
5779 (<code>IHardDisk</code>, <code>IDVDImage</code>,
5780 <code>IHostDVDDrive</code>, <code>IFloppyImage</code> and
5781 <code>IHostFloppyDrive</code>) have been merged into IMedium; CD/DVD
5782 and floppy media no longer need special treatment. The device type
5783 of a medium determines in which context it can be used. Some
5784 functionality was moved to the other storage-related
5785 interfaces.</para>
5786
5787 <para><code>IMachine::attachHardDisk</code> and similar methods have
5788 been renamed and generalized to deal with any type of drive and
5789 medium.
5790 <link linkend="IMachine__attachDevice">IMachine::attachDevice()</link>
5791 is the API method for adding any drive to a storage controller. The
5792 floppy and DVD/CD drives are no longer handled specially, and that
5793 means you can have more than one of them. As before, drives can only
5794 be changed while the VM is powered off. Mounting (or unmounting)
5795 removable media at runtime is possible with
5796 <link linkend="IMachine__mountMedium">IMachine::mountMedium()</link>.</para>
5797
5798 <para>Newly created virtual machines have no storage controllers
5799 associated with them. Even the IDE Controller needs to be created
5800 explicitly. The floppy controller is now visible as a separate
5801 controller, with a new storage bus type. For each storage bus type
5802 you can query the device types which can be attached, so that it is
5803 not necessary to hardcode any attachment rules.</para>
5804
5805 <para>This required matching changes e.g. in the callback interfaces
5806 (the medium specific change notification was replaced by a generic
5807 medium change notification) and removing associated enums (e.g.
5808 <code>DriveState</code>). In many places the incorrect use of the
5809 plural form "media" was replaced by "medium", to improve
5810 consistency.</para>
5811 </listitem>
5812
5813 <listitem>
5814 <para>Reading the
5815 <link linkend="IMedium__state">IMedium::state</link> attribute no
5816 longer automatically performs an accessibility check; a new method
5817 <link linkend="IMedium__refreshState">IMedium::refreshState()</link>
5818 does this. The attribute only returns the state now.</para>
5819 </listitem>
5820
5821 <listitem>
5822 <para>There were substantial changes related to snapshots, triggered
5823 by the "branched snapshots" functionality introduced with version
5824 3.1. IConsole::discardSnapshot was renamed to
5825 <computeroutput>IConsole::deleteSnapshot()</computeroutput>.
5826 IConsole::discardCurrentState and
5827 IConsole::discardCurrentSnapshotAndState were removed; corresponding
5828 new functionality is in
5829 <computeroutput>IConsole::restoreSnapshot()</computeroutput>.
5830 Also, when <computeroutput>IConsole::takeSnapshot()</computeroutput>
5831 is called on a running virtual machine, a live snapshot will be
5832 created. The old behavior was to temporarily pause the virtual
5833 machine while creating an online snapshot.</para>
5834 </listitem>
5835
5836 <listitem>
5837 <para>The <computeroutput>IVRDPServer</computeroutput>,
5838 <computeroutput>IRemoteDisplayInfo"</computeroutput> and
5839 <computeroutput>IConsoleCallback</computeroutput> interfaces were
5840 changed to reflect VRDP server ability to bind to one of available
5841 ports from a list of ports.</para>
5842
5843 <para>The <computeroutput>IVRDPServer::port</computeroutput>
5844 attribute has been replaced with
5845 <computeroutput>IVRDPServer::ports</computeroutput>, which is a
5846 comma-separated list of ports or ranges of ports.</para>
5847
5848 <para>An <computeroutput>IRemoteDisplayInfo::port"</computeroutput>
5849 attribute has been added for querying the actual port VRDP server
5850 listens on.</para>
5851
5852 <para>An IConsoleCallback::onRemoteDisplayInfoChange() notification
5853 callback has been added.</para>
5854 </listitem>
5855
5856 <listitem>
5857 <para>The parameter lists for the following functions were
5858 modified:<itemizedlist>
5859 <listitem>
5860 <para><link linkend="IHost__removeHostOnlyNetworkInterface">IHost::removeHostOnlyNetworkInterface()</link></para>
5861 </listitem>
5862
5863 <listitem>
5864 <para><link linkend="IHost__removeUSBDeviceFilter">IHost::removeUSBDeviceFilter()</link></para>
5865 </listitem>
5866 </itemizedlist></para>
5867 </listitem>
5868
5869 <listitem>
5870 <para>In the OOWS bindings for JAX-WS, the behavior of structures
5871 changed: for one, we implemented natural structures field access so
5872 you can just call a "get" method to obtain a field. Secondly,
5873 setters in structures were disabled as they have no expected effect
5874 and were at best misleading.</para>
5875 </listitem>
5876 </itemizedlist>
5877 </sect1>
5878
5879 <sect1>
5880 <title>Incompatible API changes with version 3.0</title>
5881
5882 <itemizedlist>
5883 <listitem>
5884 <para>In the object-oriented web service bindings for JAX-WS, proper
5885 inheritance has been introduced for some classes, so explicit
5886 casting is no longer needed to call methods from a parent class. In
5887 particular, IHardDisk and other classes now properly derive from
5888 <link linkend="IMedium">IMedium</link>.</para>
5889 </listitem>
5890
5891 <listitem>
5892 <para>All object identifiers (machines, snapshots, disks, etc)
5893 switched from GUIDs to strings (now still having string
5894 representation of GUIDs inside). As a result, no particular internal
5895 structure can be assumed for object identifiers; instead, they
5896 should be treated as opaque unique handles. This change mostly
5897 affects Java and C++ programs; for other languages, GUIDs are
5898 transparently converted to strings.</para>
5899 </listitem>
5900
5901 <listitem>
5902 <para>The uses of NULL strings have been changed greatly. All out
5903 parameters now use empty strings to signal a null value. For in
5904 parameters both the old NULL and empty string is allowed. This
5905 change was necessary to support more client bindings, especially
5906 using the web service API. Many of them either have no special NULL
5907 value or have trouble dealing with it correctly in the respective
5908 library code.</para>
5909 </listitem>
5910
5911 <listitem>
5912 <para>Accidentally, the <code>TSBool</code> interface still appeared
5913 in 3.0.0, and was removed in 3.0.2. This is an SDK bug, do not use
5914 the SDK for VirtualBox 3.0.0 for developing clients.</para>
5915 </listitem>
5916
5917 <listitem>
5918 <para>The type of
5919 <link linkend="IVirtualBoxErrorInfo__resultCode">IVirtualBoxErrorInfo::resultCode</link>
5920 changed from
5921 <computeroutput>result</computeroutput> to
5922 <computeroutput>long</computeroutput>.</para>
5923 </listitem>
5924
5925 <listitem>
5926 <para>The parameter list of IVirtualBox::openHardDisk was
5927 changed.</para>
5928 </listitem>
5929
5930 <listitem>
5931 <para>The method IConsole::discardSavedState was renamed to
5932 IConsole::forgetSavedState, and a parameter was added.</para>
5933 </listitem>
5934
5935 <listitem>
5936 <para>The method IConsole::powerDownAsync was renamed to
5937 <link linkend="IConsole__powerDown">IConsole::powerDown</link>,
5938 and the previous method with that name was deleted. So effectively a
5939 parameter was added.</para>
5940 </listitem>
5941
5942 <listitem>
5943 <para>In the
5944 <link linkend="IFramebuffer">IFramebuffer</link> interface, the
5945 following were removed:<itemizedlist>
5946 <listitem>
5947 <para>the <computeroutput>operationSupported</computeroutput>
5948 attribute;</para>
5949
5950 <para>(as a result, the
5951 <computeroutput>FramebufferAccelerationOperation</computeroutput>
5952 enum was no longer needed and removed as well);</para>
5953 </listitem>
5954
5955 <listitem>
5956 <para>the <computeroutput>solidFill()</computeroutput>
5957 method;</para>
5958 </listitem>
5959
5960 <listitem>
5961 <para>the <computeroutput>copyScreenBits()</computeroutput>
5962 method.</para>
5963 </listitem>
5964 </itemizedlist></para>
5965 </listitem>
5966
5967 <listitem>
5968 <para>In the <link linkend="IDisplay">IDisplay</link>
5969 interface, the following were removed:<itemizedlist>
5970 <listitem>
5971 <para>the
5972 <computeroutput>setupInternalFramebuffer()</computeroutput>
5973 method;</para>
5974 </listitem>
5975
5976 <listitem>
5977 <para>the <computeroutput>lockFramebuffer()</computeroutput>
5978 method;</para>
5979 </listitem>
5980
5981 <listitem>
5982 <para>the <computeroutput>unlockFramebuffer()</computeroutput>
5983 method;</para>
5984 </listitem>
5985
5986 <listitem>
5987 <para>the
5988 <computeroutput>registerExternalFramebuffer()</computeroutput>
5989 method.</para>
5990 </listitem>
5991 </itemizedlist></para>
5992 </listitem>
5993 </itemizedlist>
5994 </sect1>
5995
5996 <sect1>
5997 <title>Incompatible API changes with version 2.2</title>
5998
5999 <itemizedlist>
6000 <listitem>
6001 <para>Added explicit version number into JAX-WS Java package names,
6002 such as <computeroutput>org.virtualbox_2_2</computeroutput>,
6003 allowing connect to multiple VirtualBox clients from single Java
6004 application.</para>
6005 </listitem>
6006
6007 <listitem>
6008 <para>The interfaces having a "2" suffix attached to them with
6009 version 2.1 were renamed again to have that suffix removed. This
6010 time around, this change involves only the name, there are no
6011 functional differences.</para>
6012
6013 <para>As a result, IDVDImage2 is now IDVDImage; IHardDisk2 is now
6014 IHardDisk; IHardDisk2Attachment is now IHardDiskAttachment.</para>
6015
6016 <para>Consequentially, all related methods and attributes that had a
6017 "2" suffix have been renamed; for example, IMachine::attachHardDisk2
6018 now becomes IMachine::attachHardDisk().</para>
6019 </listitem>
6020
6021 <listitem>
6022 <para>IVirtualBox::openHardDisk has an extra parameter for opening a
6023 disk read/write or read-only.</para>
6024 </listitem>
6025
6026 <listitem>
6027 <para>The remaining collections were replaced by more performant
6028 safe-arrays. This affects the following collections:</para>
6029
6030 <itemizedlist>
6031 <listitem>
6032 <para>IGuestOSTypeCollection</para>
6033 </listitem>
6034
6035 <listitem>
6036 <para>IHostDVDDriveCollection</para>
6037 </listitem>
6038
6039 <listitem>
6040 <para>IHostFloppyDriveCollection</para>
6041 </listitem>
6042
6043 <listitem>
6044 <para>IHostUSBDeviceCollection</para>
6045 </listitem>
6046
6047 <listitem>
6048 <para>IHostUSBDeviceFilterCollection</para>
6049 </listitem>
6050
6051 <listitem>
6052 <para>IProgressCollection</para>
6053 </listitem>
6054
6055 <listitem>
6056 <para>ISharedFolderCollection</para>
6057 </listitem>
6058
6059 <listitem>
6060 <para>ISnapshotCollection</para>
6061 </listitem>
6062
6063 <listitem>
6064 <para>IUSBDeviceCollection</para>
6065 </listitem>
6066
6067 <listitem>
6068 <para>IUSBDeviceFilterCollection</para>
6069 </listitem>
6070 </itemizedlist>
6071 </listitem>
6072
6073 <listitem>
6074 <para>Since "Host Interface Networking" was renamed to "bridged
6075 networking" and host-only networking was introduced, all associated
6076 interfaces needed renaming as well. In detail:</para>
6077
6078 <itemizedlist>
6079 <listitem>
6080 <para>The HostNetworkInterfaceType enum has been renamed to
6081 <link linkend="HostNetworkInterfaceMediumType">HostNetworkInterfaceMediumType</link></para>
6082 </listitem>
6083
6084 <listitem>
6085 <para>The IHostNetworkInterface::type attribute has been renamed
6086 to
6087 <link linkend="IHostNetworkInterface__mediumType">IHostNetworkInterface::mediumType</link></para>
6088 </listitem>
6089
6090 <listitem>
6091 <para>INetworkAdapter::attachToHostInterface() has been renamed
6092 to INetworkAdapter::attachToBridgedInterface</para>
6093 </listitem>
6094
6095 <listitem>
6096 <para>In the IHost interface, createHostNetworkInterface() has
6097 been renamed to
6098 <link linkend="IHost__createHostOnlyNetworkInterface">createHostOnlyNetworkInterface()</link></para>
6099 </listitem>
6100
6101 <listitem>
6102 <para>Similarly, removeHostNetworkInterface() has been renamed
6103 to
6104 <link linkend="IHost__removeHostOnlyNetworkInterface">removeHostOnlyNetworkInterface()</link></para>
6105 </listitem>
6106 </itemizedlist>
6107 </listitem>
6108 </itemizedlist>
6109 </sect1>
6110
6111 <sect1>
6112 <title>Incompatible API changes with version 2.1</title>
6113
6114 <itemizedlist>
6115 <listitem>
6116 <para>With VirtualBox 2.1, error codes were added to many error
6117 infos that give the caller a machine-readable (numeric) feedback in
6118 addition to the error string that has always been available. This is
6119 an ongoing process, and future versions of this SDK reference will
6120 document the error codes for each method call.</para>
6121 </listitem>
6122
6123 <listitem>
6124 <para>The hard disk and other media interfaces were completely
6125 redesigned. This was necessary to account for the support of VMDK,
6126 VHD and other image types; since backwards compatibility had to be
6127 broken anyway, we seized the moment to redesign the interfaces in a
6128 more logical way.</para>
6129
6130 <itemizedlist>
6131 <listitem>
6132 <para>Previously, the old IHardDisk interface had several
6133 derivatives called IVirtualDiskImage, IVMDKImage, IVHDImage,
6134 IISCSIHardDisk and ICustomHardDisk for the various disk formats
6135 supported by VirtualBox. The new IHardDisk2 interface that comes
6136 with version 2.1 now supports all hard disk image formats
6137 itself.</para>
6138 </listitem>
6139
6140 <listitem>
6141 <para>IHardDiskFormat is a new interface to describe the
6142 available back-ends for hard disk images (e.g. VDI, VMDK, VHD or
6143 iSCSI). The IHardDisk2::format attribute can be used to find out
6144 the back-end that is in use for a particular hard disk image.
6145 ISystemProperties::hardDiskFormats[] contains a list of all
6146 back-ends supported by the system.
6147 <link linkend="ISystemProperties__defaultHardDiskFormat">ISystemProperties::defaultHardDiskFormat</link>
6148 contains the default system format.</para>
6149 </listitem>
6150
6151 <listitem>
6152 <para>In addition, the new
6153 <link linkend="IMedium">IMedium</link> interface is a generic
6154 interface for hard disk, DVD and floppy images that contains the
6155 attributes and methods shared between them. It can be considered
6156 a parent class of the more specific interfaces for those images,
6157 which are now IHardDisk2, IDVDImage2 and IFloppyImage2.</para>
6158
6159 <para>In each case, the "2" versions of these interfaces replace
6160 the earlier versions that did not have the "2" suffix.
6161 Previously, the IDVDImage and IFloppyImage interfaces were
6162 entirely unrelated to IHardDisk.</para>
6163 </listitem>
6164
6165 <listitem>
6166 <para>As a result, all parts of the API that previously
6167 referenced IHardDisk, IDVDImage or IFloppyImage or any of the
6168 old subclasses are gone and will have replacements that use
6169 IHardDisk2, IDVDImage2 and IFloppyImage2; see, for example,
6170 IMachine::attachHardDisk2.</para>
6171 </listitem>
6172
6173 <listitem>
6174 <para>In particular, the IVirtualBox::hardDisks2 array replaces
6175 the earlier IVirtualBox::hardDisks collection.</para>
6176 </listitem>
6177 </itemizedlist>
6178 </listitem>
6179
6180 <listitem>
6181 <para><link linkend="IGuestOSType">IGuestOSType</link> was
6182 extended to group operating systems into families and for 64-bit
6183 support.</para>
6184 </listitem>
6185
6186 <listitem>
6187 <para>The
6188 <link linkend="IHostNetworkInterface">IHostNetworkInterface</link>
6189 interface was completely rewritten to account for the changes in how
6190 Host Interface Networking is now implemented in VirtualBox
6191 2.1.</para>
6192 </listitem>
6193
6194 <listitem>
6195 <para>The IVirtualBox::machines2[] array replaces the former
6196 IVirtualBox::machines collection.</para>
6197 </listitem>
6198
6199 <listitem>
6200 <para>Added
6201 <link linkend="IHost__getProcessorFeature">IHost::getProcessorFeature()</link>
6202 and <link linkend="ProcessorFeature">ProcessorFeature</link>
6203 enumeration.</para>
6204 </listitem>
6205
6206 <listitem>
6207 <para>The parameter list for
6208 <link linkend="IVirtualBox__createMachine">IVirtualBox::createMachine()</link>
6209 was modified.</para>
6210 </listitem>
6211
6212 <listitem>
6213 <para>Added IMachine::pushGuestProperty.</para>
6214 </listitem>
6215
6216 <listitem>
6217 <para>New attributes in IMachine:
6218 <link linkend="IMachine__accelerate3DEnabled">accelerate3DEnabled</link>,
6219 HWVirtExVPIDEnabled,
6220 <computeroutput>IMachine::guestPropertyNotificationPatterns</computeroutput>,
6221 <link linkend="IMachine__CPUCount">CPUCount</link>.</para>
6222 </listitem>
6223
6224 <listitem>
6225 <para>Added
6226 <link linkend="IConsole__powerUpPaused">IConsole::powerUpPaused()</link>
6227 and
6228 <link linkend="IConsole__getGuestEnteredACPIMode">IConsole::getGuestEnteredACPIMode()</link>.</para>
6229 </listitem>
6230
6231 <listitem>
6232 <para>Removed ResourceUsage enumeration.</para>
6233 </listitem>
6234 </itemizedlist>
6235 </sect1>
6236 </chapter>
6237</book>
6238<!-- vim: set shiftwidth=2 tabstop=2 expandtab: -->
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette