You are previewing Professional Xen® Virtualization.
O'Reilly logo
Professional Xen® Virtualization

Book Description

This book presents you with a complete foundation on the Xen technology and shows you how Xen virtualization offers faster response times for new server and service requests, a simplified system administration for multiple systems, and better availability for critical computing resources. Packed with detailed examples of Xen configuration files, system configuration files, and system-level configuration information, this book shows you why Xen virtualization is among the leading emerging technologies on the Linux platform and is being integrated into virtually every commercial distribution.

Table of Contents

  1. Copyright
  2. About the Author
  3. Credits
  4. Acknowledgments
  5. Introduction
    1. Who Should Read This Book
    2. What This Book Covers
    3. How This Book Is Organized
    4. What You Need To Use This Book
    5. Source Code
    6. Errata
    7. p2p.wrox.com
  6. 1. Overview of Virtualization
    1. 1.1. What Is Virtualization?
      1. 1.1.1. Application Virtualization
      2. 1.1.2. Desktop Virtualization
      3. 1.1.3. Network Virtualization
      4. 1.1.4. Server and Machine Virtualization
      5. 1.1.5. Storage Virtualization
      6. 1.1.6. System-Level or Operating System Virtualization
    2. 1.2. Why Virtualization Today?
    3. 1.3. Basic Approaches to Virtual Systems
    4. 1.4. Advantages of Virtualization
      1. 1.4.1. Better Use of Existing Hardware
      2. 1.4.2. Reduction in New Hardware Costs
      3. 1.4.3. Reduction in IT Infrastructure Costs
      4. 1.4.4. Simplified System Administration
      5. 1.4.5. Increased Uptime and Faster Failure Recovery
      6. 1.4.6. Simplified Capacity Expansion
      7. 1.4.7. Simpler Support for Legacy Systems and Applications
      8. 1.4.8. Simplified System-Level Development
      9. 1.4.9. Simplified System Installation and Deployment
      10. 1.4.10. Simplified System and Application Testing
    5. 1.5. Virtualization Caveats
      1. 1.5.1. Single Point of Failure Problems
      2. 1.5.2. Server Sharing and Performance Issues
      3. 1.5.3. Per-Server Network Congestion
      4. 1.5.4. Increase in Networking Complexity and Debugging Time
      5. 1.5.5. Increased Administrative Complexity
    6. 1.6. Identifying Candidates for Virtualization
    7. 1.7. Summary
  7. 2. Introduction to Xen
    1. 2.1. History of Xen
    2. 2.2. Overview of Xen and x86 Virtualization
      1. 2.2.1. X86 Protection Levels: One Ring to Rule Them All
      2. 2.2.2. X86 Protection Levels and Virtualization
    3. 2.3. Xen Domains and the Hypervisor
      1. 2.3.1. Interacting with the Hypervisor
      2. 2.3.2. Controlling Hypervisor Scheduling
      3. 2.3.3. Advanced Topics in Operating System Schedulers
    4. 2.4. Types of Virtual Machines Supported by Xen
      1. 2.4.1. Paravirtualized Systems
      2. 2.4.2. Unmodified Guest Systems
      3. 2.4.3. Combining 32-Bit and 64-Bit Kernels, Filesystems, and Applications
    5. 2.5. Popular Xen and Virtualization Resources on the Internet
    6. 2.6. Other Popular Virtualization Software
      1. 2.6.1. FreeVPS
      2. 2.6.2. Kernel Virtual Machine
      3. 2.6.3. Linux-VServer
      4. 2.6.4. Microsoft Virtual Server
      5. 2.6.5. OpenVZ/Virtuozzo
      6. 2.6.6. Parallels Workstation
      7. 2.6.7. paravirt ops
      8. 2.6.8. User-Mode Linux
      9. 2.6.9. Virtual Iron
      10. 2.6.10. VirtualBox
      11. 2.6.11. VMware
      12. 2.6.12. Win4Lin Virtual Desktop Server
      13. 2.6.13. XenSource
    7. 2.7. Popular Emulation Software
      1. 2.7.1. Microsoft Virtual PC
      2. 2.7.2. QEMU
    8. 2.8. Summary
  8. 3. Obtaining and Installing Xen
    1. 3.1. Hardware Requirements for Xen
      1. 3.1.1. Host System Hardware Requirements
      2. 3.1.2. Hardware Issues for Virtual Machines
    2. 3.2. Software Packages Required for Running Xen
    3. 3.3. Downloading and Installing Xen from Binaries
      1. 3.3.1. Getting and Installing Distribution-Specific Xen Packages
      2. 3.3.2. Commercial Xen Solutions
        1. 3.3.2.1. Downloading Binaries from XenSource
        2. 3.3.2.2. Evaluating XenSource Server Products
        3. 3.3.2.3. Evaluating Virtual Iron Products
    4. 3.4. Getting the Xen Source Code
      1. 3.4.1. Downloading Official Source Tarballs
      2. 3.4.2. Getting Xen Sources with Mercurial
      3. 3.4.3. Patching a Vanilla Linux Kernel for Xen
      4. 3.4.4. Configuring the Standard Xen Kernel Source
      5. 3.4.5. Xen Support in the Mainline Linux Kernel
    5. 3.5. Building Xen from Source Code
      1. 3.5.1. Software Requirements for Building Xen
      2. 3.5.2. Compiling Xen
    6. 3.6. Installing Xen
    7. 3.7. Summary
  9. 4. Booting and Configuring a Xen Host
    1. 4.1. Overview of Xen and Linux System Startup
      1. 4.1.1. BIOS Initialization and System Startup
      2. 4.1.2. GRUB
      3. 4.1.3. The Xen Boot and Initialization Process
      4. 4.1.4. Loading the Kernel and Optional RAM Disk
        1. 4.1.4.1. Loading and Using an Initial RAM Disk or RAM Filesystem
        2. 4.1.4.2. Comparing Initial RAM Disks and RAM-Based Filesystems
      5. 4.1.5. The Linux System Startup Process
        1. 4.1.5.1. System Runlevels
        2. 4.1.5.2. sysvinit System Initialization
        3. 4.1.5.3. upstart System Initialization
      6. 4.1.6. Xen-Related Startup Scripts and Processes
      7. 4.1.7. Capturing Xen and Linux Boot and Startup Information
    2. 4.2. Configuring GRUB for Xen
      1. 4.2.1. GRUB Boot Options for the Xen Hypervisor
      2. 4.2.2. Shared Xen and Linux Boot Options
      3. 4.2.3. Xen-Specific Linux Boot Options
    3. 4.3. Hiding PCI Devices from domain0
      1. 4.3.1. Locating the pciback Driver on Your System
      2. 4.3.2. Hiding a PCI Device Using Kernel Command-Line Arguments
      3. 4.3.3. Hiding a PCI Device Using a Loadable Kernel Module
    4. 4.4. Summary
  10. 5. Configuring and Booting Virtual Machines
    1. 5.1. Virtual Machine Requirements
      1. 5.1.1. Requirements for Paravirtualized Xen Guest Domains
      2. 5.1.2. Requirements for Xen Hardware Virtual Machines
    2. 5.2. Obtaining Sample Xen Filesystem Images
      1. 5.2.1. FreeOsZoo
      2. 5.2.2. Jailtime.org
      3. 5.2.3. rPath's rBuilder Online
        1. 5.2.3.1. Locating Xen Images on the rPath Site
        2. 5.2.3.2. Building Your Own Xen Images with rBuilder
    3. 5.3. Defining and Starting a Paravirtualized VM
      1. 5.3.1. Creating Xen Configuration Files for Paravirtualization
      2. 5.3.2. Integrating Loadable Kernel Modules into Your Root Filesystem
      3. 5.3.3. Checking Other Configuration Files in the Root Filesystem
      4. 5.3.4. Creating Initial RAM Disks and Filesystems for Your Kernel
      5. 5.3.5. Manually Starting Paravirtualized Xen Domains
    4. 5.4. Defining and Starting Xen Hardware Virtual Machines
      1. 5.4.1. Creating Xen HVM Configuration Files
      2. 5.4.2. Identifying Physical Resources for Xen Domains
      3. 5.4.3. Manually Starting HVM Xen Domains
    5. 5.5. Automatically Starting Xen Domains at Boot Time
    6. 5.6. Troubleshooting Configuration Files and Guest Domains
      1. 5.6.1. Troubleshooting Xen Configuration Files
      2. 5.6.2. Troubleshooting Xen VM Startup
      3. 5.6.3. Troubleshooting Virtual Machines
    7. 5.7. Summary
  11. 6. Building Filesystems for Virtual Machines
    1. 6.1. Linux Storage and Filesystems
      1. 6.1.1. Filesystem or Disk Images
      2. 6.1.2. Local Filesystems
      3. 6.1.3. RAID Storage
      4. 6.1.4. Logical Volumes
      5. 6.1.5. Network Filesystems
      6. 6.1.6. Networked Block-Level Storage
    2. 6.2. Filesystem Choices, Locations, and Flexibility
      1. 6.2.1. Single domain0 System Configuration
      2. 6.2.2. Running Multiple domain0 Systems
    3. 6.3. Building Virtual Machine Filesystems
      1. 6.3.1. Creating Filesystem Image Files
      2. 6.3.2. Creating Physical Partitions
      3. 6.3.3. Creating Logical Volumes
      4. 6.3.4. Creating a Filesystem in an Image File, Partition, or Logical Volume
      5. 6.3.5. Mounting an Image File, Partition, or Logical Volume
      6. 6.3.6. Creating Root Filesystems
        1. 6.3.6.1. Cloning Existing Root Filesystems
        2. 6.3.6.2. Using debootstrap on Debian and Ubuntu Systems
        3. 6.3.6.3. Using rpm and yum on Fedora, Red Hat and Similar Systems
        4. 6.3.6.4. Using yast2 on SUSE Linux Systems
        5. 6.3.6.5. Creating Root Filesystems for Use with NFS
        6. 6.3.6.6. Manually Creating Minimal Filesystems
    4. 6.4. Creating Swap Filesystems for Xen
    5. 6.5. Adding Applications to a Xen Root Filesystem
    6. 6.6. Creating and Using QEMU Disk Images
      1. 6.6.1. Creating a QEMU Disk Image
      2. 6.6.2. Installing a Paravirtualized domainU Guest
      3. 6.6.3. Manually Installing the Xen Kernel in a QEMU Disk
      4. 6.6.4. Using pygrub to Locate and Boot the Xen Kernel
    7. 6.7. Summary
  12. 7. Managing and Monitoring Virtual Machines
    1. 7.1. Overview of the Xen Daemon
      1. 7.1.1. Configuring the Xen Daemon
      2. 7.1.2. Xen Daemon Log Files
    2. 7.2. Using the xm Command
      1. 7.2.1. Getting Information About Virtual Machines
      2. 7.2.2. Starting Virtual Machines
      3. 7.2.3. Connecting and Disconnecting from Xen Domain Consoles
      4. 7.2.4. Adjusting Memory Use in Virtual Machines
      5. 7.2.5. Getting Xen System and Configuration Information
      6. 7.2.6. Common xm Errors
    3. 7.3. XenStore and Related Utilities
    4. 7.4. Xen Tracing and Performance Monitoring
      1. 7.4.1. XenMon
      2. 7.4.2. XenPerf
      3. 7.4.3. XenTop
      4. 7.4.4. XenTrace
    5. 7.5. Reporting Bugs in Xen
    6. 7.6. Open Source Xen Management Utilities
    7. 7.7. Distribution-Specific Xen Management Software
      1. 7.7.1. Fedora and Red Hat Xen Tools
      2. 7.7.2. SUSE Xen Tools
    8. 7.8. Summary
  13. 8. Xen Networking
    1. 8.1. Overview of Xen Networking
      1. 8.1.1. Virtual Network Interfaces
      2. 8.1.2. Bridged Networking
      3. 8.1.3. NAT Networking
      4. 8.1.4. Routed Networking
    2. 8.2. Specifying Parameters for Xen Network Startup
      1. 8.2.1. General Parameters for Xen Networking Startup
      2. 8.2.2. Parameters for domainU Networking Startup
    3. 8.3. Using Multiple Ethernet Cards with Xen
    4. 8.4. Virtual, Non-Routable Subnets for Xen Guests
    5. 8.5. Virtual LANs and Xen Guests
    6. 8.6. DHCP Tips for Xen Environments
    7. 8.7. Fine-Tuning Services on Xen Guests
      1. 8.7.1. Open Port and Active Server Minimization
      2. 8.7.2. Disabling xinetd-Based Network Services
    8. 8.8. Troubleshooting Xen Networking
    9. 8.9. Summary
  14. 9. Advanced Virtual Machine Configuration
    1. 9.1. domain0 and domainU Memory Management in Xen
      1. 9.1.1. Controlling domain0 Memory Use
      2. 9.1.2. Fine-Tuning Linux Memory Use
    2. 9.2. Accessing New and Removable Storage in domainU Guests
      1. 9.2.1. Mounting and Unmounting Additional Block Devices
      2. 9.2.2. Changing CDs and DVDs
    3. 9.3. Using Dedicated Hardware in Guest Domains
      1. 9.3.1. Using Dedicated PCI Devices in domainU Guests
      2. 9.3.2. Using USB Devices in domainU Guests
        1. 9.3.2.1. USB Pointer Device Support
        2. 9.3.2.2. Using USB Storage Device Partitions in PV Guests
        3. 9.3.2.3. Using USB Devices in HVM Guests
        4. 9.3.2.4. Using USB Devices Over the Network
    4. 9.4. Working with Sound on domainU Guests
    5. 9.5. Time Synchronization in domainO and domainU
    6. 9.6. domainO and domainU Kernel and Binary Considerations
      1. 9.6.1. Using Different Kernels for Different Domains
      2. 9.6.2. Running 32-Bit Paravirtualized Guests on 64-bit Hardware
    7. 9.7. The Many Moods of Graphics for domainU Guests
      1. 9.7.1. Using SDL and VNC Consoles for HVM Guests
      2. 9.7.2. Connecting to a Graphical Console Using VNC
      3. 9.7.3. The X Window System and Paravirtualized Guests
        1. 9.7.3.1. Starting a Graphical Console for a Paravirtualized Guest
        2. 9.7.3.2. Configuring and Starting an X Server in a Virtual Frame Buffer
        3. 9.7.3.3. Configuring and Starting a VNC X Server
        4. 9.7.3.4. X11 and Xen Tips and Tricks for VNC
    8. 9.8. Xen Lifecycle Management
    9. 9.9. Xen Access Control and Security Policies
      1. 9.9.1. Xen, Tools, and Package Requirements for Access Control
      2. 9.9.2. Creating an Access Control Policy
      3. 9.9.3. Deploying Policy Files
      4. 9.9.4. Associating Policies with domainU Guests
      5. 9.9.5. Labeling Resources
      6. 9.9.6. Removing Policies from a Xen System
    10. 9.10. Xen and Trusted Computing
      1. 9.10.1. Building Xen with TPM Support and Associated Tools
      2. 9.10.2. Requirements for Running the vTPM Manager
      3. 9.10.3. Starting the TPM Emulator
      4. 9.10.4. Starting the vTPM Manager
      5. 9.10.5. Adding vTPM Support to Guest Domains
      6. 9.10.6. Using the Virtual TPM in a domainU Guest
      7. 9.10.7. Troubleshooting
    11. 9.11. Summary
  15. 10. Using Xen in the Data Center
    1. 10.1. Documenting Your Virtual Machines
    2. 10.2. Deploying Virtual Machines
      1. 10.2.1. Preparing for Automation
      2. 10.2.2. Configuring and Using the xendomains Init Script
        1. 10.2.2.1. VM Startup Configuration Options
        2. 10.2.2.2. VM Shutdown Configuration Options
        3. 10.2.2.3. VM Migration Configuration Options
        4. 10.2.2.4. xendomains Startup Sequence
        5. 10.2.2.5. xendomains Shutdown Sequence
      3. 10.2.3. Clean VM Shutdown and Faster Startup
        1. 10.2.3.1. Overview of Filesystem Consistency
        2. 10.2.3.2. Automating VM Filesystem Consistency Checks
      4. 10.2.4. Saving Xen Domain State
      5. 10.2.5. Migrating Virtual Machines for High Availability
    3. 10.3. Centralized Logging for Virtual Machines
      1. 10.3.1. Configuring syslogd or sysklogd to Receive Networked Log Messages
      2. 10.3.2. Configuring Networked Log Message Targets for syslogd or sysklogd
      3. 10.3.3. Configuring syslog-ng to Receive Networked Log Messages
      4. 10.3.4. Configuring Log Message Targets for syslog-ng
      5. 10.3.5. System Logging for Microsoft Windows Systems
    4. 10.4. Centralized Warning Systems for Virtual Machines
    5. 10.5. Backup Strategies for Xen Domains
      1. 10.5.1. Selecting a Backup Target
      2. 10.5.2. Identifying and Minimizing Backup Load
      3. 10.5.3. Backing Up Selected Files and Directories Using rsync
      4. 10.5.4. Backing Up Logical Volumes Using Snapshots
      5. 10.5.5. Backing Up Filesystems over the Network
        1. 10.5.5.1. Installing and Configuring BackupPC
        2. 10.5.5.2. Identifying Hosts to Back Up
        3. 10.5.5.3. Defining a Backup Using rsyncd
        4. 10.5.5.4. Defining a Backup Using SMB
        5. 10.5.5.5. Starting Backups in BackupPC
        6. 10.5.5.6. Restoring from Backups in BackupPC
    6. 10.6. Summary
  16. A. xm Command and Option Reference
    1. A.1. addlabel: Add a Security Label to a Domain or Resource
    2. A.2. block-attach: Create a New Virtual Block Device
    3. A.3. block-configure: Change Block Device Configuration
    4. A.4. block-detach: Destroy a Domain's Virtual Block Device
    5. A.5. block-list: List Virtual Block Devices for a Domain
    6. A.6. cfgbootpolicy: Add Policy to Boot Configuration
    7. A.7. console: Attach to <Domain>'s Console
    8. A.8. create: Create a Domain Based on a Configuration File
    9. A.9. debug-keys: Send Debug Keys to Xen
    10. A.10. delete: Remove a Domain from xend Domain Management
    11. A.11. destroy: Terminate a Domain Immediately
    12. A.12. dmesg: Read and Optionally Clean the Xen Daemon Message Buffer
    13. A.13. domid: Convert a Domain Name to a Domain ID
    14. A.14. domname: Convert a Domain ID to a Domain Name
    15. A.15. dry-run: Test If a Domain Can Access Its Resources
    16. A.16. dump-core: Dump the Core for a Specific Domain
    17. A.17. dumppolicy: Print Hypervisor ACM State Information
    18. A.18. getlabel: Show the Security Label for a Domain or Resource
    19. A.19. help: Display Information about xm Subcommands
    20. A.20. info: Get Information about a Xen Host
    21. A.21. labels: List Labels for an Active Policy
    22. A.22. list: List Information about All or Some Domains
    23. A.23. loadpolicy: Load a Binary Policy Into a Hypervisor
    24. A.24. log: Print the xend Log
    25. A.25. makepolicy: Build Policy and Create .bin and .map Files
    26. A.26. mem-max: Set the Maximum Amount Reservation for a Domain
    27. A.27. mem-set: Set the Current Memory Usage for a Domain
    28. A.28. migrate: Migrate a Domain to Another Machine
    29. A.29. network-attach: Create a New Virtual Network Device
    30. A.30. network-detach: Destroy a Domain's Virtual Network Device
    31. A.31. network-list: List Virtual Network Interfaces for a Domain
    32. A.32. new: Add a Domain to xend Domain Management
    33. A.33. pause: Pause the Execution of a Domain
    34. A.34. reboot: Reboot a Domain
    35. A.35. rename: Rename a Domain
    36. A.36. resources: Show Information for Each Labeled Resource
    37. A.37. restore: Restore a Domain From a Saved State
    38. A.38. resume: Resume a xend Managed Domain
    39. A.39. rmlabel: Remove a Security Label from a Domain
    40. A.40. save: Save a Domain State to Restore Later
    41. A.41. sched-credit: Get/Set Credit Scheduler Parameters
    42. A.42. sched-sedf: Get/Set SEDF Scheduler Parameters
    43. A.43. serve: Proxy xend XML-RPC over stdio
    44. A.44. shell: Launch an Interactive Shell
    45. A.45. shutdown: Shutdown a Domain
    46. A.46. start: Start a xend-managed Domain
    47. A.47. suspend: Suspend a xend-managed Domain
    48. A.48. sysrq: Send a System Request to a Domain
    49. A.49. top: Monitor a Host and the Domains in Real Time
    50. A.50. trigger: Send a Trigger to a Domain
    51. A.51. unpause: Unpause a Paused Domain
    52. A.52. uptime: Print Uptime for a Domain
    53. A.53. vcpu-list: List the VCPUs for a Domain or All Domains
    54. A.54. vcpu-pin: Assign VCPUs to a CPU
    55. A.55. vcpu-set: Set the Number of Active VCPUs Allowed for a Domain
    56. A.56. vnet-create: Create a vnet from a Configuration File
    57. A.57. vnet-delete: Delete a vnet
    58. A.58. vnet-list: List vnets
    59. A.59. vtpm-list: List Virtual TPM Devices
  17. B. Xen Virtual Machine Configuration File Reference