22
Outline for Today • Announcements –1 st programming assignment coming soon. • Objective of the lecture – OS and Virtual Machines

Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Embed Size (px)

Citation preview

Page 1: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Outline for Today

• Announcements– 1st programming assignment coming soon.

• Objective of the lecture– OS and Virtual Machines

Page 2: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Shells?

Page 3: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Producer/Consumer Pipes

outputinput

char inbuffer[1024];char outbuffer[1024];

while (inbytes != 0) { inbytes = read(stdin, inbuffer, 1024); outbytes = process data from inbuffer to outbuffer; write(stdout, outbuffer, outbytes);}

Pipes support a simple form of parallelism with built-in flow control.

e.g.: sort <grades | grep Dan | mail justin

Page 4: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Shell = Command Line Interpreter

• Not GUI• Application-level program (not part of OS)• Loops

– Prompting for input– Reads and parses input on command line– Invokes program specified with arguments supplied– Waits (or not – “&”) for completion

• Allows hooking up of multiple programs via pipes (“|”) and redirection of stdin and stdout (“<“ and “>”).

• Reads shell scripts.

Page 5: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Introduction to Virtual Machine Monitors

Page 6: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Traditional Multiprogrammed OS

• Multiple applications running with the abstraction of dedicated machine provided by OS

• Pass through of non-privileged instructions

• ISA – instruction set architecture

• ABI – application binary interface

HW

OS

Application(s)

ISA

ABI Syscalls

instr

Page 7: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Traditional Multiprogrammed OS

HW

OS

Application(s)

• Multiple applications running with the abstraction of dedicated machine provided by OS

• Pass through of non-privileged instructions

• ISA – instruction set architecture

• ABI – application binary interface

ISA

ABI Syscalls instr

Page 8: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

©James Smith, U.Wisc

Page 9: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Virtualization Layer

©James Smith, U.Wisc

Page 10: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Variations on the Theme

©James Smith, U.Wisc

Page 11: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Virtual Machines

• History: invented by IBM in 1960’s

• Fully protected and isolated copy of the physical machine providing the abstraction of a dedicated machine

• Layer: Virtual Machine Monitor (VMM)

• Replicating machine for multiple OSs

• Security Isolation

©James Smith, U.Wisc

Page 12: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Virtual Machine Monitor

©J. Sugarman, USENIX01

Page 13: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Issues

• Hardware must be fully virtualizable – all sensitive (privileged) instructions must trap to VMM– X86 is not fully virtualizable

• In traditional model, all devices need drivers in VMM– PCs have lots of possible devices – leverage the

host OS for its drivers => hosted model

Page 14: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

VMware Hosted Model

©J. Sugarman, USENIX01

Page 15: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Hosting Implications• World switch – heavier weight than normal context switch• VMM runs with full privileges (e.g., kernel mode)• I/O operations involve

– Interception by VMM– Switch to host world via Vmdriver– Issuing I/O operation to host OS via Vmapp

• Interrupts handled by host OS– VMM yields control to host OS– Reasserts interrupts to Guest OS

• Host OS does scheduling and can also pageout memory of a virtual machine

Page 16: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

VMware Hosted Model

Page 17: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Xen 2.0 Features

• Secure isolation between VMs

• Resource control and QoS

• Only guest kernel needs to be ported– All user-level apps and libraries run unmodified– Linux 2.4/2.6, NetBSD, FreeBSD, Plan9

• Execution performance is close to native

• Supports the same hardware as Linux x86

• Live Relocation of VMs between Xen nodes

Page 18: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Xen 2.0 Architecture

Event Channel Virtual MMUVirtual CPU Control IF

Hardware (SMP, MMU, physical memory, Ethernet, SCSI/IDE)

NativeDeviceDriver

GuestOS(XenLinux)

Device Manager & Control s/w

VM0

NativeDeviceDriver

GuestOS(XenLinux)

UnmodifiedUser

Software

VM1

Front-EndDevice Drivers

GuestOS(XenLinux)

UnmodifiedUser

Software

VM2

Front-EndDevice Drivers

GuestOS(XenBSD)

UnmodifiedUser

Software

VM3

Safe HW IF

Xen Virtual Machine Monitor

Back-End Back-End

Page 19: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Para-Virtualization in Xen

• Arch xen_x86 : like x86, but Xen hypercalls required for privileged operations– Avoids binary rewriting– Minimize number of privilege transitions into Xen– Modifications relatively simple and self-contained

• Modify kernel to understand virtualised env.– Wall-clock time vs. virtual processor time

• Xen provides both types of alarm timer

– Expose real resource availability• Enables OS to optimise behaviour

Page 20: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

x86 CPU virtualization

• Xen runs in ring 0 (most privileged)• Ring 1/2 for guest OS, 3 for user-space

– GPF if guest attempts to use privileged instr

• Xen lives in top 64MB of linear addr space– Segmentation used to protect Xen as switching page

tables too slow on standard x86

• Hypercalls jump to Xen in ring 0• Guest OS may install ‘fast trap’ handler

– Direct user-space to guest OS system calls

• MMU virtualisation: shadow vs. direct-mode

Page 21: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

Para-Virtualizing the MMU

• Guest OSes allocate and manage own PTs– Hypercall to change PT base

• Xen must validate PT updates before use– Allows incremental updates, avoids revalidation

• Validation rules applied to each PTE:1. Guest may only map pages it owns*

2. Pagetable pages may only be mapped RO

• Xen traps PTE updates and emulates, or ‘unhooks’ PTE page for bulk updates

Page 22: Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines

I/O Architecture• Xen IO-Spaces delegate guest OSes protected access

to specified h/w devices– Virtual PCI configuration space– Virtual interrupts

• Devices are virtualised and exported to other VMs via Device Channels– Safe asynchronous shared memory transport– ‘Backend’ drivers export to ‘frontend’ drivers– Net: use normal bridging, routing, iptables– Block: export any blk dev e.g. sda4,loop0,vg3