Virtual Machinesالآلات الافتراضية

الشريحة 1 من 14

مقدمة الفصل

ماذا ستتعلم في هذا الفصل

  1. The history and benefits of virtual machines.
  2. The various virtual machine technologies: Type 0, Type 1 and Type 2 hypervisors, paravirtualization, programming-environment virtualization, emulation and application containment.
  3. The methods used to implement virtualization: trap-and-emulate, binary translation, hardware assistance.
  4. Live migration as an OS component built on VMM features.
تفاصيل المصدرشرائح الفصل 7 · الشرائح ⁦2–3⁩
المصدر
شرائح الفصل 7 · الشرائح ⁦2–3⁩
ملاحظات حول المصدر (1)
  • ترقيم الفصل غير متسق في المصدر (الملف: الفصل 7، صفحة العنوان: Chapter 06، الشريحة 2: Chapter 16).

Virtual machines: overviewنظرة عامة

Overview: host, VMM, guest

Fundamental idea
Abstract hardware of a single computer into several different execution environments — like the layered approach, but the layer creates a virtual system (virtual machine, VM) on which operating systems or applications can run.
Hostالمضيف
The underlying hardware system.
VMM or hypervisorمدير الآلات الافتراضية
Creates and runs virtual machines by providing an interface that is identical to the host (except in the case of paravirtualization).
Guestالضيف
A process provided with a virtual copy of the host — usually an operating system.
  • A single physical machine can run multiple operating systems concurrently, each in its own virtual machine.

Which component creates and runs virtual machines by providing an interface identical to the host?

تفاصيل المصدرشرائح الفصل 7 · الشرائح ⁦4–5⁩
المصدر
شرائح الفصل 7 · الشرائح ⁦4–5⁩

Implementations of VMMsأنواع المديرين

Implementation of VMMs (slides 6–7)
TypeالنوعWhat it is (slides 6–7)ما هوExamplesأمثلة
Type 0 hypervisor
  • Hardware-based
  • VM creation and management via firmware
IBM LPARs, Oracle LDOMs
Type 1 hypervisorOperating-system-like software built to provide virtualizationVMware ESX, Joyent SmartOS, Citrix XenServer
Type 1 (general-purpose OS)General-purpose OSs that provide standard functions as well as VMM functionsWindows Server with HyperV, RedHat Linux with KVM
Type 2 hypervisorApplications on standard OSs that provide VMM features to guest OSsVMware Workstation and Fusion, Parallels Desktop, Oracle VirtualBox
ParavirtualizationGuest OS modified to cooperate with the VMM to optimize performanceلا تذكر الشرائح شيئًا هنا.
Programming-environment virtualization
  • Does not virtualize real hardware
  • creates an optimized virtual system
Oracle Java, Microsoft .Net
EmulatorsRun applications written for one hardware environment on a very different one (e.g., a different CPU)لا تذكر الشرائح شيئًا هنا.
Application containment
  • Not virtualization at all
  • segregates applications from the OS
Oracle Solaris Zones, BSD Jails, IBM AIX WPARs

VMware ESX and Citrix XenServer are examples of which kind of VMM?

تفاصيل المصدرشرائح الفصل 7 · الشرائح ⁦6–7⁩
المصدر
شرائح الفصل 7 · الشرائح ⁦6–7⁩
ملاحظات حول المصدر (1)
  • الشريحة 6 تذكر «Type 1 hypervisors» مرتين: المرة الثانية للأنظمة العامة التي تقدم وظائف المدير أيضًا.

Historyالتاريخ

  • First appeared in IBM mainframes in 1972; allowed multiple users to share a batch-oriented system.

التعريف الرسمي في ثلاث نقاط.

  1. 1Essentially identical environment
  2. 2Minor performance decreases
  3. 3Complete control
  • Late 1990s: Intel CPUs fast enough to virtualize general-purpose PCs; Xen and VMware created technologies still used today.

Which is part of the formal definition of virtualization?

تفاصيل المصدرشرائح الفصل 7 · الشريحة ⁦8⁩
المصدر
شرائح الفصل 7 · الشريحة ⁦8⁩

Benefits and featuresالمزايا

  • Protection: host protected from VMs, VMs protected from each other (a virus less likely to spread); sharing via a shared file system volume or network communication.
  • Freeze, suspend, running VM → move or copy somewhere else and resume; snapshot a state and restore it (some VMMs allow multiple snapshots); clone by copying and running both.
  • Great for OS research, better system development efficiency; run multiple, different OSes on a single machine; consolidation, app dev.
Templatingالقوالب
Create an OS + application VM, provide it to customers, and use it to create multiple instances of that combination.
Live migrationالترحيل الحي
Move a running VM from one host to another — no interruption of user access.
Cloud computingالحوسبة السحابية
All those features together: using APIs, programs tell cloud infrastructure (servers, networking, storage) to create new guests, VMs, virtual desktops.

An administrator saves the state of a VM before an update so it can be restored if the update fails. Which feature is this?

