The Need for a Virtual Machine by zhouwenjuan


									Virtual Machine

   The Need for a Virtual Machine
    Faced with large, heterogeneous information systems and the accelerated rate of
technological innovation, software engineers are beginning to rediscover the benefits of
targeting virtual machines.

    The name of the game in software development is return on investment. Companies want to
invest money in software that will be useful long enough for the resources spent to be justified.
Porting a software package from one platform to another is costly and, depending on the
number of platforms supported, can prove to be a Sisyphean nightmare.

    The worst-case scenario occurs when business logic is stranded on an aging system. Due to
historical forces, a large base of code may end up on an obsolete platform that no one wants to
deal with. The people who wrote the original code have either quit or been promoted and don't
remember anything (sometimes intentionally). The source code has been transformed by time
into an encrypted historical artifact that will require years of work by researchers to decipher.
If the language and tools used to develop the initial code are linked to the original platform,
porting may be out of the question. In pathological cases, the code may be so obscure and
illegible that maintenance engineers are too scared to touch anything. I'm sure Y2K
programmers are familiar with this type of imbroglio. The only recourse may be a complete
rewrite and this is an extremely expensive alternative, fraught with all sorts of dangers and
hidden costs. This is the kind of situation CIOs lose sleep over.

    Using a virtual machine offers a degree of insurance against this kind of thing happening.
When confronted with a new hardware platform or operating system, the only application that
needs to be ported is the virtual machine itself. If a virtual machine is, say, 100,000 lines of
code, you might think that actually porting the code is a bad investment. 100,000 lines of code
is not a trivial porting job. However, let's say that the virtual machine runs an application suite
that consists of 11 million lines of code. Suddenly, porting the virtual machine is not such a
bad deal because the alternative would be to port the 11 million lines of application code. Don't
think that this isn't realistic. I once visited an automobile insurance company that had around
30 million lines of application code.

                                    Dept. of Computer Engineering, ICOER, Pune.              1
Virtual Machine

    Objective was to build a virtual machine that satisfied three criterion. In order of priority,
these are:

           1. Portability
           2. Simplicity
           3. Performance

    Portability is the most important feature because being able to work with a uniform
software interface, across multiple platforms, is the primary benefit of using a virtual machine.
If you can't port a virtual machine, then you're stuck with a given platform, in which case you
might as well use tools that compile to the native machine encoding.

    Portability is also the most important priority in the sense that I had to make sacrifices in
terms of simplicity and performance in order to achieve it. There is rarely a solution that is ever
optimal under all conditions in software engineering.

    One way of boosting performance would be to make heavy use of assembly code.
However, using an assembler does not necessarily guarantee faster program execution. In order
to be able to justify using an assembler, the programmer has to have an intimate knowledge of
both the assembly code a compiler generates and the kind of optimizations it performs. The
goal is to be able to write faster assembly code than the compiler can. This requires a certain
amount of vigilance and skill because, in most cases, the optimizer in a C compiler can do a
better job than the average programmer.

    Another problem with using assembly language is that it ties your code to the hardware
you're working on. To port the code to new hardware, you'll need to rewrite every single line of
assembly code. This can turn out to be much more work than you think. Again, in the effort to
maintain a certain degree of portability, I opted out of low-level, high-performance assembly
coding and wrote everything in ANSI C.

     simplicity has priority over performance by virtue of my desire to make the code
maintainable. A year from now, I would like to be able to modify my code without having to
call in a team of archaeologists. Code that is optimized for performance can become very
brittle and resistant to change. Developers writing high-performance C code will often use all
sorts of misleading and confusing conventions, like bitwise shifting to divide by 2. What is
produced is usually illegible by anyone but the original developer, and given enough time even
the original developer may forget what he had done and why he had done it. In an extreme
case, a programmer who has created a mess and is too scared to clean it up may opt to quit and
go work somewhere else. I've heard people refer to this as "the final solution" or "calling in for
air support and pulling out."
                                    Dept. of Computer Engineering, ICOER, Pune.              2
Virtual Machine

   Run-time Systems
    A run-time system is an environment in which computer programs execute. A run-time
