Xen v3.0 用户手册

1. Introduction(介绍)

Xen is an open-source para-virtualizing virtual machine monitor (VMM), or ``hypervisor'', for the x86 processor architecture. Xen can securely execute multiple virtual machines on a single physical system with close-to-native performance. Xen facilitates enterprise-grade functionality, including:

Xen 是一个开放源代码的para-virtualizing虚拟机(VMM),或管理程序,是为x86架构的机器而设计的。Xen 可以在一套物理硬件上安全的执行多个虚拟机

  • Virtual machines with performance close to native hardware. (虚拟机的性能更接近真实硬件环境)

  • Live migration of running virtual machines between physical hosts. (在真实物理环境的平台和虚拟平台间自由切换)

  • Up to 32 virtual CPUs per guest virtual machine, with VCPU hotplug.(在每个客户虚拟机支持到 32个虚拟CPU,通过 VCPU热插拔)

  • x86/32, x86/32 with PAE, and x86/64 platform support.x86/32,支持PAE指令集的x86/32, x86/64平台)

  • Intel Virtualization Technology (VT-x) for unmodified guest operating systems (including Microsoft Windows).(通过Intel 虚拟支持VT的支持来用虚拟原始操作系统(未经修改的)支持(包括Microsoft Windows

  • Excellent hardware support (supports almost all Linux device drivers).(优秀的硬件支持.支持几乎所有的Linux设备驱动)

1.1 Usage Scenarios(应用范围)

Usage scenarios for Xen include:
Xen
的应用范围包括:

Server Consolidation. (服务器整合)

Move multiple servers onto a single physical host with performance and fault isolation provided at the virtual machine boundaries.

在虚拟机范围内,在一台物理主机上安装多个服务器, 用于演示及故障隔绝。

Hardware Independence.(无硬件依赖)

Allow legacy applications and operating systems to exploit new hardware.(允许应用程序和操作系统对新硬件的移值测试)

Multiple OS configurations.(多操作系统配置)

Run multiple operating systems simultaneously, for development or testing purposes.(以开发和测试为目的,同时运行多个操作系统)

Kernel Development.(内核开发)

Test and debug kernel modifications in a sand-boxed virtual machine -- no need for a separate test machine.(在虚拟机的沙盒中,做内核的测试和调试,无需为了测试而半独架设一台独立的机器)

Cluster Computing.(集群运算)

Management at VM granularity provides more flexibility than separately managing each physical host, but better control and isolation than single-system image solutions, particularly by using live migration for load balancing. (和单独的管理每个物理主机相比较,VM级管理更加灵活,在负载均衡方面,更易于控制,和隔离).

Hardware support for custom OSes.(为客户操作系统提供硬件技术支持)

Allow development of new OSes while benefiting from the wide-ranging hardware support of existing OSes such as Linux. (可以开发新的操作系统, 以得益于现存操作系统的广泛硬件支持,比如Linux.

1.2 Operating System Support (操作系统支持)

Para-virtualization permits very high performance virtualization, even on architectures like x86 that are traditionally very hard to virtualize.

This approach requires operating systems to be ported to run on Xen. Porting an OS to run on Xen is similar to supporting a new hardware platform, however the process is simplified because the para-virtual machine architecture is very similar to the underlying native hardware. Even though operating system kernels must explicitly support Xen, a key feature is that user space applications and libraries do not require modification.

With hardware CPU virtualization as provided by Intel VT and AMD SVM technology, the ability to run an unmodified guest OS kernel is available. No porting of the OS is required, although some additional driver support is necessary within Xen itself. Unlike traditional full virtualization hypervisors, which suffer a tremendous performance overhead, the combination of Xen and VT or Xen and Pacifica technology complement one another to offer superb performance for para-virtualized guest operating systems and full support for unmodified guests running natively on the processor. Full support for VT and Pacifica chipsets will appear in early 2006.

Paravirtualized Xen support is available for increasingly many operating systems: currently, mature Linux support is available and included in the standard distribution. Other OS ports--including NetBSD, FreeBSD and Solaris x86 v10--are nearing completion.

1.3 Hardware Support(硬件支持)

Xen currently runs on the x86 architecture, requiring a ``P6'' or newer processor (e.g. Pentium Pro, Celeron, PentiumII, PentiumIII, PentiumIV, Xeon, AMDAthlon, AMDDuron). Multiprocessor machines are supported, and there is support for HyperThreading (SMT). In addition, ports to IA64 and Power architectures are in progress.Xen

目前运行在x86架构的机器上,需要P6或更新的处理器(比如 Pentium Pro, Celeron, PentiumII, PentiumIII, PentiumIV, Xeon, AMDAthlon, AMDDuron)。支持多处理器,并且支持超线程(SMT)。另外对IA64Power架构的开发也在进行中。

The default 32-bit Xen supports up to 4GB of memory. However Xen 3.0 adds support for Intel's Physical Addressing Extensions (PAE), which enable x86/32 machines to address up to 64 GB of physical memory. Xen 3.0 also supports x86/64 platforms such as Intel EM64T and AMD Opteron which can currently address up to 1TB of physical memory.

32Xen支持最大4GB内存。可是Xen 3.0 Intel处理器物理指令集(PAE)提供支持,这样就能使x86/32架构的机器支持到64GB的物理内存。Xen 3.0也能支持x86/64 平台支持,比如 Intel EM64T AMD Opteron能支持1TB的物理 内存以上;

Xen offloads most of the hardware support issues to the guest OS running in the Domain0 management virtual machine. Xen itself contains only the code required to detect and start secondary processors, set up interrupt routing, and perform PCI bus enumeration. Device drivers run within a privileged guest OS rather than within Xen itself. This approach provides compatibility with the majority of device hardware supported by Linux. The default XenLinux build contains support for most server-class network and disk hardware, but you can add support for other hardware by configuring your XenLinux kernel in the normal way.

1.4 Structure of a Xen-Based System(基于Xen的操作系统架构)

A Xen system has multiple layers, the lowest and most privileged of which is Xen itself.

一个Xen系统拥有多个层,最底层和最高特权层是 Xen程序本身。

Xen may host multiple guest operating systems, each of which is executed within a secure virtual machine. In Xen terminology, a domain. Domains are scheduled by Xen to make effective use of the available physical CPUs. Each guest OS manages its own applications. This management includes the responsibility of scheduling each application within the time allotted to the VM by Xen.

Xen 可以管理多个客户操作系统,每个操作系统都能在一个安全的虚拟机中实现。在Xen的术语中,DomainXen控制,以高效的利用CPU的物理资源。每个客户操作系统可以管理它自身的应用。这种管理包括每个程序在规定时间内的响应到执行,是通过Xen调度到虚拟机中实现。

The first domain, domain0, is created automatically when the system boots and has special management privileges. Domain0 builds other domains and manages their virtual devices. It also performs administrative tasks such as suspending, resuming and migrating other virtual machines.

第一个domain,也就是domain 0(注:其实它就是第一个虚拟的客户系统),是在系统引导时自动创建,它拥有特殊的管理权限。Domain 0 可以构建其它的更多的Domain ,并管理虚拟设备。它还能执行管理任务,比如虚拟机的体眠、唤醒和迁移其它虚拟机。

Within domain0, a process called xend runs to manage the system. Xend is responsible for managing virtual machines and providing access to their consoles. Commands are issued to xend over an HTTP interface, via a command-line tool.

一个被称为xend的服务器进程通过domain 0来管理系统,Xend 负责管理众多的虚拟主机,并且提供进入这些系统的控制台。命令经一个命令行的工具通过一个HTTP的接口被传送到xend

1.5 History(历史)

Xen was originally developed by the Systems Research Group at the University of Cambridge Computer Laboratory as part of the XenoServers project, funded by the UK-EPSRC.

XenoServers aim to provide a ``public infrastructure for global distributed computing''. Xen plays a key part in that, allowing one to efficiently partition a single machine to enable multiple independent clients to run their operating systems and applications in an environment. This environment provides protection, resource isolation and accounting. The project web page contains further information along with pointers to papers and technical reports: http://www.cl.cam.ac.uk/xeno

Xen has grown into a fully-fledged project in its own right, enabling us to investigate interesting research issues regarding the best techniques for virtualizing resources such as the CPU, memory, disk and network. Project contributors now include XenSource, Intel, IBM, HP, AMD, Novell, RedHat.

Xen was first described in a paper presented at SOSP in <rtx w:st="on">2003<a name="tex2html1"></a></rtx>1.1, and the first public release (1.0) was made that October. Since then, Xen has significantly matured and is now used in production scenarios on many sites.

1.6 What's New(最新特性)

Xen <chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">3.0.0</chsdate> offersXen 3.0.0 拥有):

  • Support for up to 32-way SMP guest operating systems (支持最多32路的处理器的客户虚拟系统)

  • Intel (Physical Addressing Extensions) PAE to support 32-bit servers with more than 4GB physical memory

  • x86/64 support (Intel EM64T, AMD Opteron)

  • Intel VT-x support to enable the running of unmodified guest operating systems (Windows XP/<rtx w:st="on">2003</rtx>, Legacy Linux)

  • Enhanced control tools

  • Improved ACPI support

  • AGP/DRM graphics

Xen 3.0 features greatly enhanced hardware support, configuration flexibility, usability and a larger complement of supported operating systems. This latest release takes Xen a step closer to being the definitive open source solution for virtualization.

1 Installation(安装)

2. Basic Installation(基础安装)

The Xen distribution includes three main components: Xen itself, ports of Linux and NetBSD to run on Xen, and the userspace tools required to manage a Xen-based system. This chapter describes how to install the Xen3.0 distribution from source. Alternatively, there may be pre-built packages available as part of your operating system distribution.

Xen 发行版包括三个主要的部件:Xen本身,在Xen上运行LinuxNetBSD的接口,及管理基于Xen的系统的用户工具。这一节我们讲述以源代码的安装方式安装Xen 3.0 。当然,您也可以根据您所用的发行版来选择已经预编译好的Xen的软件包


2.1 Prerequisites
 (准备工作)

The following is a full list of prerequisites. Items marked `<shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></path><lock aspectratio="t" v:ext="edit"></lock></shapetype><shape id="_x0000_i1025" style="WIDTH: 9pt; HEIGHT: 24pt" alt="$\dag $" type="#_x0000_t75"><imagedata o:href="http://www.linuxsir.org/main/doc/Xen3man/img2.png" src="file:///C:%5CDOCUME~1%5Czouzhen%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image001.gif"></imagedata></shape>' are required by the xend control tools, and hence required if you want to run more than one virtual machine; items marked `*' are only required if you wish to build from source.

$$

A working Linux distribution using the GRUB bootloader and running on a P6-class or newer CPU.(用GRUB的导Linux系统,并且运行在一个 P6级或更新的 CPU机器上)

<shape id="_x0000_i1026" style="WIDTH: 9pt; HEIGHT: 24pt" alt="$\dag $" type="#_x0000_t75"><imagedata o:href="http://www.linuxsir.org/main/doc/Xen3man/img2.png" src="file:///C:%5CDOCUME~1%5Czouzhen%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image001.gif"></imagedata></shape>

The iproute2 packageiproute2软件包

<shape id="_x0000_i1028" style="WIDTH: 9pt; HEIGHT: 24pt" alt="$\dag $" type="#_x0000_t75"><imagedata o:href="http://www.linuxsir.org/main/doc/Xen3man/img2.png" src="file:///C:%5CDOCUME~1%5Czouzhen%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image001.gif"></imagedata></shape>

The Linux bridge-utilsLinux桥接工具 )2.1 (e.g., /sbin/brctl)

<shape id="_x0000_i1027" style="WIDTH: 9pt; HEIGHT: 24pt" alt="$\dag $" type="#_x0000_t75"><imagedata o:href="http://www.linuxsir.org/main/doc/Xen3man/img2.png" src="file:///C:%5CDOCUME~1%5Czouzhen%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image001.gif"></imagedata></shape>

The Linux hotplug system2.2 (e.g., /sbin/hotplug and related scripts). On newer distributions, this is included alongside the Linux udev system2.3.

*

Build tools (gcc v3.2.x or v3.3.x, binutils, GNU make). {编译工具(gcc v3.2 v3.3.x binutilsGNU make)

*

Development installation of zlib (e.g., zlib-dev).zlib的开发库(例如zlib-dev)}

*

Development installation of Python v2.2 or later (e.g., python-dev).Python v2.2 或高于v2.2的版本的开发库(比如 python-dev)}

*

LATEX and transfig are required to build the documentation.

Once you have satisfied these prerequisites, you can now install either a binary or source distribution of Xen.

一旦您已经做好这些准备工作,您现在可以通过二进制包或源码包来安装Xen

2.2 Installing from Binary Tarball(通过二进制软件包安装)

Pre-built tarballs are available for download from the XenSource downloads page:
可以到XenSource 下载预编译好的二进制包,下载地址发下:

http://www.xensource.com/downloads/

Once you've downloaded the tarball, simply unpack and install:
一旦您下载了软件包,就可以轻松的解压和安装:

# tar zxvf xen-3.0-install.tgz
# cd xen-3.0-install
# sh ./install.sh

Once you've installed the binaries you need to configure your system as described in Section2.5.
一旦您已经安装了二进制包,您需要配置您的系统,请参考 2.5的章节

2.3 Installing from RPMsRPM包安装

Pre-built RPMs are available for download from the XenSource downloads page:
可以到XenSource 下载预编译好的RPM 包,下载地址发下:

http://www.xensource.com/downloads/

Once you've downloaded the RPMs, you typically install them via the RPM commands:
一旦您下载了RPM包,可以通过RPM的管理工具来安装他们:

# rpm -iv rpmname

See the instructions and the Release Notes for each RPM set referenced at:
这里提供了每个相关RPM的介绍和发行说明

http://www.xensource.com/downloads/.

2.4 Installing from Source(通过源码包安装)

This section describes how to obtain, build and install Xen from source.
这一节主要介绍如何获取源码包并进行编译和安装;

<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899"><span style="mso-bookmark: SECTION02141000000000000000"><strong><span lang="EN-US" style="LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">2.4.1</span></strong></span></chsdate> Obtaining the Source(获取源码包)

The Xen source tree is available as either a compressed source tarball or as a clone of our master Mercurial repository.

Obtaining the Source Tarball(获取源码包)


Stable versions and daily snapshots of the Xen source tree are available from the Xen download page:

稳定版和开发版的每日快照下载页:

http://www.xensource.com/downloads/

Obtaining the source via Mercurial(通过Mercurial获取源代码)


The source tree may also be obtained via the public Mercurial repository at:

可以使用公共 Mercurial库从以下地址获取代码树:

http://xenbits.xensource.com

See the instructions and the Getting Started Guide referenced at(获取介绍和指导手册):

http://www.xensource.com/downloads/

<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899"><span style="mso-bookmark: SECTION02142000000000000000"><strong><span lang="EN-US" style="LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">2.4.2</span></strong></span></chsdate> Building from Source(从源码包编译安装)

The top-level Xen Makefile includes a target ``world'' that will do the following:

  • Build Xen

  • 编译Xen

  • Build the control tools, including xend

  • 编译控制工具,包括xend

  • Download (if necessary) and unpack the Linux 2.6 source code, and patch it for use with Xen.

  • 下载Linux 2.6内核源码,并且为内核打补丁

  • Build a Linux kernel to use in domain0 and a smaller unprivileged kernel, which can be used for unprivileged virtual machines.

  • 编译一个 Linux的内核,主要是用于domain 0 ,并且是一个比较小的无特权的内核。它能用于无特权的虚拟机;

After the build has completed you should have a top-level directory called dist/ in which all resulting targets will be placed. Of particular interest are the two XenLinux kernel images, one with a ``-xen0'' extension which contains hardware device drivers and drivers for Xen's virtual devices, and one with a ``-xenU'' extension that just contains the virtual ones. These are found in dist/install/boot/ along with the image for Xen itself and the configuration files used during the build.

内核编译完成后,您应该有一个顶级目录dist/,所有的编译好的包将放在这里。总共有两个内核,一个是文件名带有"_xen0"的,它包括硬件设备驱动和Xen虚拟设备。另一个内核文件扩展名带有"_xenU"的,这个内核包括虚拟设备。这些文件连同Xen本身及编译过程中所需要的配置文件位于 dist/install/boot目录中

To customize the set of kernels built you need to edit the top-level Makefile. Look for the line:

为了自定义内核配置,您需要编辑顶级目录的 Makefile 。看起来象下面的一行;

KERNELS ?= linux-2.6-xen0 linux-2.6-xenU

You can edit this line to include any set of operating system kernels which have configurations in the top-level buildconfigs/ directory.
您可以把这行加入到操作系统本身拥有的内核配置文件中,此文件位于 buildconfigs/目录;

<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899"><span style="mso-bookmark: SECTION02143000000000000000"><strong><span lang="EN-US" style="LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">2.4.3</span></strong></span></chsdate> Custom Kernels自义义内核

If you wish to build a customized XenLinux kernel (e.g. to support additional devices or enable distribution-required features), you can use the standard Linux configuration mechanisms, specifying that the architecture being built for is xen, e.g:
如果您想自定义编译XenLinuxmw 内核(比如支持附加设备或打开发行版的一些特性或功能),您可以用标准的Linux内核配置文件

# cd linux-<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">2.6.12</chsdate>-xen0
# make ARCH=xen xconfig
# cd ..
# make

You can also copy an existing Linux configuration (.config) into e.g. linux-<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">2.6.12</chsdate>-xen0 and execute:
您也可以复制已有的Linux发行版的内核配置文件。比如Linux- 2.6.12-xen0,然后执行:

# make ARCH=xen oldconfig

You may be prompted with some Xen-specific options. We advise accepting the defaults for these options.
也可以启用一些Xen的特殊选项。我们建议您用默认的选项。

Note that the only difference between the two types of Linux kernels that are built is the configuration file used for each. The ``U'' suffixed (unprivileged) versions don't contain any of the physical hardware device drivers, leading to a 30% reduction in size; hence you may prefer these for your non-privileged domains. The ``0'' suffixed privileged versions can be used to boot the system, as well as in driver domains and unprivileged domains.

注意,编译出来的两个内核是不同的。文件名中带有U的,是无特权内核,这个是用来引导被虚拟的操作系统而用的,它不包括物理硬件的驱动等。而文件名中带有0的包括物理硬件的驱动,它才是被用于引导真实操作系统的内核。 

<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899"><span style="mso-bookmark: SECTION02144000000000000000"><strong><span lang="EN-US" style="LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">2.4.4</span></strong></span></chsdate> Installing Generated Binaries (安装已经编译好的二进制内核)

The files produced by the build process are stored under the dist/install/ directory. To install them in their default locations, do:
当编译好内核后,他们被存放在 dist/install/目录中。我们通过如下的命令来安装:

# make install

Alternatively, users with special installation requirements may wish to install them manually by copying the files to their appropriate destinations.

用户可以根据自己的需要做以手动复制到相应的目录,这一过程是可选的。

The dist/install/boot directory will also contain the config files used for building the XenLinux kernels, and also versions of Xen and XenLinux kernels that contain debug symbols such as (xen-syms-<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">3.0.0 a</chsdate>nd vmlinux-syms-2.6.12.6-xen0) which are essential for interpreting crash dumps. Retain these files as the developers may wish to see them if you post on the mailing list.

在目录 /dist/install/boot目录中,包含编译 XenLinux内核的配置文件config ,也包含XenLinux内核的debug链接文件,比如(xen-syms-<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">3.0.0</chsdate>vmlinux-syms-2.6.12.6 -xen0),当系统崩溃时,他们还是有必要的,因为做为开发者,他们需要这些崩溃纪录,您可以通过邮件列表发送给开发者。


2.5 Configuration
(配置)

Once you have built and installed the Xen distribution, it is simple to prepare the machine for booting and running Xen.
如果您编译并安装好了Xen的发行版,您要做一些准备工作,以让机器引导时运行Xen

<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899"><span style="mso-bookmark: SECTION02151000000000000000"><strong><span lang="EN-US" style="LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">2.5.1</span></strong></span></chsdate> GRUB ConfigurationGRUB的配置)

An entry should be added to grub.conf (often found under /boot/ or /boot/grub/) to allow Xen / XenLinux to boot. This file is sometimes called menu.lst, depending on your distribution. The entry should look something like the following:

编译好内核后,您应该修改grub.conf文件(这个文件大多是位于/boot/boot/grub目录中),目的是允许引导 Xen/XenLinux grub.conf有时也被称为menul.st 。在grub.confmenu.lst中应该加入类似下面的一段:

title Xen 3.0 / XenLinux 2.6
kernel /boot/xen-3.0.gz dom0_mem=262144
module /boot/vmlinuz-2.6-xen0 root=/dev/sda4 ro console=tty0

The kernel line tells GRUB where to find Xen itself and what boot parameters should be passed to it (in this case, setting the domain0 memory allocation in kilobytes and the settings for the serial port). For more details on the various Xen boot parameters see Section10.3.

kernel 一行告诉GRUB引导时能找到Xen,以及使用哪些引导参数(在这里,能设置domain 0所占用物理内存大小,其单位是kb,也能设置所占用的串口)。详细请参阅Xen 引导参数章节 10.3color: #3

你可能感兴趣的:(linux,虚拟机,python,配置管理,OS)