46
Xen & XCP Tutorial Patrick F. Wilbur Clarkson University Josh West One.com Steve Maresca Zentific Todd Deshane Xen.org Unit 1 - 2011 Xen Day Boston

Xen and XCP Tutorial

Embed Size (px)

DESCRIPTION

Se describe Xen funciones, historia. Proyectos en los que se utiliza Xen

Citation preview

Page 1: Xen and XCP Tutorial

Xen & XCP Tutorial

Patrick F. WilburClarkson University

Josh WestOne.com

Steve MarescaZentific

Todd DeshaneXen.org

Unit 1 - 2011 Xen Day Boston

Page 2: Xen and XCP Tutorial

Copyright Notice

Copyright 2011, Patrick F. Wilbur.Last modified: December 12, 2011 2:39 PM EST. The Xen panda logo is property of Xen.org . == LICENSE: Patrick F. Wilbur

http://pdub.net

Current slides available at: http://cosi.clarkson.edu/docs/installingxen/

These slides and content are released under the Creative Commons Attribution-Share Alike 3.0 Unported license, available online at http://creativecommons.org/licenses/by-sa/3.0/ You may share (copy, distribute, and transmit) this work, and remix (adapt) this work, as long as you attribute this work to the author and share adapted works under the same or similar license by leaving this entire notice in place (including the original author's name/contact information/URL and this license notice).

Page 3: Xen and XCP Tutorial

Acknowledgments

Portions of this 2011 Xen Day work are derived from the 2010 Xen Training / Tutorial, by Todd Deshane and Patrick F. Wilbur, which is derived from the 2009 Xen Training / Tutorial as updated by Zach Shepherd and Jeanna Matthews from the original version written by Zach Shepherd and Wenjin Hu, originally derived from materials written by Todd Deshane and Patrick F. Wilbur.

Portions of this work are inspired by Jeremy Fitzhardinge's Pieces of Xen slides.

Page 4: Xen and XCP Tutorial

Patrick F. Wilbur Biography

Patrick F. Wilbur is a computer science Ph.D. student at Clarkson University, where he is a member of the Applied C.S. Labs. His research and teaching interests include usable security, virtualization, operating systems, file systems, artificial intelligence, ubiquitous computing, systems biology, and human-computer interaction. He is a co-author of Running Xen and has taught several Xen tutorials.

In his spare time, he enjoys being involved with his local church, near-space weather balloons, hiking, cooking, and writing essays, poetry, and music.

http://pdub.net

Page 5: Xen and XCP Tutorial

Unit 1Xen & XCP Tutorial

Page 6: Xen and XCP Tutorial

Unit 1: Xen & XCP Tutorial - Overview• Introduction & Xen vs. Xen Cloud Platform

 • Xen/XCP Installation & Configuration

 • XCP Concepts:  pools, hosts, storage, networks, VMs 

 

Page 7: Xen and XCP Tutorial

Introduction &Xen vs. Xen Cloud Platform

Xen, XCP, Project Kronos

Page 8: Xen and XCP Tutorial

Types of Virtualization

Emulation:Fully-emulate the underlying hardware architecture

Full virtualization:Simulate the base hardware architecture

Paravirtualization:Abstract the base architecture

OS-level virtualization:Shared kernel (and architecture), separate user spaces

Page 9: Xen and XCP Tutorial

What is Xen?

• Xen is a virtualization system supporting both paravirtualization and hardware-assisted full virtualization

 • Name from neXt gENeration virtualization 

 • Initially created by University of Cambridge Computer Laboratory

 • Open source (licensed under GPL)

Page 10: Xen and XCP Tutorial

What is Xen Cloud Platform (XCP)?

• Xen Cloud Platform (XCP) is a turnkey virtualization solution that provides out-of-the-box virtualization/cloud computing

• XCP includes: o Open-source Xen hypervisoro Enterprise-level XenAPI (XAPI) management tool stacko Support for Open vSwitch (open-source, standards-compliant

virtual switch)

Page 11: Xen and XCP Tutorial

What is Project Kronos?

• Port of XCP's XenAPI toolstack to Debian and Ubuntu dom0 • Gives users the ability to install Debian or Ubuntu, thenapt-get install xcp-xapi 

 • Provides Xen users with the option of using the same API and

toolstack that XCP and XenServer provide • Early adopters can try new changes to the XenAPI before they get

released in mainstream XCP and XenServer versions • Now much, much easier to build tools outside of an SDK VM

Page 12: Xen and XCP Tutorial

XCP/XenServer Class Diagram

Page 13: Xen and XCP Tutorial

XCP Architecture

Page 14: Xen and XCP Tutorial

