VirtualBox

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

Last change on this file since 74981 was 73276, checked in by vboxsync, 6 years ago

doc/manual: Big build system overhaul, because the use of entities and catalogs eliminates the need to have placeholders in XML which previously needed separate preprocessing. Many cleanups, including replacing almost all pattern rules (since their dependencies had to be too generous) and using defines instead. Also integrated many cleanups for the user manual text (which needs careful review, couldn't check yet if it uses any additional tags which some of our XSLT would ignore).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 268.6 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.vbox
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.vbox
1559
1560for m in mgr.getArray(vbox, 'machines'):
1561print "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="hgcm">
2553 <title>Host-Guest Communication Manager</title>
2554
2555 <para>The VirtualBox Host-Guest Communication Manager (HGCM) allows a
2556 guest application or a guest driver to call a host shared library. The
2557 following features of VirtualBox are implemented using HGCM: <itemizedlist>
2558 <listitem>
2559 <para>Shared Folders</para>
2560 </listitem>
2561
2562 <listitem>
2563 <para>Shared Clipboard</para>
2564 </listitem>
2565
2566 <listitem>
2567 <para>Guest configuration interface</para>
2568 </listitem>
2569 </itemizedlist></para>
2570
2571 <para>The shared library contains a so called HGCM service. The guest HGCM
2572 clients establish connections to the service to call it. When calling a
2573 HGCM service the client supplies a function code and a number of
2574 parameters for the function.</para>
2575
2576 <sect1>
2577 <title>Virtual hardware implementation</title>
2578
2579 <para>HGCM uses the VMM virtual PCI device to exchange data between the
2580 guest and the host. The guest always acts as an initiator of requests. A
2581 request is constructed in the guest physical memory, which must be
2582 locked by the guest. The physical address is passed to the VMM device
2583 using a 32-bit <computeroutput>out edx, eax</computeroutput>
2584 instruction. The physical memory must be allocated below 4GB by 64-bit
2585 guests.</para>
2586
2587 <para>The host parses the request header and data and queues the request
2588 for a host HGCM service. The guest continues execution and usually waits
2589 on a HGCM event semaphore.</para>
2590
2591 <para>When the request has been processed by the HGCM service, the VMM
2592 device sets the completion flag in the request header, sets the HGCM
2593 event and raises an IRQ for the guest. The IRQ handler signals the HGCM
2594 event semaphore and all HGCM callers check the completion flag in the
2595 corresponding request header. If the flag is set, the request is
2596 considered completed.</para>
2597 </sect1>
2598
2599 <sect1>
2600 <title>Protocol specification</title>
2601
2602 <para>The HGCM protocol definitions are contained in the
2603 <computeroutput>VBox/VBoxGuest.h</computeroutput></para>
2604
2605 <sect2>
2606 <title>Request header</title>
2607
2608 <para>HGCM request structures contains a generic header
2609 (VMMDevHGCMRequestHeader): <table>
2610 <title>HGCM Request Generic Header</title>
2611
2612 <tgroup cols="2">
2613 <tbody>
2614 <row>
2615 <entry><emphasis role="bold">Name</emphasis></entry>
2616
2617 <entry><emphasis role="bold">Description</emphasis></entry>
2618 </row>
2619
2620 <row>
2621 <entry>size</entry>
2622
2623 <entry>Size of the entire request.</entry>
2624 </row>
2625
2626 <row>
2627 <entry>version</entry>
2628
2629 <entry>Version of the header, must be set to
2630 <computeroutput>0x10001</computeroutput>.</entry>
2631 </row>
2632
2633 <row>
2634 <entry>type</entry>
2635
2636 <entry>Type of the request.</entry>
2637 </row>
2638
2639 <row>
2640 <entry>rc</entry>
2641
2642 <entry>HGCM return code, which will be set by the VMM
2643 device.</entry>
2644 </row>
2645
2646 <row>
2647 <entry>reserved1</entry>
2648
2649 <entry>A reserved field 1.</entry>
2650 </row>
2651
2652 <row>
2653 <entry>reserved2</entry>
2654
2655 <entry>A reserved field 2.</entry>
2656 </row>
2657
2658 <row>
2659 <entry>flags</entry>
2660
2661 <entry>HGCM flags, set by the VMM device.</entry>
2662 </row>
2663
2664 <row>
2665 <entry>result</entry>
2666
2667 <entry>The HGCM result code, set by the VMM device.</entry>
2668 </row>
2669 </tbody>
2670 </tgroup>
2671 </table> <note>
2672 <itemizedlist>
2673 <listitem>
2674 <para>All fields are 32-bit.</para>
2675 </listitem>
2676
2677 <listitem>
2678 <para>Fields from <computeroutput>size</computeroutput> to
2679 <computeroutput>reserved2</computeroutput> are a standard VMM
2680 device request header, which is used for other interfaces as
2681 well.</para>
2682 </listitem>
2683 </itemizedlist>
2684 </note></para>
2685
2686 <para>The <emphasis role="bold">type</emphasis> field indicates the
2687 type of the HGCM request: <table>
2688 <title>Request Types</title>
2689
2690 <tgroup cols="2">
2691 <tbody>
2692 <row>
2693 <entry><emphasis role="bold">Name (decimal
2694 value)</emphasis></entry>
2695
2696 <entry><emphasis role="bold">Description</emphasis></entry>
2697 </row>
2698
2699 <row>
2700 <entry>VMMDevReq_HGCMConnect
2701 (<computeroutput>60</computeroutput>)</entry>
2702
2703 <entry>Connect to a HGCM service.</entry>
2704 </row>
2705
2706 <row>
2707 <entry>VMMDevReq_HGCMDisconnect
2708 (<computeroutput>61</computeroutput>)</entry>
2709
2710 <entry>Disconnect from the service.</entry>
2711 </row>
2712
2713 <row>
2714 <entry>VMMDevReq_HGCMCall32
2715 (<computeroutput>62</computeroutput>)</entry>
2716
2717 <entry>Call a HGCM function using the 32-bit
2718 interface.</entry>
2719 </row>
2720
2721 <row>
2722 <entry>VMMDevReq_HGCMCall64
2723 (<computeroutput>63</computeroutput>)</entry>
2724
2725 <entry>Call a HGCM function using the 64-bit
2726 interface.</entry>
2727 </row>
2728
2729 <row>
2730 <entry>VMMDevReq_HGCMCancel
2731 (<computeroutput>64</computeroutput>)</entry>
2732
2733 <entry>Cancel a HGCM request currently being processed by a
2734 host HGCM service.</entry>
2735 </row>
2736 </tbody>
2737 </tgroup>
2738 </table></para>
2739
2740 <para>The <emphasis role="bold">flags</emphasis> field may contain:
2741 <table>
2742 <title>Flags</title>
2743
2744 <tgroup cols="2">
2745 <tbody>
2746 <row>
2747 <entry><emphasis role="bold">Name (hexadecimal
2748 value)</emphasis></entry>
2749
2750 <entry><emphasis role="bold">Description</emphasis></entry>
2751 </row>
2752
2753 <row>
2754 <entry>VBOX_HGCM_REQ_DONE
2755 (<computeroutput>0x00000001</computeroutput>)</entry>
2756
2757 <entry>The request has been processed by the host
2758 service.</entry>
2759 </row>
2760
2761 <row>
2762 <entry>VBOX_HGCM_REQ_CANCELLED
2763 (<computeroutput>0x00000002</computeroutput>)</entry>
2764
2765 <entry>This request was cancelled.</entry>
2766 </row>
2767 </tbody>
2768 </tgroup>
2769 </table></para>
2770 </sect2>
2771
2772 <sect2>
2773 <title>Connect</title>
2774
2775 <para>The connection request must be issued by the guest HGCM client
2776 before it can call the HGCM service (VMMDevHGCMConnect): <table>
2777 <title>Connect request</title>
2778
2779 <tgroup cols="2">
2780 <tbody>
2781 <row>
2782 <entry><emphasis role="bold">Name</emphasis></entry>
2783
2784 <entry><emphasis role="bold">Description</emphasis></entry>
2785 </row>
2786
2787 <row>
2788 <entry>header</entry>
2789
2790 <entry>The generic HGCM request header with type equal to
2791 VMMDevReq_HGCMConnect
2792 (<computeroutput>60</computeroutput>).</entry>
2793 </row>
2794
2795 <row>
2796 <entry>type</entry>
2797
2798 <entry>The type of the service location information (32
2799 bit).</entry>
2800 </row>
2801
2802 <row>
2803 <entry>location</entry>
2804
2805 <entry>The service location information (128 bytes).</entry>
2806 </row>
2807
2808 <row>
2809 <entry>clientId</entry>
2810
2811 <entry>The client identifier assigned to the connecting
2812 client by the HGCM subsystem (32-bit).</entry>
2813 </row>
2814 </tbody>
2815 </tgroup>
2816 </table> The <emphasis role="bold">type</emphasis> field tells the
2817 HGCM how to look for the requested service: <table>
2818 <title>Location Information Types</title>
2819
2820 <tgroup cols="2">
2821 <tbody>
2822 <row>
2823 <entry><emphasis role="bold">Name (hexadecimal
2824 value)</emphasis></entry>
2825
2826 <entry><emphasis role="bold">Description</emphasis></entry>
2827 </row>
2828
2829 <row>
2830 <entry>VMMDevHGCMLoc_LocalHost
2831 (<computeroutput>0x1</computeroutput>)</entry>
2832
2833 <entry>The requested service is a shared library located on
2834 the host and the location information contains the library
2835 name.</entry>
2836 </row>
2837
2838 <row>
2839 <entry>VMMDevHGCMLoc_LocalHost_Existing
2840 (<computeroutput>0x2</computeroutput>)</entry>
2841
2842 <entry>The requested service is a preloaded one and the
2843 location information contains the service name.</entry>
2844 </row>
2845 </tbody>
2846 </tgroup>
2847 </table> <note>
2848 <para>Currently preloaded HGCM services are hard-coded in
2849 VirtualBox: <itemizedlist>
2850 <listitem>
2851 <para>VBoxSharedFolders</para>
2852 </listitem>
2853
2854 <listitem>
2855 <para>VBoxSharedClipboard</para>
2856 </listitem>
2857
2858 <listitem>
2859 <para>VBoxGuestPropSvc</para>
2860 </listitem>
2861
2862 <listitem>
2863 <para>VBoxSharedOpenGL</para>
2864 </listitem>
2865 </itemizedlist></para>
2866 </note> There is no difference between both types of HGCM services,
2867 only the location mechanism is different.</para>
2868
2869 <para>The client identifier is returned by the host and must be used
2870 in all subsequent requests by the client.</para>
2871 </sect2>
2872
2873 <sect2>
2874 <title>Disconnect</title>
2875
2876 <para>This request disconnects the client and makes the client
2877 identifier invalid (VMMDevHGCMDisconnect): <table>
2878 <title>Disconnect request</title>
2879
2880 <tgroup cols="2">
2881 <tbody>
2882 <row>
2883 <entry><emphasis role="bold">Name</emphasis></entry>
2884
2885 <entry><emphasis role="bold">Description</emphasis></entry>
2886 </row>
2887
2888 <row>
2889 <entry>header</entry>
2890
2891 <entry>The generic HGCM request header with type equal to
2892 VMMDevReq_HGCMDisconnect
2893 (<computeroutput>61</computeroutput>).</entry>
2894 </row>
2895
2896 <row>
2897 <entry>clientId</entry>
2898
2899 <entry>The client identifier previously returned by the
2900 connect request (32-bit).</entry>
2901 </row>
2902 </tbody>
2903 </tgroup>
2904 </table></para>
2905 </sect2>
2906
2907 <sect2>
2908 <title>Call32 and Call64</title>
2909
2910 <para>Calls the HGCM service entry point (VMMDevHGCMCall) using 32-bit
2911 or 64-bit addresses: <table>
2912 <title>Call request</title>
2913
2914 <tgroup cols="2">
2915 <tbody>
2916 <row>
2917 <entry><emphasis role="bold">Name</emphasis></entry>
2918
2919 <entry><emphasis role="bold">Description</emphasis></entry>
2920 </row>
2921
2922 <row>
2923 <entry>header</entry>
2924
2925 <entry>The generic HGCM request header with type equal to
2926 either VMMDevReq_HGCMCall32
2927 (<computeroutput>62</computeroutput>) or
2928 VMMDevReq_HGCMCall64
2929 (<computeroutput>63</computeroutput>).</entry>
2930 </row>
2931
2932 <row>
2933 <entry>clientId</entry>
2934
2935 <entry>The client identifier previously returned by the
2936 connect request (32-bit).</entry>
2937 </row>
2938
2939 <row>
2940 <entry>function</entry>
2941
2942 <entry>The function code to be processed by the service (32
2943 bit).</entry>
2944 </row>
2945
2946 <row>
2947 <entry>cParms</entry>
2948
2949 <entry>The number of following parameters (32-bit). This
2950 value is 0 if the function requires no parameters.</entry>
2951 </row>
2952
2953 <row>
2954 <entry>parms</entry>
2955
2956 <entry>An array of parameter description structures
2957 (HGCMFunctionParameter32 or
2958 HGCMFunctionParameter64).</entry>
2959 </row>
2960 </tbody>
2961 </tgroup>
2962 </table></para>
2963
2964 <para>The 32-bit parameter description (HGCMFunctionParameter32)
2965 consists of 32-bit type field and 8 bytes of an opaque value, so 12
2966 bytes in total. The 64-bit variant (HGCMFunctionParameter64) consists
2967 of the type and 12 bytes of a value, so 16 bytes in total.</para>
2968
2969 <para><table>
2970 <title>Parameter types</title>
2971
2972 <tgroup cols="2">
2973 <tbody>
2974 <row>
2975 <entry><emphasis role="bold">Type</emphasis></entry>
2976
2977 <entry><emphasis role="bold">Format of the
2978 value</emphasis></entry>
2979 </row>
2980
2981 <row>
2982 <entry>VMMDevHGCMParmType_32bit (1)</entry>
2983
2984 <entry>A 32-bit value.</entry>
2985 </row>
2986
2987 <row>
2988 <entry>VMMDevHGCMParmType_64bit (2)</entry>
2989
2990 <entry>A 64-bit value.</entry>
2991 </row>
2992
2993 <row>
2994 <entry>VMMDevHGCMParmType_PhysAddr (3)</entry>
2995
2996 <entry>A 32-bit size followed by a 32-bit or 64-bit guest
2997 physical address.</entry>
2998 </row>
2999
3000 <row>
3001 <entry>VMMDevHGCMParmType_LinAddr (4)</entry>
3002
3003 <entry>A 32-bit size followed by a 32-bit or 64-bit guest
3004 linear address. The buffer is used both for guest to host
3005 and for host to guest data.</entry>
3006 </row>
3007
3008 <row>
3009 <entry>VMMDevHGCMParmType_LinAddr_In (5)</entry>
3010
3011 <entry>Same as VMMDevHGCMParmType_LinAddr but the buffer is
3012 used only for host to guest data.</entry>
3013 </row>
3014
3015 <row>
3016 <entry>VMMDevHGCMParmType_LinAddr_Out (6)</entry>
3017
3018 <entry>Same as VMMDevHGCMParmType_LinAddr but the buffer is
3019 used only for guest to host data.</entry>
3020 </row>
3021
3022 <row>
3023 <entry>VMMDevHGCMParmType_LinAddr_Locked (7)</entry>
3024
3025 <entry>Same as VMMDevHGCMParmType_LinAddr but the buffer is
3026 already locked by the guest.</entry>
3027 </row>
3028
3029 <row>
3030 <entry>VMMDevHGCMParmType_LinAddr_Locked_In (1)</entry>
3031
3032 <entry>Same as VMMDevHGCMParmType_LinAddr_In but the buffer
3033 is already locked by the guest.</entry>
3034 </row>
3035
3036 <row>
3037 <entry>VMMDevHGCMParmType_LinAddr_Locked_Out (1)</entry>
3038
3039 <entry>Same as VMMDevHGCMParmType_LinAddr_Out but the buffer
3040 is already locked by the guest.</entry>
3041 </row>
3042 </tbody>
3043 </tgroup>
3044 </table></para>
3045
3046 <para>The</para>
3047 </sect2>
3048
3049 <sect2>
3050 <title>Cancel</title>
3051
3052 <para>This request cancels a call request (VMMDevHGCMCancel): <table>
3053 <title>Cancel request</title>
3054
3055 <tgroup cols="2">
3056 <tbody>
3057 <row>
3058 <entry><emphasis role="bold">Name</emphasis></entry>
3059
3060 <entry><emphasis role="bold">Description</emphasis></entry>
3061 </row>
3062
3063 <row>
3064 <entry>header</entry>
3065
3066 <entry>The generic HGCM request header with type equal to
3067 VMMDevReq_HGCMCancel
3068 (<computeroutput>64</computeroutput>).</entry>
3069 </row>
3070 </tbody>
3071 </tgroup>
3072 </table></para>
3073 </sect2>
3074 </sect1>
3075
3076 <sect1>
3077 <title>Guest software interface</title>
3078
3079 <para>The guest HGCM clients can call HGCM services from both drivers
3080 and applications.</para>
3081
3082 <sect2>
3083 <title>The guest driver interface</title>
3084
3085 <para>The driver interface is implemented in the VirtualBox guest
3086 additions driver (VBoxGuest), which works with the VMM virtual device.
3087 Drivers must use the VBox Guest Library (VBGL), which provides an API
3088 for HGCM clients (<computeroutput>VBox/VBoxGuestLib.h</computeroutput>
3089 and <computeroutput>VBox/VBoxGuest.h</computeroutput>).</para>
3090
3091 <para><screen>
3092DECLR0VBGL(int) VbglR0HGCMConnect(VBGLHGCMHANDLE *pHandle, const char *pszServiceName, HGCMCLIENTID *pidClient);
3093 </screen> Connects to the service: <screen>
3094 VBoxGuestHGCMConnectInfo data;
3095
3096 memset(&amp;data, sizeof(VBoxGuestHGCMConnectInfo));
3097
3098 data.result = VINF_SUCCESS;
3099 data.Loc.type = VMMDevHGCMLoc_LocalHost_Existing;
3100 strcpy (data.Loc.u.host.achName, "VBoxSharedFolders");
3101
3102 rc = VbglHGCMConnect (&amp;handle, "VBoxSharedFolders"&amp;data);
3103
3104 if (RT_SUCCESS (rc))
3105 {
3106 rc = data.result;
3107 }
3108
3109 if (RT_SUCCESS (rc))
3110 {
3111 /* Get the assigned client identifier. */
3112 ulClientID = data.u32ClientID;
3113 }
3114 </screen></para>
3115
3116 <para><screen>
3117DECLVBGL(int) VbglHGCMDisconnect (VBGLHGCMHANDLE handle, VBoxGuestHGCMDisconnectInfo *pData);
3118 </screen> Disconnects from the service. <screen>
3119 VBoxGuestHGCMDisconnectInfo data;
3120
3121 RtlZeroMemory (&amp;data, sizeof (VBoxGuestHGCMDisconnectInfo));
3122
3123 data.result = VINF_SUCCESS;
3124 data.u32ClientID = ulClientID;
3125
3126 rc = VbglHGCMDisconnect (handle, &amp;data);
3127 </screen></para>
3128
3129 <para><screen>
3130DECLVBGL(int) VbglHGCMCall (VBGLHGCMHANDLE handle, VBoxGuestHGCMCallInfo *pData, uint32_t cbData);
3131 </screen> Calls a function in the service. <screen>
3132typedef struct _VBoxSFRead
3133{
3134 VBoxGuestHGCMCallInfo callInfo;
3135
3136 /** pointer, in: SHFLROOT
3137 * Root handle of the mapping which name is queried.
3138 */
3139 HGCMFunctionParameter root;
3140
3141 /** value64, in:
3142 * SHFLHANDLE of object to read from.
3143 */
3144 HGCMFunctionParameter handle;
3145
3146 /** value64, in:
3147 * Offset to read from.
3148 */
3149 HGCMFunctionParameter offset;
3150
3151 /** value64, in/out:
3152 * Bytes to read/How many were read.
3153 */
3154 HGCMFunctionParameter cb;
3155
3156 /** pointer, out:
3157 * Buffer to place data to.
3158 */
3159 HGCMFunctionParameter buffer;
3160
3161} VBoxSFRead;
3162
3163/** Number of parameters */
3164#define SHFL_CPARMS_READ (5)
3165
3166...
3167
3168 VBoxSFRead data;
3169
3170 /* The call information. */
3171 data.callInfo.result = VINF_SUCCESS; /* Will be returned by HGCM. */
3172 data.callInfo.u32ClientID = ulClientID; /* Client identifier. */
3173 data.callInfo.u32Function = SHFL_FN_READ; /* The function code. */
3174 data.callInfo.cParms = SHFL_CPARMS_READ; /* Number of parameters. */
3175
3176 /* Initialize parameters. */
3177 data.root.type = VMMDevHGCMParmType_32bit;
3178 data.root.u.value32 = pMap-&gt;root;
3179
3180 data.handle.type = VMMDevHGCMParmType_64bit;
3181 data.handle.u.value64 = hFile;
3182
3183 data.offset.type = VMMDevHGCMParmType_64bit;
3184 data.offset.u.value64 = offset;
3185
3186 data.cb.type = VMMDevHGCMParmType_32bit;
3187 data.cb.u.value32 = *pcbBuffer;
3188
3189 data.buffer.type = VMMDevHGCMParmType_LinAddr_Out;
3190 data.buffer.u.Pointer.size = *pcbBuffer;
3191 data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
3192
3193 rc = VbglHGCMCall (handle, &amp;data.callInfo, sizeof (data));
3194
3195 if (RT_SUCCESS (rc))
3196 {
3197 rc = data.callInfo.result;
3198 *pcbBuffer = data.cb.u.value32; /* This is returned by the HGCM service. */
3199 }
3200 </screen></para>
3201 </sect2>
3202
3203 <sect2>
3204 <title>Guest application interface</title>
3205
3206 <para>Applications call the VirtualBox Guest Additions driver to
3207 utilize the HGCM interface. There are IOCTL's which correspond to the
3208 <computeroutput>Vbgl*</computeroutput> functions: <itemizedlist>
3209 <listitem>
3210 <para><computeroutput>VBOXGUEST_IOCTL_HGCM_CONNECT</computeroutput></para>
3211 </listitem>
3212
3213 <listitem>
3214 <para><computeroutput>VBOXGUEST_IOCTL_HGCM_DISCONNECT</computeroutput></para>
3215 </listitem>
3216
3217 <listitem>
3218 <para><computeroutput>VBOXGUEST_IOCTL_HGCM_CALL</computeroutput></para>
3219 </listitem>
3220 </itemizedlist></para>
3221
3222 <para>These IOCTL's get the same input buffer as
3223 <computeroutput>VbglHGCM*</computeroutput> functions and the output
3224 buffer has the same format as the input buffer. The same address can
3225 be used as the input and output buffers.</para>
3226
3227 <para>For example see the guest part of shared clipboard, which runs
3228 as an application and uses the HGCM interface.</para>
3229 </sect2>
3230 </sect1>
3231
3232 <sect1>
3233 <title>HGCM Service Implementation</title>
3234
3235 <para>The HGCM service is a shared library with a specific set of entry
3236 points. The library must export the
3237 <computeroutput>VBoxHGCMSvcLoad</computeroutput> entry point: <screen>
3238extern "C" DECLCALLBACK(DECLEXPORT(int)) VBoxHGCMSvcLoad (VBOXHGCMSVCFNTABLE *ptable)
3239 </screen></para>
3240
3241 <para>The service must check the
3242 <computeroutput>ptable-&gt;cbSize</computeroutput> and
3243 <computeroutput>ptable-&gt;u32Version</computeroutput> fields of the
3244 input structure and fill the remaining fields with function pointers of
3245 entry points and the size of the required client buffer size.</para>
3246
3247 <para>The HGCM service gets a dedicated thread, which calls service
3248 entry points synchronously, that is the service will be called again
3249 only when a previous call has returned. However, the guest calls can be
3250 processed asynchronously. The service must call a completion callback
3251 when the operation is actually completed. The callback can be issued
3252 from another thread as well.</para>
3253
3254 <para>Service entry points are listed in the
3255 <computeroutput>VBox/hgcmsvc.h</computeroutput> in the
3256 <computeroutput>VBOXHGCMSVCFNTABLE</computeroutput> structure. <table>
3257 <title>Service entry points</title>
3258
3259 <tgroup cols="2">
3260 <tbody>
3261 <row>
3262 <entry><emphasis role="bold">Entry</emphasis></entry>
3263
3264 <entry><emphasis role="bold">Description</emphasis></entry>
3265 </row>
3266
3267 <row>
3268 <entry>pfnUnload</entry>
3269
3270 <entry>The service is being unloaded.</entry>
3271 </row>
3272
3273 <row>
3274 <entry>pfnConnect</entry>
3275
3276 <entry>A client <computeroutput>u32ClientID</computeroutput>
3277 is connected to the service. The
3278 <computeroutput>pvClient</computeroutput> parameter points to
3279 an allocated memory buffer which can be used by the service to
3280 store the client information.</entry>
3281 </row>
3282
3283 <row>
3284 <entry>pfnDisconnect</entry>
3285
3286 <entry>A client is being disconnected.</entry>
3287 </row>
3288
3289 <row>
3290 <entry>pfnCall</entry>
3291
3292 <entry>A guest client calls a service function. The
3293 <computeroutput>callHandle</computeroutput> must be used in
3294 the VBOXHGCMSVCHELPERS::pfnCallComplete callback when the call
3295 has been processed.</entry>
3296 </row>
3297
3298 <row>
3299 <entry>pfnHostCall</entry>
3300
3301 <entry>Called by the VirtualBox host components to perform
3302 functions which should be not accessible by the guest. Usually
3303 this entry point is used by VirtualBox to configure the
3304 service.</entry>
3305 </row>
3306
3307 <row>
3308 <entry>pfnSaveState</entry>
3309
3310 <entry>The VM state is being saved and the service must save
3311 relevant information using the SSM API
3312 (<computeroutput>VBox/ssm.h</computeroutput>).</entry>
3313 </row>
3314
3315 <row>
3316 <entry>pfnLoadState</entry>
3317
3318 <entry>The VM is being restored from the saved state and the
3319 service must load the saved information and be able to
3320 continue operations from the saved state.</entry>
3321 </row>
3322 </tbody>
3323 </tgroup>
3324 </table></para>
3325 </sect1>
3326 </chapter>
3327
3328 <chapter id="rdpweb">
3329 <title>RDP Web Control</title>
3330
3331 <para>The VirtualBox <emphasis>RDP Web Control</emphasis> (RDPWeb)
3332 provides remote access to a running VM. RDPWeb is a RDP (Remote Desktop
3333 Protocol) client based on Flash technology and can be used from a Web
3334 browser with a Flash plugin.</para>
3335
3336 <sect1>
3337 <title>RDPWeb features</title>
3338
3339 <para>RDPWeb is embedded into a Web page and can connect to VRDP server
3340 in order to displays the VM screen and pass keyboard and mouse events to
3341 the VM.</para>
3342 </sect1>
3343
3344 <sect1>
3345 <title>RDPWeb reference</title>
3346
3347 <para>RDPWeb consists of two required components:<itemizedlist>
3348 <listitem>
3349 <para>Flash movie
3350 <computeroutput>RDPClientUI.swf</computeroutput></para>
3351 </listitem>
3352
3353 <listitem>
3354 <para>JavaScript helpers
3355 <computeroutput>webclient.js</computeroutput></para>
3356 </listitem>
3357 </itemizedlist></para>
3358
3359 <para>The VirtualBox SDK contains sample HTML code
3360 including:<itemizedlist>
3361 <listitem>
3362 <para>JavaScript library for embedding Flash content
3363 <computeroutput>SWFObject.js</computeroutput></para>
3364 </listitem>
3365
3366 <listitem>
3367 <para>Sample HTML page
3368 <computeroutput>webclient3.html</computeroutput></para>
3369 </listitem>
3370 </itemizedlist></para>
3371
3372 <sect2>
3373 <title>RDPWeb functions</title>
3374
3375 <para><computeroutput>RDPClientUI.swf</computeroutput> and
3376 <computeroutput>webclient.js</computeroutput> work with each other.
3377 JavaScript code is responsible for a proper SWF initialization,
3378 delivering mouse events to the SWF and processing resize requests from
3379 the SWF. On the other hand, the SWF contains a few JavaScript callable
3380 methods, which are used both from
3381 <computeroutput>webclient.js</computeroutput> and the user HTML
3382 page.</para>
3383
3384 <sect3>
3385 <title>JavaScript functions</title>
3386
3387 <para><computeroutput>webclient.js</computeroutput> contains helper
3388 functions. In the following table ElementId refers to an HTML
3389 element name or attribute, and Element to the HTML element itself.
3390 HTML code<programlisting>
3391 &lt;div id="FlashRDP"&gt;
3392 &lt;/div&gt;
3393</programlisting> would have ElementId equal to FlashRDP and Element equal to
3394 the div element.</para>
3395
3396 <para><itemizedlist>
3397 <listitem>
3398 <programlisting>RDPWebClient.embedSWF(SWFFileName, ElementId)</programlisting>
3399
3400 <para>Uses SWFObject library to replace the HTML element with
3401 the Flash movie.</para>
3402 </listitem>
3403
3404 <listitem>
3405 <programlisting>RDPWebClient.isRDPWebControlById(ElementId)</programlisting>
3406
3407 <para>Returns true if the given id refers to a RDPWeb Flash
3408 element.</para>
3409 </listitem>
3410
3411 <listitem>
3412 <programlisting>RDPWebClient.isRDPWebControlByElement(Element)</programlisting>
3413
3414 <para>Returns true if the given element is a RDPWeb Flash
3415 element.</para>
3416 </listitem>
3417
3418 <listitem>
3419 <programlisting>RDPWebClient.getFlashById(ElementId)</programlisting>
3420
3421 <para>Returns an element, which is referenced by the given id.
3422 This function will try to resolve any element, event if it is
3423 not a Flash movie.</para>
3424 </listitem>
3425 </itemizedlist></para>
3426 </sect3>
3427
3428 <sect3>
3429 <title>Flash methods callable from JavaScript</title>
3430
3431 <para><computeroutput>RDPWebClienUI.swf</computeroutput> methods can
3432 be called directly from JavaScript code on a HTML page.</para>
3433
3434 <itemizedlist>
3435 <listitem>
3436 <para>getProperty(Name)</para>
3437 </listitem>
3438
3439 <listitem>
3440 <para>setProperty(Name)</para>
3441 </listitem>
3442
3443 <listitem>
3444 <para>connect()</para>
3445 </listitem>
3446
3447 <listitem>
3448 <para>disconnect()</para>
3449 </listitem>
3450
3451 <listitem>
3452 <para>keyboardSendCAD()</para>
3453 </listitem>
3454 </itemizedlist>
3455 </sect3>
3456
3457 <sect3>
3458 <title>Flash JavaScript callbacks</title>
3459
3460 <para><computeroutput>RDPWebClienUI.swf</computeroutput> calls
3461 JavaScript functions provided by the HTML page.</para>
3462 </sect3>
3463 </sect2>
3464
3465 <sect2>
3466 <title>Embedding RDPWeb in an HTML page</title>
3467
3468 <para>It is necessary to include
3469 <computeroutput>webclient.js</computeroutput> helper script. If
3470 SWFObject library is used, the
3471 <computeroutput>swfobject.js</computeroutput> must be also included
3472 and RDPWeb flash content can be embedded to a Web page using dynamic
3473 HTML. The HTML must include a "placeholder", which consists of 2
3474 <computeroutput>div</computeroutput> elements.</para>
3475 </sect2>
3476 </sect1>
3477
3478 <sect1>
3479 <title>RDPWeb change log</title>
3480
3481 <sect2>
3482 <title>Version 1.2.28</title>
3483
3484 <itemizedlist>
3485 <listitem>
3486 <para><computeroutput>keyboardLayout</computeroutput>,
3487 <computeroutput>keyboardLayouts</computeroutput>,
3488 <computeroutput>UUID</computeroutput> properties.</para>
3489 </listitem>
3490
3491 <listitem>
3492 <para>Support for German keyboard layout on the client.</para>
3493 </listitem>
3494
3495 <listitem>
3496 <para>Rebranding to Oracle.</para>
3497 </listitem>
3498 </itemizedlist>
3499 </sect2>
3500
3501 <sect2>
3502 <title>Version 1.1.26</title>
3503
3504 <itemizedlist>
3505 <listitem>
3506 <para><computeroutput>webclient.js</computeroutput> is a part of
3507 the distribution package.</para>
3508 </listitem>
3509
3510 <listitem>
3511 <para><computeroutput>lastError</computeroutput> property.</para>
3512 </listitem>
3513
3514 <listitem>
3515 <para><computeroutput>keyboardSendScancodes</computeroutput> and
3516 <computeroutput>keyboardSendCAD</computeroutput> methods.</para>
3517 </listitem>
3518 </itemizedlist>
3519 </sect2>
3520
3521 <sect2>
3522 <title>Version 1.0.24</title>
3523
3524 <itemizedlist>
3525 <listitem>
3526 <para>Initial release.</para>
3527 </listitem>
3528 </itemizedlist>
3529 </sect2>
3530 </sect1>
3531 </chapter>
3532
3533 <chapter id="dnd">
3534 <title>Drag and Drop</title>
3535
3536 <para>Since VirtualBox 4.2 it's possible to transfer files from host to the
3537 Linux guests by dragging files, directories or text from the host into the
3538 guest's screen. This is called <emphasis>drag and drop
3539 (DnD)</emphasis>.</para>
3540
3541 <para>In version 5.0 support for Windows guests has been added, as well as
3542 the ability to transfer data the other way around, that is, from the guest
3543 to the host.</para>
3544
3545 <note><para>Currently only the VirtualBox Manager frontend supports drag and
3546 drop.</para></note>
3547
3548 <para>This chapter will show how to use the required interfaces provided
3549 by VirtualBox for adding drag and drop functionality to third-party
3550 frontends.</para>
3551
3552 <sect1>
3553 <title>Basic concepts</title>
3554
3555 <para>In order to use the interfaces provided by VirtualBox, some basic
3556 concepts needs to be understood first: To successfully initiate a
3557 drag and drop operation at least two sides needs to be involved, a
3558 <emphasis>source</emphasis> and a <emphasis>target</emphasis>:</para>
3559
3560 <para>The <emphasis>source</emphasis> is the side which provides the
3561 data, e.g. is the origin of data. This data can be stored within the
3562 source directly or can be retrieved on-demand by the source itself. Other
3563 interfaces don't care where the data from this source actually came
3564 from.</para>
3565
3566 <para>The <emphasis>target</emphasis> on the other hand is the side which
3567 provides the source a visual representation where the user can drop the
3568 data the source offers. This representation can be a window (or just a
3569 certain part of it), for example.</para>
3570
3571 <para>The source and the target have abstract interfaces called
3572 <link linkend="IDnDSource">IDnDSource</link> and
3573 <link linkend="IDnDTarget">IDnDTarget</link>. VirtualBox also
3574 provides implementations of both interfaces, called
3575 <link linkend="IGuestDnDSource">IGuestDnDSource</link> and
3576 <link linkend="IGuestDnDTarget">IGuestDnDTarget</link>. Both
3577 implementations are also used in the VirtualBox Manager frontend.</para>
3578 </sect1>
3579
3580 <sect1>
3581 <title>Supported formats</title>
3582
3583 <para>As the target needs to perform specific actions depending on the
3584 data the source provided, the target first needs to know what type of
3585 data it actually is going to retrieve. It might be that the source offers
3586 data the target cannot (or intentionally does not want to)
3587 support.</para>
3588
3589 <para>VirtualBox handles those data types by providing so-called
3590 <emphasis>MIME types</emphasis> -- these MIME types were originally
3591 defined in
3592 <ulink url="https://tools.ietf.org/html/rfc2046">RFC 2046</ulink> and
3593 are also called <emphasis>Content-types</emphasis>.
3594 <link linkend="IGuestDnDSource">IGuestDnDSource</link> and
3595 <link linkend="IGuestDnDTarget">IGuestDnDTarget</link> support
3596 the following MIME types by default:<itemizedlist>
3597 <listitem>
3598 <para><emphasis role="bold">text/uri-list</emphasis> - A list of
3599 URIs (Uniform Resource Identifier, see
3600 <ulink url="https://tools.ietf.org/html/rfc3986">RFC 3986</ulink>)
3601 pointing to the file and/or directory paths already transferred
3602 from the source to the target.</para>
3603 </listitem>
3604 <listitem>
3605 <para><emphasis role="bold">text/plain;charset=utf-8</emphasis> and
3606 <emphasis role="bold">UTF8_STRING</emphasis> - text in UTF-8
3607 format.</para>
3608 </listitem>
3609 <listitem>
3610 <para><emphasis role="bold">text/plain, TEXT</emphasis>
3611 and <emphasis role="bold">STRING</emphasis> - plain ASCII text,
3612 depending on the source's active ANSI page (if any).</para>
3613 </listitem>
3614 </itemizedlist>
3615 </para>
3616
3617 <para>If, for whatever reason, a certain default format should not be
3618 supported or a new format should be registered,
3619 <link linkend="IDnDSource">IDnDSource</link> and
3620 <link linkend="IDnDTarget">IDnDTarget</link> have methods derived from
3621 <link linkend="IDnDBase">IDnDBase</link> which provide adding,
3622 removing and enumerating specific formats.
3623 <note><para>Registering new or removing default formats on the guest side
3624 currently is not implemented.</para></note></para>
3625 </sect1>
3626
3627 </chapter>
3628
3629 <chapter id="vbox-auth">
3630 <title>VirtualBox external authentication modules</title>
3631
3632 <para>VirtualBox supports arbitrary external modules to perform
3633 authentication. The module is used when the authentication method is set
3634 to "external" for a particular VM VRDE access and the library was
3635 specified with <computeroutput>VBoxManage setproperty
3636 vrdeauthlibrary</computeroutput>. Web service also use the authentication
3637 module which was specified with <computeroutput>VBoxManage setproperty
3638 websrvauthlibrary</computeroutput>.</para>
3639
3640 <para>This library will be loaded by the VM or web service process on
3641 demand, i.e. when the first remote desktop connection is made by a client
3642 or when a client that wants to use the web service logs on.</para>
3643
3644 <para>External authentication is the most flexible as the external handler
3645 can both choose to grant access to everyone (like the "null"
3646 authentication method would) and delegate the request to the guest
3647 authentication component. When delegating the request to the guest
3648 component, the handler will still be called afterwards with the option to
3649 override the result.</para>
3650
3651 <para>An authentication library is required to implement exactly one entry
3652 point:</para>
3653
3654 <screen>#include "VBoxAuth.h"
3655
3656/**
3657 * Authentication library entry point.
3658 *
3659 * Parameters:
3660 *
3661 * szCaller The name of the component which calls the library (UTF8).
3662 * pUuid Pointer to the UUID of the accessed virtual machine. Can be NULL.
3663 * guestJudgement Result of the guest authentication.
3664 * szUser User name passed in by the client (UTF8).
3665 * szPassword Password passed in by the client (UTF8).
3666 * szDomain Domain passed in by the client (UTF8).
3667 * fLogon Boolean flag. Indicates whether the entry point is called
3668 * for a client logon or the client disconnect.
3669 * clientId Server side unique identifier of the client.
3670 *
3671 * Return code:
3672 *
3673 * AuthResultAccessDenied Client access has been denied.
3674 * AuthResultAccessGranted Client has the right to use the
3675 * virtual machine.
3676 * AuthResultDelegateToGuest Guest operating system must
3677 * authenticate the client and the
3678 * library must be called again with
3679 * the result of the guest
3680 * authentication.
3681 *
3682 * Note: When 'fLogon' is 0, only pszCaller, pUuid and clientId are valid and the return
3683 * code is ignored.
3684 */
3685AuthResult AUTHCALL AuthEntry(
3686 const char *szCaller,
3687 PAUTHUUID pUuid,
3688 AuthGuestJudgement guestJudgement,
3689 const char *szUser,
3690 const char *szPassword
3691 const char *szDomain
3692 int fLogon,
3693 unsigned clientId)
3694{
3695 /* Process request against your authentication source of choice. */
3696 // if (authSucceeded(...))
3697 // return AuthResultAccessGranted;
3698 return AuthResultAccessDenied;
3699}</screen>
3700
3701 <para>A note regarding the UUID implementation of the
3702 <computeroutput>pUuid</computeroutput> argument: VirtualBox uses a
3703 consistent binary representation of UUIDs on all platforms. For this
3704 reason the integer fields comprising the UUID are stored as little endian
3705 values. If you want to pass such UUIDs to code which assumes that the
3706 integer fields are big endian (often also called network byte order), you
3707 need to adjust the contents of the UUID to e.g. achieve the same string
3708 representation. The required changes are:<itemizedlist>
3709 <listitem>
3710 <para>reverse the order of byte 0, 1, 2 and 3</para>
3711 </listitem>
3712
3713 <listitem>
3714 <para>reverse the order of byte 4 and 5</para>
3715 </listitem>
3716
3717 <listitem>
3718 <para>reverse the order of byte 6 and 7.</para>
3719 </listitem>
3720 </itemizedlist>Using this conversion you will get identical results when
3721 converting the binary UUID to the string representation.</para>
3722
3723 <para>The <computeroutput>guestJudgement</computeroutput> argument
3724 contains information about the guest authentication status. For the first
3725 call, it is always set to
3726 <computeroutput>AuthGuestNotAsked</computeroutput>. In case the
3727 <computeroutput>AuthEntry</computeroutput> function returns
3728 <computeroutput>AuthResultDelegateToGuest</computeroutput>, a guest
3729 authentication will be attempted and another call to the
3730 <computeroutput>AuthEntry</computeroutput> is made with its result. This
3731 can be either granted / denied or no judgement (the guest component chose
3732 for whatever reason to not make a decision). In case there is a problem
3733 with the guest authentication module (e.g. the Additions are not installed
3734 or not running or the guest did not respond within a timeout), the "not
3735 reacted" status will be returned.</para>
3736 </chapter>
3737
3738 <chapter id="javaapi">
3739 <title>Using Java API</title>
3740
3741 <sect1>
3742 <title>Introduction</title>
3743
3744 <para>VirtualBox can be controlled by a Java API, both locally
3745 (COM/XPCOM) and from remote (SOAP) clients. As with the Python bindings,
3746 a generic glue layer tries to hide all platform differences, allowing
3747 for source and binary compatibility on different platforms.</para>
3748 </sect1>
3749
3750 <sect1>
3751 <title>Requirements</title>
3752
3753 <para>To use the Java bindings, there are certain requirements depending
3754 on the platform. First of all, you need JDK 1.5 (Java 5) or later. Also
3755 please make sure that the version of the VirtualBox API .jar file
3756 exactly matches the version of VirtualBox you use. To avoid confusion,
3757 the VirtualBox API provides versioning in the Java package name, e.g.
3758 the package is named <computeroutput>org.virtualbox_3_2</computeroutput>
3759 for VirtualBox version 3.2. <itemizedlist>
3760 <listitem>
3761 <para><emphasis role="bold">XPCOM</emphasis> - for all platforms,
3762 but Microsoft Windows. A Java bridge based on JavaXPCOM is shipped
3763 with VirtualBox. The classpath must contain
3764 <computeroutput>vboxjxpcom.jar</computeroutput> and the
3765 <computeroutput>vbox.home</computeroutput> property must be set to
3766 location where the VirtualBox binaries are. Please make sure that
3767 the JVM bitness matches bitness of VirtualBox you use as the XPCOM
3768 bridge relies on native libraries.</para>
3769
3770 <para>Start your application like this: <programlisting>
3771 java -cp vboxjxpcom.jar -Dvbox.home=/opt/virtualbox MyProgram
3772 </programlisting></para>
3773 </listitem>
3774
3775 <listitem>
3776 <para><emphasis role="bold">COM</emphasis> - for Microsoft
3777 Windows. We rely on <computeroutput>Jacob</computeroutput> - a
3778 generic Java to COM bridge - which has to be installed seperately.
3779 See <ulink
3780 url="http://sourceforge.net/projects/jacob-project/">http://sourceforge.net/projects/jacob-project/</ulink>
3781 for installation instructions. Also, the VirtualBox provided
3782 <computeroutput>vboxjmscom.jar</computeroutput> must be in the
3783 class path.</para>
3784
3785 <para>Start your application like this:
3786 <programlisting>java -cp vboxjmscom.jar;c:\jacob\jacob.jar -Djava.library.path=c:\jacob MyProgram</programlisting></para>
3787 </listitem>
3788
3789 <listitem>
3790 <para><emphasis role="bold">SOAP</emphasis> - all platforms. Java
3791 6 is required, as it comes with builtin support for SOAP via the
3792 JAX-WS library. Also, the VirtualBox provided
3793 <computeroutput>vbojws.jar</computeroutput> must be in the class
3794 path. In the SOAP case it's possible to create several
3795 VirtualBoxManager instances to communicate with multiple
3796 VirtualBox hosts.</para>
3797
3798 <para>Start your application like this: <programlisting>
3799 java -cp vboxjws.jar MyProgram
3800 </programlisting></para>
3801 </listitem>
3802 </itemizedlist></para>
3803
3804 <para>Exception handling is also generalized by the generic glue layer,
3805 so that all methods could throw
3806 <computeroutput>VBoxException</computeroutput> containing human-readable
3807 text message (see <computeroutput>getMessage()</computeroutput> method)
3808 along with wrapped original exception (see
3809 <computeroutput>getWrapped()</computeroutput> method).</para>
3810 </sect1>
3811
3812 <sect1>
3813 <title>Example</title>
3814
3815 <para>This example shows a simple use case of the Java API. Differences
3816 for SOAP vs. local version are minimal, and limited to the connection
3817 setup phase (see <computeroutput>ws</computeroutput> variable). In the
3818 SOAP case it's possible to create several VirtualBoxManager instances to
3819 communicate with multiple VirtualBox hosts. <programlisting>
3820 import org.virtualbox_4_3.*;
3821 ....
3822 VirtualBoxManager mgr = VirtualBoxManager.createInstance(null);
3823 boolean ws = false; // or true, if we need the SOAP version
3824 if (ws)
3825 {
3826 String url = "http://myhost:18034";
3827 String user = "test";
3828 String passwd = "test";
3829 mgr.connect(url, user, passwd);
3830 }
3831 IVirtualBox vbox = mgr.getVBox();
3832 System.out.println("VirtualBox version: " + vbox.getVersion() + "\n");
3833 // get first VM name
3834 String m = vbox.getMachines().get(0).getName();
3835 System.out.println("\nAttempting to start VM '" + m + "'");
3836 // start it
3837 mgr.startVm(m, null, 7000);
3838
3839 if (ws)
3840 mgr.disconnect();
3841
3842 mgr.cleanup();
3843 </programlisting> For more a complete example, see
3844 <computeroutput>TestVBox.java</computeroutput>, shipped with the
3845 SDK. It contains exception handling and error printing code, which
3846 is important for reliable larger scale projects.</para>
3847
3848 <para>It is good practice in long-running API clients to process the
3849 system events every now and then in the main thread (does not work
3850 in other threads). As a rule of thumb it makes sense to process them
3851 every few 100msec to every few seconds). This is done by
3852 calling<programlisting>
3853 mgr.waitForEvents(0);
3854 </programlisting>
3855 This avoids that a large number of system events accumulate, which can
3856 need a significant amount of memory, and as they also play a role in
3857 object cleanup it helps freeing additional memory in a timely manner
3858 which is used by the API implementation itself. Java's garbage collection
3859 approach already needs more memory due to the delayed freeing of memory
3860 used by no longer accessible objects, and not processing the system
3861 events exacerbates the memory usage. The
3862 <computeroutput>TestVBox.java</computeroutput> example code sprinkles
3863 such lines over the code to achieve the desired effect. In multi-threaded
3864 applications it can be called from the main thread periodically.
3865 Sometimes it's possible to use the non-zero timeout variant of the
3866 method, which then waits the specified number of milliseconds for
3867 events, processing them immediately as they arrive. It achieves better
3868 runtime behavior than separate sleeping/processing.</para>
3869 </sect1>
3870 </chapter>
3871
3872 <chapter>
3873 <title>License information</title>
3874
3875 <para>The sample code files shipped with the SDK are generally licensed
3876 liberally to make it easy for anyone to use this code for their own
3877 application code.</para>
3878
3879 <para>The Java files under
3880 <computeroutput>bindings/webservice/java/jax-ws/</computeroutput> (library
3881 files for the object-oriented web service) are, by contrast, licensed
3882 under the GNU Lesser General Public License (LGPL) V2.1.</para>
3883
3884 <para>See
3885 <computeroutput>sdk/bindings/webservice/java/jax-ws/src/COPYING.LIB</computeroutput>
3886 for the full text of the LGPL 2.1.</para>
3887
3888 <para>When in doubt, please refer to the individual source code files
3889 shipped with this SDK.</para>
3890 </chapter>
3891
3892 <chapter>
3893 <title>Main API change log</title>
3894
3895 <para>Generally, VirtualBox will maintain API compatibility within a major
3896 release; a major release occurs when the first or the second of the three
3897 version components of VirtualBox change (that is, in the x.y.z scheme, a
3898 major release is one where x or y change, but not when only z
3899 changes).</para>
3900
3901 <para>In other words, updates like those from 2.0.0 to 2.0.2 will not come
3902 with API breakages.</para>
3903
3904 <para>Migration between major releases most likely will lead to API
3905 breakage, so please make sure you updated code accordingly. The OOWS Java
3906 wrappers enforce that mechanism by putting VirtualBox classes into
3907 version-specific packages such as
3908 <computeroutput>org.virtualbox_2_2</computeroutput>. This approach allows
3909 for connecting to multiple VirtualBox versions simultaneously from the
3910 same Java application.</para>
3911
3912 <para>The following sections list incompatible changes that the Main API
3913 underwent since the original release of this SDK Reference with VirtualBox
3914 2.0. A change is deemed "incompatible" only if it breaks existing client
3915 code (e.g. changes in method parameter lists, renamed or removed
3916 interfaces and similar). In other words, the list does not contain new
3917 interfaces, methods or attributes or other changes that do not affect
3918 existing client code.</para>
3919
3920 <sect1>
3921 <title>Incompatible API changes with version x.x</title>
3922
3923 <itemizedlist>
3924
3925 <listitem><para>Guest Control APIs were changed as follows:
3926 <itemizedlist>
3927 <listitem><para><link linkend="IGuest__createSession">IGuest::createSession()</link>,
3928 <link linkend="IGuestSession__processCreate">IGuestSession::processCreate()</link>,
3929 <link linkend="IGuestSession__processCreateEx">IGuestSession::processCreateEx()</link>,
3930 <link linkend="IGuestSession__directoryOpen">IGuestSession::directoryOpen()</link> and
3931 <link linkend="IGuestSession__fileOpen">IGuestSession::fileOpen()</link> now will
3932 return the new error code VBOX_E_MAXIMUM_REACHED if the limit for the according object
3933 group has been reached.</para>
3934 </listitem>
3935
3936 <listitem><para>The enumerations FileOpenExFlags, FsObjMoveFlags and DirectoryCopyFlags have
3937 been renamed to <link linkend="FileOpenExFlag">FileOpenExFlag</link>,
3938 <link linkend="FsObjMoveFlag">FsObjMoveFlag</link> and <link linkend="DirectoryCopyFlag">DirectoryCopyFlag</link>
3939 accordingly to match the rest of the API.</para>
3940 </listitem>
3941
3942 <listitem>
3943 <para>The following methods have been implemented:
3944 <computeroutput>IGuestSession::directoryCopyFromGuest()</computeroutput> and
3945 <computeroutput>IGuestSession::directoryCopyToGuest()</computeroutput>.
3946 </para>
3947
3948 <para>The following attributes have been implemented:
3949 <computeroutput>IGuestFsObjInfo::accessTime</computeroutput>,
3950 <computeroutput>IGuestFsObjInfo::birthTime</computeroutput>,
3951 <computeroutput>IGuestFsObjInfo::changeTime</computeroutput> and
3952 <computeroutput>IGuestFsObjInfo::modificationTime</computeroutput>.
3953 </para>
3954
3955 </listitem>
3956 </itemizedlist>
3957 </para></listitem>
3958
3959 </itemizedlist>
3960
3961 </sect1>
3962
3963 <sect1>
3964 <title>Incompatible API changes with version 5.x</title>
3965
3966 <itemizedlist>
3967 <listitem><para>ProcessCreateFlag::NoProfile has been renamed to
3968 <link linkend="ProcessCreateFlag__Profile">ProcessCreateFlag::Profile</link>,
3969 whereas the semantics also has been changed: ProcessCreateFlag::NoProfile
3970 explicitly <emphasis role="bold">did not</emphasis> utilize the guest user's profile data,
3971 which in turn <link linkend="ProcessCreateFlag__Profile">ProcessCreateFlag::Profile</link>
3972 explicitly <emphasis role="bold">does now</emphasis>.</para>
3973 </listitem>
3974 </itemizedlist>
3975
3976 </sect1>
3977
3978 <sect1>
3979 <title>Incompatible API changes with version 5.0</title>
3980
3981 <itemizedlist>
3982 <listitem>
3983 <para>The methods for saving state, adopting a saved state file,
3984 discarding a saved state, taking a snapshot, restoring
3985 a snapshot and deleting a snapshot have been moved from
3986 <computeroutput>IConsole</computeroutput> to
3987 <computeroutput>IMachine</computeroutput>. This straightens out the
3988 logical placement of methods and was necessary to resolve a
3989 long-standing issue, preventing 32-bit API clients from invoking
3990 those operations in the case where no VM is running.
3991 <itemizedlist>
3992 <listitem><para><link linkend="IMachine__saveState">IMachine::saveState()</link>
3993 replaces
3994 <computeroutput>IConsole::saveState()</computeroutput></para>
3995 </listitem>
3996 <listitem>
3997 <para><link linkend="IMachine__adoptSavedState">IMachine::adoptSavedState()</link>
3998 replaces
3999 <computeroutput>IConsole::adoptSavedState()</computeroutput></para>
4000 </listitem>
4001 <listitem>
4002 <para><link linkend="IMachine__discardSavedState">IMachine::discardSavedState()</link>
4003 replaces
4004 <computeroutput>IConsole::discardSavedState()</computeroutput></para>
4005 </listitem>
4006 <listitem>
4007 <para><link linkend="IMachine__takeSnapshot">IMachine::takeSnapshot()</link>
4008 replaces
4009 <computeroutput>IConsole::takeSnapshot()</computeroutput></para>
4010 </listitem>
4011 <listitem>
4012 <para><link linkend="IMachine__deleteSnapshot">IMachine::deleteSnapshot()</link>
4013 replaces
4014 <computeroutput>IConsole::deleteSnapshot()</computeroutput></para>
4015 </listitem>
4016 <listitem>
4017 <para><link linkend="IMachine__deleteSnapshotAndAllChildren">IMachine::deleteSnapshotAndAllChildren()</link>
4018 replaces
4019 <computeroutput>IConsole::deleteSnapshotAndAllChildren()</computeroutput></para>
4020 </listitem>
4021 <listitem>
4022 <para><link linkend="IMachine__deleteSnapshotRange">IMachine::deleteSnapshotRange()</link>
4023 replaces
4024 <computeroutput>IConsole::deleteSnapshotRange()</computeroutput></para>
4025 </listitem>
4026 <listitem>
4027 <para><link linkend="IMachine__restoreSnapshot">IMachine::restoreSnapshot()</link>
4028 replaces
4029 <computeroutput>IConsole::restoreSnapshot()</computeroutput></para>
4030 </listitem>
4031 </itemizedlist>
4032 Small adjustments to the parameter lists have been made to reduce
4033 the number of API calls when taking online snapshots (no longer
4034 needs explicit pausing), and taking a snapshot also returns now
4035 the snapshot id (useful for finding the right snapshot if there
4036 are non-unique snapshot names).</para>
4037 </listitem>
4038
4039 <listitem>
4040 <para>Two new machine states have been introduced to allow proper
4041 distinction between saving state and taking a snapshot.
4042 <link linkend="MachineState__Saving">MachineState::Saving</link>
4043 now is used exclusively while the VM's state is being saved, without
4044 any overlaps with snapshot functionality. The new state
4045 <link linkend="MachineState__Snapshotting">MachineState::Snapshotting</link>
4046 is used when an offline snapshot is taken and likewise the new state
4047 <link linkend="MachineState__OnlineSnapshotting">MachineState::OnlineSnapshotting</link>
4048 is used when an online snapshot is taken.</para>
4049 </listitem>
4050
4051 <listitem>
4052 <para>A new event has been introduced, which signals when a snapshot
4053 has been restored:
4054 <link linkend="ISnapshotRestoredEvent">ISnapshotRestoredEvent</link>.
4055 Previously the event
4056 <link linkend="ISnapshotDeletedEvent">ISnapshotDeletedEvent</link>
4057 was signalled, which isn't logical (but could be distinguished from
4058 actual deletion by the fact that the snapshot was still
4059 there).</para>
4060 </listitem>
4061
4062 <listitem>
4063 <para>The method
4064 <link linkend="IVirtualBox__createMedium">IVirtualBox::createMedium()</link>
4065 replaces
4066 <computeroutput>VirtualBox::createHardDisk()</computeroutput>.
4067 Adjusting existing code needs adding two parameters with
4068 value <computeroutput>AccessMode_ReadWrite</computeroutput>
4069 and <computeroutput>DeviceType_HardDisk</computeroutput>
4070 respectively. The new method supports creating floppy and
4071 DVD images, and (less obviously) further API functionality
4072 such as cloning floppy images.</para>
4073 </listitem>
4074
4075 <listitem>
4076 <para>The method
4077 <link linkend="IMachine__getStorageControllerByInstance">IMachine::getStorageControllerByInstance()</link>
4078 now has an additional parameter (first parameter), for specifying the
4079 storage bus which the storage controller must be using. The method
4080 was not useful before, as the instance numbers are only unique for a
4081 specfic storage bus.</para>
4082 </listitem>
4083
4084 <listitem>
4085 <para>The attribute
4086 <computeroutput>IMachine::sessionType</computeroutput> has been
4087 renamed to
4088 <link linkend="IMachine__sessionName">IMachine::sessionName()</link>.
4089 This cleans up the confusing terminology (as the session type is
4090 something different).</para>
4091 </listitem>
4092
4093 <listitem>
4094 <para>The attribute
4095 <computeroutput>IMachine::guestPropertyNotificationPatterns</computeroutput>
4096 has been removed. In practice it was not usable because it is too
4097 global and didn't distinguish between API clients.</para>
4098 </listitem>
4099
4100 <listitem><para>Drag and drop APIs were changed as follows:<itemizedlist>
4101
4102 <listitem>
4103 <para>Methods for providing host to guest drag and drop
4104 functionality, such as
4105 <computeroutput>IGuest::dragHGEnter</computeroutput>,
4106 <computeroutput>IGuest::dragHGMove()</computeroutput>,
4107 <computeroutput>IGuest::dragHGLeave()</computeroutput>,
4108 <computeroutput>IGuest::dragHGDrop()</computeroutput> and
4109 <computeroutput>IGuest::dragHGPutData()</computeroutput>,
4110 have been moved to an abstract base class called
4111 <link linkend="IDnDTarget">IDnDTarget</link>.
4112 VirtualBox implements this base class in the
4113 <link linkend="IGuestDnDTarget">IGuestDnDTarget</link>
4114 interface. The implementation can be used by using the
4115 <link linkend="IGuest__dnDTarget">IGuest::dnDTarget()</link>
4116 method.</para>
4117 <para>Methods for providing guest to host drag and drop
4118 functionality, such as
4119 <computeroutput>IGuest::dragGHPending()</computeroutput>,
4120 <computeroutput>IGuest::dragGHDropped()</computeroutput> and
4121 <computeroutput>IGuest::dragGHGetData()</computeroutput>,
4122 have been moved to an abstract base class called
4123 <link linkend="IDnDSource">IDnDSource</link>.
4124 VirtualBox implements this base class in the
4125 <link linkend="IGuestDnDSource">IGuestDnDSource</link>
4126 interface. The implementation can be used by using the
4127 <link linkend="IGuest__dnDSource">IGuest::dnDSource()</link>
4128 method.</para>
4129 </listitem>
4130
4131 <listitem>
4132 <para>The <computeroutput>DragAndDropAction</computeroutput>
4133 enumeration has been renamed to
4134 <link linkend="DnDAction">DnDAction</link>.</para>
4135 </listitem>
4136
4137 <listitem>
4138 <para>The <computeroutput>DragAndDropMode</computeroutput>
4139 enumeration has been renamed to
4140 <link linkend="DnDMode">DnDMode</link>.</para>
4141 </listitem>
4142
4143 <listitem>
4144 <para>The attribute
4145 <computeroutput>IMachine::dragAndDropMode</computeroutput>
4146 has been renamed to
4147 <link linkend="IMachine__dnDMode">IMachine::dnDMode()</link>.</para>
4148 </listitem>
4149
4150 <listitem>
4151 <para>The event
4152 <computeroutput>IDragAndDropModeChangedEvent</computeroutput>
4153 has been renamed to
4154 <link linkend="IDnDModeChangedEvent">IDnDModeChangedEvent</link>.</para>
4155 </listitem>
4156
4157 </itemizedlist></para>
4158 </listitem>
4159
4160 <listitem><para>IDisplay and IFramebuffer interfaces were changed to
4161 allow IFramebuffer object to reside in a separate frontend
4162 process:<itemizedlist>
4163
4164 <listitem><para>
4165 IDisplay::ResizeCompleted() has been removed, because the
4166 IFramebuffer object does not provide the screen memory anymore.
4167 </para></listitem>
4168
4169 <listitem><para>
4170 IDisplay::SetFramebuffer() has been replaced with
4171 IDisplay::AttachFramebuffer() and IDisplay::DetachFramebuffer().
4172 </para></listitem>
4173
4174 <listitem><para>
4175 IDisplay::GetFramebuffer() has been replaced with
4176 IDisplay::QueryFramebuffer().
4177 </para></listitem>
4178
4179 <listitem><para>
4180 IDisplay::GetScreenResolution() has a new output parameter
4181 <computeroutput>guestMonitorStatus</computeroutput>
4182 which tells whether the monitor is enabled in the guest.
4183 </para></listitem>
4184
4185 <listitem><para>
4186 IDisplay::TakeScreenShot() and IDisplay::TakeScreenShotToArray()
4187 have a new parameter
4188 <computeroutput>bitmapFormat</computeroutput>. As a consequence of
4189 this, IDisplay::TakeScreenShotPNGToArray() has been removed.
4190 </para></listitem>
4191
4192 <listitem><para>
4193 IFramebuffer::RequestResize() has been replaced with
4194 IFramebuffer::NotifyChange().
4195 </para></listitem>
4196
4197 <listitem><para>
4198 IFramebuffer::NotifyUpdateImage() added to support IFramebuffer
4199 objects in a different process.
4200 </para></listitem>
4201
4202 <listitem><para>
4203 IFramebuffer::Lock(), IFramebuffer::Unlock(),
4204 IFramebuffer::Address(), IFramebuffer::UsesGuestVRAM() have been
4205 removed because the IFramebuffer object does not provide the screen
4206 memory anymore.
4207 </para></listitem>
4208
4209 </itemizedlist></para>
4210 </listitem>
4211
4212 <listitem><para>IGuestSession, IGuestFile and IGuestProcess interfaces
4213 were changed as follows:
4214 <itemizedlist>
4215 <listitem>
4216 <para>Replaced IGuestSession::directoryQueryInfo and
4217 IGuestSession::fileQueryInfo with a new
4218 <link linkend="IGuestSession__fsObjQueryInfo">IGuestSession::fsObjQueryInfo</link>
4219 method that works on any type of file system object.</para>
4220 </listitem>
4221 <listitem>
4222 <para>Replaced IGuestSession::fileRemove,
4223 IGuestSession::symlinkRemoveDirectory and
4224 IGuestSession::symlinkRemoveFile with a new
4225 <link linkend="IGuestSession__fsObjRemove">IGuestSession::fsObjRemove</link>
4226 method that works on any type of file system object except
4227 directories. (fileRemove also worked on any type of object
4228 too, though that was not the intent of the method.)</para>
4229 </listitem>
4230 <listitem>
4231 <para>Replaced IGuestSession::directoryRename and
4232 IGuestSession::directoryRename with a new
4233 <link linkend="IGuestSession__fsObjRename">IGuestSession::fsObjRename</link>
4234 method that works on any type of file system object.
4235 (directoryRename and fileRename may already have worked for
4236 any kind of object, but that was never the intent of the
4237 methods.)</para>
4238 </listitem>
4239 <listitem>
4240 <para>Replaced the unimplemented IGuestSession::directorySetACL
4241 and IGuestSession::fileSetACL with a new
4242 <link linkend="IGuestSession__fsObjSetACL">IGuestSession::fsObjSetACL</link>
4243 method that works on all type of file system object. Also
4244 added a UNIX-style mode parameter as an alternative to the
4245 ACL.</para>
4246 </listitem>
4247 <listitem>
4248 <para>Replaced IGuestSession::fileRemove,
4249 IGuestSession::symlinkRemoveDirectory and
4250 IGuestSession::symlinkRemoveFile with a new
4251 <link linkend="IGuestSession__fsObjRemove">IGuestSession::fsObjRemove</link>
4252 method that works on any type of file system object except
4253 directories (fileRemove also worked on any type of object,
4254 though that was not the intent of the method.)</para>
4255 </listitem>
4256 <listitem>
4257 <para>Renamed IGuestSession::copyTo to
4258 <link linkend="IGuestSession__fileCopyToGuest">IGuestSession::fileCopyToGuest</link>.</para>
4259 </listitem>
4260 <listitem>
4261 <para>Renamed IGuestSession::copyFrom to
4262 <link linkend="IGuestSession__fileCopyFromGuest">IGuestSession::fileCopyFromGuest</link>.</para>
4263 </listitem>
4264 <listitem>
4265 <para>Renamed the CopyFileFlag enum to
4266 <link linkend="FileCopyFlag">FileCopyFlag</link>.</para>
4267 </listitem>
4268 <listitem>
4269 <para>Renamed the IGuestSession::environment attribute to
4270 <link linkend="IGuestSession__environmentChanges">IGuestSession::environmentChanges</link>
4271 to better reflect what it does.</para>
4272 </listitem>
4273 <listitem>
4274 <para>Changed the
4275 <link linkend="IProcess__environment">IGuestProcess::environment</link>
4276 to a stub returning E_NOTIMPL since it wasn't doing what was
4277 advertised (returned changes, not the actual environment).</para>
4278 </listitem>
4279 <listitem>
4280 <para>Renamed IGuestSession::environmentSet to
4281 <link linkend="IGuestSession__environmentScheduleSet">IGuestSession::environmentScheduleSet</link>
4282 to better reflect what it does.</para>
4283 </listitem>
4284 <listitem>
4285 <para>Renamed IGuestSession::environmentUnset to
4286 <link linkend="IGuestSession__environmentScheduleUnset">IGuestSession::environmentScheduleUnset</link>
4287 to better reflect what it does.</para>
4288 </listitem>
4289 <listitem>
4290 <para>Removed IGuestSession::environmentGet it was only getting
4291 changes while giving the impression it was actual environment
4292 variables, and it did not represent scheduled unset
4293 operations.</para>
4294 </listitem>
4295 <listitem>
4296 <para>Removed IGuestSession::environmentClear as it duplicates
4297 assigning an empty array to the
4298 <link linkend="IGuestSession__environmentChanges">IGuestSession::environmentChanges</link>
4299 (formerly known as IGuestSession::environment).</para>
4300 </listitem>
4301 <listitem>
4302 <para>Changed the
4303 <link linkend="IGuestSession__processCreate">IGuestSession::processCreate</link>
4304 and
4305 <link linkend="IGuestSession__processCreateEx">IGuestSession::processCreateEx</link>
4306 methods to accept arguments starting with argument zero (argv[0])
4307 instead of argument one (argv[1]). (Not yet implemented on the
4308 guest additions side, so argv[0] will probably be ignored for a
4309 short while.)</para>
4310 </listitem>
4311
4312 <listitem>
4313 <para>Added a followSymlink parameter to the following methods:
4314 <itemizedlist>
4315 <listitem><para><link linkend="IGuestSession__directoryExists">IGuestSession::directoryExists</link></para></listitem>
4316 <listitem><para><link linkend="IGuestSession__fileExists">IGuestSession::fileExists</link></para></listitem>
4317 <listitem><para><link linkend="IGuestSession__fileQuerySize">IGuestSession::fileQuerySize</link></para></listitem>
4318 </itemizedlist></para>
4319 </listitem>
4320 <listitem>
4321 <para>The parameters to the
4322 <link linkend="IGuestSession__fileOpen">IGuestSession::fileOpen</link>
4323 and
4324 <link linkend="IGuestSession__fileOpenEx">IGuestSession::fileOpenEx</link>
4325 methods were altered:<itemizedlist>
4326 <listitem><para>The openMode string parameter was replaced by
4327 the enum
4328 <link linkend="FileAccessMode">FileAccessMode</link>
4329 and renamed to accessMode.</para></listitem>
4330 <listitem><para>The disposition string parameter was replaced
4331 by the enum
4332 <link linkend="FileOpenAction">FileOpenAction</link>
4333 and renamed to openAction.</para></listitem>
4334 <listitem><para>The unimplemented sharingMode string parameter
4335 was replaced by the enum
4336 <link linkend="FileSharingMode">FileSharingMode</link>
4337 (fileOpenEx only).</para></listitem>
4338 <listitem><para>Added a flags parameter taking a list of
4339 <link linkend="FileOpenExFlag">FileOpenExFlag</link> values
4340 (fileOpenEx only).</para></listitem>
4341 <listitem><para>Removed the offset parameter (fileOpenEx
4342 only).</para></listitem>
4343 </itemizedlist></para>
4344 </listitem>
4345
4346 <listitem>
4347 <para><link linkend="IFile__seek">IGuestFile::seek</link> now
4348 returns the new offset.</para>
4349 </listitem>
4350 <listitem>
4351 <para>Renamed the FileSeekType enum used by
4352 <link linkend="IFile__seek">IGuestFile::seek</link>
4353 to <link linkend="FileSeekOrigin">FileSeekOrigin</link> and
4354 added the missing End value and renaming the Set to
4355 Begin.</para>
4356 </listitem>
4357 <listitem>
4358 <para>Extended the unimplemented
4359 <link linkend="IFile__setACL">IGuestFile::setACL</link>
4360 method with a UNIX-style mode parameter as an alternative to
4361 the ACL.</para>
4362 </listitem>
4363 <listitem>
4364 <para>Renamed the IFile::openMode attribute to
4365 <link linkend="IFile__accessMode">IFile::accessMode</link>
4366 and change the type from string to
4367 <link linkend="FileAccessMode">FileAccessMode</link> to reflect
4368 the changes to the fileOpen methods.</para>
4369 </listitem>
4370 <listitem>
4371 <para>Renamed the IGuestFile::disposition attribute to
4372 <link linkend="IFile__openAction">IFile::openAction</link> and
4373 change the type from string to
4374 <link linkend="FileOpenAction">FileOpenAction</link> to reflect
4375 the changes to the fileOpen methods.</para>
4376 </listitem>
4377
4378 <!-- Non-incompatible things worth mentioning (stubbed methods/attrs aren't worth it). -->
4379 <listitem>
4380 <para>Added
4381 <link linkend="IGuestSession__pathStyle">IGuestSession::pathStyle</link>
4382 attribute.</para>
4383 </listitem>
4384 <listitem>
4385 <para>Added
4386 <link linkend="IGuestSession__fsObjExists">IGuestSession::fsObjExists</link>
4387 attribute.</para>
4388 </listitem>
4389
4390 </itemizedlist>
4391 </para>
4392 </listitem>
4393
4394 <listitem><para>
4395 IConsole::GetDeviceActivity() returns information about multiple
4396 devices.
4397 </para></listitem>
4398
4399 <listitem><para>
4400 IMachine::ReadSavedThumbnailToArray() has a new parameter
4401 <computeroutput>bitmapFormat</computeroutput>. As a consequence of
4402 this, IMachine::ReadSavedThumbnailPNGToArray() has been removed.
4403 </para></listitem>
4404
4405 <listitem><para>
4406 IMachine::QuerySavedScreenshotPNGSize() has been renamed to
4407 IMachine::QuerySavedScreenshotInfo() which also returns
4408 an array of available screenshot formats.
4409 </para></listitem>
4410
4411 <listitem><para>
4412 IMachine::ReadSavedScreenshotPNGToArray() has been renamed to
4413 IMachine::ReadSavedScreenshotToArray() which has a new parameter
4414 <computeroutput>bitmapFormat</computeroutput>.
4415 </para></listitem>
4416
4417 <listitem><para>
4418 IMachine::QuerySavedThumbnailSize() has been removed.
4419 </para></listitem>
4420
4421 <listitem>
4422 <para>The method
4423 <link linkend="IWebsessionManager__getSessionObject">IWebsessionManager::getSessionObject()</link>
4424 now returns a new <link linkend="ISession">ISession</link> instance
4425 for every invocation. This puts the behavior in line with other
4426 binding styles, which never forced the equivalent of establishing
4427 another connection and logging in again to get another
4428 instance.</para>
4429 </listitem>
4430 </itemizedlist>
4431 </sect1>
4432
4433 <sect1>
4434 <title>Incompatible API changes with version 4.3</title>
4435
4436 <itemizedlist>
4437 <listitem>
4438 <para>The explicit medium locking methods
4439 <link linkend="IMedium__lockRead">IMedium::lockRead()</link>
4440 and <link linkend="IMedium__lockWrite">IMedium::lockWrite()</link>
4441 have been redesigned. They return a lock token object reference
4442 now, and calling the
4443 <link linkend="IToken__abandon">IToken::abandon()</link> method (or
4444 letting the reference count to this object drop to 0) will unlock
4445 it. This eliminates the rather common problem that an API client
4446 crash left behind locks, and also improves the safety (API clients
4447 can't release locks they didn't obtain).</para>
4448 </listitem>
4449
4450 <listitem>
4451 <para>The parameter list of
4452 <link linkend="IAppliance__write">IAppliance::write()</link>
4453 has been changed slightly, to allow multiple flags to be
4454 passed.</para>
4455 </listitem>
4456
4457 <listitem>
4458 <para><computeroutput>IMachine::delete</computeroutput>
4459 has been renamed to
4460 <link linkend="IMachine__deleteConfig">IMachine::deleteConfig()</link>,
4461 to improve API client binding compatibility.</para>
4462 </listitem>
4463
4464 <listitem>
4465 <para><computeroutput>IMachine::export</computeroutput>
4466 has been renamed to
4467 <link linkend="IMachine__exportTo">IMachine::exportTo()</link>,
4468 to improve API client binding compatibility.</para>
4469 </listitem>
4470
4471 <listitem>
4472 <para>For
4473 <link linkend="IMachine__launchVMProcess">IMachine::launchVMProcess()</link>
4474 the meaning of the <computeroutput>type</computeroutput> parameter
4475 has changed slightly. Empty string now means that the per-VM or
4476 global default frontend is launched. Most callers of this method
4477 should use the empty string now, unless they really want to override
4478 the default and launch a particular frontend.</para>
4479 </listitem>
4480
4481 <listitem>
4482 <para>Medium management APIs were changed as follows:<itemizedlist>
4483
4484 <listitem>
4485 <para>The type of attribute
4486 <link linkend="IMedium__variant">IMedium::variant()</link>
4487 changed from <computeroutput>unsigned long</computeroutput>
4488 to <computeroutput>safe-array MediumVariant</computeroutput>.
4489 It is an array of flags instead of a set of flags which were
4490 stored inside one variable.
4491 </para>
4492 </listitem>
4493
4494 <listitem>
4495 <para>The parameter list for
4496 <link linkend="IMedium__cloneTo">IMedium::cloneTo()</link>
4497 was modified. The type of parameter variant was changed from
4498 unsigned long to safe-array MediumVariant.
4499 </para>
4500 </listitem>
4501
4502 <listitem>
4503 <para>The parameter list for
4504 <link linkend="IMedium__createBaseStorage">IMedium::createBaseStorage()</link>
4505 was modified. The type of parameter variant was changed from
4506 unsigned long to safe-array MediumVariant.
4507 </para>
4508 </listitem>
4509
4510 <listitem>
4511 <para>The parameter list for
4512 <link linkend="IMedium__createDiffStorage">IMedium::createDiffStorage()</link>
4513 was modified. The type of parameter variant was changed from
4514 unsigned long to safe-array MediumVariant.
4515 </para>
4516 </listitem>
4517
4518 <listitem>
4519 <para>The parameter list for
4520 <link linkend="IMedium__cloneToBase">IMedium::cloneToBase()</link>
4521 was modified. The type of parameter variant was changed from
4522 unsigned long to safe-array MediumVariant.
4523 </para>
4524 </listitem>
4525 </itemizedlist></para>
4526 </listitem>
4527
4528 <listitem>
4529 <para>The type of attribute
4530 <link linkend="IMediumFormat__capabilities">IMediumFormat::capabilities()</link>
4531 changed from <computeroutput>unsigned long</computeroutput> to
4532 <computeroutput>safe-array MediumFormatCapabilities</computeroutput>.
4533 It is an array of flags instead of a set of flags which were stored
4534 inside one variable.
4535 </para>
4536 </listitem>
4537
4538 <listitem>
4539 <para>The attribute
4540 <link linkend="IMedium__logicalSize">IMedium::logicalSize()</link>
4541 now returns the logical size of exactly this medium object (whether
4542 it is a base or diff image). The old behavior was no longer
4543 acceptable, as each image can have a different capacity.</para>
4544 </listitem>
4545
4546 <listitem>
4547 <para>Guest control APIs - such as
4548 <link linkend="IGuest">IGuest</link>,
4549 <link linkend="IGuestSession">IGuestSession</link>,
4550 <link linkend="IGuestProcess">IGuestProcess</link> and so on - now
4551 emit own events to provide clients much finer control and the ability
4552 to write own frontends for guest operations. The event
4553 <link linkend="IGuestSessionEvent">IGuestSessionEvent</link> acts as
4554 an abstract base class for all guest control events. Certain guest
4555 events contain a
4556 <link linkend="IVirtualBoxErrorInfo">IVirtualBoxErrorInfo</link>
4557 member to provide more information in case of an error happened on
4558 the guest side.</para>
4559 </listitem>
4560
4561 <listitem>
4562 <para>Guest control sessions on the guest started by
4563 <link linkend="IGuest__createSession">IGuest::createSession()</link>
4564 now are dedicated guest processes to provide more safety and
4565 performance for certain operations. Also, the
4566 <link linkend="IGuest__createSession">IGuest::createSession()</link>
4567 call does not wait for the guest session being created anymore due
4568 to the dedicated guest session processes just mentioned. This also
4569 will enable webservice clients to handle guest session creation
4570 more gracefully. To wait for a guest session being started, use the
4571 newly added attribute
4572 <link linkend="IGuestSession__status">IGuestSession::status()</link>
4573 to query the current guest session status.</para>
4574 </listitem>
4575
4576 <listitem>
4577 <para>The <link linkend="IGuestFile">IGuestFile</link>
4578 APIs are now implemented to provide native guest file access from
4579 the host.</para>
4580 </listitem>
4581
4582 <listitem>
4583 <para>The parameter list for
4584 <link linkend="IGuest__updateGuestAdditions">IMedium::updateGuestAdditions()</link>
4585 was modified. It now supports specifying optional command line
4586 arguments for the Guest Additions installer performing the actual
4587 update on the guest.
4588 </para>
4589 </listitem>
4590
4591 <listitem>
4592 <para>A new event
4593 <link linkend="IGuestUserStateChangedEvent">IGuestUserStateChangedEvent</link>
4594 was introduced to provide guest user status updates to the host via
4595 event listeners. To use this event there needs to be at least the 4.3
4596 Guest Additions installed on the guest. At the moment only the states
4597 "Idle" and "InUse" of the
4598 <link linkend="GuestUserState">GuestUserState</link> enumeration arei
4599 supported on Windows guests, starting at Windows 2000 SP2.</para>
4600 </listitem>
4601
4602 <listitem>
4603 <para>
4604 The attribute
4605 <link linkend="IGuestSession__protocolVersion">IGuestSession::protocolVersion</link>
4606 was added to provide a convenient way to lookup the guest session's
4607 protocol version it uses to communicate with the installed Guest
4608 Additions on the guest. Older Guest Additions will set the protocol
4609 version to 1, whereas Guest Additions 4.3 will set the protocol
4610 version to 2. This might change in the future as new features
4611 arise.</para>
4612 </listitem>
4613
4614 <listitem>
4615 <para><computeroutput>IDisplay::getScreenResolution</computeroutput>
4616 has been extended to return the display position in the guest.</para>
4617 </listitem>
4618
4619 <listitem>
4620 <para>
4621 The <link linkend="IUSBController">IUSBController</link>
4622 class is not a singleton of
4623 <link linkend="IMachine">IMachine</link> anymore but
4624 <link linkend="IMachine">IMachine</link> contains a list of USB
4625 controllers present in the VM. The USB device filter handling was
4626 moved to
4627 <link linkend="IUSBDeviceFilters">IUSBDeviceFilters</link>.
4628 </para>
4629 </listitem>
4630 </itemizedlist>
4631 </sect1>
4632
4633 <sect1>
4634 <title>Incompatible API changes with version 4.2</title>
4635
4636 <itemizedlist>
4637 <listitem>
4638 <para>Guest control APIs for executing guest processes, working with
4639 guest files or directories have been moved to the newly introduced
4640 <link linkend="IGuestSession">IGuestSession</link> interface which
4641 can be created by calling
4642 <link linkend="IGuest__createSession">IGuest::createSession()</link>.</para>
4643
4644 <para>A guest session will act as a
4645 guest user's impersonation so that the guest credentials only have to
4646 be provided when creating a new guest session. There can be up to 32
4647 guest sessions at once per VM, each session serving up to 2048 guest
4648 processes running or files opened.</para>
4649
4650 <para>Instead of working with process or directory handles before
4651 version 4.2, there now are the dedicated interfaces
4652 <link linkend="IGuestProcess">IGuestProcess</link>,
4653 <link linkend="IGuestDirectory">IGuestDirectory</link> and
4654 <link linkend="IGuestFile">IGuestFile</link>. To retrieve more
4655 information of a file system object the new interface
4656 <link linkend="IGuestFsObjInfo">IGuestFsObjInfo</link> has been
4657 introduced.</para>
4658
4659 <para>Even though the guest control API was changed it is backwards
4660 compatible so that it can be used with older installed Guest
4661 Additions. However, to use upcoming features like process termination
4662 or waiting for input / output new Guest Additions must be installed
4663 when these features got implemented.</para>
4664
4665 <para>The following limitations apply:
4666 <itemizedlist>
4667 <listitem><para>The <link linkend="IGuestFile">IGuestFile</link>
4668 interface is not fully implemented yet.</para>
4669 </listitem>
4670 <listitem><para>The symbolic link APIs
4671 <link linkend="IGuestSession__symlinkCreate">IGuestSession::symlinkCreate()</link>,
4672 <link linkend="IGuestSession__symlinkExists">IGuestSession::symlinkExists()</link>,
4673 <link linkend="IGuestSession__symlinkRead">IGuestSession::symlinkRead()</link>,
4674 IGuestSession::symlinkRemoveDirectory() and
4675 IGuestSession::symlinkRemoveFile() are not
4676 implemented yet.</para>
4677 </listitem>
4678 <listitem><para>The directory APIs
4679 <link linkend="IGuestSession__directoryRemove">IGuestSession::directoryRemove()</link>,
4680 <link linkend="IGuestSession__directoryRemoveRecursive">IGuestSession::directoryRemoveRecursive()</link>,
4681 IGuestSession::directoryRename() and
4682 IGuestSession::directorySetACL() are not
4683 implemented yet.</para>
4684 </listitem>
4685 <listitem><para>The temporary file creation API
4686 <link linkend="IGuestSession__fileCreateTemp">IGuestSession::fileCreateTemp()</link>
4687 is not implemented yet.</para>
4688 </listitem>
4689 <listitem><para>Guest process termination via
4690 <link linkend="IProcess__terminate">IProcess::terminate()</link>
4691 is not implemented yet.</para>
4692 </listitem>
4693 <listitem><para>Waiting for guest process output via
4694 <link linkend="ProcessWaitForFlag__StdOut">ProcessWaitForFlag::StdOut</link>
4695 and
4696 <link linkend="ProcessWaitForFlag__StdErr">ProcessWaitForFlag::StdErr</link>
4697 is not implemented yet.</para>
4698 <para>To wait for process output,
4699 <link linkend="IProcess__read">IProcess::read()</link> with
4700 appropriate flags still can be used to periodically check for
4701 new output data to arrive. Note that
4702 <link linkend="ProcessCreateFlag__WaitForStdOut">ProcessCreateFlag::WaitForStdOut</link>
4703 and / or
4704 <link linkend="ProcessCreateFlag__WaitForStdErr">ProcessCreateFlag::WaitForStdErr</link>
4705 need to be specified when creating a guest process via
4706 <link linkend="IGuestSession__processCreate">IGuestSession::processCreate()</link>
4707 or
4708 <link linkend="IGuestSession__processCreateEx">IGuestSession::processCreateEx()</link>.</para>
4709 </listitem>
4710 <listitem>
4711 <para>ACL (Access Control List) handling in general is not
4712 implemented yet.</para>
4713 </listitem>
4714 </itemizedlist>
4715 </para>
4716 </listitem>
4717
4718 <listitem>
4719 <para>The <link linkend="LockType">LockType</link>
4720 enumeration now has an additional value
4721 <computeroutput>VM</computeroutput> which tells
4722 <link linkend="IMachine__lockMachine">IMachine::lockMachine()</link>
4723 to create a full-blown object structure for running a VM. This was
4724 the previous behavior with <computeroutput>Write</computeroutput>,
4725 which now only creates the minimal object structure to save time and
4726 resources (at the moment the Console object is still created, but all
4727 sub-objects such as Display, Keyboard, Mouse, Guest are not.</para>
4728 </listitem>
4729
4730 <listitem>
4731 <para>Machines can be put in groups (actually an array of groups).
4732 The primary group affects the default placement of files belonging
4733 to a VM.
4734 <link linkend="IVirtualBox__createMachine">IVirtualBox::createMachine()</link>
4735 and
4736 <link linkend="IVirtualBox__composeMachineFilename">IVirtualBox::composeMachineFilename()</link>
4737 have been adjusted accordingly, the former taking an array of groups
4738 as an additional parameter and the latter taking a group as an
4739 additional parameter. The create option handling has been changed for
4740 those two methods, too.</para>
4741 </listitem>
4742
4743 <listitem>
4744 <para>The method IVirtualBox::findMedium() has been removed, since
4745 it provides a subset of the functionality of
4746 <link linkend="IVirtualBox__openMedium">IVirtualBox::openMedium()</link>.</para>
4747 </listitem>
4748
4749 <listitem>
4750 <para>The use of acronyms in API enumeration, interface, attribute
4751 and method names has been made much more consistent, previously they
4752 sometimes were lowercase and sometimes mixed case. They are now
4753 consistently all caps:<table>
4754 <title>Renamed identifiers in VirtualBox 4.2</title>
4755
4756 <tgroup cols="2" style="verywide">
4757 <tbody>
4758 <row>
4759 <entry><emphasis role="bold">Old name</emphasis></entry>
4760
4761 <entry><emphasis role="bold">New name</emphasis></entry>
4762 </row>
4763 <row>
4764 <entry>PointingHidType</entry>
4765 <entry><link linkend="PointingHIDType">PointingHIDType</link></entry>
4766 </row>
4767 <row>
4768 <entry>KeyboardHidType</entry>
4769 <entry><link linkend="KeyboardHIDType">KeyboardHIDType</link></entry>
4770 </row>
4771 <row>
4772 <entry>IPciAddress</entry>
4773 <entry><link linkend="IPCIAddress">IPCIAddress</link></entry>
4774 </row>
4775 <row>
4776 <entry>IPciDeviceAttachment</entry>
4777 <entry><link linkend="IPCIDeviceAttachment">IPCIDeviceAttachment</link></entry>
4778 </row>
4779 <row>
4780 <entry>IMachine::pointingHidType</entry>
4781 <entry><link linkend="IMachine__pointingHIDType">IMachine::pointingHIDType</link></entry>
4782 </row>
4783 <row>
4784 <entry>IMachine::keyboardHidType</entry>
4785 <entry><link linkend="IMachine__keyboardHIDType">IMachine::keyboardHIDType</link></entry>
4786 </row>
4787 <row>
4788 <entry>IMachine::hpetEnabled</entry>
4789 <entry><link linkend="IMachine__HPETEnabled">IMachine::HPETEnabled</link></entry>
4790 </row>
4791 <row>
4792 <entry>IMachine::sessionPid</entry>
4793 <entry><link linkend="IMachine__sessionPID">IMachine::sessionPID</link></entry>
4794 </row>
4795 <row>
4796 <entry>IMachine::ioCacheEnabled</entry>
4797 <entry><link linkend="IMachine__IOCacheEnabled">IMachine::IOCacheEnabled</link></entry>
4798 </row>
4799 <row>
4800 <entry>IMachine::ioCacheSize</entry>
4801 <entry><link linkend="IMachine__IOCacheSize">IMachine::IOCacheSize</link></entry>
4802 </row>
4803 <row>
4804 <entry>IMachine::pciDeviceAssignments</entry>
4805 <entry><link linkend="IMachine__PCIDeviceAssignments">IMachine::PCIDeviceAssignments</link></entry>
4806 </row>
4807 <row>
4808 <entry>IMachine::attachHostPciDevice()</entry>
4809 <entry><link linkend="IMachine__attachHostPCIDevice">IMachine::attachHostPCIDevice</link></entry>
4810 </row>
4811 <row>
4812 <entry>IMachine::detachHostPciDevice()</entry>
4813 <entry><link linkend="IMachine__detachHostPCIDevice">IMachine::detachHostPCIDevice()</link></entry>
4814 </row>
4815 <row>
4816 <entry>IConsole::attachedPciDevices</entry>
4817 <entry><link linkend="IConsole__attachedPCIDevices">IConsole::attachedPCIDevices</link></entry>
4818 </row>
4819 <row>
4820 <entry>IHostNetworkInterface::dhcpEnabled</entry>
4821 <entry><link linkend="IHostNetworkInterface__DHCPEnabled">IHostNetworkInterface::DHCPEnabled</link></entry>
4822 </row>
4823 <row>
4824 <entry>IHostNetworkInterface::enableStaticIpConfig()</entry>
4825 <entry><link linkend="IHostNetworkInterface__enableStaticIPConfig">IHostNetworkInterface::enableStaticIPConfig()</link></entry>
4826 </row>
4827 <row>
4828 <entry>IHostNetworkInterface::enableStaticIpConfigV6()</entry>
4829 <entry><link linkend="IHostNetworkInterface__enableStaticIPConfigV6">IHostNetworkInterface::enableStaticIPConfigV6()</link></entry>
4830 </row>
4831 <row>
4832 <entry>IHostNetworkInterface::enableDynamicIpConfig()</entry>
4833 <entry><link linkend="IHostNetworkInterface__enableDynamicIPConfig">IHostNetworkInterface::enableDynamicIPConfig()</link></entry>
4834 </row>
4835 <row>
4836 <entry>IHostNetworkInterface::dhcpRediscover()</entry>
4837 <entry><link linkend="IHostNetworkInterface__DHCPRediscover">IHostNetworkInterface::DHCPRediscover()</link></entry>
4838 </row>
4839 <row>
4840 <entry>IHost::Acceleration3DAvailable</entry>
4841 <entry><link linkend="IHost__acceleration3DAvailable">IHost::acceleration3DAvailable</link></entry>
4842 </row>
4843 <row>
4844 <entry>IGuestOSType::recommendedPae</entry>
4845 <entry><link linkend="IGuestOSType__recommendedPAE">IGuestOSType::recommendedPAE</link></entry>
4846 </row>
4847 <row>
4848 <entry>IGuestOSType::recommendedDvdStorageController</entry>
4849 <entry><link linkend="IGuestOSType__recommendedDVDStorageController">IGuestOSType::recommendedDVDStorageController</link></entry>
4850 </row>
4851 <row>
4852 <entry>IGuestOSType::recommendedDvdStorageBus</entry>
4853 <entry><link linkend="IGuestOSType__recommendedDVDStorageBus">IGuestOSType::recommendedDVDStorageBus</link></entry>
4854 </row>
4855 <row>
4856 <entry>IGuestOSType::recommendedHdStorageController</entry>
4857 <entry><link linkend="IGuestOSType__recommendedHDStorageController">IGuestOSType::recommendedHDStorageController</link></entry>
4858 </row>
4859 <row>
4860 <entry>IGuestOSType::recommendedHdStorageBus</entry>
4861 <entry><link linkend="IGuestOSType__recommendedHDStorageBus">IGuestOSType::recommendedHDStorageBus</link></entry>
4862 </row>
4863 <row>
4864 <entry>IGuestOSType::recommendedUsbHid</entry>
4865 <entry><link linkend="IGuestOSType__recommendedUSBHID">IGuestOSType::recommendedUSBHID</link></entry>
4866 </row>
4867 <row>
4868 <entry>IGuestOSType::recommendedHpet</entry>
4869 <entry><link linkend="IGuestOSType__recommendedHPET">IGuestOSType::recommendedHPET</link></entry>
4870 </row>
4871 <row>
4872 <entry>IGuestOSType::recommendedUsbTablet</entry>
4873 <entry><link linkend="IGuestOSType__recommendedUSBTablet">IGuestOSType::recommendedUSBTablet</link></entry>
4874 </row>
4875 <row>
4876 <entry>IGuestOSType::recommendedRtcUseUtc</entry>
4877 <entry><link linkend="IGuestOSType__recommendedRTCUseUTC">IGuestOSType::recommendedRTCUseUTC</link></entry>
4878 </row>
4879 <row>
4880 <entry>IGuestOSType::recommendedUsb</entry>
4881 <entry><link linkend="IGuestOSType__recommendedUSB">IGuestOSType::recommendedUSB</link></entry>
4882 </row>
4883 <row>
4884 <entry>INetworkAdapter::natDriver</entry>
4885 <entry><link linkend="INetworkAdapter__NATEngine">INetworkAdapter::NATEngine</link></entry>
4886 </row>
4887 <row>
4888 <entry>IUSBController::enabledEhci</entry>
4889 <entry>IUSBController::enabledEHCI"</entry>
4890 </row>
4891 <row>
4892 <entry>INATEngine::tftpPrefix</entry>
4893 <entry><link linkend="INATEngine__TFTPPrefix">INATEngine::TFTPPrefix</link></entry>
4894 </row>
4895 <row>
4896 <entry>INATEngine::tftpBootFile</entry>
4897 <entry><link linkend="INATEngine__TFTPBootFile">INATEngine::TFTPBootFile</link></entry>
4898 </row>
4899 <row>
4900 <entry>INATEngine::tftpNextServer</entry>
4901 <entry><link linkend="INATEngine__TFTPNextServer">INATEngine::TFTPNextServer</link></entry>
4902 </row>
4903 <row>
4904 <entry>INATEngine::dnsPassDomain</entry>
4905 <entry><link linkend="INATEngine__DNSPassDomain">INATEngine::DNSPassDomain</link></entry>
4906 </row>
4907 <row>
4908 <entry>INATEngine::dnsProxy</entry>
4909 <entry><link linkend="INATEngine__DNSProxy">INATEngine::DNSProxy</link></entry>
4910 </row>
4911 <row>
4912 <entry>INATEngine::dnsUseHostResolver</entry>
4913 <entry><link linkend="INATEngine__DNSUseHostResolver">INATEngine::DNSUseHostResolver</link></entry>
4914 </row>
4915 <row>
4916 <entry>VBoxEventType::OnHostPciDevicePlug</entry>
4917 <entry><link linkend="VBoxEventType__OnHostPCIDevicePlug">VBoxEventType::OnHostPCIDevicePlug</link></entry>
4918 </row>
4919 <row>
4920 <entry>ICPUChangedEvent::cpu</entry>
4921 <entry><link linkend="ICPUChangedEvent__CPU">ICPUChangedEvent::CPU</link></entry>
4922 </row>
4923 <row>
4924 <entry>INATRedirectEvent::hostIp</entry>
4925 <entry><link linkend="INATRedirectEvent__hostIP">INATRedirectEvent::hostIP</link></entry>
4926 </row>
4927 <row>
4928 <entry>INATRedirectEvent::guestIp</entry>
4929 <entry><link linkend="INATRedirectEvent__guestIP">INATRedirectEvent::guestIP</link></entry>
4930 </row>
4931 <row>
4932 <entry>IHostPciDevicePlugEvent</entry>
4933 <entry><link linkend="IHostPCIDevicePlugEvent">IHostPCIDevicePlugEvent</link></entry>
4934 </row>
4935 </tbody>
4936 </tgroup></table></para>
4937 </listitem>
4938 </itemizedlist>
4939 </sect1>
4940
4941 <sect1>
4942 <title>Incompatible API changes with version 4.1</title>
4943
4944 <itemizedlist>
4945 <listitem>
4946 <para>The method
4947 <link linkend="IAppliance__importMachines">IAppliance::importMachines()</link>
4948 has one more parameter now, which allows to configure the import
4949 process in more detail.
4950 </para>
4951 </listitem>
4952
4953 <listitem>
4954 <para>The method
4955 <link linkend="IVirtualBox__openMedium">IVirtualBox::openMedium()</link>
4956 has one more parameter now, which allows resolving duplicate medium
4957 UUIDs without the need for external tools.</para>
4958 </listitem>
4959
4960 <listitem>
4961 <para>The <link linkend="INetworkAdapter">INetworkAdapter</link>
4962 interface has been cleaned up. The various methods to activate an
4963 attachment type have been replaced by the
4964 <link linkend="INetworkAdapter__attachmentType">INetworkAdapter::attachmentType</link>
4965 setter.</para>
4966 <para>Additionally each attachment mode now has its own attribute,
4967 which means that host only networks no longer share the settings with
4968 bridged interfaces.</para>
4969 <para>To allow introducing new network attachment implementations
4970 without making API changes, the concept of a generic network
4971 attachment driver has been introduced, which is configurable through
4972 key/value properties.</para>
4973 </listitem>
4974
4975 <listitem>
4976 <para>This version introduces the guest facilities concept. A guest
4977 facility either represents a module or feature the guest is running
4978 or offering, which is defined by
4979 <link linkend="AdditionsFacilityType">AdditionsFacilityType</link>.
4980 Each facility is member of a
4981 <link linkend="AdditionsFacilityClass">AdditionsFacilityClass</link>
4982 and has a current status indicated by
4983 <link linkend="AdditionsFacilityStatus">AdditionsFacilityStatus</link>,
4984 together with a timestamp (in ms) of the last status update.</para>
4985 <para>To address the above concept, the following changes were made:
4986 <itemizedlist>
4987 <listitem>
4988 <para>
4989 In the <link linkend="IGuest">IGuest</link> interface, the
4990 following were removed:
4991 <itemizedlist>
4992 <listitem>
4993 <para>the
4994 <computeroutput>supportsSeamless</computeroutput>
4995 attribute;</para>
4996 </listitem>
4997 <listitem>
4998 <para>the
4999 <computeroutput>supportsGraphics</computeroutput>
5000 attribute;</para>
5001 </listitem>
5002 </itemizedlist>
5003 </para>
5004 </listitem>
5005 <listitem>
5006 <para>
5007 The function
5008 <link linkend="IGuest__getFacilityStatus">IGuest::getFacilityStatus()</link>
5009 was added. It quickly provides a facility's status without
5010 the need to get the facility collection with
5011 <link linkend="IGuest__facilities">IGuest::facilities</link>.
5012 </para>
5013 </listitem>
5014 <listitem>
5015 <para>
5016 The attribute
5017 <link linkend="IGuest__facilities">IGuest::facilities</link>
5018 was added to provide an easy to access collection of all
5019 currently known guest facilities, that is, it contains all
5020 facilies where at least one status update was made since the
5021 guest was started.
5022 </para>
5023 </listitem>
5024 <listitem>
5025 <para>
5026 The interface
5027 <link linkend="IAdditionsFacility">IAdditionsFacility</link>
5028 was added to represent a single facility returned by
5029 <link linkend="IGuest__facilities">IGuest::facilities</link>.
5030 </para>
5031 </listitem>
5032 <listitem>
5033 <para>
5034 <link linkend="AdditionsFacilityStatus">AdditionsFacilityStatus</link>
5035 was added to represent a facility's overall status.
5036 </para>
5037 </listitem>
5038 <listitem>
5039 <para>
5040 <link linkend="AdditionsFacilityType">AdditionsFacilityType</link> and
5041 <link linkend="AdditionsFacilityClass">AdditionsFacilityClass</link> were
5042 added to represent the facility's type and class.
5043 </para>
5044 </listitem>
5045 </itemizedlist>
5046 </para>
5047 </listitem>
5048 </itemizedlist>
5049 </sect1>
5050
5051 <sect1>
5052 <title>Incompatible API changes with version 4.0</title>
5053
5054 <itemizedlist>
5055 <listitem>
5056 <para>A new Java glue layer replacing the previous OOWS JAX-WS
5057 bindings was introduced. The new library allows for uniform code
5058 targeting both local (COM/XPCOM) and remote (SOAP) transports. Now,
5059 instead of <computeroutput>IWebsessionManager</computeroutput>, the
5060 new class <computeroutput>VirtualBoxManager</computeroutput> must be
5061 used. See <xref linkend="javaapi"/> for details.</para>
5062 </listitem>
5063
5064 <listitem>
5065 <para>The confusingly named and impractical session APIs were
5066 changed. In existing client code, the following changes need to be
5067 made:<itemizedlist>
5068 <listitem>
5069 <para>Replace any
5070 <computeroutput>IVirtualBox::openSession(uuidMachine,
5071 ...)</computeroutput> API call with the machine's
5072 <link linkend="IMachine__lockMachine">IMachine::lockMachine()</link>
5073 call and a
5074 <computeroutput>LockType.Write</computeroutput> argument. The
5075 functionality is unchanged, but instead of "opening a direct
5076 session on a machine" all documentation now refers to
5077 "obtaining a write lock on a machine for the client
5078 session".</para>
5079 </listitem>
5080
5081 <listitem>
5082 <para>Similarly, replace any
5083 <computeroutput>IVirtualBox::openExistingSession(uuidMachine,
5084 ...)</computeroutput> call with the machine's
5085 <link linkend="IMachine__lockMachine">IMachine::lockMachine()</link>
5086 call and a <computeroutput>LockType.Shared</computeroutput>
5087 argument. Whereas it was previously impossible to connect a
5088 client session to a running VM process in a race-free manner,
5089 the new API will atomically either write-lock the machine for
5090 the current session or establish a remote link to an existing
5091 session. Existing client code which tried calling both
5092 <computeroutput>openSession()</computeroutput> and
5093 <computeroutput>openExistingSession()</computeroutput> can now
5094 use this one call instead.</para>
5095 </listitem>
5096
5097 <listitem>
5098 <para>Third, replace any
5099 <computeroutput>IVirtualBox::openRemoteSession(uuidMachine,
5100 ...)</computeroutput> call with the machine's
5101 <link linkend="IMachine__launchVMProcess">IMachine::launchVMProcess()</link>
5102 call. The functionality is unchanged.</para>
5103 </listitem>
5104
5105 <listitem>
5106 <para>The <link linkend="SessionState">SessionState</link> enum
5107 was adjusted accordingly: "Open" is now "Locked", "Closed" is
5108 now "Unlocked", "Closing" is now "Unlocking".</para>
5109 </listitem>
5110 </itemizedlist></para>
5111 </listitem>
5112
5113 <listitem>
5114 <para>Virtual machines created with VirtualBox 4.0 or later no
5115 longer register their media in the global media registry in the
5116 <computeroutput>VirtualBox.xml</computeroutput> file. Instead, such
5117 machines list all their media in their own machine XML files. As a
5118 result, a number of media-related APIs had to be modified again.
5119 <itemizedlist>
5120 <listitem>
5121 <para>Neither
5122 <computeroutput>IVirtualBox::createHardDisk()</computeroutput>
5123 nor
5124 <link linkend="IVirtualBox__openMedium">IVirtualBox::openMedium()</link>
5125 register media automatically any more.</para>
5126 </listitem>
5127
5128 <listitem>
5129 <para><link linkend="IMachine__attachDevice">IMachine::attachDevice()</link>
5130 and
5131 <link linkend="IMachine__mountMedium">IMachine::mountMedium()</link>
5132 now take an IMedium object instead of a UUID as an argument. It
5133 is these two calls which add media to a registry now (either a
5134 machine registry for machines created with VirtualBox 4.0 or
5135 later or the global registry otherwise). As a consequence, if a
5136 medium is opened but never attached to a machine, it is no
5137 longer added to any registry any more.</para>
5138 </listitem>
5139
5140 <listitem>
5141 <para>To reduce code duplication, the APIs
5142 IVirtualBox::findHardDisk(), getHardDisk(), findDVDImage(),
5143 getDVDImage(), findFloppyImage() and getFloppyImage() have all
5144 been merged into IVirtualBox::findMedium(), and
5145 IVirtualBox::openHardDisk(), openDVDImage() and
5146 openFloppyImage() have all been merged into
5147 <link linkend="IVirtualBox__openMedium">IVirtualBox::openMedium()</link>.</para>
5148 </listitem>
5149
5150 <listitem>
5151 <para>The rare use case of changing the UUID and parent UUID
5152 of a medium previously handled by
5153 <computeroutput>openHardDisk()</computeroutput> is now in a
5154 separate IMedium::setIDs method.</para>
5155 </listitem>
5156
5157 <listitem>
5158 <para><computeroutput>ISystemProperties::get/setDefaultHardDiskFolder()</computeroutput>
5159 have been removed since disk images are now by default placed
5160 in each machine's folder.</para>
5161 </listitem>
5162
5163 <listitem>
5164 <para>The
5165 <link linkend="ISystemProperties__infoVDSize">ISystemProperties::infoVDSize</link>
5166 attribute replaces the
5167 <computeroutput>getMaxVDISize()</computeroutput>
5168 API call; this now uses bytes instead of megabytes.</para>
5169 </listitem>
5170 </itemizedlist></para>
5171 </listitem>
5172
5173 <listitem>
5174 <para>Machine management APIs were enhanced as follows:<itemizedlist>
5175 <listitem>
5176 <para><link linkend="IVirtualBox__createMachine">IVirtualBox::createMachine()</link>
5177 is no longer restricted to creating machines in the default
5178 "Machines" folder, but can now create machines at arbitrary
5179 locations. For this to work, the parameter list had to be
5180 changed.</para>
5181 </listitem>
5182
5183 <listitem>
5184 <para>The long-deprecated
5185 <computeroutput>IVirtualBox::createLegacyMachine()</computeroutput>
5186 API has been removed.</para>
5187 </listitem>
5188
5189 <listitem>
5190 <para>To reduce code duplication and for consistency with the
5191 aforementioned media APIs,
5192 <computeroutput>IVirtualBox::getMachine()</computeroutput> has
5193 been merged with
5194 <link linkend="IVirtualBox__findMachine">IVirtualBox::findMachine()</link>,
5195 and
5196 <computeroutput>IMachine::getSnapshot()</computeroutput> has
5197 been merged with
5198 <link linkend="IMachine__findSnapshot">IMachine::findSnapshot()</link>.</para>
5199 </listitem>
5200
5201 <listitem>
5202 <para><computeroutput>IVirtualBox::unregisterMachine()</computeroutput>
5203 was replaced with
5204 <link linkend="IMachine__unregister">IMachine::unregister()</link>
5205 with additional functionality for cleaning up machine
5206 files.</para>
5207 </listitem>
5208
5209 <listitem>
5210 <para><computeroutput>IMachine::deleteSettings</computeroutput>
5211 has been replaced by IMachine::delete, which allows specifying
5212 which disk images are to be deleted as part of the deletion,
5213 and because it can take a while it also returns a
5214 <computeroutput>IProgress</computeroutput> object reference,
5215 so that the completion of the asynchronous activities can be
5216 monitored.</para>
5217 </listitem>
5218
5219 <listitem>
5220 <para><computeroutput>IConsole::forgetSavedState</computeroutput>
5221 has been renamed to
5222 <computeroutput>IConsole::discardSavedState()</computeroutput>.</para>
5223 </listitem>
5224 </itemizedlist></para>
5225 </listitem>
5226
5227 <listitem>
5228 <para>All event callbacks APIs were replaced with a new, generic
5229 event mechanism that can be used both locally (COM, XPCOM) and
5230 remotely (web services). Also, the new mechanism is usable from
5231 scripting languages and a local Java. See
5232 <link linkend="IEvent">events</link> for details. The new concept
5233 will require changes to all clients that used event callbacks.</para>
5234 </listitem>
5235
5236 <listitem>
5237 <para><computeroutput>additionsActive()</computeroutput> was replaced
5238 with
5239 <link linkend="IGuest__additionsRunLevel">additionsRunLevel()</link>
5240 and
5241 <link linkend="IGuest__getAdditionsStatus">getAdditionsStatus()</link>
5242 in order to support a more detailed status of the current Guest
5243 Additions loading/readiness state.
5244 <link linkend="IGuest__additionsVersion">IGuest::additionsVersion()</link>
5245 no longer returns the Guest Additions interface version but the
5246 installed Guest Additions version and revision in form of
5247 <computeroutput>3.3.0r12345</computeroutput>.</para>
5248 </listitem>
5249
5250 <listitem>
5251 <para>To address shared folders auto-mounting support, the following
5252 APIs were extended to require an additional
5253 <computeroutput>automount</computeroutput> parameter: <itemizedlist>
5254 <listitem>
5255 <para><link linkend="IVirtualBox__createSharedFolder">IVirtualBox::createSharedFolder()</link></para>
5256 </listitem>
5257
5258 <listitem>
5259 <para><link linkend="IMachine__createSharedFolder">IMachine::createSharedFolder()</link></para>
5260 </listitem>
5261
5262 <listitem>
5263 <para><link linkend="IConsole__createSharedFolder">IConsole::createSharedFolder()</link></para>
5264 </listitem>
5265 </itemizedlist> Also, a new property named
5266 <computeroutput>autoMount</computeroutput> was added to the
5267 <link linkend="ISharedFolder">ISharedFolder</link>
5268 interface.</para>
5269 </listitem>
5270
5271 <listitem>
5272 <para>The appliance (OVF) APIs were enhanced as
5273 follows:<itemizedlist>
5274 <listitem>
5275 <para><computeroutput>IMachine::export</computeroutput>
5276 received an extra parameter
5277 <computeroutput>location</computeroutput>, which is used to
5278 decide for the disk naming.</para>
5279 </listitem>
5280
5281 <listitem>
5282 <para><link linkend="IAppliance__write">IAppliance::write()</link>
5283 received an extra parameter
5284 <computeroutput>manifest</computeroutput>, which can suppress
5285 creating the manifest file on export.</para>
5286 </listitem>
5287
5288 <listitem>
5289 <para><link linkend="IVFSExplorer__entryList">IVFSExplorer::entryList()</link>
5290 received two extra parameters
5291 <computeroutput>sizes</computeroutput> and
5292 <computeroutput>modes</computeroutput>, which contains the
5293 sizes (in bytes) and the file access modes (in octal form) of
5294 the returned files.</para>
5295 </listitem>
5296 </itemizedlist></para>
5297 </listitem>
5298
5299 <listitem>
5300 <para>Support for remote desktop access to virtual machines has been
5301 cleaned up to allow third party implementations of the remote
5302 desktop server. This is called the VirtualBox Remote Desktop
5303 Extension (VRDE) and can be added to VirtualBox by installing the
5304 corresponding extension package; see the VirtualBox User Manual for
5305 details.</para>
5306
5307 <para>The following API changes were made to support the VRDE
5308 interface: <itemizedlist>
5309 <listitem>
5310 <para><computeroutput>IVRDPServer</computeroutput> has been
5311 renamed to
5312 <link linkend="IVRDEServer">IVRDEServer</link>.</para>
5313 </listitem>
5314
5315 <listitem>
5316 <para><computeroutput>IRemoteDisplayInfo</computeroutput> has
5317 been renamed to
5318 <link linkend="IVRDEServerInfo">IVRDEServerInfo</link>.</para>
5319 </listitem>
5320
5321 <listitem>
5322 <para><link linkend="IMachine__VRDEServer">IMachine::VRDEServer</link>
5323 replaces
5324 <computeroutput>VRDPServer.</computeroutput></para>
5325 </listitem>
5326
5327 <listitem>
5328 <para><link linkend="IConsole__VRDEServerInfo">IConsole::VRDEServerInfo</link>
5329 replaces
5330 <computeroutput>RemoteDisplayInfo</computeroutput>.</para>
5331 </listitem>
5332
5333 <listitem>
5334 <para><link linkend="ISystemProperties__VRDEAuthLibrary">ISystemProperties::VRDEAuthLibrary</link>
5335 replaces
5336 <computeroutput>RemoteDisplayAuthLibrary</computeroutput>.</para>
5337 </listitem>
5338
5339 <listitem>
5340 <para>The following methods have been implemented in
5341 <computeroutput>IVRDEServer</computeroutput> to support
5342 generic VRDE properties: <itemizedlist>
5343 <listitem>
5344 <para><link linkend="IVRDEServer__setVRDEProperty">IVRDEServer::setVRDEProperty</link></para>
5345 </listitem>
5346
5347 <listitem>
5348 <para><link linkend="IVRDEServer__getVRDEProperty">IVRDEServer::getVRDEProperty</link></para>
5349 </listitem>
5350
5351 <listitem>
5352 <para><link linkend="IVRDEServer__VRDEProperties">IVRDEServer::VRDEProperties</link></para>
5353 </listitem>
5354 </itemizedlist></para>
5355
5356 <para>A few implementation-specific attributes of the old
5357 <computeroutput>IVRDPServer</computeroutput> interface have
5358 been removed and replaced with properties: <itemizedlist>
5359 <listitem>
5360 <para><computeroutput>IVRDPServer::Ports</computeroutput>
5361 has been replaced with the
5362 <computeroutput>"TCP/Ports"</computeroutput> property.
5363 The property value is a string, which contains a
5364 comma-separated list of ports or ranges of ports. Use a
5365 dash between two port numbers to specify a range.
5366 Example:
5367 <computeroutput>"5000,5010-5012"</computeroutput></para>
5368 </listitem>
5369
5370 <listitem>
5371 <para><computeroutput>IVRDPServer::NetAddress</computeroutput>
5372 has been replaced with the
5373 <computeroutput>"TCP/Address"</computeroutput> property.
5374 The property value is an IP address string. Example:
5375 <computeroutput>"127.0.0.1"</computeroutput></para>
5376 </listitem>
5377
5378 <listitem>
5379 <para><computeroutput>IVRDPServer::VideoChannel</computeroutput>
5380 has been replaced with the
5381 <computeroutput>"VideoChannel/Enabled"</computeroutput>
5382 property. The property value is either
5383 <computeroutput>"true"</computeroutput> or
5384 <computeroutput>"false"</computeroutput></para>
5385 </listitem>
5386
5387 <listitem>
5388 <para><computeroutput>IVRDPServer::VideoChannelQuality</computeroutput>
5389 has been replaced with the
5390 <computeroutput>"VideoChannel/Quality"</computeroutput>
5391 property. The property value is a string which contain a
5392 decimal number in range 10..100. Invalid values are
5393 ignored and the quality is set to the default value 75.
5394 Example: <computeroutput>"50"</computeroutput></para>
5395 </listitem>
5396 </itemizedlist></para>
5397 </listitem>
5398 </itemizedlist></para>
5399 </listitem>
5400
5401 <listitem>
5402 <para>The VirtualBox external authentication module interface has
5403 been updated and made more generic. Because of that,
5404 <computeroutput>VRDPAuthType</computeroutput> enumeration has been
5405 renamed to <link linkend="AuthType">AuthType</link>.</para>
5406 </listitem>
5407 </itemizedlist>
5408 </sect1>
5409
5410 <sect1>
5411 <title>Incompatible API changes with version 3.2</title>
5412
5413 <itemizedlist>
5414 <listitem>
5415 <para>The following interfaces were renamed for consistency:
5416 <itemizedlist>
5417 <listitem>
5418 <para>IMachine::getCpuProperty() is now
5419 <link linkend="IMachine__getCPUProperty">IMachine::getCPUProperty()</link>;</para>
5420 </listitem>
5421
5422 <listitem>
5423 <para>IMachine::setCpuProperty() is now
5424 <link linkend="IMachine__setCPUProperty">IMachine::setCPUProperty()</link>;</para>
5425 </listitem>
5426
5427 <listitem>
5428 <para>IMachine::getCpuIdLeaf() is now
5429 <link linkend="IMachine__getCPUIDLeaf">IMachine::getCPUIDLeaf()</link>;</para>
5430 </listitem>
5431
5432 <listitem>
5433 <para>IMachine::setCpuIdLeaf() is now
5434 <link linkend="IMachine__setCPUIDLeaf">IMachine::setCPUIDLeaf()</link>;</para>
5435 </listitem>
5436
5437 <listitem>
5438 <para>IMachine::removeCpuIdLeaf() is now
5439 <link linkend="IMachine__removeCPUIDLeaf">IMachine::removeCPUIDLeaf()</link>;</para>
5440 </listitem>
5441
5442 <listitem>
5443 <para>IMachine::removeAllCpuIdLeafs() is now
5444 <link linkend="IMachine__removeAllCPUIDLeaves">IMachine::removeAllCPUIDLeaves()</link>;</para>
5445 </listitem>
5446
5447 <listitem>
5448 <para>the CpuPropertyType enum is now
5449 <link linkend="CPUPropertyType">CPUPropertyType</link>.</para>
5450 </listitem>
5451
5452 <listitem>
5453 <para>IVirtualBoxCallback::onSnapshotDiscarded() is now
5454 IVirtualBoxCallback::onSnapshotDeleted.</para>
5455 </listitem>
5456 </itemizedlist></para>
5457 </listitem>
5458
5459 <listitem>
5460 <para>When creating a VM configuration with
5461 <link linkend="IVirtualBox__createMachine">IVirtualBox::createMachine()</link>
5462 it is now possible to ignore existing configuration files which would
5463 previously have caused a failure. For this the
5464 <computeroutput>override</computeroutput> parameter was added.</para>
5465 </listitem>
5466
5467 <listitem>
5468 <para>Deleting snapshots via
5469 <computeroutput>IConsole::deleteSnapshot()</computeroutput> is now
5470 possible while the associated VM is running in almost all cases.
5471 The API is unchanged, but client code that verifies machine states
5472 to determine whether snapshots can be deleted may need to be
5473 adjusted.</para>
5474 </listitem>
5475
5476 <listitem>
5477 <para>The IoBackendType enumeration was replaced with a boolean flag
5478 (see
5479 <link linkend="IStorageController__useHostIOCache">IStorageController::useHostIOCache</link>).</para>
5480 </listitem>
5481
5482 <listitem>
5483 <para>To address multi-monitor support, the following APIs were
5484 extended to require an additional
5485 <computeroutput>screenId</computeroutput> parameter: <itemizedlist>
5486 <listitem>
5487 <para>IMachine::querySavedThumbnailSize()</para>
5488 </listitem>
5489
5490 <listitem>
5491 <para><link linkend="IMachine__readSavedThumbnailToArray">IMachine::readSavedThumbnailToArray()</link></para>
5492 </listitem>
5493
5494 <listitem>
5495 <para><link linkend="IMachine__querySavedScreenshotInfo">IMachine::querySavedScreenshotPNGSize()</link></para>
5496 </listitem>
5497
5498 <listitem>
5499 <para><link linkend="IMachine__readSavedScreenshotToArray">IMachine::readSavedScreenshotPNGToArray()</link></para>
5500 </listitem>
5501 </itemizedlist></para>
5502 </listitem>
5503
5504 <listitem>
5505 <para>The <computeroutput>shape</computeroutput> parameter of
5506 IConsoleCallback::onMousePointerShapeChange was changed from a
5507 implementation-specific pointer to a safearray, enabling scripting
5508 languages to process pointer shapes.</para>
5509 </listitem>
5510 </itemizedlist>
5511 </sect1>
5512
5513 <sect1>
5514 <title>Incompatible API changes with version 3.1</title>
5515
5516 <itemizedlist>
5517 <listitem>
5518 <para>Due to the new flexibility in medium attachments that was
5519 introduced with version 3.1 (in particular, full flexibility with
5520 attaching CD/DVD drives to arbitrary controllers), we seized the
5521 opportunity to rework all interfaces dealing with storage media to
5522 make the API more flexible as well as logical. The
5523 <link linkend="IStorageController">IStorageController</link>,
5524 <link linkend="IMedium">IMedium</link>,
5525 <link linkend="IMediumAttachment">IMediumAttachment</link> and
5526 <link linkend="IMachine">IMachine</link> interfaces were
5527 affected the most. Existing code using them to configure storage and
5528 media needs to be carefully checked.</para>
5529
5530 <para>All media (hard disks, floppies and CDs/DVDs) are now
5531 uniformly handled through the <link linkend="IMedium">IMedium</link>
5532 interface. The device-specific interfaces
5533 (<code>IHardDisk</code>, <code>IDVDImage</code>,
5534 <code>IHostDVDDrive</code>, <code>IFloppyImage</code> and
5535 <code>IHostFloppyDrive</code>) have been merged into IMedium; CD/DVD
5536 and floppy media no longer need special treatment. The device type
5537 of a medium determines in which context it can be used. Some
5538 functionality was moved to the other storage-related
5539 interfaces.</para>
5540
5541 <para><code>IMachine::attachHardDisk</code> and similar methods have
5542 been renamed and generalized to deal with any type of drive and
5543 medium.
5544 <link linkend="IMachine__attachDevice">IMachine::attachDevice()</link>
5545 is the API method for adding any drive to a storage controller. The
5546 floppy and DVD/CD drives are no longer handled specially, and that
5547 means you can have more than one of them. As before, drives can only
5548 be changed while the VM is powered off. Mounting (or unmounting)
5549 removable media at runtime is possible with
5550 <link linkend="IMachine__mountMedium">IMachine::mountMedium()</link>.</para>
5551
5552 <para>Newly created virtual machines have no storage controllers
5553 associated with them. Even the IDE Controller needs to be created
5554 explicitly. The floppy controller is now visible as a separate
5555 controller, with a new storage bus type. For each storage bus type
5556 you can query the device types which can be attached, so that it is
5557 not necessary to hardcode any attachment rules.</para>
5558
5559 <para>This required matching changes e.g. in the callback interfaces
5560 (the medium specific change notification was replaced by a generic
5561 medium change notification) and removing associated enums (e.g.
5562 <code>DriveState</code>). In many places the incorrect use of the
5563 plural form "media" was replaced by "medium", to improve
5564 consistency.</para>
5565 </listitem>
5566
5567 <listitem>
5568 <para>Reading the
5569 <link linkend="IMedium__state">IMedium::state</link> attribute no
5570 longer automatically performs an accessibility check; a new method
5571 <link linkend="IMedium__refreshState">IMedium::refreshState()</link>
5572 does this. The attribute only returns the state now.</para>
5573 </listitem>
5574
5575 <listitem>
5576 <para>There were substantial changes related to snapshots, triggered
5577 by the "branched snapshots" functionality introduced with version
5578 3.1. IConsole::discardSnapshot was renamed to
5579 <computeroutput>IConsole::deleteSnapshot()</computeroutput>.
5580 IConsole::discardCurrentState and
5581 IConsole::discardCurrentSnapshotAndState were removed; corresponding
5582 new functionality is in
5583 <computeroutput>IConsole::restoreSnapshot()</computeroutput>.
5584 Also, when <computeroutput>IConsole::takeSnapshot()</computeroutput>
5585 is called on a running virtual machine, a live snapshot will be
5586 created. The old behavior was to temporarily pause the virtual
5587 machine while creating an online snapshot.</para>
5588 </listitem>
5589
5590 <listitem>
5591 <para>The <computeroutput>IVRDPServer</computeroutput>,
5592 <computeroutput>IRemoteDisplayInfo"</computeroutput> and
5593 <computeroutput>IConsoleCallback</computeroutput> interfaces were
5594 changed to reflect VRDP server ability to bind to one of available
5595 ports from a list of ports.</para>
5596
5597 <para>The <computeroutput>IVRDPServer::port</computeroutput>
5598 attribute has been replaced with
5599 <computeroutput>IVRDPServer::ports</computeroutput>, which is a
5600 comma-separated list of ports or ranges of ports.</para>
5601
5602 <para>An <computeroutput>IRemoteDisplayInfo::port"</computeroutput>
5603 attribute has been added for querying the actual port VRDP server
5604 listens on.</para>
5605
5606 <para>An IConsoleCallback::onRemoteDisplayInfoChange() notification
5607 callback has been added.</para>
5608 </listitem>
5609
5610 <listitem>
5611 <para>The parameter lists for the following functions were
5612 modified:<itemizedlist>
5613 <listitem>
5614 <para><link linkend="IHost__removeHostOnlyNetworkInterface">IHost::removeHostOnlyNetworkInterface()</link></para>
5615 </listitem>
5616
5617 <listitem>
5618 <para><link linkend="IHost__removeUSBDeviceFilter">IHost::removeUSBDeviceFilter()</link></para>
5619 </listitem>
5620 </itemizedlist></para>
5621 </listitem>
5622
5623 <listitem>
5624 <para>In the OOWS bindings for JAX-WS, the behavior of structures
5625 changed: for one, we implemented natural structures field access so
5626 you can just call a "get" method to obtain a field. Secondly,
5627 setters in structures were disabled as they have no expected effect
5628 and were at best misleading.</para>
5629 </listitem>
5630 </itemizedlist>
5631 </sect1>
5632
5633 <sect1>
5634 <title>Incompatible API changes with version 3.0</title>
5635
5636 <itemizedlist>
5637 <listitem>
5638 <para>In the object-oriented web service bindings for JAX-WS, proper
5639 inheritance has been introduced for some classes, so explicit
5640 casting is no longer needed to call methods from a parent class. In
5641 particular, IHardDisk and other classes now properly derive from
5642 <link linkend="IMedium">IMedium</link>.</para>
5643 </listitem>
5644
5645 <listitem>
5646 <para>All object identifiers (machines, snapshots, disks, etc)
5647 switched from GUIDs to strings (now still having string
5648 representation of GUIDs inside). As a result, no particular internal
5649 structure can be assumed for object identifiers; instead, they
5650 should be treated as opaque unique handles. This change mostly
5651 affects Java and C++ programs; for other languages, GUIDs are
5652 transparently converted to strings.</para>
5653 </listitem>
5654
5655 <listitem>
5656 <para>The uses of NULL strings have been changed greatly. All out
5657 parameters now use empty strings to signal a null value. For in
5658 parameters both the old NULL and empty string is allowed. This
5659 change was necessary to support more client bindings, especially
5660 using the web service API. Many of them either have no special NULL
5661 value or have trouble dealing with it correctly in the respective
5662 library code.</para>
5663 </listitem>
5664
5665 <listitem>
5666 <para>Accidentally, the <code>TSBool</code> interface still appeared
5667 in 3.0.0, and was removed in 3.0.2. This is an SDK bug, do not use
5668 the SDK for VirtualBox 3.0.0 for developing clients.</para>
5669 </listitem>
5670
5671 <listitem>
5672 <para>The type of
5673 <link linkend="IVirtualBoxErrorInfo__resultCode">IVirtualBoxErrorInfo::resultCode</link>
5674 changed from
5675 <computeroutput>result</computeroutput> to
5676 <computeroutput>long</computeroutput>.</para>
5677 </listitem>
5678
5679 <listitem>
5680 <para>The parameter list of IVirtualBox::openHardDisk was
5681 changed.</para>
5682 </listitem>
5683
5684 <listitem>
5685 <para>The method IConsole::discardSavedState was renamed to
5686 IConsole::forgetSavedState, and a parameter was added.</para>
5687 </listitem>
5688
5689 <listitem>
5690 <para>The method IConsole::powerDownAsync was renamed to
5691 <link linkend="IConsole__powerDown">IConsole::powerDown</link>,
5692 and the previous method with that name was deleted. So effectively a
5693 parameter was added.</para>
5694 </listitem>
5695
5696 <listitem>
5697 <para>In the
5698 <link linkend="IFramebuffer">IFramebuffer</link> interface, the
5699 following were removed:<itemizedlist>
5700 <listitem>
5701 <para>the <computeroutput>operationSupported</computeroutput>
5702 attribute;</para>
5703
5704 <para>(as a result, the
5705 <computeroutput>FramebufferAccelerationOperation</computeroutput>
5706 enum was no longer needed and removed as well);</para>
5707 </listitem>
5708
5709 <listitem>
5710 <para>the <computeroutput>solidFill()</computeroutput>
5711 method;</para>
5712 </listitem>
5713
5714 <listitem>
5715 <para>the <computeroutput>copyScreenBits()</computeroutput>
5716 method.</para>
5717 </listitem>
5718 </itemizedlist></para>
5719 </listitem>
5720
5721 <listitem>
5722 <para>In the <link linkend="IDisplay">IDisplay</link>
5723 interface, the following were removed:<itemizedlist>
5724 <listitem>
5725 <para>the
5726 <computeroutput>setupInternalFramebuffer()</computeroutput>
5727 method;</para>
5728 </listitem>
5729
5730 <listitem>
5731 <para>the <computeroutput>lockFramebuffer()</computeroutput>
5732 method;</para>
5733 </listitem>
5734
5735 <listitem>
5736 <para>the <computeroutput>unlockFramebuffer()</computeroutput>
5737 method;</para>
5738 </listitem>
5739
5740 <listitem>
5741 <para>the
5742 <computeroutput>registerExternalFramebuffer()</computeroutput>
5743 method.</para>
5744 </listitem>
5745 </itemizedlist></para>
5746 </listitem>
5747 </itemizedlist>
5748 </sect1>
5749
5750 <sect1>
5751 <title>Incompatible API changes with version 2.2</title>
5752
5753 <itemizedlist>
5754 <listitem>
5755 <para>Added explicit version number into JAX-WS Java package names,
5756 such as <computeroutput>org.virtualbox_2_2</computeroutput>,
5757 allowing connect to multiple VirtualBox clients from single Java
5758 application.</para>
5759 </listitem>
5760
5761 <listitem>
5762 <para>The interfaces having a "2" suffix attached to them with
5763 version 2.1 were renamed again to have that suffix removed. This
5764 time around, this change involves only the name, there are no
5765 functional differences.</para>
5766
5767 <para>As a result, IDVDImage2 is now IDVDImage; IHardDisk2 is now
5768 IHardDisk; IHardDisk2Attachment is now IHardDiskAttachment.</para>
5769
5770 <para>Consequentially, all related methods and attributes that had a
5771 "2" suffix have been renamed; for example, IMachine::attachHardDisk2
5772 now becomes IMachine::attachHardDisk().</para>
5773 </listitem>
5774
5775 <listitem>
5776 <para>IVirtualBox::openHardDisk has an extra parameter for opening a
5777 disk read/write or read-only.</para>
5778 </listitem>
5779
5780 <listitem>
5781 <para>The remaining collections were replaced by more performant
5782 safe-arrays. This affects the following collections:</para>
5783
5784 <itemizedlist>
5785 <listitem>
5786 <para>IGuestOSTypeCollection</para>
5787 </listitem>
5788
5789 <listitem>
5790 <para>IHostDVDDriveCollection</para>
5791 </listitem>
5792
5793 <listitem>
5794 <para>IHostFloppyDriveCollection</para>
5795 </listitem>
5796
5797 <listitem>
5798 <para>IHostUSBDeviceCollection</para>
5799 </listitem>
5800
5801 <listitem>
5802 <para>IHostUSBDeviceFilterCollection</para>
5803 </listitem>
5804
5805 <listitem>
5806 <para>IProgressCollection</para>
5807 </listitem>
5808
5809 <listitem>
5810 <para>ISharedFolderCollection</para>
5811 </listitem>
5812
5813 <listitem>
5814 <para>ISnapshotCollection</para>
5815 </listitem>
5816
5817 <listitem>
5818 <para>IUSBDeviceCollection</para>
5819 </listitem>
5820
5821 <listitem>
5822 <para>IUSBDeviceFilterCollection</para>
5823 </listitem>
5824 </itemizedlist>
5825 </listitem>
5826
5827 <listitem>
5828 <para>Since "Host Interface Networking" was renamed to "bridged
5829 networking" and host-only networking was introduced, all associated
5830 interfaces needed renaming as well. In detail:</para>
5831
5832 <itemizedlist>
5833 <listitem>
5834 <para>The HostNetworkInterfaceType enum has been renamed to
5835 <link linkend="HostNetworkInterfaceMediumType">HostNetworkInterfaceMediumType</link></para>
5836 </listitem>
5837
5838 <listitem>
5839 <para>The IHostNetworkInterface::type attribute has been renamed
5840 to
5841 <link linkend="IHostNetworkInterface__mediumType">IHostNetworkInterface::mediumType</link></para>
5842 </listitem>
5843
5844 <listitem>
5845 <para>INetworkAdapter::attachToHostInterface() has been renamed
5846 to INetworkAdapter::attachToBridgedInterface</para>
5847 </listitem>
5848
5849 <listitem>
5850 <para>In the IHost interface, createHostNetworkInterface() has
5851 been renamed to
5852 <link linkend="IHost__createHostOnlyNetworkInterface">createHostOnlyNetworkInterface()</link></para>
5853 </listitem>
5854
5855 <listitem>
5856 <para>Similarly, removeHostNetworkInterface() has been renamed
5857 to
5858 <link linkend="IHost__removeHostOnlyNetworkInterface">removeHostOnlyNetworkInterface()</link></para>
5859 </listitem>
5860 </itemizedlist>
5861 </listitem>
5862 </itemizedlist>
5863 </sect1>
5864
5865 <sect1>
5866 <title>Incompatible API changes with version 2.1</title>
5867
5868 <itemizedlist>
5869 <listitem>
5870 <para>With VirtualBox 2.1, error codes were added to many error
5871 infos that give the caller a machine-readable (numeric) feedback in
5872 addition to the error string that has always been available. This is
5873 an ongoing process, and future versions of this SDK reference will
5874 document the error codes for each method call.</para>
5875 </listitem>
5876
5877 <listitem>
5878 <para>The hard disk and other media interfaces were completely
5879 redesigned. This was necessary to account for the support of VMDK,
5880 VHD and other image types; since backwards compatibility had to be
5881 broken anyway, we seized the moment to redesign the interfaces in a
5882 more logical way.</para>
5883
5884 <itemizedlist>
5885 <listitem>
5886 <para>Previously, the old IHardDisk interface had several
5887 derivatives called IVirtualDiskImage, IVMDKImage, IVHDImage,
5888 IISCSIHardDisk and ICustomHardDisk for the various disk formats
5889 supported by VirtualBox. The new IHardDisk2 interface that comes
5890 with version 2.1 now supports all hard disk image formats
5891 itself.</para>
5892 </listitem>
5893
5894 <listitem>
5895 <para>IHardDiskFormat is a new interface to describe the
5896 available back-ends for hard disk images (e.g. VDI, VMDK, VHD or
5897 iSCSI). The IHardDisk2::format attribute can be used to find out
5898 the back-end that is in use for a particular hard disk image.
5899 ISystemProperties::hardDiskFormats[] contains a list of all
5900 back-ends supported by the system.
5901 <link linkend="ISystemProperties__defaultHardDiskFormat">ISystemProperties::defaultHardDiskFormat</link>
5902 contains the default system format.</para>
5903 </listitem>
5904
5905 <listitem>
5906 <para>In addition, the new
5907 <link linkend="IMedium">IMedium</link> interface is a generic
5908 interface for hard disk, DVD and floppy images that contains the
5909 attributes and methods shared between them. It can be considered
5910 a parent class of the more specific interfaces for those images,
5911 which are now IHardDisk2, IDVDImage2 and IFloppyImage2.</para>
5912
5913 <para>In each case, the "2" versions of these interfaces replace
5914 the earlier versions that did not have the "2" suffix.
5915 Previously, the IDVDImage and IFloppyImage interfaces were
5916 entirely unrelated to IHardDisk.</para>
5917 </listitem>
5918
5919 <listitem>
5920 <para>As a result, all parts of the API that previously
5921 referenced IHardDisk, IDVDImage or IFloppyImage or any of the
5922 old subclasses are gone and will have replacements that use
5923 IHardDisk2, IDVDImage2 and IFloppyImage2; see, for example,
5924 IMachine::attachHardDisk2.</para>
5925 </listitem>
5926
5927 <listitem>
5928 <para>In particular, the IVirtualBox::hardDisks2 array replaces
5929 the earlier IVirtualBox::hardDisks collection.</para>
5930 </listitem>
5931 </itemizedlist>
5932 </listitem>
5933
5934 <listitem>
5935 <para><link linkend="IGuestOSType">IGuestOSType</link> was
5936 extended to group operating systems into families and for 64-bit
5937 support.</para>
5938 </listitem>
5939
5940 <listitem>
5941 <para>The
5942 <link linkend="IHostNetworkInterface">IHostNetworkInterface</link>
5943 interface was completely rewritten to account for the changes in how
5944 Host Interface Networking is now implemented in VirtualBox
5945 2.1.</para>
5946 </listitem>
5947
5948 <listitem>
5949 <para>The IVirtualBox::machines2[] array replaces the former
5950 IVirtualBox::machines collection.</para>
5951 </listitem>
5952
5953 <listitem>
5954 <para>Added
5955 <link linkend="IHost__getProcessorFeature">IHost::getProcessorFeature()</link>
5956 and <link linkend="ProcessorFeature">ProcessorFeature</link>
5957 enumeration.</para>
5958 </listitem>
5959
5960 <listitem>
5961 <para>The parameter list for
5962 <link linkend="IVirtualBox__createMachine">IVirtualBox::createMachine()</link>
5963 was modified.</para>
5964 </listitem>
5965
5966 <listitem>
5967 <para>Added IMachine::pushGuestProperty.</para>
5968 </listitem>
5969
5970 <listitem>
5971 <para>New attributes in IMachine:
5972 <link linkend="IMachine__accelerate3DEnabled">accelerate3DEnabled</link>,
5973 HWVirtExVPIDEnabled,
5974 <computeroutput>IMachine::guestPropertyNotificationPatterns</computeroutput>,
5975 <link linkend="IMachine__CPUCount">CPUCount</link>.</para>
5976 </listitem>
5977
5978 <listitem>
5979 <para>Added
5980 <link linkend="IConsole__powerUpPaused">IConsole::powerUpPaused()</link>
5981 and
5982 <link linkend="IConsole__getGuestEnteredACPIMode">IConsole::getGuestEnteredACPIMode()</link>.</para>
5983 </listitem>
5984
5985 <listitem>
5986 <para>Removed ResourceUsage enumeration.</para>
5987 </listitem>
5988 </itemizedlist>
5989 </sect1>
5990 </chapter>
5991</book>
5992<!-- 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