Virtual Machines Virtual Servers Virtualization Design of IBM's VM

Virtual Machines Virtual Servers Virtualization Design of IBM's VM

Virtual machines Virtual Servers Virtual machine systems can give everyone the OS (and hardware) that they want. Virtual machines are very widespread. IBM’s VM provided an exact copy of the Many web and database servers assume that they are hardware to the user. the only thing running on a machine. They are designed that way (is this a good idea?). Using virtual servers means that multiple servers can be running simultaneously on the one machine. Errors, or security problems with one server do not Advantages affect the other servers on the same machine. (In You can choose your OS. theory.) You can modify or develop new OSs without crashing machines or having to reboot. As long as the expected loads are not going to An extra level of safety – each user’s virtual machine is overwhelm the machine, this is definitely a cost completely separate from all the others. effective solution. Less hardware to buy and you Virtual servers (next slide) use what you have more efficiently. Disadvantages Added flexibility - VMs can be migrated from one Some resources allocated to one VM can’t be shared by machine to another without having to reboot. another. (Virtual networks) Tricky to implement. An extra layer of complexity. Each layer Copy - it is trivial to create a new VM as a copy of can provide its own bugs. an existing one. Operating Systems Lecture 04 page 1 Operating Systems Lecture 04 page 2 Virtualization Design of IBM’s VM Popek and Goldberg (1974) • Fidelity – software should run identically (except for speed) on the Virtual Machine as on the real machine. • Performance – most instructions in a VM must run directly on the hardware (therefore at the same speed as on the real machine). Not the same as emulation. • Safety (also known as resource control)– the Virtual Machine Monitor/Manager (VMM) is CPU scheduling can create the appearance that users have their own in complete control of system resources and processor. must be safe from any actions of the VM. Spooling and a file system can provide virtual line printers and Also one VM must be safe from the actions virtual disks (minidisks). of another VM. A normal user time-sharing terminal serves as the virtual machine operator’s console. Host OS – the operating system which the Virtual user and kernel modes are provided. VMM is running on. VM did very little emulation. System calls caused traps to the VM and calls back to the correct kernel. Guest OS – the operating system running inside Only privileged instructions needed to be emulated. a VM. Operating Systems Lecture 04 page 3 Operating Systems Lecture 04 page 4 Hypervisor Types Type 1 & Type 2 The textbook has 3 types of hypervisor (or Type 1 VMMs), Popek and Goldberg had 2. Special purpose OSs - they load at boot time and provide the optimised environment to run guest OSs. Type 0 (not universally accepted as a type) - Now supported by hardware on Intel and AMD implemented in hardware and firmware, it processors (see later). loads at boot time. The guest OSs load into Run in kernel mode. partitions separated by the hardware. They are allocated dedicated resources e.g. They implement device drivers and the guests access processors, memory, devices. Guests OSs are the devices through them. native with a subset of the hardware. They also provide services to manage the guests - backup, monitoring. So these are the VMs used in data centres or the cloud. e.g. VMWare’s ESX, XenServer Some “standard” OSs can also be made to run as Type 1 - e.g. Enterprise Linux, Windows Hyper-V Type 2 These run as applications on the host OS. e.g. VMWare Workstation (or Player) and VirtualBox. Operating Systems Lecture 04 page 5 Operating Systems Lecture 04 page 6 x86 Virtualization problems Solutions • User level code is fine – it will actually run in • Until 2006, all x86 type CPUs had problems user mode and can't do anything privileged. If with classical – trap and emulate it tries to it will cause an exception which virtualization. will be caught by the VMM and passed back to the guest OS kernel. http://en.wikipedia.org/wiki/X86_virtualization • So the problem only occurs when in the • Some instructions ran in both user and kernel kernel of the guest OS. modes (they just worked differently in kernel mode). So they were not privileged • Binary translation - instructions and executing them did not cause • Code running in kernel mode is translated at run-time a trap into the VMM. into something which doesn't have these problems. • Some instructions allowed the program to Isn't that terribly slow? determine if it was running in privileged • The translation is very simple (and hence efficient). mode. The kernel of a guest OS should be • Only translates code which is actually run. privileged however if it checked it would see • Much of the code is exactly the same as the original. it was in user mode, breaking the fidelity • The translated code is cached and reused. requirement. • Uses all sorts of tricks to speed up emulation. • Even worse there were problems with • Performs very well compared to true protecting the page table information and hardware virtualization – which struggles keeping it all consistent. with page-table modifications. Operating Systems Lecture 04 page 7 Operating Systems Lecture 04 page 8 Hardware Virtualization (x86) OS level virtualization If virtualizing servers we can often use the same OS. This means we virtualize less. Both Intel and AMD have developed their own solutions to deal with virtualization. Containers look like servers – they can be rebooted separately, have their own IP Intel VT and AMD-V – an extra high privilege addresses, root, programs etc. area for the VMM. OS still runs in ring 0 (kernel mode). But they all use the same underlying kernel. Hardware transitions from ring 0 to the VMM. And they are still separate from each other. Processor state is maintained for each guest OS e.g. Parallels Virtuozzo and OpenVZ - see http:// (and the VMM) in separate address spaces. en.wikipedia.org/wiki/OpenVZ Container Container Container AMD-V – included tagged translation lookaside buffers (so virtual memory didn't have a hit when changing virtual machines) processes processes processes Both AMD and Intel processors now do Second Level Address Translation (SLAT) determine the guest physical address from the guest virtual address using hardware Kernel then turn the guest physical address into the host physical address also using hardware Operating Systems Lecture 04 page 9 Operating Systems Lecture 04 page 10 More VM styles C and OS implementations Paravirtualization - Xen – software approach. Why has C been the language of choice for most Requires modifications to the OS source operating system implementations? code to use the Xen layer. e.g. To read from a file the guest directly calls host read routines. That is what it was designed for: Ken Thompson and Dennis Ritchie converted UNIX from assembly language to C to provide portability. Application virtualization - an application runs on a layer which provides the resources it Close to the hardware. needs even though it may be running on a Low-level access to memory different OS e.g. Wine or running programs Maps easily to machine instructions from old versions of Windows on a newer Easy to inline assembly language code (depends on the one. compiler) Programming-Environment Virtualization, Has small requirements for runtime support Java VM & CLR/Mono Implement a different architecture on top of any hardware/OS. Sometimes referred to as a high-level assembler. Programs are compiled to the Java VM or CLR architecture then run by either compiling or interpreting that code. Earlier versions – late 70’s UCSD Pascal system. Operating Systems Lecture 04 page 11 Operating Systems Lecture 04 page 12 Direct access to memory Accessing registers C pointers can have integers assigned to them You can use the “register” storage class specifier This means that actual addresses can be stored in a pointer to say that a variable should be kept in a and then used to access that address processor register. e.g. Memory mapped devices can then be controlled directly from normal C. register long number = 1234; e.g. #include <stdio.h> #include <stdlib.h> However this does not guarantee that a value is #define ADDRESS 0x7fff52cb08a0 stored in a register, it depends on the number int main(void) { of available registers. long number = 1234; long *pointer = &number; printf("number is %ld\n", number); Also compilers do a really good job of printf("The value at %p is %ld.\n", pointer, *pointer); optimising register usage and it is not usually *pointer = 42; printf("number is %ld\n", number); a good idea for a programmer to worry about // And I can do the same thing with any address this level of optimisation. // it could cause a segmentation error // since MacOS now uses ASLR pointer = (long *)ADDRESS; printf("The value at %p is %ld.\n", (void *)ADDRESS, *pointer); Memory mapped registers can be accessed return EXIT_SUCCESS; } directly using pointer manipulation as on the previous slide. Pointer arithmetic gave fast access to elements in arrays or structs Operating Systems Lecture 04 page 13 Operating Systems Lecture 04 page 14 Volatile Memory management Volatile is a storage class qualifier All local variables disappear when functions are e.g. returned from. volatile unsigned char *reg; Space is allocated on the stack for the variables in each This means the variable may change in a non-local way, in function invocation. other words there is no way the compiler could possibly There is a limit to the size of the stack (especially for know whether the value has changed or not between threads as each thread needs its own stack) references.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us