Virtual Machines: Abstract Hardware & Benefits

Virtual Machines: Abstract Hardware & Benefits
Slide Note
Embed
Share

Virtual Machines (VMs) abstract hardware, allowing multiple execution environments on a single computer. Learn about VMs, their benefits such as protection, isolation, and features like cloning, migration, and load balancing. Explore trap-and-emulate and binary translation techniques for efficient VM operation.

  • Virtual Machines
  • Benefits
  • Abstract Hardware
  • Trap and Emulate
  • Binary Translation

Uploaded on Feb 20, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. School of Computing Science School of Computing Science Simon Fraser University Simon Fraser University CMPT 300: Operating Systems I Virtual Machines Keval Vora 1

  2. Virtual Machine Abstract hardware of single computer into several different execution environments Illusion that each separate environment is running on its own private computer Virtual Machine Manager (VMM) Also called Hypervisor Creates & runs virtual machines which run guest operating systems Similar but complicated responsibilities than OS Why? Many different types Hardware & software 2

  3. Virtual Machine 3

  4. Benefits & Features Protection & Isolation Host from guests, guests from each other Host different kinds of operating systems Suspend, snapshot, resume Clone Backup Migration Load balance, power/cooling management Cloud computing Custom machines spun instantly Perfect to do OS research! 4

  5. Trap and Emulate Extend dual-mode systems Virtual user mode and virtual system mode When guest attempts to execute privileged instruction Raise a trap to VMM in the real machine VMM executes (or emulates ) the action for guest Slowdown since not run directly on hardware 5

  6. Binary Translation If CPU commands behave differently based on privilege E.g., x86 popf instruction (call them special) Tran and emulate cannot be used When guest in user mode, run natively on physical CPU When guest in kernel mode, VMM examines every instruction dynamically If not special, run natively If special, translate into a new set of instructions that perform expected task Performance Use caching to reuse recent translations 6

  7. Binary Translation 7

  8. Binary Translation (Nested Page Tables) VMM maps guest page tables to Nested Page Tables (NPT) Each guest paging operation gets translated to NPT operation 8

  9. Hardware Assistance Two modes of operations Host and guest vCPU data structures Load & store guest CPU states quickly Memory management Hardware Nested Page Tables DMA support Guest might set up DMA transfer that affects other memory Protection domains => which memory belongs to which guest Hardware translates addresses for guest DMA operations Interrupt remapping Routing interrupts to correct guests 9

  10. Types of Hypervisors Type 0, Type 1, Type 2 Programming Environment Virtualization Emulation Application Containment 10

  11. Type 0 Hypervisors Hardware feature Partitions hardware for different guests Typically provides dedicated resources Guests can host guests 11

  12. Type 1 Hypervisors Custom operating systems running on hardware They create, run and manage guest operating systems Don t provide traditional support like system calls Interface API provided for guest applications like backup, monitoring, security, etc. Typical in data centers Mainly aimed towards consolidation Use 10 guest VMs instead of 10 servers at 10% utilization Provide sophisticated management features for data-center managers/admins 12

  13. Type 2 Hypervisors Application level virtual machine managers Simply a process managed by host Host doesn t know virtualization is happening Need admin privileges to access hardware assistance features in modern systems Don t need to change host OS Easily host custom guest OS types 13

  14. Programming Environment Virtualization Virtualization of programming environments Java Virtual Machine (JVM) Interpreted languages JVM runs as a native program on systems Java program runs within JVM Functionalities of JVM accessed by its API 14

  15. Emulation Guest system is compiled for a different architecture compared to that of the host system E.g., Old popular games needs to run on a different CPU Translate source system s instructions to equivalent instructions on target system Performance challenge 15

  16. Application Containment Multiple applications require same OS, don t need complete virtualization Don t provide complete virtualization Extract out common components Enable sharing Examples LXC, rkt 16

  17. Application Containment Possible using cgroups & namespaces Docker (packaging containers) https://www.docker.com 17

  18. Functionalities CPU Scheduling Memory Management I/O Management Storage Management Live Migration 18

  19. CPU Scheduling Mapping vCPUs to physical CPUs ? Dedicated when |vCPU| < |CPU| Over commitment Standard CPU scheduling with fairness Any issues? Guest CPU scheduling algorithm is negatively affected Progress assumptions break Due to scheduling, time-of-day clocks in vCPUs are incorrect VMMs include applications to correct clock drifts 19

  20. Memory Management Memory pressure is high More users, more applications, and over commitment is a norm Double paging VMM has its own page-replacement and pages that guest believes are in memory are actually on disk Performance degrades Install custom module in guest Communicates with VMM and allocates (blocks) memory in guest OS and pins the allocated pages in memory Guest page replacement forced to work on remaining memory Host VMM can give the extra memory to other guests Page sharing Detect same pages loaded multiple times & keep them only once Same pages detected by hashing followed by entire page check Practical because many common OS modules, applications, etc. 20

  21. I/O & Storage Management I/O Management Easy to control since drivers are loadable modules Direct I/O control provided to improve I/O performance Eliminates hypervisor from I/O path Storage Management Disk image maintained as a single file Easy for cloning, backup, migration Requires physical to virtual conversion of disk blocks Map parts of disk image to files/data in guest Multiple file systems maintained as separate images 21

  22. Live Migration Type 0 and type 1 hypervisors Seamless load balancing, server maintenance, etc. No suspend-restart required and user sessions are maintained 22

  23. Summary Virtual Machine Abstract hardware of single computer into several different execution environments Virtual Machine Manager Basic Techniques Trap & Emulation, Binary Translation, Hardware support Hypervisor types Type 0, Type 1, Type 2, Programming Environment Virtualization, Emulation, Application Containment Core functionalities Live migration, CPU scheduling, memory management, I/O management, storage management 23

More Related Content