system provides everything a program needs in order to run. For example, a run-time system is
responsible for allocating memory for an application, loading the application into the allocated
memory, and facilitating the execution of the program's instructions. If the program requests
services from the underlying operating system through the invocation of system calls, the run-
time system is in charge of handling those service requests. For instance, if an application
wants to perform file I/O, the run-time system must offer a mechanism to communicate with
the disk controller and provide read/write access.

    There are different kinds of run-time systems. One way to classify run-time systems is to
categorize them based on how they execute a program's instructions. For programs whose
instructions use the processor's native machine encoding, the run-time system consists of a
tightly knit collaboration between the computer's processor and the operating system. The
processor provides a mechanism for executing program instructions. The CPU does nothing
more than fetch instructions from memory, which are encoded as numeric values, and perform
the actions corresponding to those instructions. The operating system implements the policy
side of a computer's native run-time system. The CPU may execute instructions, but the
operating system decides how, when, and where things happen. Think of the operating system
as a fixed set of rules the CPU has to obey during the course of instruction execution.

    Thus, for programs written in native machine instructions, the computer itself is the run-
time system. Program instructions are executed at the machine level, by the physical CPU, and
the operating system manages how the execution occurs. This type of run-time system involves
a mixture of hardware and software.

    Programs whose instructions are not directly executed by the physical processor require a
run-time system that consists entirely of software. In such a case, the program's instructions are
executed by a virtual machine. A virtual machine is a software program that acts like a
computer. It fetches and executes instructions just like a normal processor. The difference is
that the processing of those instructions happens at the software level instead of the hardware
level. A virtual machine also usually contains facilities to manage the path of execution and to
offer an interface to services normally provided by the native operating system.

    A virtual machine is defined by a specification. A virtual machine is not a particular
software implementation, but rather a set of rules. These rules form a contract that the
engineer, who builds an instantiation of the virtual machine, must honor. A virtual machine can
be implemented in any programming language on any hardware platform, as long as it obeys
the specification. You could create a version of the HEC virtual machine on an OS/390 using
APL if you really wanted to. This is what makes the idea of a virtual machine so powerful.
You can run HEC executables, without recompilation, anywhere there is a run-time system that
obeys the specification.

                                   Dept. of Computer Engineering, ICOER, Pune.              3
Virtual Machine

    Virtual machine was originally defined by Popek and Goldberg as "an efficient, isolated
duplicate of a real machine". Current use includes virtual machines which have no direct
correspondence to any real hardware.

     Virtual machines are separated into two major categories, based on their use and degree of
correspondence to any real machine. A system virtual machine provides a complete system
platform which supports the execution of a complete operating system (OS). In contrast, a
process virtual machine is designed to run a single program, which means that it supports a
single process. An essential characteristic of a virtual machine is that the software running
inside is limited to the resources and abstractions provided by the virtual machine -- it cannot
break out of its virtual world.

    Example: A program written in Java receives services from the Java Runtime Environment
(JRE) software by issuing commands to, and receiving the expected results from, the Java
software. By providing these services to the program, the Java software is acting as a "virtual
machine", taking the place of the operating system or hardware for which the program would
ordinarily be tailored.

                                   Dept. of Computer Engineering, ICOER, Pune.             4
Virtual Machine

   System virtual machines
    System virtual machines (sometimes called hardware virtual machines) allow the sharing of
the underlying physical machine resources between different virtual machines, each running its
own operating system. The software layer providing the virtualization is called a virtual
machine monitor or hypervisor. A hypervisor can run on bare hardware (Type 1 or native VM)
or on top of an operating system (Type 2 or hosted VM).

   The main advantages of system VMs are:

            multiple OS environments can co-exist on the same computer, in strong
       isolation from each other
            the virtual machine can provide an instruction set architecture (ISA) that is
       somewhat different from that of the real machine

    Multiple VMs each running their own operating system (called guest operating system) are
frequently used in server consolidation, where different services that used to run on individual
machines in order to avoid interference are instead run in separate VMs on the same physical
machine. This use is frequently called quality-of-service isolation (QoS isolation).

   The desire to run multiple operating systems was the original motivation for virtual
