1 / 50

薛智文 cwhsueh@csie.ntu.tw csie.ntu.tw/~cwhsueh/

前瞻 資訊科技 (II) - 虛擬化 (2) - Virtualization(V12N ) . 薛智文 cwhsueh@csie.ntu.edu.tw http://www.csie.ntu.edu.tw/~cwhsueh/ 101 Spring, March 22, Fri 678, DTH 104. Outline. Case Study Xen Architecture Hypercall CPU Virtualization Memory Virtualization I/O Device Virtualization

crete
Download Presentation

薛智文 cwhsueh@csie.ntu.tw csie.ntu.tw/~cwhsueh/

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 前瞻資訊科技(II) -虛擬化 (2) -Virtualization(V12N) 薛智文 cwhsueh@csie.ntu.edu.tw http://www.csie.ntu.edu.tw/~cwhsueh/ 101 Spring,March 22, Fri 678, DTH 104

  2. Outline • Case Study • Xen • Architecture • Hypercall • CPU Virtualization • Memory Virtualization • I/O Device Virtualization • Hardware Virtual Machine • Benchmark • Domain X • KVM • Ubitus • BitCoin • WeOS • Summary /49

  3. How to Virtualize ? • Binary translation • Hypercall Trap and emulate Full Virtualization Para Virtualization Hardware Assisted Virtualization Intel VT-x & AMD SVM /49

  4. Virtual Machine Monitor (VMM)Hypervisor VM : Virtual Machine, Guest OS + Virtual Devices VM0 VM1 VMN … Hosted VMM, e.g. KVM, VMware VM0 VM1 VMN … Hypervisor, e.g. Xen, VMware Host Operating System Hardware Hardware Type I - Hypervisor Type II – Hosted VMM /49

  5. Hypervisor (VMM) Type Type I • Type I + Microkernel • Xen (open source, Citrix), • Microsoft Hyper-V • Type I + Integrated kernel • VMware ESX, • KVM (kernel-base VM) • Type II (Host OS + Guest OS) • VMware GSX, workstation, • Microsoft virtual PC, • Microsoft virtual server, • Sun Virtual Box Type II /49

  6. Xen Architecture (1/2) Domain U Domain U Domain 0 Domain U QEMU /49

  7. Xen Architecture (2/2) • Compare to common Linux /49

  8. Hyper Call System Call • int 0x80 • int 0x82 01 02 03 04 05 06 07 // linux/include/asm/unistd.h #define __NR_restart_syscall 0 #define __NR_exit 1 #define __NR_fork 2 #define __NR_read 3 … Guest OS Hypervisor HYPERVOSIR_sched_op int 82h hypercall Hypercall_table do_sched_op iret Hyper Call resume Guest OS 01 02 03 04 05 06 07 // xen/include/public/xen.h #define __HYPERVISOR_set_trap_table 0 #define __HYPERVISOR_mmu_update 1 #define __HYPERVISOR_set_gdt 2 #define __HYPERVISOR_stack_switch 3 … /49

  9. Grant Table Domain A Domain B Domain A Domain B create GR create GR send GR send GR map page transfer page access page inform receive page unmap page release GR inform release GR • Page mapping & Page transferring • Page as a unit • Grant reference (GR)  Grant entry /49

  10. Xen Architecture (1/2) Domain U Domain U Domain 0 Domain U /49

  11. Event Channel IDC IPI IPI vIRQ pIRQ • A lightweight signal mechanism • Use “ports” as identifers (pending+mask) • Four major purposes Guest OS Guest OS … VCPU VCPU … … VCPU VCPU Hypervisor VirtualMemory … Virtual CPU Scheduling Hardware PhysicalCPU PhysicalMemory … Eth0 Eth1 /49

  12. CPU Virtualization • Architecture • 2 scheduling algorithms (Non-Work Conserving) • Simple Earliest Deadline First (SEDF) • Credit App App Guest OS Guest OS … Hypervisor … VCPU VCPU VCPU Scheduling PCPU PCPU PCPU … /49

  13. PIC PIC Interrupt • Physical interrupt • For the hypervisor or for guest OSes • Virtual interrupt • Ask guest OSes to do • 8 for now (max is 24) Guest OS Guest OS … event OS Hypervisor ISR Hardware Hardware Device Device IRQn IRQn /49

  14. Memory Virtualization (1/2) • Two-level memory • Three-level memory • Virtual, Pseudo-physical, Machine hypervisor Application - Virtual Memory OS Guest OS -Physical Memory -Pseudo-Physical Memory P2M M2P Hypervisor -Machine Memory /49

  15. Memory Virtualization (2/2) 168M memory for hypervisor 0xFC000000 0xFC400000 Heap 0xFFFFFFFF /49

  16. Memory Virtualization - Translation • 4 mechanisms to manipulate page tables • Paravirtualized page tables • Write page tables (Only level 1 is writable) • Shadow page tables • Hardware-assisted paging Virtual Memory Page Table Shadow Page Table MMU Page Fault ! (VM->PFN) (VM->MFN or VM->P2M) Pseudo-Physical Memory Second Level PagingHAP P2M Machine Memory /49

  17. Memory Virtualization - Shared Info Page Structure Compare with start_info_page MAX : 32 VCPUs event channel TSC memory wall clock /49

  18. I/O Device Virtualization • Hypervisor also provides three mechanisms to use devices. • Emulated Devices • ParavirtualizedDriver • Pass-through /49

  19. I/O Device Virtualization - Emulated Devices • Implemented by QEMU • e.g. sound card, ac97, sb16, etc QEMU-DM /49

  20. I/O Device Virtualization - Paravirtualized Driver • Split Device Driver Model • An example of sending packets Back-End Driver Front-End Driver Native Driver /49

  21. I/O Device Virtualization - I/O Ring • Without data, it only transfers request/reply • An example with GR Dom U Dom 0 GR GR GR Grant Table I/O Channel Hypervisor Active Grant Table Device /49

  22. I/O Device Virtualization - Pass-Through • Pass and directly use the device Dom U Dom 0 Dom U … NativeDriver NativeDriver Hypervisor VirtualMemory … Virtual CPU Scheduling Hardware PhysicalCPU PhysicalMemory … Eth0 Eth1 /49

  23. Hardware Virtual Machine • Intel Virtualization Technology /49

  24. CPU Benchmark (1/2) 8.3% Average over 100 tests, Deviation: 0.066~0.128% /49

  25. CPU Benchmark (2/2) 5% Calculate the 32M digits of . /49

  26. Hard Disk Drive Benchmark /49

  27. Network Benchmark (1/2) 59% Testing Time: 180 seconds, Deviation: 0.12~0.26%. /49

  28. Network Benchmark (2/2) Average: 9.82% Sample Period: 2 seconds /49

  29. Architecture Domain 1, X – A Fake Domain 0 assignable hardware non-assignable hardware VGA eth usb … Dom1 Dom0 DomU … Windows Linux Android xend Drivers Drivers payload hypervisor BIOS /49

  30. KVM Architecture (1/2) • KVM (Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V). Guest OS Guest OS Machine Emulator MachineEmulator user space UserProcess UserProcess ... kernel space KVM Linux Kernel /49

  31. KVM Architecture (2/2) • KVM consists of • A loadable kernel module, kvm.ko. • Provides the core virtualization infrastructure. • A processor specific module, kvm-intel.koor kvm-amd.ko. • Provides the support of hardware virtualization. KVM kvm-intel.ko kvm-amd.ko kvm.ko create a device when loading kvm.ko /49

  32. Machine Emulator for KVM • QEMU-KVM is modified from QEMU supporting KVM. • QEMU is a generic and open source machine emulator and virtualizer. QEMU-KVM User Interface CPU Emulator Event Loop Translation Buffer Exception Handler Memory Management Emulated Devices ... KVM API /49

  33. KVM API • There are three types (implemented by ioctl): • On KVM device. • KVM_CREATE_VM • KVM_CHECK_EXTENSION • … • On Virtual Machine (VM). • KVM_CREATE_VCPU • KVM_ASSIGN_PCI_DEVICE • … • On Virtual CPU (VCPU). • KVM_RUN • KVM_GET_REGS • KVM_GET_SREGS • … create VMs return VM id create VCPUs return VCPU id control VM control VCPU /49

  34. Using KVM in QEMU-KVM In cpus.c 924 static voidqemu_kvm_start_vcpu(CPUState *env) 925 { ... 929 qemu_thread_create(qemu_kvm_cpu_thread_fn, ...); ... 933 } user space In cpus.c 717 static void *qemu_kvm_cpu_thread_fn(void *arg) 718 { ... 738 while (1) { 739 r = kvm_cpu_exec(env); ... ... 745 qemu_kvm_wait_io_event(env); 746 } 749 } Guest OS QEMU-KVM … threads … KVM_RUN In kvm-all.c 954 intkvm_cpu_exec(CPUState *env) 955 { ... 987 run_ret= kvm_vcpu_ioctl(env, KVM_RUN, 0); ... 1005 switch (run->exit_reason) { 1006 case KVM_EXIT_IO: KVM kernel space /49

  35. Compare to Xen In 2010, Andrea has following conclusions [1]: 1. KVMproved great stability and reliability. 2. Right now (2010), Xen hypervisor seems to be the best solution, particularly when using the paravirtualized approach. [1] Andrea Chierici, "A quantitative comparison between xen and kvm", Journal of Physics: Conference Series, IOP Publishing, vol. 219, no. 4, 2010. /49

  36. Types of Virtualization • Hardware/platform virtualization • Desktop virtualization • Software virtualization • OS-level, Workspace, Application • Storage virtualization • E.g. Virtual Tape Library, 1.2B USD sold to CA, 1996. • Data virtualization • Database virtualization • Network virtualization /49

  37. /49

  38. /49

  39. /49

  40. /49

  41. WeOS: emerge OurServices Seller Buyer Logistics Cash Flow ... 網民當家作主,共創資訊價值! 日本 AutonomousID Autonomous Distributed Match Engine 京都 ... 東京 大阪 ... ... ... USA Seattle Internet ... 台北 台灣 DC LA ... ... 嘉義 ... ... 台南 ... ... ... V12N to help G11N (I18N + L10N). /49

  42. Computer Science and Information Engineering 資訊工程 資訊科學 資訊管理 資訊教育 資訊電子 資訊處理 資訊傳播 生物資訊 醫學資訊 圖書資訊 金融資訊 /49

  43. 市值 2013/06/30 System Software Hardware Application Software 台積電 1307x 系微 1x (20.7 億台幣) 訊連 5x 鴻海 417x 趨勢 61x 聯發科 213x 宏達電華碩 廣達 99x 99x 119x Amazon 1832x Cisco 1885x Adobe 332x Citrix 164x Intel1746x Semantec 227x Vmware 416x TI560x Microsoft4181x ARM244x Google, Yahoo4233x, 394x IBM3071x Apple5395x /49

  44. 市值 2013/10/08 System Software Hardware Application Software 台積電 1342x 系微 1x (20.1 億台幣) 訊連 4x 鴻海 492x 趨勢 77x 聯發科 255x 宏達電華碩 廣達 57x 88x 124x Amazon 2077x Cisco 1799x Adobe 372x Citrix 194x Intel1668x Semantec 254x Vmware 508x TI644x Microsoft4067x ARM322x Google, Yahoo4227x, 511x IBM2923x Apple6497x /49

  45. 市值 2013/12/27 System Software Hardware Application Software 台積電1462x 系微 1x (18.3億台幣) 訊連 5x 鴻海568x 趨勢 77x 聯發科318x 宏達電華碩 廣達65x 108x 145x Amazon 3043x Cisco 1916x Adobe 489x Citrix 188x Intel2100x Semantec263x Vmware629x TI784x Microsoft5138x ARM420x Google, Yahoo6137x, 678x IBM3309x Apple8341x /49

  46. Answers for Big Questions • How fast can virtualization achieve? • 95+%  99.9% • What kinds of applications? • Well … • What problems it might incur? • Technical • Big Data? • Security • How much? • Business • Politics • Globalization (G11N) = • Internationalization (I18N) + Localization (L10N) • … /49

  47. Homework • Refer to • Xen To-Do List, http://wiki.xen.org/wiki/Xen_Document_Days/TODO • BitCoin, http://bitcoin.org/zh_TW/ • WeOS • Each of you send a one-page report (學號.pdf) to iwantplay@gmail.com, answering any of the big or related questions with your words, what problems you would like to solve?And how? • Due on Dec 29. • Your reports will be posted on course wiki on Dec 30. /49

  48. 假若真時真亦假虛擬實處實還虛 /49

  49. Summary • Stay hungry to be full [of passion]. • Stay foolish to be smart [on absorption]. • Virtualized realityvs. Real virtualization. • Life of Pi, trust yourself. • 專題 vs. PhD • 創意 vs. 創業, 人事時地物本 • e.g. 鼎王1B, 麻油1B, 鳳梨酥20+B, 掏寶, evernote, Line, ubitus, whoscall (6M0.5B), 阿里巴巴, 萬達, PTT? • Virtualized to go anywhere? • Just Do it, NTU CSIE eSystem! • For Taiwan Industry • Key is system, System is key. /49

  50. Reference • 五分鐘看懂美國國債危機 • http://www.youtube.com/watch?v=K2hhck_kmz0 /49

More Related