تفاصيل المصدرشرائح الفصل 7 · الشرائح ⁦9–10⁩
المصدر
شرائح الفصل 7 · الشرائح ⁦9–10⁩

VCPU and trap-and-emulateالحجز والمحاكاة

Virtual CPU (VCPU)
Implemented by most VMMs to represent the state of the CPU per guest as the guest believes it to be; loaded and stored when the guest is context switched onto the CPU.
  • The guest executes in user mode; the VM needs virtual user mode and virtual kernel mode, both running in real user mode.

Trap-and-emulate (slide 13)

  1. 1

    The guest attempts a privileged instruction in user mode → an error → trap.

  2. 2

    The VMM gains control and analyzes the error.

  3. 3

    The VMM executes the operation as attempted by the guest.

  4. 4

    The VMM returns control to the guest in user mode.

  • User-mode guest code runs at the same speed as if not a guest; kernel-mode guest code runs slower — especially with multiple guests.

In trap-and-emulate, what does the VMM do after the trap caused by a guest's privileged instruction?

تفاصيل المصدرشرائح الفصل 7 · الشرائح ⁦11–14⁩
المصدر
شرائح الفصل 7 · الشرائح ⁦11–14⁩

Binary translationالترجمة الثنائية

  • Some CPUs (earlier Intel x86) have no clean separation between privileged and nonprivileged instructions: x86 popf replaces all flags in privileged mode but only some in user mode — no trap is generated, so trap-and-emulate fails for such special instructions.

Binary translation (slide 16)

  1. 1

    If the guest VCPU is in user mode, the guest runs instructions natively.

  2. 2

    If the guest VCPU is in kernel mode, the VMM examines every instruction the guest is about to execute, reading a few instructions ahead of the program counter.

  3. 3

    Non-special instructions run natively.

  4. 4

    Special instructions are translated into a new set of instructions that perform an equivalent task (e.g., changing the flags in the VCPU).

  • VMware uses caching — translate once and reuse the cached translation (slide 17).
  • Booting Windows XP as a guest: 950,000 translations × 3 µs = 3 seconds (5%) slowdown over native.

With binary translation, what happens when the guest VCPU is in kernel mode?

تفاصيل المصدرشرائح الفصل 7 · الشرائح ⁦15–18⁩
المصدر
شرائح الفصل 7 · الشرائح ⁦15–18⁩

Hardware assistanceدعم العتاد

  • All virtualization needs some HW support; more support → more feature rich, stable, better guest performance.
  • Intel VT-x (2005) and AMD AMD-V (2006): CPUs with these instructions remove the need for binary translation.
  • They define more CPU modes — "guest" and "host"; in guest mode the guest OS thinks it is running natively.
  • Access to a virtualized device or privileged instructions cause a trap to the VMM; the CPU maintains the VCPU and context switches it as needed.
  • HW support also for nested page tables, DMA and interrupts over time.
تفاصيل المصدرشرائح الفصل 7 · الشريحة ⁦19⁩
المصدر
شرائح الفصل 7 · الشريحة ⁦19⁩

VM lifecycle and Type 0دورة الحياة والنوع 0

VM lifecycle and hypervisor types 0, 1, 2

A VM's lifecycle (slide 20)

  1. 1

    Created by the VMM.

  2. 2

    Resources assigned (number of cores, amount of memory, networking details, storage details) — dedicated in Type 0; dedicated, shared or mixed in other types.

  3. 3

    When no longer needed, the VM can be deleted, freeing resources.

  • Simpler and faster than a physical machine install — but can lead to virtual machine sprawl (history and state difficult to track).

Type 0 hypervisor (slide 21)

  • Old idea under names like "partitions", "domains"; a HW feature implemented by firmware (the VMM is in firmware).
  • Smaller feature set; each guest has dedicated HW; I/O a challenge (a control partition may provide shared I/O).
  • Can provide virtualization-within-virtualization.

Creating VMs is simpler and faster than installing physical machines. What problem can this lead to?

تفاصيل المصدرشرائح الفصل 7 · الشرائح ⁦20–22⁩
المصدر
شرائح الفصل 7 · الشرائح ⁦20–22⁩

Type 1 and Type 2 hypervisorsالنوعان 1 و2

VM lifecycle and hypervisor types 0, 1, 2

Type 1النوع 1

  • Commonly found in company datacenters — "datacenter operating systems"
  • Special-purpose OSs that run natively on HW, creating, running and managing guest OSes
  • Run in kernel mode; guests generally don't know they are in a VM
  • Implement device drivers for host HW; CPU and memory management
  • Variation: a general-purpose OS with VMM functionality (KVM, Hyper-V) — typically less feature rich