machines, as it allowed time-sharing a single computer between several single-tasking OSes.

    The guest OSes do not have to be all the same, making it possible to run different OSes on
the same computer (e.g., Microsoft Windows and Linux, or older versions of an OS in order to
support software that has not yet been ported to the latest version). The use of virtual machines
to support different guest OSes is becoming popular in embedded systems; a typical use is to
support a real-time operating system at the same time as a high-level OS such as Linux or

   Another use is to sandbox an OS that is not trusted, possibly because it is a system under
development. Virtual machines have other advantages for OS development, including better
debugging access and faster reboots.[2]

    Alternate techniques such as Solaris Zones provides a level of isolation within a single
operating system. This does not have isolation as complete as a VM. A kernel exploit in a
system with multiple zones will affect all zones. Achieving the same goal in a virtual machine
implementation would require exploiting a weakness in the hypervisor. A hypervisor typically
has a smaller "attack surface" than a complete operating system, making this more challenging.
Further, a kernel exploit in a VM guest would not affect other VMs on the host, just as a
successful intrusion into one zone would not necessarily affect other zones. Zones are not
virtual machines, but an example of "operating-system virtualization". This includes other
"virtual environments" (also called "virtual servers") such as Virtuozzo, FreeBSD Jails, Linux-
VServer, chroot jail, and OpenVZ. These provide some form of encapsulation of processes
within an operating system. These technologies have the advantages of being more resource-
efficient than full virtualization and having better observability into multiple guests

                                   Dept. of Computer Engineering, ICOER, Pune.             5
Virtual Machine

simultaneously; the disadvantage is that, generally, they can only run a single operating system
and a single version/patch level of that operating system - so, for example, they cannot be used
to run two applications, one of which only supports a newer OS version and the other only
supporting an older OS version on the same hardware. However, Sun Microsystems has
enhanced Solaris Zones to allow some zones to behave like Solaris 8 or Solaris 9 systems by
adding a system call translator

                                   Dept. of Computer Engineering, ICOER, Pune.             6
Virtual Machine

   Process virtual machines
    A process VM, sometimes called an application virtual machine, runs as a normal
application inside an OS and supports a single process. It is created when that process is started
and destroyed when it exits. Its purpose is to provide a platform-independent programming
environment that abstracts away details of the underlying hardware or operating system, and
allows a program to execute in the same way on any platform.

    A process VM provides a high-level abstraction — that of a high-level programming
language (compared to the low-level ISA abstraction of the system VM). Process VMs are
implemented using an interpreter; performance comparable to compiled programming
languages is achieved by the use of just-in-time compilation.

   This type of VM has become popular with the Java programming language, which is
implemented using the Java virtual machine. Another example is the .NET Framework, which
runs on a VM called the Common Language Runtime.

    A special case of process VMs are systems that abstract over the communication
mechanisms of a (potentially heterogeneous) computer cluster. Such a VM does not consist of
a single process, but one process per physical machine in the cluster. They are designed to ease
the task of programming parallel applications by letting the programmer focus on algorithms
rather than the communication mechanisms provided by the interconnect and the OS. They do
not hide the fact that communication takes place, and as such do not attempt to present the
cluster as a single parallel machine.

   Unlike other process VMs, these systems do not provide a specific programming language,
but are embedded in an existing language; typically such a system provides bindings for
several languages (e.g., C and FORTRAN). Examples are PVM (Parallel Virtual Machine) and
MPI (Message Passing Interface). They are not strictly virtual machines, as the applications
running on top still have access to all OS services, and are therefore not confined to the system
model provided by the "VM".

                                   Dept. of Computer Engineering, ICOER, Pune.              7
