Download Operating System Virtualization - University of Wisconsin

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Operating System Virtualization
Adam Nofsinger
Department of Software Engineering
University of Wisconsin, Platteville
[email protected]
Abstract
Though the technology has been in use and development since the 1970s, recent
developments in virtualization have greatly increased its value in Software Engineering,
and many other technology fields. OS virtualization describes the abstraction of an
operating system from any underlying hardware architecture. Although this can create
overhead associated with the extra layers of software between the OS and the resources it
uses, the benefits created by this abstraction are numerous.
This report will expand upon what some of these benefits are, particularly with respect to
the field of software engineering. There will also be some discussion of what techniques
are used to implement OS virtualization, what software is currently available for it, and
what technology is shaping its future.
Virtualization
When defining what operating system virtualization is, and what it accomplishes, it is
helpful to begin with a description of virtualization as it pertains to computing in general.
Virtualization is the separation of a resource or service from the typical physical means of
providing it. This separation should typically provide some benefit.
There are many examples of virtualization in computing that a typical user benefits from
daily. Virtual memory, for instance, allows operating systems and programs to use more
memory than is physically available to a system in RAM. Some of the contents of
memory are stored on a disk drive, or other storage medium, creating the illusion of more
memory for programs. A Virtual Private Network, or VPN, allows a workstation to be
connected to a private network that can be hundreds of miles away from it. A tunnel
connection is formed using a standard TCP/IP internet connection, and the workstation is
given access to all of the resources on the private network, as if it were physically on-site.
A good example of virtualization in programming is the Java Virtual Machine. This
software, when installed on a system, allows execution of Java byte code. In theory, this
lets Java programmers write all Java programs the same, independent of the platform and
operating system the target computer is running. In all of these examples, there is some
overhead involved. However, the benefits—Virtual memory’s added resources, VPN’s
telecommuting possibilities, and Java’s platform-independence respectively—typically
outweigh the costs associated with the layer of abstraction.
Operating system level virtualization specifically describes the abstraction of an
operating system from the computer hardware that typically runs that operating system.
Often times, this layer of virtualization is run on top of an existing operating system and
hardware stack. This “host” operating system may have several “guest” operating
systems running on top of it. It is also possible to run guest operating systems without
the presence of a Host OS—this will be further examined under virtualization techniques.
Guest OS
Guest OS
Guest OS
Virtual Layer
Host OS
Hardware
Figure 1: The Virtual Layer
Virtualization Techniques
There are several different ways of going about OS virtualization. The question that each
technique must answer: how does a guest operating system utilize the resources of the
physical hardware? All of these techniques have their advantages and their disadvantages
when compared to the other techniques, and which one is most useful usually depends on
the situation.
Virtual Monitors
A true virtual monitor achieves OS virtualization completely in software. This technique
is often referred to as emulation; for instance, a virtual monitor that runs a Guest OS that
is targeted for the x86 computer architecture can be referred to as an x86 emulator. [1]
The virtual monitor operates by presenting a virtual hardware set to the Guest OS. Any
hardware access calls that are made by the Guest OS to this virtual hardware are picked
up by the virtual monitor and handled appropriately. For instance, an attempt by the
Guest OS to write to a virtual hard drive will be delivered to the virtual monitor, and in
turn delivered to the Host OS, then written to a file on a physical disk. An interesting
feature of this example is that the Guest OS may think it is running on a completely
different file system than the Host OS, or using a SCSI disk rather than an IDE. Now,
consider the process if the Guest OS tries sends some data out to a virtual network
interface. The data gets passed to the virtual monitor, the Host OS, and then eventually a
real network adapter on the system. The Host OS could have a modem connection, a
standard NIC connection, or even a DSL modem hooked up through USB; the virtual
monitor abstracts this detail from the Guest OS, which operates as if it has its own
connection to the network.
Most software instructions executed on the Guest OS are also emulated for it by the
Virtual Monitor. This allows the Guest OS to be targeted at a different architecture than
the Host OS is actually running on. A Guest OS installation of Mac OS X, targeted at the
PowerPC architecture, could be run on a Windows XP Host OS, which is targeted at the
x86 architecture. Most virtual monitors can even perform 64-bit emulation, allowing 64bit guests on a 32-bit host system. [2]
Hypervisors
A hypervisor is a very thin layer of software that runs between guest operating systems
and the physical hardware. This lean, virtualization-motivated kernel can completely
remove the need for a host operating system, thus cutting down on the virtualization
overhead. Through the hypervisor, the Guest OS can gain access directly to the system
hardware.
Currently, this approach to virtualization is mostly used for running services on server
hardware. It lends itself very nicely to server partitioning, which will be discussed later.
However, Parallels Workstation virtualization software package does use it to some
extent. Parallels Workstation does require a Host OS to be installed on the system, and it
runs on top of this for most hardware access. However, it also claims to be “…the first
desktop virtualization solution to include a lightweight hypervisor that directly controls
some of the host computer’s hardware resources.” [3]
Para-virtualization
Often, performance and stability can be increased by modifying a Guest OS so that it is
“aware” that it is being run on a layer of virtualization. This is referred to as paravirtualization. As with hypervisors, para-virtualization gives the Guest OS a more direct
approach to accessing the system’s physical hardware, allowing it to bypass the Host OS
layer of software.
The most well-known implementation of para-virtualization is the popular Xen virtual
machine for Linux. Xen requires that the kernel—the low-level operating system
functionality—of a Guest OS be modified to run on a Xen virtual machine. This allows
the Guest OS to achieve performance that is near native, that is to say it can be close to
what it would be if there was not a virtualization layer present. Vmware also achieves a
certain level of para-virtualization through the use of its Virtual Tools. Virtual Tools is a
set of drivers—SVGA, Mouse, Network, etc—that are installed on a Guest OS; they give
the virtual device that they are driving a shortcut to the physical hardware. [4]
Virtualization in Software Engineering
The applications of OS virtualization in the field of software engineering are limitless.
Here, I will attempt to list some of the more prevalent and important of its contributions
to developers.
Development and Testing
One of the more obvious benefits virtualization gives to software engineering is the
ability to easily test a system under development on multiple platforms. For instance, if
you were developing an application that is targeted at multiple operating systems, say
Windows and Linux, you could install several versions of Windows and several
distributions of Linux each on their own virtual machines. Then, you could compile and
debug your software on the virtual machines to ensure that all the different versions of
your software function properly. Any costs associated with purchasing the virtualization
software can quickly be offset by saving in hardware purchases, upgrades, and
maintenance.
The hardware emulation present in most virtual OS environments can also be helpful to
software engineers. It ensures that all of the test environments are operating on exactly
the same set of hardware. This eliminates unknowns that can be introduced into testing
from having different hardware setups on different testing workstations. Also, this allows
testers to simulate hardware that may not be physically present in a system—e.g. a SCSI
hard drive, or a network card. Finally, a tester can create virtual machines that have
limited access to system resources so as to stress test applications on virtual low-end
machines. This can be useful in determining estimated system requirements. [5]
When developing an operating system of your own, virtualization can be a vital asset for
testing. Normally, when testing an OS under development, any crash caused by the OS
can result in a system reset. This can cause you to lose vital information pertaining to the
state of the system when the error occurred. A solution to this problem is to run the OS
under test on a virtual machine. Now, any Guest OS crashes that occur should not result
in a restart of the Host OS. This can save the tester time, since they no longer have to
wait for their workstation to restart. Also, most virtualization software will let you obtain
useful debug information about the virtual machine, such as CPU register values,
memory dumps, serial and parallel port stream dumps, the instruction that caused the
fault, etc.
Isolation and Encapsulation
Most virtualization software available today allows the user to create and maintain
multiple, independent virtual machines. These machines each have their own virtual
disks on file, virtual hardware sets, and guest operating systems. This separation between
a virtual machine, its host operating system and hardware, and other virtual machines
creates a valuable amount of isolation. This can be great for installing and testing
“untrustworthy” applications—ones that may cause damage to the system they are
installed on.
It can also protect the Host OS from certain risky activities. Spyware and other malware
that commonly infect a system through casual internet browsing can be avoided by using
a web browser in a virtual machine. If the virtual machine becomes infected, it is usually
easy to remedy by reverting to a previous snapshot of the system. This isolation is so
useful that an application, an OS, and a virtual machine are often bundled together; this is
commonly referred to as a Virtual Appliance.
This can also be used to overcome the fact that sometimes certain applications do not
commingle well. The two enemy apps can be installed on separate virtual machines, or
even a separate branch of the same virtual machines snapshot tree. This allows the two
applications to be run on the same physical hardware; for instance, two different
databases that require the other not be installed could be run on the same server.
Encapsulation is inherent in a virtualized environment: the entire virtual machine, its
setting, and its snapshots are typically contained in single file or folder on a disk drive.
This makes it easy to migrate a virtual machine from one physical system to another, or
to make a backup copy of a virtual machine.
Partitioning
OS virtualization allows the partitioning of one physical hardware set for use by multiple
operating systems and applications to allow for a more efficient resource usage. In the
web server industry, server administrators try to squeeze every dollar out of their
expensive server hardware; virtualization has become an essential tool in achieving this
goal. It is also an important concept for software engineers and test engineers to
understand. A developer may be asked to implement and test an application that will be
run in a partitioned environment, probably on a hypervisor of some kind. Testing in a
similar environment helps remove chances for erroneous results caused by differences in
the test environments. Also, this allows testers to more accurately simulate a network
infrastructure without the presence of the physical infrastructure. One could simulate, for
instance, a Windows 98 machine connected to a Linux router connected to an OpenBSD
router connected to a Windows XP machine—and all simulated using one system. This
might be useful for testing a networked application; one could easily use packet-sniffers
and other tools to verify the state of the data at each level of the network protocol.
Legacy Applications
Certain legacy applications are very difficult to get working on newer operating systems
and hardware. It can be useful to have a virtual machine with DOS, Windows 98, or
other such legacy operating systems on them for using phased out applications.
Sometimes it can be more cost-effective for an organization to stick with an older
appliance and pay the price in maintenance and upkeep, than to update the software with
a newer package. And even if it is wiser to upgrade, many organizations are slow to
make any change.
On a lighter note, the video game industry has recently seen a boom in popularity of older
video games. Some older PC games have memory and OS requirements that do not
allow them to be played on today’s high-end machines. This can also be overcome
through virtualization.
Experimentation and Training
OS virtualization can provide a convenient and safe way for a person to familiarize
themselves with a particular operating system. In the business world today, many
companies are trying to capitalize on the use of open source software—including open
source operating systems, such as Linux. A Linux virtual machine is a great way for an
employee to temporarily practice and learn about open source solutions while
maintaining their commercial solutions as a fall-back. Of course, it is also very suitable
for personal experimentation outside the office if an individual would like to learn more
in their free time. In fact, this idea of experimenting with operating systems is the
primary goal of one very powerful virtual monitor, QEMU. [6]
Shortcomings of Virtualization
Despite all of its usefulness to a software engineer, there are several drawbacks and
things one should be aware of.
One of the main uses of virtualization we discussed earlier was in testing applications
under development. It is easy to see how virtualization lends itself to this area so well.
However, there is always room to question exactly how accurate is a virtual machine at
simulating a real setup. If a test passes or fails in a virtual environment, can we be 100
percent sure we will obtain the same result in a standard environment. The answer to this
is, unfortunately, no. However, for nearly all situations and circumstances, a virtual
machine will be a sufficiently close enough approximation. Some applications that
interface very closely with system hardware may be undesirable to test on a virtual
machine. It should also be noted that virtualization solutions that use Para-virtualization,
such as Xen, actually make modifications to the Guest OS. This introduces even more
unknowns into the equation. Yet, for most cases, virtualization is still a viable option.
Virtualization can sometimes have steep system requirements, depending on the needs of
the Guest OS, and the requirements keep stacking up the more virtual machines you want
running simultaneously. Whatever amount of a system resource is needed on a virtual
machine, you will need a great deal more of the actual physical means of providing that
resource. For instance, say you wanted to run a Windows XP virtual machine on a
Windows XP host operating system. The bare minimum requirements for memory for
Windows XP is 256MB, though most experts recommend double that. So, you would
need at least 512MB of physical memory to be partitioned between the Host OS and the
Guest OS. In fact, you might need quite a bit more than that, since most virtual monitors
will reserve more than half of the physical memory for itself and the Host OS. Now,
imagine how quickly these requirements could go up if you were trying to simulate a
multiple computer infrastructure like we discussed earlier. Unless you have some
powerful computer equipment available, it may become necessary to choose an
alternative to virtualization, at least for some of the intended virtual machines. It is worth
noting that some types of hardware resources are affected more by partitioning than other
types. For instance, the CPU is typically easier to partition, since in a regular workstation
environment more CPU cycles are given to the active task. That is to say, the CPU
spends more time with the virtual machine when the user is working there, and then
spends more time with the Host OS when the user is working there.
Perhaps the worst shortcoming of virtualization to some users is its lack of support for
certain hardware. Many workstation virtualization solutions have limited support for
USB devices and other specialized hardware, such as TV Tuners, Scanners, or Printers.
And if you are interested in developing or testing games, most virtual monitors do not
currently support access to the 3D graphics cards necessary to run modern video games.
Again, chances are fairly low that one would need this kind of support to test the average
application, but we can certainly hope to see more along these lines in the future.
The Future of Virtualization
Knowing what we do now about OS Virtualization, it is easy to imagine fresh and
exciting ways it may be used in the future. We can envision a hypervisor sitting on top of
every computer BIOS, letting computer professionals and hobbyists alike install and run
multiple operating systems simultaneously, switching between them with ease; or a team
of testers at a company remotely connecting to a virtual machine server to grab the latest
test environment virtual machine to run on their local workstation, saving hours of wasted
setup time; or a college professor distributing a real-time embedded operating system
virtual machine, so students can test their lab work on TinyOS or some other real-time
OS without risk of damaging a valuable embedded architecture device.
The value of virtualization to computer science and its industries has been known for
some time, but it is constantly being expanded upon. Recently, hardware developers
have also been taking notice.
Intel Vanderpool and AMD Pacifica
Intel, inspired by the current boom in OS virtualization, has been working to remedy
certain problems with the IA-32 architecture which make it difficult to virtualize certain
instructions. The company is now shipping processors with Intel Virtualization
Technology, previously codenamed “Vanderpool.” This technology adds several new
instructions to the instruction set specific to virtualization, known as Virtual Machine
Extensions (VMX). They include instructions such as VMXON and VMXOFF, which are to
be executed when a virtual monitor receives CPU time and when it loses it respectively.
Also present are VMLAUNCH and VMRESUME, which the virtual monitor executes before
and after it starts giving virtual CPU time to a virtual machine. All of these instructions,
and several others, let the CPU know that a virtual machine is currently using it, and that
certain instructions need special handling. [7]
AMD is developing a parallel technology code-named “Pacifica.” Besides providing the
extra instructions that Intel boasts, AMD claims it will also provide numerous additions
to the x86 architecture that will better support virtualization. [8]
Conclusion
OS Virtualization may not be a very new technology, but it certainly is growing in its
uses for industry and at home. We have seen how it can be used for development and
testing, partitioning of hardware, encapsulation and isolation of a resource, and
experimentation with new ideas. Hopefully, I have also conveyed that virtualization can
be good old fashioned fun to play with. This is important, since some of the best ideas
for uses of a technology come while tinkering.
References
[1] Vmware, Virtualization Overview
http://www.vmware.com/virtualization/
[2] Vmware, Virtualization White Paper
http://www.vmware.com/pdf/virtualization.pdf [pdf]
[3] Parallels Software, Parallels Workstation
http://www.parallels.com/en/products/workstation/
[4] Cambridge University Systems Research Group, Xen Website
http://www.cl.cam.ac.uk/Research/SRG/netos/xen/
[5] Amit Sing, An Introduction to Virtualization
http://www.kernelthread.com/publications/virtualization/
[6] Fabrice Bellard, QEMU Virtual Monitor
http://fabrice.bellard.free.fr/qemu/
[7] Gabriel Torres, Intel Virtualization Technology (VT) Explained
http://www.hardwaresecrets.com/printpage/263
[8] AMD, “Pacifica” Virtualization Technology
http://enterprise.amd.com/Downloads/Pacifica_en.pdf [pdf]