Type 2النوع 2

  • Very little OS involvement in virtualization
  • The VMM is simply another process, run and managed by the host
  • Tends to have poorer overall performance (can't use some HW features)
  • Benefit: requires no changes to the host OS

Which hypervisor type requires no changes to the host OS but tends to have poorer overall performance?

تفاصيل المصدرشرائح الفصل 7 · الشرائح ⁦23–25⁩
المصدر
شرائح الفصل 7 · الشرائح ⁦23–25⁩

Paravirtualization and programming environmentsالافتراضية الجزئية

Paravirtualization, programming environments, emulation, containment

Paravirtualization
Does not fit the definition of virtualization — the VMM does not present an exact duplication of the hardware — but the VMM provides services that the guest must be modified to use, leading to increased performance; less needed as HW support grows.

Xen (slides 26–27)

  • Clean and simple device abstractions; efficient I/O; each device has a circular buffer shared by guest and VMM via shared memory.
  • No nested page tables: each guest has its own read-only tables and uses a hypercall (call to hypervisor) when page-table changes are needed.
  • Allowed virtualization of older x86 CPUs without binary translation; on modern CPUs Xen no longer requires guest modification → no longer paravirtualization.
Programming-environment virtualization
Not really virtualization: a language runs within a custom-built virtualized environment — e.g., Java programs run in the JVM no matter the underlying system; virtualization here means providing APIs for the language; similar to interpreted languages.

Why does paravirtualization not fit the definition of virtualization?

تفاصيل المصدرشرائح الفصل 7 · الشرائح ⁦26–28⁩
المصدر
شرائح الفصل 7 · الشرائح ⁦26–28⁩

Emulation and application containmentالمحاكاة والاحتواء

Paravirtualization, programming environments, emulation, containment

Virtualizationالافتراضية

  • Requires the underlying CPU to be the same as the guest was compiled for

Emulationالمحاكاة

  • Allows the guest to run on a different CPU
  • Translates all guest instructions from the guest CPU to the native CPU
  • An order of magnitude slower than native code
  • Popular in gaming (old consoles emulated on new)
Application containment
Segregation of apps, resource management, easy start/stop/move without full-fledged virtualization: e.g., Oracle zones create a virtual layer between the OS and apps; only one kernel running — the host OS; each zone has its own applications, networking stack, addresses, ports and user accounts; CPU and memory are divided between zones.

A company replaces old servers with new ones that have a different CPU architecture but must keep running old applications. Which technique fits?

تفاصيل المصدرشرائح الفصل 7 · الشرائح ⁦29–31⁩
المصدر
شرائح الفصل 7 · الشرائح ⁦29–31⁩

Live migrationالترحيل الحي

Live migration
A running guest can be moved between systems without interrupting user access to the guest or its apps — useful for resource management, maintenance downtime windows, etc.

Steps (slides 32–33)

  1. 1

    The source VMM establishes a connection with the target VMM.

  2. 2

    The target creates a new guest (a new VCPU, etc.).

  3. 3

    The source sends all read-only guest memory pages.

  4. 4

    The source sends all read-write pages, marking them as clean.

  5. 5

    The source repeats step 4, because some pages were modified meanwhile and are now dirty.

  6. 6

    When the 4–5 cycle becomes very short, the source freezes the guest, sends the VCPU's final state, other state details and the final dirty pages, and tells the target to start running the guest.

  7. 7

    Once the target acknowledges the guest is running, the source terminates the guest.

In live migration, when does the source VMM freeze the guest?

تفاصيل المصدرشرائح الفصل 7 · الشرائح ⁦32–33⁩
المصدر
شرائح الفصل 7 · الشرائح ⁦32–33⁩

الخلاصة

تفاصيل المصدر
المصدر
شرائح الفصل 7

خريطة الفصل

    1. 1مقدمة الفصل
  1. Overview: host, VMM, guestنظرة عامة: المضيف والمدير والضيف

    1. 2Virtual machines: overviewنظرة عامة
    1. 3Implementations of VMMsأنواع المديرين
  2. History of virtualizationتاريخ الافتراضية

    1. 4Historyالتاريخ
    1. 5Benefits and featuresالمزايا
  3. Building blocks: VCPU and trap-and-emulateاللبنات: المعالج الافتراضي والحجز والمحاكاة

    1. 6VCPU and trap-and-emulateالحجز والمحاكاة
  4. Binary translation and hardware assistanceالترجمة الثنائية ودعم العتاد

    1. 7Binary translationالترجمة الثنائية
    2. 8Hardware assistanceدعم العتاد
  5. VM lifecycle and hypervisor types 0, 1, 2دورة حياة الآلة الافتراضية والأنواع 0 و1 و2

    1. 9VM lifecycle and Type 0دورة الحياة والنوع 0
    2. 10Type 1 and Type 2 hypervisorsالنوعان 1 و2
  6. Paravirtualization, programming environments, emulation, containmentالافتراضية الجزئية وبيئات البرمجة والمحاكاة والاحتواء

    1. 11Paravirtualization and programming environmentsالافتراضية الجزئية
    2. 12Emulation and application containmentالمحاكاة والاحتواء
    1. 13Live migrationالترحيل الحي
    1. 14الخلاصة