Virtual Machine

   List of hardware with virtual machine support

            Alcatel-Lucent 3B20D/3B21D emulated on commercial off-the-shelf computers
      with 3B2OE or 3B21E system
          AMD-V (formerly code-named Pacifica)
          ARM TrustZone
          Boston Circuits gCore (grid-on-chip) with 16 ARC 750D cores and Time-
      machine hardware virtualization module.
          Freescale PowerPC MPC8572 and MPC8641D
          IBM System/370, System/390, and zSeries mainframes
          Intel VT (formerly code-named Vanderpool)
          Sun Microsystems sun4v (UltraSPARC T1 and T2) -- utilized by Logical

            HP vPAR and cell based nPAR
            GE Project MAC then
            Honeywell Multics systems
            Honeywell 200/2000 systems Liberator replacing IBM 14xx systems, Level
      62/64/66 GCOS
           IBM System/360 Model 145 Hardware emulator for Honeywell 200/2000
           RCA Spectra/70 Series emulated IBM System/360
           NAS CPUs emulated IBM and Amdahl machines
           Honeywell Level 6 minicomputers emulated predecessor 316/516/716 minis
           Xerox Sigma 6 CPUs were modified to emulate GE/Honeywell 600/6000

                              Dept. of Computer Engineering, ICOER, Pune.        8
Virtual Machine

   List of virtual machine software
    Process   (Application)   virtual   machine       System (Hardware)            virtual   machine
software                                          software[clarification needed]

            Common                  Language                    ATL (A MTL Virtual Machine)
       Infrastructure - C#, Visual Basic .NET,                   Bochs, portable open source x86
       J#, C++/CLI (formerly Managed C++)                 and AMD64 PCs emulator
            Dalvik virtual machine - part of                  CoLinux Open Source Linux
       the Android mobile phone platform                  inside Windows
            Dis - Inferno operating system                    Denali, uses paravirtualization
       and its Limbo programming language                 of x86 for running para-virtualized PC
            Dosbox                                       operating systems.
            EiffelStudio for the Eiffel                       FAUmachine
       programming language                                    Hercules        emulator,     free
            Erlang programming language                  System/370, ESA/390, z/Mainframe
            Forth virtual machine - Forth                     KVM
            Glulx - Glulx, Z-code                             LilyVM is a lightweight virtual
            Hec - Hasm Assembler                         machineAn introduction
            Java Virtual Machine - Java,                      Logical Domains
       Nice, NetREXX                                           Microsoft Virtual PC and
            Low Level Virtual Machine                    Microsoft Virtual Server
       (LLVM) - currently C, C++, Stacker                      OKL4 from Open Kernel Labs
            Lua                                               Oracle VM
            Macromedia Flash Player -                         OVPsim [1] is a freely available
       SWF                                                virtual platform simulator designed to
            MMIX - MMIXAL                                simulate     complex     multiprocessor
            Neko virtual machine - currently             systems at very high speeds
       Neko and haXe                                           Parallels Workstation, provides
            O-code machine - BCPL                        virtualization of x86 for running
            p-code machine - Pascal                      unmodified PC operating systems
            Parrot - Perl 6                                   Parallels Desktop for Mac,
            Perl virtual machine - Perl                  provides virtualization of x86 for
            CPython - Python                             running virtual machines on Mac OS X
            YARV - Ruby MRI                              or higher
            Rubinius - Ruby                                   QEMU, is a simulator based on
            ScummVM - Scumm                              a virtual machine.
            SECD machine - ISWIM,                             SheepShaver.
       Lispkit Lisp                                            Simics
            Sed the stream-editor can also                    Sun xVM
       be seen as a VM with 2 storage spaces.                  SVISTA
            Smalltalk virtual machine -                       Trango Virtual Processors
       Smalltalk                                               twoOStwo
            SQLite virtual machine - SQLite                   User-mode Linux

                                   Dept. of Computer Engineering, ICOER, Pune.                 9