The Case for Xen

• True Type 1 virtualization:o Reduced size trusted computing base (TCB) o Versatile Dom0 (Linux, BSD, Solaris all possible) o Dom0 disaggregation (storage domains, stub domains,

restartable management domain) o Inherent separation between VMs & system resources 

 • Best security, isolation, performance, scalability mix 

Page 15: Xen and XCP Tutorial

The Case for Xen

• Xen is mature • Open source (even XenAPI)

 • XenAPI is better than libvirt, especially for enterprise use*

* Detailed by Ewan Mellor: http://wiki.openstack.org/XenAPI 

Page 16: Xen and XCP Tutorial

The Case for Xen

• Proven enterprise use (Citrix XenServer, Oracle VM, etc.)  • Hypervisor of choice for cloud (Amazon, Rackspace, Linode,

Google, etc.)   • Hypervisor of choice for client (XenClient, Virtual Computer's

NxTop, Qubes OS, etc.) 

Page 17: Xen and XCP Tutorial

So, Why Xen?

• Open source • Proven to be versatile

 • Amazing community

 • Great momentum in various directions 

Page 18: Xen and XCP Tutorial

Xen Definitions

• Xen provides a virtual machine monitor (or hypervisor), which a physical machine runs to manage virtual machines

• There exist one or more virtual machines (or domains) running beneath the hypervisor

 • A virtual machine is an encapsulated operating system which can

run applications as if on a physical machine

• The management virtual machine (called Domain0 or dom0) interacts with the hypervisor & runs device drivers

• Other virtual machines are called guests (guest domains)

Page 19: Xen and XCP Tutorial

Xen: Hypervisor Role

• Thin, privileged abstraction layer between the hardware and operating systems

 • Defines the virtual machine that guest domains see instead of

physical hardware:o Grants portions of physical resources to each guesto Exports simplified devices to guestso Enforces isolation among guests

Page 20: Xen and XCP Tutorial

Xen: Domain0 (dom0) Role

• Creates and manages guest VMsxl  (Xen management tool)

A client application to send commands Xen, replaces xm  • Supplies device and I/O services:

o Runs (backend) device driverso Provides domain storage

Page 21: Xen and XCP Tutorial

Normal Linux Boot Process

BIOS       

GRUB 

Linux

Master Boot Record (MBR)

Kernel Module

Page 22: Xen and XCP Tutorial

The Xen Boot Process

GRUB starts               

Hypervisor starts              

Domain0 starts               

Guest domain starts               

Guest OS boots

Kernel

Module

xl

  

Page 23: Xen and XCP Tutorial

Virtualization in Xen

Paravirtualization: • Uses a modified Linux kernel • Guest loads Dom0's pygrub or Dom0's kernel• Front-end and back-end virtual device model • Cannot run Windows• Guest "knows" it's a VM and cooperates with hypervisor

 Hardware-assisted full virtualization (HVM):  • Uses the same, normal, OS kernel• Guest contains grub and kernel • Normal device drivers• Can run Windows• Guest doesn't "know" it's a VM, so hardware manages it

Page 24: Xen and XCP Tutorial

Virtualization in Xen

Paravirtualization: • High performance (claim to fame)• High scalability• Runs a modified operating system

   Hardware-assisted full virtualization (HVM):  • "Co-evolution" of hardware & software on x86 architecture• Uses an unmodified operating system 

 

Page 25: Xen and XCP Tutorial

Guest Relocation (Migration) in Xen• Cold Relocation

• Warm Migration

• Live Migration

Page 26: Xen and XCP Tutorial

Cold Relocation

Motivation:Moving guest between hosts without shared storage or with different architectures or hypervisor versions  Process: 1. Shut down a guest on the source host– Move the guest from one Domain0's file system to another's by

manually copying the guest's disk image and configuration files– Start the guest on the destination host

Page 27: Xen and XCP Tutorial

Cold Relocation

Benefits:• Hardware maintenance with less downtime• Shared storage not required• Domain0s can be different • Multiple copies and duplications

Limitation:• More manual process• Service should be down during copy

Page 28: Xen and XCP Tutorial

Warm Migration

Motivation:Move a guest between hosts when uptime is not critical

Result:1.Pauses a guest's execution• Transfers guest's state across network to a new host• Resumes guest's execution on destination host

Page 29: Xen and XCP Tutorial

Warm Migration

Benefits:• Guest and processes remains running• Less data transfer than live migration

 Limitations:• For a short time, the guest is not externally accessible • Requires shared storage • Network connections to and from guest are interrupted and will

probably timeout

Page 30: Xen and XCP Tutorial

Live Migration

Motivation:Load balancing, hardware maintenance, and power management Result:

