5 Virtualization Structure Tools and Mechanisms
5 Virtualization Structure Tools and Mechanisms
Virtualization
Outline
• Virtualization
• Virtualization Structure Tools and Mechanisms
• Virtualization of CPU, Memory and IO
• Importance of Virtualization in Cloud
• Disadvantages of Virtualization
Virtualization
• Virtualization -- the abstraction of computer resources.
• Virtualization hides the physical characteristics of computing
resources from their users, applications, or end users.
• This includes making a single physical resource (such as a server, an
operating system, an application, or storage device) appear to
function as multiple virtual resources;
resources it can also include making
multiple physical resources (such as storage devices or servers) appear
as a single virtual resource.
resource
• In computing, a process of creating a illusion of something like
computer hardware, operating system (OS), storage device, or
computer network resources is Virtualization.
Virtualization Layers
Privilege Rings
Virtual Machines and Virtualization Middleware
Types of Virtualization
• We mainly focus on Platform virtualization which is mostly related to
cloud-computing [1]
Guest
Code
Translator
CPU
TC Translation Callouts Emulation
Index Cache Routines
Direct Execution
• This is a mode that can be combined with binary
translation.
• With direct execution,
execution most code is executed directly on
the CPU, and only the code that needs to be translated is
actually translated
Virtualization Techniques
Full Virtualization / Host-based
Virtualization
• Full Virtualization provides complete simulation of the
underlying hardware.
hardware
• Simulate all computing elements such as instruction set, set main
memory,
memory interrupts,
interrupts exceptions,
exceptions and device access.
access
• The result is a system in which all software (including all OS’s)
capable of execution on the raw hardware can be run in the virtual
machine
• The combination of binary translation and direct execution provides
Full Virtualization as the guest OS is fully abstracted (completely
decoupled) from the underlying hardware by the virtualization layer.
• The guest OS is not aware it is being virtualized and requires no
modification.
Full Virtualization
• The hypervisor translates all operating system instructions on the fly
and caches the results for future use, while user level instructions run
unmodified at native speed.
• Full Virtualization is done at run time.
• Examples
– VMware
– Microsoft Virtual Server
• Full virtualization has proven highly successful
– Sharing a computer system among multiple users
– Isolating users from each other (and from the control program)
and
– Emulating new hardware to achieve improved reliability, security
and productivity.
productivity.
Full Virtualization with
Binary translation
• CPU Virtualization
• Memory Virtualization
• IO Virtualization
CPU Virtualization
• A VM is a duplicate of an existing computer system
• Majority of the VM instructions are executed on the host
processor in native mode.
• Unprivileged instructions of VMs run directly on the host
machine for higher efficiency.
• Other critical instructions should be handled carefully for
correctness and stability.
• Critical Instructions are divided as privileged instructions,
control-sensitive instructions, and behavior-
control- behavior-sensitive
instructions.
CPU Virtualization
Critical Instructions:
• Privileged instructions execute in a privileged mode
mod and will
be trapped if executed outside this mode.
mode
• Control-
Control-sensitive instructions attempt to change the
configuration of resources used.
• Behavior-
Behavior-sensitive instructions have different behaviors
depending on the configuration of resources,
resources including the
load and store operations over the virtual memory.
CPU Virtualization
• VM’s privileged and unprivileged instructions run in the CPU’s user mode
while the VMM runs in supervisor mode.
mod
• When the privileged instructions including control- and behavior-sensitive
instructions of a VM are executed, they are trapped in the VMM.
VMM
• Not all CPU architectures are virtualizable. RISC CPU architectures can be
naturally virtualized because all control and behavior-sensitive instructions
are considered privileged instructions.
instructions
• On the contrary,, x86 CPU architectures are not primarily designed to
support virtualization.
instructions such as SGDT and SMSW,
• This is because about 10 sensitive instructions,
are not privileged instructions. They modify the global memory segments.
• When these instructions execute in virtualization, they cannot be trapped in
the VMM.
• Binary Translation need to be implemented. (Full Virtualization)
CPU Virtualization
Solution:
Solution: Hardware-
Hardware-Assisted CPU Virtualization
• Intel and AMD add an additional mode called privilege mode level
(some people call it Ring-1) to x86 processors.
processors
• Therefore, operating systems can still run at Ring 0 and the hypervisor
hyperviso
can run at Ring -1.
• All the privileged and sensitive instructions are trapped in the hypervisor
automatically.
• This technique removes the difficulty of implementing binary
translation of full virtualization.
virtualization.
• It also lets the operating system run in VMs without modification.
modification
CPU Virtualization
Solution:
Solution: Hardware-
Hardware-Assisted CPU Virtualization
Memory Virtualization
• To run multiple virtual machines on a
single system,
system another level of memory
virtualization is required.
VM1 VM2
Source: VMware white paper, “Understanding Full Virtualization, Paravirtualization, and Hardware Assist”
Device and I/O Virtualization
Device and I/O Virtualization
Para-
Para- Virtualized I/O:
I/O Full Device emulation:
emulation Direct I/O:
I/O
Frontend driver manages I/O from Replication of all devices VM access device
Guest OS. Backend driver manages real is done in a software. directly. It is challenging
I/O devices S/w is located in VMM task
Conclusions on CPU, Memory
and I/O Virtualization
• CPU virtualization demands hardware-
hardware-assisted traps of sensitive
instructions by the VMM
Hardware
OS-Level Virtualization
OS--level virtualization
• OS
• From the user’s point of view,
VEs look like real servers.
servers OS-Level Virtualization
• This means a VE has its own set
of processes, file system, user OS OS OS
Container 1 Container 2 Container 3
accounts, network interfaces with
IP addresses, routing tables, OS virtualization
layer
firewall rules, and other personal
settings. Standard
Host OS
• Although VEs can be customized
customiz
for different people,
people they share the Hardware
same operating system kernel.
kernel
• Therefore, OS-level virtualization
is also called single-
single-OS image
virtualization..
OS-Level Virtualization
OS-
OS-level virtualization
• The biggest limitation of this
approach is that all the guest OS-Level Virtualization
servers must run the same OS.
OS
OS OS OS
• Each virtual server remains Container 1 Container 2 Container 3
Source: VMware white paper, “Understanding Full Virtualization, Paravirtualization, and Hardware Assist”
Importance of Virtualization in Cloud
• Cloud can exist without Virtualization,
Virtualization although it will be difficult
and inefficient.
• Cloud makes notion of ”Pay Pay for what you use”
use and ”infinite
infinite
availability-
availability- use as much as you want”.
want
• These notions are practical only if we have
– lot of flexibility.
flexibility.
– efficiency in the back-
back-end.
end
• This efficiency is readily available in Virtualized Environments and
Machines.
• Virtualization is not necessary to create a cloud environment,
environment but it
enables rapid scaling of resources in a way that non-virtualized
environments find hard to achieve.
Disadvantages of Virtualization
• Specific hardware requirements
• Upfront cost
• Some programs don’t take Virtualization
• VMs need lot of power
• You still need those old desktops
• You will need fast network
• Computing is virtual, peripherals are real.
real.
• Some hardware architectures or features are impossible to virtualize such as:
– Certain registers or state not exposed
– Clocks, time, and real-time behavior
• Virtualization may not work well for :
– Resource-
Resource-intensive applications
–VMs may have RAM/CPU limitations
– Performance testing
– Hardware compatibility testing
Multi-Core Virtualization:
VCPU vs. traditional CPU
Figure 3.16 Four VCPUs are exposed to the software, only three cores are actually
present. VCPUs V0, V1, and V3 have been transparently migrated, while VCPU V2
has been transparently suspended. (Courtesy of Wells, et al., “Dynamic Heterogeneity
and the Need for Multicore Virtualization”, ACM SIGOPS Operating Systems
Review, ACM Press, 2009 [68] )
Copyright © 2012, Elsevier Inc. All rights reserved. 1 - 60
Virtual Cores vs. Physical Processor Cores
Physical cores Virtual cores
The actual physical cores present in There can be more virtual cores
the processor. visible to a single OS than there are
physical cores.
More burden on the software to Design of software becomes easier
write applications which can run as the hardware assists the software
directly on the cores. in dynamic resource utilization.
Hardware provides no assistance to Hardware provides assistance to
the software and is hence simpler. the software and is hence more
complex.
Poor resource management. Better resource management.
The lowest level of system software The lowest level of system
has to be modified. Copyright © 2012, Elsevier Inc. Allsoftware
rights reserved.need not be modified. 1 - 61
CMP Server consolidation by Space-sharing of
VMs
(Courtesy of Marty and Hill, 2007)
Virtual Clusters in Many Cores
Space Sharing of VMs -- Virtual Hierarchy
Kingsoft Office