Virtual Machine

      opcodes                                           VirtualBox
           Squeak      virtual machine -               Virtual Iron (Virtual Iron 3.1)
      Squeak                                            VM from IBM
           SWEET16                                     VMware (ESX Server, Fusion,
           Tamarin (JavaScript engine) -        Virtual Server, Workstation, Player and
      ActionScript VM in Flash 9                 ACE)
           TrueType virtual machine -                vSMP         Foundation       (From
      TrueType                                   ScaleMP)
           Valgrind - checking of memory             Xen
      accesses and leaks in x86/x86-64 code           IBM POWER SYSTEMS
      under Linux
           Virtual Processor (VP) from       OS-level virtualization software
      Tao Group (UK).
           VX32       virtual machine -                OpenVZ
      application-level virtualization for              FreeVPS
      native code                                       Linux-VServer
           Waba - Virtual machine for                  FreeBSD Jails
      small devices, similar to Java                    Solaris Containers
           Warren Abstract Machine -                   AIX Workload Partitions
      Prolog, CSC GraphTalk
           Z-machine - Z-Code
           Zend Engine - PHP

                              Dept. of Computer Engineering, ICOER, Pune.          10
Virtual Machine

   VMware Architecture

    All the vm app work in complete isolation from each other. The app is given the impression
that it is working on the same platform as a normal process the user does not come out to know
any diff exits in the platform or the execution.

                                 Dept. of Computer Engineering, ICOER, Pune.           11
Virtual Machine

   VMware Workstation
    VMware Workstation is a virtual machine software suite for x86 and x86-64 computers
from VMware, a division of EMC Corporation. This software suite allows users to set up
multiple x86 and x86-64 virtual computers and to use one or more of these virtual machines
simultaneously with the hosting operating system. Each virtual machine instance can execute
its own guest operating system, such as Windows, Linux, BSD variants, or others. In simple
terms, VMware Workstation allows one physical machine to run multiple operating systems
simultaneously. Other VMware products help manage or migrate VMware virtual machines
across multiple host machines.

   Besides bridging to existing host network adapters, CD-ROM devices, hard disk drives,
and USB devices, VMware Workstation also provides the ability to simulate some hardware.
For example, it can mount an ISO file as a CD-ROM, and .vmdk files as hard disks; and can
configure its network adapter driver to use network address translation (NAT) through the host
machine rather than bridging through it (which would require an IP address for each guest
machine on the host network).

    VMware Workstation also allows the testing of live CDs without first burning them onto
physical discs or rebooting the computer. One can also take multiple successive snapshots of
an operating system running under VMware Workstation. Each snapshot allows you to roll
back the virtual machine to the saved status at any time. The ability to use multiple snapshots
makes VMware Workstation useful as a tool for salespersons demonstrating complex software
products, and for developers setting up virtual development or test environments. VMware
Workstation includes the ability to designate multiple virtual machines as a team which
administrators can then power on and off, suspend, and resume as a single object — making it
particularly useful for testing client-server environments.

   Known issues

   Known limitations of VMware Workstation, as of June, 2008, include the following:

   Hardware support

              VMware virtual machines do not directly support FireWire.[10]
              VMware Workstation cannot use more than 2 CPUs (or cores) per virtual
       machine. This means that a single virtual machine cannot use the full power of the
       underlying hardware on machines with the total number of cores greater than 2 (Quad
       Core 2, or 2 x Core 2). This is true also for the last version 6.5.
            VMware virtual machines provide only experimental support for 3D hardware
       acceleration, via Microsoft's Direct3D 8 API.[11][12] A video has appeared on YouTube
       that demonstrates several 3D-accelerated games running under VMware Fusion and
       Mac OS X. The release notes for Fusion beta 2 include a list of 3D-accelerated
       computer games that can run within Windows XP-based virtual machines. In version
       6.5, Direct3D 9.0 API support (up to Shader Model 2.0) is provided on Windows XP
       guests and on any host OS.

                                 Dept. of Computer Engineering, ICOER, Pune.            12
Virtual Machine

              Five-button mouse is supported in version 6.5.[citation needed]
              Additionally, when using VMware Workstation in an environment using Media
       Access Control (MAC) addresses as unique identifiers (UID), one should (and often
       must) manually configure the MAC address for each virtual machine in order to ensure
       uniqueness (for example, in an environment in which network switches implement
       MAC security; or in an environment in which Altiris products use the MAC address as
       the UID). In such a situation, disabling all networks/adapters other than "bridged" and
       editing each virtual machine's .vmx file to change "ethernet0.address" to a unique MAC
       and "ethernet0.addresstype" to "static" will help.

   OS support

   64-bit Solaris 10 1/06 (Update 1) and Solaris 10 6/06 (Update 2) fail with a triple fault on
