Chapter 5 Virtual Ization
Chapter 5 Virtual Ization
Chapter 5 Virtualization
Introduction
• The previous chapter describes the basic infrastructure of a data center, including physical infrastructure, such
as power and cooling, as well as racks, pods, servers, networks, and storage facilities.
• This chapter begins the description of virtualization mechanisms and technologies that allow a cloud owner to
use the facilities to provide elastic computing focusing on the concept and support systems of a Virtual Machine.
• The next chapters describe an alternative virtualization technology used in data centers, virtual networks and
virtual storage facilities.
Approaches To Virtualization
• The concept of virtual machines existed long before cloud computing was invented.
• The technologies used to implement virtual machines can be divided into three broad categories:
o Software emulation
▪ Enables programs compiled for one machine to be run via software on another system
which increases the portability of compilers and other apps.
▪ Software emulation incurs significant execution overhead, making it ineligible as a form
of virtualization in a data center.
o Para-virtualization
▪ An early form of virtualization that allows multiple operating systems to run on a
computer at the same time by using special software known as a hypervisor to control the
operating systems.
▪ Unlike software emulation, para-virtualization allows software to run at high speed by
allowing the processor to execute instructions directly with no extra software involved.
We say that para-virtualization allows instructions to execute natively.
▪ Para-virtualization has the advantage of allowing high-speed execution and the
disadvantage of requiring code to be altered to replace privileged instructions before it
can be run.
o Full virtualization
▪ Allows multiple operating systems to run on a single computer at the same time and at
high speed without requiring operating system code to be altered.
Approaches To Virtualization
• The full virtualization technologies currently used to support Virtual Machines (VMs) in cloud data centers have
three key properties:
o Emulation of commercial instruction sets - A VM gives the appearance of being identical to a
conventional computer, including the complete instruction set. Code that has been compiled to run on a
commercial computer will run on a VM unchanged.
o Isolated facilities and operation - Each VM run an operating system at the same time, so from the point
of view of an operating system running on a VM, the operating system thinks it controls all of physical
memory, a set of I/O devices, and the processor, including all cores
o Efficient, low-overhead execution – When an application runs on a VM, most instructions execute as
fast as they do when the application executes directly on the underlying processor.
Conceptual Organization Of VM Systems
• The general idea behind VM is to load software onto a server that allows the cloud provider to create multiple
VMs. And allow the tenant who owns each VM to boot and use an operating system on the VM.
• The key piece of software responsible for creating and managing VMs is known as a hypervisor. Effectively,
the hypervisor can be viewed as controlling the underlying hardware.
• Figure 5.1 illustrates the conceptual organization of a server running hypervisor software, and a set of VMs that
each run an operating system and apps. The figure shows a type 1 hypervisor, commonly used in data centers
VM 1 VM 2 VM N
app 1 app 2 app 3 app 4 app 5 app 6 ... app 7 app 8 app 9
OS 1 OS 2 OS N
hypervisor software
server hardw
a are
• To prevent vulnerabilities, the processor hardware used in a conventional computer has two privilege levels or
modes of operation.
• Operating system code runs in kernel mode, which allows the operating system to perform all possible
instructions. When it switches the processor to application code, the operating system also changes to user
mode, which means only basic instructions are available.
• If the application makes a system call to request an operating system service (e.g., to read from a file), the
processor transitions back to kernel mode.
OS starts first
OS starts an app
app invokes an
OS service
Figure 5.2 Illustration of operating system and app code in memory. The processor executes each at
the same high speed, changing mode when transitioning from one to the other.
• If an application, which runs in user mode, attempts to make an instruction that requires privilege or attempts,
an illegal memory access, the processor raises an exception, which transfers back to a special point in the
operating system to allow the operating system to handle the problem.
• Only the hypervisor can create a VM and allocate memory to the VM. The operating system is restricted to the
memory that has been allocated to its VM. As with a conventional computer, the processor always runs code
directly from memory, allowing the code to be executed at hardware speed.
Figure 5.3 Illustration of transitions among code in memory when a hypervisor runs a VM with an
operating system and the operating system runs an app.
Levels of Trust
• We can think of the three processor modes as imposing three levels of trust:
o In hypervisor mode, the processor can perform any operation available on the hardware so the hypervisor
code is trusted completely.
o In kernel mode, the processor restricts the set of operations to ensure that the operating system cannot
affect other VMs or the hypervisor, so the operating system code does not need to be trusted as much as
hypervisor code.
o In user mode, the processor restricts the set of operations, making it impossible for an app to affect
other apps or the operating system so an app does not need to be trusted as much as an operating system.
• Each virtual machine runs its own operating system, and a virtual machine can boot a standard operating
system, but the hypervisor cannot allow one of the operating systems to gain exclusive control of I/O devices
because the devices must be usable by all virtual machines.
• When an operating system on a VM attempts to use the bus to access an I/O device, the access violates privilege,
which means the hypervisor is invoked. The hypervisor runs the appropriate virtual device software, and
then arranges to send the response to the operating system as if a physical device responded.
• From an operating system’s point of view, a virtual device is indistinguishable from a real device because
communication with a virtual device uses the same bus operations that communication with a physical device
uses.
o Invent a new, imaginary device - Allows a programmer to create a virtual device with clean design that
avoids the messy hardware details, making it much easier to write device driver software. It may also
be possible to increase efficiency (e.g., by creating an imaginary disk with large blocks).
o Emulate an existing hardware device - Involves creating an imaginary device consisting of software
that emulates an existing hardware device.
• Because the device driver software used with one operating system is incompatible with other operating systems,
creating a new, imaginary device requires that a separate driver be created for each operating system.
• Building virtual device software that emulates an existing hardware device avoids having to build new device
drivers — an operating system can load and run existing device driver software.
• The downside of building a virtual device that emulates an existing hardware device arises because the virtual
device must behave exactly like a real hardware device. It must accept all the same requests and respond to
each request exactly like the hardware device responds.
• The virtual disk code occupies a position between an operating system that runs in a VM and the network code
in the hypervisor.
VM
operating system
Figure 5.4 The conceptual organization of an operating system, virtual disk code, and network
code.
• Each time it receives a request, the virtual disk code uses the network to communicate with the storage facility
in the data center. The virtual disk specifies the VM that made a request, and either sends data to be stored on
the VM’s disk or requests a copy of data from the VM’s disk.
A VM As A Digital Object
• Because a VM is created and managed entirely by software, all the pieces of a VM can be collected
together into a digital object.
• A hypervisor must keep a record of each VM, the region(s) of memory that have been allocated to each
VM, the virtual I/O devices that have been created for each VM (including disk space that has been allocated in
the data center storage facility), and the current status of each VM (e.g., whether the VM is currently running or
has been suspended to allow another VM to run).
• The code, data, and apps that each VM is running are all stored in memory, so when the VM’s memory has
been collected, the OS and apps will be collected. This also includes the virtual devices that have been created
for the VM since they are software as well.
VM Migration
• Virtual migration involves a hypervisor stopping a VM that is running on one server, converting the VM to a
digital object, sending the bytes across the network to a new server, and then a receiving hypervisor resuming
the VM on the new server.
• The ability to migrate VMs allows a provider to rebalance loads dynamically to eliminate hot spots.
• To enable live migration, the amount of time a VM is unavailable must be minimized. The technique used
divides migration into three phases:
o Phase 1: pre-copy –The entire memory of the VM is copied to the new server while the VM continues to
run. Pages in memory that change during this phase are handled in the next phase.
o Phase 2: stop-and-copy - The VM is temporarily suspended, and any pages that changed after the phase 1
copy are copied again. The virtual memory system on modern servers makes it easy to detect which
pages have been changed (i.e., are dirty).
o Phase 3: post-copy - The old hypervisor sends t he remaining state information to the hypervisor on the
new server. The state information includes items that are needed to unsuspend the VM, including the
contents of registers when the VM was suspended. The hypervisor on the new server uses the
information to allow the VM to continue executing.
Running Virtual Machines In An Application
• An alternative form of VM technology has been developed that allows a hypervisor to run on a conventional
operating system whereby a user launches a hypervisor application called a hosted hypervisor. A hosted
hypervisor runs along with other applications. Once it starts, the hosted hypervisor allows a user to create and
manipulate VMs.
• When the user launches a hosted hypervisor, the hypervisor runs as an application process and runs in user space.
• Each VM must run an operating system, which is called a guest operating system. A guest operating system
does not need to be the same as a host operating system, and guest operating systems may differ from one another.
VM 1 VM 2
apps on VM 1 apps on VM 2
hosted hypervisor
computer hardware
Figure 5.5 The conceptual arrangement of software on a conventional computer that results when a
user runs a hypervisor application and creates two VMs.
Three questions that arise (and will be addressed in this chapter as well a future chapter) concerning a system that runs a
hosted hypervisor on a conventional computer that runs directly on server hardware.
• How is it possible?
• What benefit does it offer a user?
• Is the technology useful in a cloud data center?
• Modern processors include a special virtualization mechanism that enables a hosted hypervisor to create VMs
that each run a guest OS. The mechanism allows a guest OS to proceed as if it were running at the highest
privilege level, even though it does not have privilege and does not have complete access to the underlying
hardware.
• A hosted hypervisor arranges a mapping between I/O requests that a guest OS makes and services in the host
operating system.
• Because a hosted hypervisor can map I/O requests from a guest operating system onto services offered by the
host operating system, it is possible for applications running on VMs and applications running on the host to
share files.
How A User Benefits From A Hosted Hypervisor
• A hosted hypervisor allows a user to run multiple operating systems on a single computer.
• Multiboot mechanisms also allow a user to boot multiple operating systems, but a user can only boot one system
at a given time.
• Alternately, a hosted hypervisor allows a user to run multiple operating systems simultaneously and switch
among them quickly without having to reboot the computer.
Summary
• Cloud data centers make extensive use of Virtual Machine (VM) technology.
• Software known as a hypervisor allows a user to create and manage VMs. Conceptually, the hypervisor owns
the underlying hardware, VMs run over the hypervisor, and each VM runs an operating system plus apps.
• A hypervisor provides each operating system with the illusion that it has direct access to peripheral devices over
a conventional I/O bus.
• All pieces of a VM can be collected into a digital object, which can be sent over a network, allowing hypervisors
to migrate a VM from one physical server to another.
• An alternative form of VM technology allows a user to run a hosted hypervisor on a conventional computer
giving he user he ability to switch among operating systems without rebooting the computer.