1.Begins transferring guest's state to new host• Repeatedly copies dirtied guest memory (due to continued

execution) until complete• Re-routes network connections, and guest continues executing

with execution and network uninterrupted

Page 31: Xen and XCP Tutorial

Live Migration

Benefits: • No downtime • Network connections to and from guest often remain active and

uninterrupted• Guest and its services remain available

 Limitations:• Requires shared storage• Hosts must be on the same layer 2 network• Sufficient spare resources needed on target machine• Hosts must be configured similarly

Page 32: Xen and XCP Tutorial

What's New in Xen 4.0+?

• Better performance and scalability • blktap2 for virtual hard drive image support (snapshots, cloning)

 • Improved IOMMU PCI passthru

 • VGA primary graphics card GPU passthru for HVM guests

 • Memory page sharing (Copy-on-Write) between VMs

 • Online resize of guest disks

Page 33: Xen and XCP Tutorial

What's New in Xen 4.0+?

• Remus Fault Tolerance (live VM synchronization) • Physical CPU/memory hotplug

 • libxenlight (libxl) replaces xend

 • PV-USB passthru

 • WHQL-certified Windows PV drivers (included in XCP)

Page 34: Xen and XCP Tutorial

Xen/Xen Cloud Platform Installation & Configuration

Xen Light, XCP Installer

Page 35: Xen and XCP Tutorial

Installing Xen

Xen4 installation instructions, including from source:     http://wiki.xensource.com/xenwiki/Xen4.0 

1. Install Linux distro 2. Install Xen hypervisor package 3. Install a dom0 kernel (packages available for many distros) 4. Modify GRUB configuration to boot Xen hypervisor instead Result: A working Xen hypervisor and "Xen Light" installation

Page 36: Xen and XCP Tutorial

Installing XCP

1. Download latest XCP ISO:             http://xen.org/download/xcp/index.html   2. Boot from ISO and proceed through XCP installer

Result: A ready-to-go Xen hypervisor, dom0, XAPI

Page 37: Xen and XCP Tutorial

Xen Cloud PlatformConcepts

Pools, hosts, storage, networks, VMs

Page 38: Xen and XCP Tutorial

Xen Cloud Platform (XCP)

• XCP was originally derived from Citrix XenServer (a free enterprise product), is open-source, and is free

 • XCP promises to contain cutting-edge features that will drive

future developments of Citrix XenServer

Page 39: Xen and XCP Tutorial

Xen Cloud Platform (XCP)

• Again, XCP includes:o Open-source Xen hypervisoro Enterprise-level XenAPI (XAPI) management tool stacko Support for Open vSwitch (open-source, standards-compliant

virtual switch)

Page 40: Xen and XCP Tutorial

XCP Features

• Fully-signed Windows PV drivers • Heterogeneous machine resource pool support

 • Installation by templates for many different guest OSes

Page 41: Xen and XCP Tutorial

XCP XenAPI Management Tool Stack• VM lifecycle: live snapshots, checkpoint, migration

 • Resource pools: live relocation, auto configuration, disaster

recovery • Flexible storage, networking, and power management

 • Event tracking: progress, notification

  • Upgrade and patching capabilities

 • Real-time performance monitoring and alerting

Page 42: Xen and XCP Tutorial

XCP's xsconsole (SSH or Local)

Page 43: Xen and XCP Tutorial

XCP's XAPI Viewer

Page 44: Xen and XCP Tutorial

XCP Command Line Interface (CLI)

# xe template-list        (or   # xe vm-import filename=lenny.xva )

# xe vm-install template=<template> new-name-label=<name>

# xe vm-param-set uuid=<uuid of new VM> other-config:install-repository=http://ftp.debian.org/

#xe network-list

#xe vif-create network-uuid=<network uuid from above> vm-uuid=<uuid of new VM> device=0

# xe vm-start vm=<name of VM>

Page 45: Xen and XCP Tutorial

Further Information

• http://pdub.net/2011/12/03/howto-install-xcp-in-kvm/• ...

Page 46: Xen and XCP Tutorial

Useful Resources and References

Community:• Xen Mailing List: http://www.xen.org/community/• Xen Wiki: http://wiki.xensource.com/xenwiki/• Xen Blog: http://blog.xen.org• http://wiki.xensource.com/xenwiki/XenCommonProblems

 Books:• The Definitive Guide to the Xen Hypervisor• Running Xen: A Hands-On Guide to the Art of Virtualization

 Discussion:• http://www.xen.org/community/xenpapers.html• Abstracts, slides, and videos from Xen Summits• http://pcisecuritystandards.org/organization_info/special_interest_groups.php