Core 2 generation processors (this includes processors codenamed Merom, Woodcrest, and
Conroe). A Sun Microsystems blog has published a workaround for this issue.

   Network protocols

    VMware Workstation can swallow CPU interrupts, making maintenance of accurate time
difficult.[13] Network Time Protocol (NTP) servers should not be run under VMware.

   Path traversal vulnerability

    In February 2008, discovered a vulnerability in the Shared Folders
function within several VMware products, including Workstation. A user logged onto a guest
VM running in VMware Workstation could gain read/write access to the host system by
specifying a pathname with the ".." substring.[14][15] However, the host is only vulnerable if the
shared folders are turned on and at least one host folder is set for sharing. This vulnerability
was fixed in VMware Workstation versions 5.5.6 and 6.0.3.

   VMware Tools

   VMware Tools is a package with drivers and other software that can be installed in guest
operating systems to increase their performance.

                                  Dept. of Computer Engineering, ICOER, Pune.              13
Virtual Machine

   Virtual appliance
    A virtual appliance is a minimalist virtual machine image designed to run under some sort
of virtualization technology (like VMware Workstation, Citrix XenServer, VirtualBox or many

   Virtual appliances are a subset of the broader class of software appliances. Like software
appliances, virtual appliances are aimed to eliminate the installation, configuration and
maintenance costs associated with running complex stacks of software.

   A key concept that differentiates a virtual appliance from a virtual machine is that a virtual
appliance is a fully pre-installed and pre-configured application and operating system
environment whereas a virtual machine is, by itself, without application software.

    Typically a virtual appliance will have a web interface to configure the inner workings of
the appliance. A virtual appliance is usually built to host a single application, and so represents
a new way of deploying network applications.

    As an example, the MediaWiki software that powers Wikipedia is available as a virtual
appliance.[1]. This appliance contains all the necessary software, including operating system,
database and MediaWiki, to run a wiki installation as a "black box".

                                   Dept. of Computer Engineering, ICOER, Pune.              14
Virtual Machine

    Although hardware-level virtualization went from being widely used during the 1970s to
near extinction in the 1980s, it has come back in a strong way. The success of VMware’s
products in the commercial marketplace, together with recent hardware support for
virtualization such as Intel’s Vanderpool technology and extensions to IBM’s Power
architecture, indicate that it is a technology just now beginning to be fully realized and that it is
here to stay.

    Computing trends indicate that the data center of the future will likely include a hardware-
level virtualization layer and a control system. Services will run in virtual machines and will be
mapped onto available hardware resources. Not only will this greatly ease the management of
data centers, it will also ease the handling of new hardware, as well as failed hardware. The
failure of a single physical box will reduce the pool of available resources, not the availability
of a particular service.

    Similarly, virtual machine technology will be used to allow aggressive innovation in the
area of system software, providing the ability to maintain backward compatibility. Virtual
machines will allow for the support of old applications, as well as the current versions, and will
test the deployment of new versions that are all based on the same hardware.

    One consequence of Moore’s law of semiconductor growth has been the exponential
increase in the performance of computing systems. The overhead of a well-tuned hardware
virtualization system is extremely small compared with the performance increase. This means
that the computing industry can, for only a few percentage points of performance, realize the
huge benefits of hardware-level virtualization. Such benefits include the management of both
the hardware and the software that runs in virtual machines—currently a large expense in
modern computing environments.

                                   Dept. of Computer Engineering, ICOER, Pune.                15
Virtual Machine


    In conclusion I would like to say that Virtual Machine is the prefect tool for the 21st century
to advance and become more powerful then it was ever before. A virtual-machine system is a
perfect vehicle for operating-systems research and development. By making the applications
platform independent and having multiple Os in a single machine have made the engineers to
use the full of its resources and manage it efficiently and give faster and better performance.

                                  Dept. of Computer Engineering, ICOER, Pune.               16
Virtual Machine




                         Dept. of Computer Engineering, ICOER, Pune.   17

To top