Introduction to Operating Systems: Unit V: Virtual Machines and Mobile OS

Virtualization Operating-System Components

Virtual Machines and Mobile OS - Introduction to Operating Systems

Operating system aspects of virtualization are management, I/O storage and unique VM migration feature.

Virtualization and Operating-System Components

Operating system aspects of virtualization are management, I/O storage and unique VM migration feature.

Following features are implemented by using virtualization:

a) How do VMMS schedule CPU use when guests believe they have dedicated CPUs?

b) How can memory management work when many guests require large amounts of memory?

CPU Scheduling

• After virtualization, single CPU system act like multiprocessor. Here one or more. virtual CPUs per guest is created. Generally VMM has one or more physical CPUs and number of threads to run on them.

• The VMM has a number of physical CPUs available and a number of threads to oys run on those CPUs, then threads can be called as VMM threads or guest threads. Guests are configured with a certain number of virtual CPUs at creation time and that number can be adjusted throughout the life of the virtual machine.

• When enough CPUs for all guests, VMM can allocate dedicated CPUs, each guest much like native operating system managing its CPUs.

• Usually not enough CPUs are available, then VMM can use standard scheduling algorithms to put threads on CPUs and add fairness aspect while allocating. Cycle stealing by VMM and over subscription of CPUs means guests do not get CPU cycles they expect.

Some VMMS provide application to run in each guest to fix time-of-day and provide other integration features.

Memory Management

Each virtual machine consumes memory based on its configured size, plus additional overhead memory for virtualization. In virtualized environments, there are more users of memory, leading to more pressure on memory use.

• Sometime, the total memory allocated to guests exceeds the amount that physically exists in the system. The extra need for efficient memory use is not lost on the implementers of VMMS, who take extensive measures to ensure the optimal use of memory.

• Suppose, VMware ESX guests have a configured amount of physical memory, then ESX uses three memory management methods.

a) Double-paging, in which the guest page table indicates a page is in a physical frame but the VMM moves some of those pages to backing store.

b) Install a pseudo-device driver in each guest.

    • Balloon memory manager communicates with VMM and is told to allocate or de-allocate memory to decrease or increase physical memory use of guest, causing guest OS to free or have more memory available.

c) De-duplication by VMM determining if same page loaded more than once, memory mapping the same page into multiple guests.

Since hypervisor manages page sharing, the virtual machine operating systems are unaware of what is happening in the physical system.

• Virtual Memory Ballooning is a computer memory reclamation technique used by a hypervisor to allow the physical host system to retrieve unused memory from play certain guest Virtual Machines (VMs) and share it with others. U

• Memory ballooning allows the total amount of RAM required by guest VMs to exceed the amount of physical RAM available on the host. When the host system runs low on physical RAM resources, memory ballooning allocates it selectively to VMs.

• If a VM only uses a portion of the memory that it was allocated, the ballooning technique makes it available for the host to use.

• For example, if all the VMs on a host are allocated 8 GB of memory, some of the VMs will only use half the allotted share. Meanwhile, one VM might need 12 GB of memory for an intensive process.

Memory ballooning allows the host to borrow that unused memory and allocate it to the VMs with higher memory demand.

The guest operating system runs inside the VM, which is allocated a portion of aah memory. Therefore, the guest OS is unaware of the total memory available.

• Memory ballooning makes the guest operating system aware of the host's memory shortage.

Virtualization providers such as VMware enable memory ballooning. VMware memory ballooning, Microsoft Hyper-V dynamic memory, and the open source KVM balloon process are similar in concept.

The host uses balloon drivers running on the VMs to determine how much memory it can take back from an under-utilizing VM. Balloon drivers must be P M installed on any VM that participates in the memory ballooning technique.

• Balloon drivers get the target balloon size from the hypervisor and then inflate by allocating the proper number of guest physical pages within the VM. This process is known as inflating the balloon; the process of releasing the available pages is known as deflating the balloon.

Input-Output Management

• I/O management is easy for VMM because I/O has lot of variation. For example, leib OS device-driver mechanism provides a uniform interface to the OS whatever the I/O device. Device-driver interfaces are designed to allow third-party hardware manufacturers to provide device drivers connecting their devices to the operating system.

• Virtualization takes advantage of dynamically loaded and unloaded of device driver by providing specific virtualized devices to guest operating systems.

• But overall I/O is complicated for VMMS, because

a) Many short paths for I/O in standard OSes for improved performance.

b) Less hypervisor needs to do for I/O for guests, the better.

c) Possibilities include direct device access, DMA pass-through, direct interrupt delivery.

• Hardware support needed for all above cases.

• With virtualization, each guest needs at least one IP address for communication. 8 So server running a VMM may have dozens of addresses and the VMM acts as a virtual switch to route the network packets to the addressed guests.

• Networking also complex as VMM and guests all need network access. VMM can bridge guest to network allowing direct access and provide Network Address Translation (NAT).

NAT address local to machine on which guest is running, VMM provides address translation to guest to hide its address.

Storage Management

• Both boot disk and general data access need be provided by VMM. Virtualized environments need to approach storage management differently than do native operating systems.

• Solution is based on the type of hypervisor. In type 1 hypervisor, storage guest root disks and configuration information within file system provided by VMM as a disk image. Type 2 hypervisor store as files in file system provided by host OS.

• Guests sometimes need more disk space than is available in their root disk image. VMMs provide a mechanism to capture a physical system as it is currently configured and convert it to a guest that the VMM can manage and run.

a) Physical-to-virtual (P-to-V) convert native disk blocks into VMM format.

b) Virtual-to-physical (V-to-P) convert from virtual format to native or disk format.

• VMM also needs to provide access to network attached storage and other disk images, disk partitions, disks etc.

Live Migration

• Live migration provides the ability to move a running virtual machine between physical hosts with no interruption to service. The virtual machine remains powered on and user applications continue to run while the virtual machine is relocated to a new physical host. In the background, the virtual machine's RAM is copied from the source host to the destination host. Storage and network connectivity are not altered.

• Taking advantage of VMM features leads to new functionality not found on general operating systems such as live migration. Running guest can be moved between systems, without interrupting user access to the guest or its apps.

Fig. 7.5.1 shows live migration of guest between servers.

• Steps:

1. The source VMM establishes a connection with the target VMM.

2. The target creates a new guest by creating a new VCPU.

3. The source sends all read-only guest memory pages to the target.

4. The source sends all read-write pages to the target, marking them as clean.

5. The source repeats step 4, as during that step some pages were probably modified by the guest and are now dirty.

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

• Once target acknowledges that guest running, source terminates guest.

Introduction to Operating Systems: Unit V: Virtual Machines and Mobile OS : Tag: : Virtual Machines and Mobile OS - Introduction to Operating Systems - Virtualization Operating-System Components