smartos-docs

SmartOS Virtualization

Virtualization: How SmartOS Does it Differently

A Non-Virtualized Computer

A non-virtualized computer

This is a diagram of a basic computer, such as your laptop.

The bottom layer shows the system’s hardware resources: CPU, memory, storage, NIC.

The operating system runs directly on the hardware, and has two components:

Note that, although this diagram shows all the applications as the same “size”, some applications need more resources than others, and an application’s resource needs may vary depending on the work it is performing.

The operating system manages (schedules) competing demands for system resources.

Virtualization in the Client-Server Context

Datacenters used to commonly run one application per server, for the following reasons:

The one-app-per-server model worked well in the 1980s and 1990s, when a single application placed heavy demand on a server’s resources.

However, Moore’s Law meant that more powerful servers were soon being severely under-utilized: utilization of only 8-15% was common.

Obviously, this was a very inefficient use of equipment, facilities, power and IT management resources. Virtualization came to the fore as a solution.

Hosted Virtualization

Hosted Virtualization

In hosted virtualization, a hypervisor running on top of a standard operating system emulates real hardware to create and manage one or many virtual machines.

It is called “hosted virtualization”, because the hypervisor sits on a Host OS, and above this are the Guest OSes.

It is also known as “application-level virtualization”, because the hypervisor runs as an application on a Host OS.

Hosted virtualization was used to consolidate servers, making it possible to put multiple servers on a single physical machine, while maintaining isolation.

Any “guest” operating system running this virtual machine believes itself to be running on its own separate, real computer, but it actually only has access to a limited set of hardware resources (as defined by the administrator).

An operating system is also known as a “supervisor”. Thus we use the term “hypervisor” for a supervisor of supervisors.

The hypervisor modifies the operating system at runtime through a process known as “binary translation”. Operating system calls to hardware are intercepted (“trapped”) and redirected.

Hosted virtualization introduced other infrastructure management benefits:

This approach increased utilization, but still had huge inefficiencies:

Bare-Metal Hardware Virtualization

Bare-metal hardware virtualization

Bare-metal virtualization addresses some of these inefficiencies by consolidating the hypervisor and the Host OS. The Host OS is stripped down to a Virtual Machine Monitor - only what it needs to run a hypervisor. It is optimized for that purpose, and the hypervisor embedded in it. (The userland is stripped down to only the virtualization vendor’s tools.)

Drawbacks:

Paravirtualization

Paravirtualization

Paravirtualization is similar to bare-metal virtualization, but it removes the virtual machine hardware emulation.

The hypervisor directly coordinates a “privileged guest” operating system which has access to the underlying hardware. The hypervisor manages the OSes like OSes manage apps: allowing one OS to access underlying hardware resources, while preventing any other OS from accessing the same resources at the same time.

However, to accomplish this, the OS must be modified to be “aware” that it is basically running on an “OS for OSes”. In the case of hardware virtualization, the OS is fooled (at runtime, by binary translation) into believing it is running directly on hardware, as it was designed to do.

The privileged guest coordinates access to hardware resources (drivers):

Advantages:

Disadvantages:

In addition, with the release in 2006 of virtualization-enabled CPUs (Intel VT and AMD-V), paravirtualization has lost some of its edge over the other forms of virtualization:

Operating System Virtualization

Operating System Virtualization

The most efficient method is to tackle virtualization at the operating system level.

Benefits:

Drawbacks:

Joyent SmartMachines are Based on Solaris Zones

Which gives us:

Zones virtualization was added to Solaris 10 in 2005.

HVM and OS Virtual Machines

HVM and OS Virtualization

OS virtualization is great for applications that can run natively in SmartOS, but many of us have legacy apps that must run in Windows or Linux, eg for Windows, Active Directory, Windows video encoding.
What can we do for them?
Joyent uses hosted virtualization for its virtual machine solution.

Remember that when you lose the Host OS, you lose any valuable capabilities it provided. In the case of Vmware, this came down to device drivers. Since they could embed these in the hypervisor, bare-metal HW virtualization made more sense.

SmartOS provides two types of hardware virtualization: KVM and Bhyve. Each provides hardware emulation and is a VMM (virtual machine monitor). Notice that it is not a strict hypervisor layer. Each HVM is independent – there is one per Guest OS instead of one supporting several VMs. This is because it has combined both the VM and the VMM.