While buffering is a useful default setting for virtualizating a few machines on a desktop computer, there are some disadvantages to this approach:
1. Delayed writing through the host OS cache is less secure. When the guest OS writes data, it considers the data written even though it has not yet arrived on a physical disk. If for some reason the write does not happen (power failure, host crash), the likelihood of data loss increases.
2. Disk image files tend to be very large. Caching them can therefore quickly use up the entire host OS cache. Depending on the efficiency of the host OS caching, this may slow down the host immensely, especially if several VMs run at the same time. For example, on Linux hosts, host caching may result in Linux delaying all writes until the host cache is nearly full and then writing out all these changes at once, possibly stalling VM execution for minutes. This can result in I/O errors in the guest as I/O requests time out there.
3. Physical memory is often wasted as guest operating systems typically have their own I/O caches, which may result in the data being cached twice (in both the guest and the host caches) for little effect.
As a result, starting with version 3.2, VirtualBox allows you to optionally disable host I/O caching of disk image files. In that case, VirtualBox uses its own small cache to buffer writes, but there is no read caching since this is already performed by the guest OS. In addition, VirtualBox fully supports asynchronous I/O for its virtual SATA, SCSI and SAS controllers through multiple I/O threads.
Since asynchronous I/O is not supported by IDE controllers, for performance reasons, you may want to leave host caching enabled for your VM’s virtual IDE controllers.
For this reason, VirtualBox allows you to configure whether the host I/O cache is used for each I/O controller separately. Either uncheck the “Use host I/O cache” box in the “Storage” settings for a given virtual storage controller, or use the following VBoxManage command to disable the host I/O cache for a virtual storage controller:
VBoxManage storagectl <vm> --name <controllername> --hostiocache off
See chapter8.15.1,VBoxManage storagectl, page114for details.
For the above reasons also, VirtualBox now uses SATA controllers by default for new virtual machines.
Note: Disabling the host I/O caches will currently yield poor performance with VHD
and sparse VMDK files. See chapter13,Known limitations, page165for details.
5.8 CD/DVD drive operation
The virtual CD/DVD drive(s) by default support only reading. The medium configuration is changeable at runtime. You can select between three options to provide the medium data:
• Host Drive defines that the guest can read from the medium in the host drive. Medium
changes of the host drives are signalled to the guest.
• Image file gives the guest read-only access to the image data (often referred to as ISO
image). A medium change is signalled when switching to a different image or selecting another option.
• Empty stands for a drive without an inserted medium. The drive responds as usual to this
situation, however no data can be read.
As mentioned, the medium change signalling depends on the selected option for the medium. Medium changes can be prevented by the guest, and VirtualBox reflects that by locking the host drive if appropriate. You can force a medium removal in such situation via the VirtualBox GUI or the VBoxManage command line tool. Effectively this is the equivalent of the emergency eject which many CD/DVD drives provide, with all associated side effects. The guest OS can issue error messages in this case, just like on real hardware. Use with caution.
In any case, only data media is supported for CD/DVD drives. This means that all data CD formats and all DVD formats can be used in principle. Since host DVD drives refuse to read encrypted DVD video media, you cannot play such videos with the regular CD/DVD drive emu- lation. You may be able to get it working with the experimental passthrough support described in chapter5.9,Writing CDs and DVDs using the host drive, page78.
Audio CD and video CD formats are not supported, which means you cannot play such media from a virtual machine.
5.9 Writing CDs and DVDs using the host drive
When you attach your host’s CD/DVD drive to a virtual machine (see chapter3.6,Storage settings, page44), this normally gives the machine read-only access to the host drive. This prevents the guest from writing to the host drive. In particular, you cannot burn CDs and DVDs from the guest this way.
As an experimental feature (which currently works for data media only, audio and video CD formats are not supported), it is possible to give the guest access to the CD/DVD writing fea- tures of the host drive (if available). There is a “Passthrough” checkbox in the GUI dialog for configuring the media attached to a storage controller, or you can use the command line:
VBoxManage storageattach <uuid|vmname> --storagectl <name> --port <number> --device <number> [--type <dvddrive|hdd|fdd> --medium <none|emptydrive|uuid|filename|host:<drive>>] [--passthrough <on|off>] [--forceunmount]
Even if pass-through is enabled, unsafe commands, such as updating the drive firmware, will be blocked. On some host drives the pass-through feature allows playing encrypted DVD video media.
On Solaris hosts, pass-through requires running VirtualBox with real root permissions due to security measures enforced by the host.
5.10 iSCSI servers
iSCSI stands for “Internet SCSI” and is a standard that allows for using the SCSI protocol over Internet (TCP/IP) connections. Especially with the advent of Gigabit Ethernet, it has become affordable to attach iSCSI storage servers simply as remote hard disks to a computer network. In iSCSI terminology, the server providing storage resources is called an “iSCSI target”, while the client connecting to the server and accessing its resources is called “iSCSI initiator”.
VirtualBox can transparently present iSCSI remote storage to a virtual machine as a virtual hard disk. The guest operating system will not see any difference between a virtual disk image (VDI file) and an iSCSI target. To achieve this, VirtualBox has an integrated iSCSI initiator.
VirtualBox’s iSCSI support has been developed according to the iSCSI standard and should work with all standard-conforming iSCSI targets. To use an iSCSI target with VirtualBox, you must first register it as a virtual hard disk with VBoxManage; see chapter 8.21, VBoxManage addiscsidisk, page118. The target will show up in the list of disk images, as described in chapter
5.3,The Virtual Media Manager, page71, and can thus be attached to one of the VM’s three hard disk slots the usual way.
5.10.1 Access iSCSI targets via Internal Networking
As an experimental feature, VirtualBox allows for accessing an iSCSI target running in a virtual machine which is configured for using Internal Networking mode (as described in chapter6.5,
Internal networking, page85). The setup of the virtual machine which uses such an iSCSI target is done as described above. The only difference is that the IP address of the target must be specified as a numeric IP address.
The IP stack accessing Internal Networking must be configured in the virtual machine which accesses the iSCSI target. A free static IP and a MAC address not used by other virtual machines must be chosen. In the example below, adapt the name of the virtual machine, the MAC address, the IP configuration and the Internal Networking name (“MyIntNet”) according to your needs. The following seven commands must be issued:
VBoxManage setextradata "VM name" VBoxInternal/Devices/IntNetIP/0/Trusted 1
VBoxManage setextradata "VM name" VBoxInternal/Devices/IntNetIP/0/Config/MAC 08:00:27:01:02:0f VBoxManage setextradata "VM name" VBoxInternal/Devices/IntNetIP/0/Config/IP 10.0.9.1
VBoxManage setextradata "VM name" VBoxInternal/Devices/IntNetIP/0/Config/Netmask 255.255.255.0 VBoxManage setextradata "VM name" VBoxInternal/Devices/IntNetIP/0/LUN#0/Driver IntNet
VBoxManage setextradata "VM name" VBoxInternal/Devices/IntNetIP/0/LUN#0/Config/Network MyIntNet VBoxManage setextradata "VM name" VBoxInternal/Devices/IntNetIP/0/LUN#0/Config/IsService 1
Finally the iSCSI disk must be registered with the-intnetoption to tell the iSCSI initiator to use internal networking:
VBoxManage addiscsidisk --server 10.0.9.30 --target iqn.2008-12.com.sun:sampletarget --intnet
The target address must be specified as a numeric IP address, as there is no DNS resolver for internal networking.
The virtual machine with the iSCSI target should be started before the VM using it is powered on. If a virtual machine using an iSCSI disk is started without having the iSCSI target powered up, it can take up to 200 seconds to detect this situation. The VM will fail to power up.
As briefly mentioned in chapter3.8,Network settings, page46, VirtualBox provides up to eight virtual PCI Ethernet cards for each virtual machine. For each such card, you can individually select
1. the hardware that will be virtualized as well as
2. the virtualization mode that the virtual card will be operating in with respect to your physical networking hardware on the host.
Four of the network cards can be configured in the “Network” section of the settings dialog in the graphical user interface of VirtualBox. You can configure all eight network cards on the command line via VBoxManage modifyvm; see chapter8.7,VBoxManage modifyvm, page104.
This chapter explains the various networking settings in more detail.
6.1 Virtual networking hardware
For each card, you can individually select what kind of hardware will be presented to the virtual machine. VirtualBox can virtualize the following six types of networking hardware:
• AMD PCNet PCI II (Am79C970A);
• AMD PCNet FAST III (Am79C973, the default); • Intel PRO/1000 MT Desktop (82540OEM); • Intel PRO/1000 T Server (82543GC); • Intel PRO/1000 MT Server (82545EM); • Paravirtualized network adapter (virtio-net).
The PCNet FAST III is the default because it is supported by nearly all operating systems out of the box, as well as the GNU GRUB boot manager. As an exception, the Intel PRO/1000 family adapters are chosen for some guest operating system types that no longer ship with drivers for the PCNet card, such as Windows Vista; see chapter4.2.1.5,Windows Vista networking, page53
for details.1
The “Paravirtualized network adapter (virtio-net)“ is special. If you select this, then VirtualBox does not virtualize common networking hardware (that is supported by common guest operating systems out of the box). Instead, VirtualBox then expects a special software interface for virtualized environments to be provided by the guest, thus avoiding the complexity of emulating networking hardware and improving network performance. Starting with version 3.1, VirtualBox provides support for the industry-standard “virtio” networking drivers, which are part of the open-source KVM project.
The “virtio” networking drivers are available for the following guest operating systems:
1Support for the Intel PRO/1000 MT Desktop type was added with VirtualBox 1.6. The T Server variant of the Intel
PRO/1000 card was added with VirtualBox 1.6.2 because this one is recognized by Windows XP guests without additional driver installation. The MT Server variant was added with VirtualBox 2.2 to facilitate OVF imports from other platforms.
• Linux kernels version 2.6.25 or later can be configured to provide virtio support; some distributions also back-ported virtio to older kernels.
• For Windows 2000, XP and Vista, virtio drivers can be downloaded and installed from the KVM project web page.2
VirtualBox also has limited support for so-calledjumbo frames, i.e. networking packets with
more than 1500 bytes of data, provided that you use the Intel card virtualization and bridged networking. In other words, jumbo frames are not supported with the AMD networking devices; in those cases, jumbo packets will silently be dropped for both the transmit and the receive direction. Guest operating systems trying to use this feature will observe this as a packet loss, which may lead to unexpected application behavior in the guest. This does not cause problems with guest operating systems in their default configuration, as jumbo frames need to be explicitly enabled.