CS695 Topics in Virtualization and Cloud Computing Spring 2019 Lecture 3 11.1.2019 -------------------- 0. Exercise #1 due 15th January 2019 https://www.cse.iitb.ac.in/~puru/ https://www.cse.iitb.ac.in/~puru/courses/spring19/cs695/exercises/ex1.html references: [ossupport] [vmarch] [vmware] [xen] [kvm] 1. Recap - the world of abstractions - process view and the system view - three main building blocks of the OS (i) privileged modes of execution required by OS to establish sole/exclusive ownership of resources and OS state (ii) interrupts and interrup-driven operations for IO and as events for OS actions (iii) the system call interface for applications to invoke OS functionality explicitly - IaaS with virtual machines, virtualize the system-view abstraction - "virtualize" the system-view (for an OS) - system view: CPU, memory, disks, devices, ISA etc. - OS gets a isolated view of a (virtual) machine - why interesting? - multiplex machines! - can run custom OSes, improved runtime isolation, OS development and debugging - nested virtualization - new granularity of hosting for IaaS - on-demand, secure, pay-on-use, flexible (software control!) - snapshotting, migration, record-replay - VM image introspection based applications---security, s/w updates etc. - the hypervisor/virtual machine monitor is the machine virtualizer! - a "guest" operating system runs inside a virtual machine. 2. Classification (i) Bare-metal hypervisors (type 1) vs. Hosted hypervisors (type 2) (ii) Full virtualization VMs vs. Para-virtualization 3. Challenges of hypervisor design a. who owns the resources? - guest OS believes that it owns the resources - side-effect, CPL=0 is expected in the kernel, corresponds the Ring 0 of execution. - More than one guest OS cannot be executing at Ring 0. b. handling system calls - invoked from user space, switches to privileged mode and then executes the syscall - diversion: how are system calls implemented - does VMM know the system call implementation of all guest OSes and multiplexes based on "context" or gives setup of IDT to guest OS --- danger! c. resource virtualization - e.g., the memory resource - guest OS assumes a linear full physical memory layout - use physical pages to update page tables - pages may not be present! as used by other VMs. - also, CR3 points to page table! is page table page valid/available for the VM? - CR3 update is per process, VMM has to know context of each process --- seems too intrusive a design. 4. The general VM setup ... - specifiy resource characterization and a kernel image or a startup disk to boot the guest OS. - access to all resources and devices is "virtualzied" - guest OS interacts and issues commands to control the resouce/device and the VMM intervenes (if required) to perform action - e.g., a device exposed to a VM sees commands for initialized and setup, and eventual actions from th guest OS. since the device is virtualized, the commands are intercepted and desired actions taken and return values sent back. e.g., - the OS may ping device to know it size, or reset the device, IO port to which device is connected etc. VMM will perform this virtualized action. - sends data to be read/written to a storage device, using a guest device driver and its commands. a simple sequence to read from a device as follows, mov x, 10 mov y, 0 mov z, #virtual address of buffer in portnumber - is there a real device for doing this IO? - maybe or maybe not. - may not be on the same port (on physical machine), may have different physical characteristics. - may be virtualized as a file! - VMM maps block number to file offset and performs data operation! 5. VMM design principles - Popek and Goldberg 1974, propoerties a VMM should satisfy (i) efficiency: as much native execution as possible (ii) resource control: VMM controls manages all resources (iii) equivalence: identical behavior on bare-metal and virtual platforms (w.r.t performance and OS system-view of machine)