Channels ▼
RSS

Parallel

Virtualization for Developers with VirtualBox


VirtualBox Network Settings

By default, a VirtualBox guest runs with networking set to Network Address Translation (NAT) with the host. This means that the guest shares the host's network connection, status, and IP address. From the guest, you'll be able to browse the web, configure an email client, and so on. However, if you want to be able to communicate between the host and guest more freely, it's best to set the guest to use a virtual "Bridged Adapter." This way, you can assign the guest its own IP address, and then have applications communicate between the host and guest as though they were truly running on separate machines (see Figure 5).

[Click image to view at full size]
Figure 5: Configuring the guest's network settings.

This is useful when you're developing a distributed application, configuring a cluster of web or application servers, or configuring an application to communicate with a remote database, for example. Figure 6 shows the different IP addresses on my Mac OS X host as well as the Windows guest.

[Click image to view at full size]
Figure 6: Both the host and the guest have their own IP addresses.

Other networking options include:

  • Internal Network: a network you configure that is visible only to guests that you allow. The network is not visible to the host, or to the outside world (the rest of your network or Internet).
  • Host-only Network: similar to an internal network, this configuration includes an additional virtual adapter on the host, and select guests. This allows the host and guests to communicate on an isolated private network.

Combined with NAT and Bridged networking, these options provide flexibility and security when configuring a network for your guests and host.

VirtualBox Multiprocessor Support

If you run on a multicore or multiprocessor machine, you can expose all or a subset of those processors/cores to a guest through the virtual machine settings (see Figure 7). Conversely, if you need to test parallel-processing code, and a simulated environment will work well enough, VirtualBox lets you configure more virtual CPUs in your guest's settings than you have actual processors for. Although this may not be ideal for all of your application test requirements, it helps in many situations.

[Click image to view at full size]
Figure 7: Guest settings allow you to configure the number of virtual processors available to your guest OS.

You can also enable and expose your processor's Physical Address Extension (PAE), which allows 32-bit guest OS's to access more than 4GB of memory. Ubuntu Server requires PAE to be on when run in a virtual environment.

The VirtualBox API

The entire virtualization engine of VirtualBox is exposed via a programming interface, with which you can build your own applications. In fact, you can control all of VirtualBox, including the execution of guests, from the API.

The API is accessible as a web service to Java developers (and other languages such as Python and Perl), or as a set of Microsoft COM objects for C/C++ developers. Regardless of programming environment, all of VirtualBox is accessible through the APIs. You can create and control virtual disks, virtual machine settings, running guests, network settings, security, hardware and peripherals (both real and virtual), display settings, and so on.

Some practical uses include the ability to simulate your application's operating environment, complete with real-world failures and disasters; the creation of a standalone, bootable, application that launches VirtualBox and guest in the background to easily demonstrate an application that would otherwise require a complicated installation; or other specialized environments such as in-car systems or other embedded environments. You can find the VirtualBox SDK and documentation here.

VirtualBox Open Source Edition

Perhaps you're interested in incorporating VirtualBox into your own application or development project. If so, you can find the open source edition -- with full source code of course -- on the VirtualBox downloads page at virtualbox.org.

Full build instructions, whether you use Linux, Windows, Mac OS X, or Solaris, is located here. The source is the same for all environments, but the build process varies. You can also access the Subversion code repository for the latest in VirtualBox development and features.

Conclusion

Virtualization can give you access to development environments you wouldn't otherwise have, such as a real-time system. For instance, Figure 8 shows Solaris running in VirtualBox on Mac OS X, which gives you access to real-time Java development with Oracle's Java RTS. Although Java RTS doesn't run on Mac OS X natively, with VirtualBox I can do real-time Java development on my Mac.

[Click image to view at full size]
Figure 8: Real-time Java development on a Mac made possible with VirtualBox.

I've been surprised at how many developers don't use virtualization, or who don't know that VirtualBox offers a lightweight, open source, yet full-featured virtualization platform that can help them target multiple OS environments on one computer. It's helped me tremendously, and it's turned my laptop into an even more valuable development environment.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video