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).
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.
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.
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.
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.
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.