view docs/src/user.tex @ 10470:411a3c01bb40

[XEN] Xen always relinquishes VGA console to domain0 when domain0
starts to boot (previous behaviour looked for console=tty0 on
dom0's command line). To prevent this 'console=vga[keep]' must
be specified.
Signed-off-by: Keir Fraser <>
date Tue Jun 20 18:51:46 2006 +0100 (2006-06-20)
parents 6d476981e3a5
children 5f5d400eb60a
line source
1 \documentclass[11pt,twoside,final,openright]{report}
2 \usepackage{a4,graphicx,html,parskip,setspace,times,xspace,url}
3 \setstretch{1.15}
5 \renewcommand{\ttdefault}{pcr}
7 \def\Xend{{Xend}\xspace}
8 \def\xend{{xend}\xspace}
10 \latexhtml{\renewcommand{\path}[1]{{\small {\tt #1}}}}{\renewcommand{\path}[1]{{\tt #1}}}
13 \begin{document}
16 \pagestyle{empty}
17 \begin{center}
18 \vspace*{\fill}
19 \includegraphics{figs/xenlogo.eps}
20 \vfill
21 \vfill
22 \vfill
23 \begin{tabular}{l}
24 {\Huge \bf Users' Manual} \\[4mm]
25 {\huge Xen v3.0} \\[80mm]
26 \end{tabular}
27 \end{center}
29 {\bf DISCLAIMER: This documentation is always under active development
30 and as such there may be mistakes and omissions --- watch out for
31 these and please report any you find to the developers' mailing list,
32 The latest version is always available
33 on-line. Contributions of material, suggestions and corrections are
34 welcome.}
36 \vfill
37 \clearpage
41 \pagestyle{empty}
43 \vspace*{\fill}
45 Xen is Copyright \copyright 2002-2005, University of Cambridge, UK, XenSource
46 Inc., IBM Corp., Hewlett-Packard Co., Intel Corp., AMD Inc., and others. All
47 rights reserved.
49 Xen is an open-source project. Most portions of Xen are licensed for copying
50 under the terms of the GNU General Public License, version 2. Other portions
51 are licensed under the terms of the GNU Lesser General Public License, the
52 Zope Public License 2.0, or under ``BSD-style'' licenses. Please refer to the
53 COPYING file for details.
55 Xen includes software by Christopher Clark. This software is covered by the
56 following licence:
58 \begin{quote}
59 Copyright (c) 2002, Christopher Clark. All rights reserved.
61 Redistribution and use in source and binary forms, with or without
62 modification, are permitted provided that the following conditions are met:
64 \begin{itemize}
65 \item Redistributions of source code must retain the above copyright notice,
66 this list of conditions and the following disclaimer.
68 \item Redistributions in binary form must reproduce the above copyright
69 notice, this list of conditions and the following disclaimer in the
70 documentation and/or other materials provided with the distribution.
72 \item Neither the name of the original author; nor the names of any
73 contributors may be used to endorse or promote products derived from this
74 software without specific prior written permission.
75 \end{itemize}
87 \end{quote}
89 \cleardoublepage
93 \pagestyle{plain}
94 \pagenumbering{roman}
95 { \parskip 0pt plus 1pt
96 \tableofcontents }
97 \cleardoublepage
101 \pagenumbering{arabic}
102 \raggedbottom
103 \widowpenalty=10000
104 \clubpenalty=10000
105 \parindent=0pt
106 \parskip=5pt
107 \renewcommand{\topfraction}{.8}
108 \renewcommand{\bottomfraction}{.8}
109 \renewcommand{\textfraction}{.2}
110 \renewcommand{\floatpagefraction}{.8}
111 \setstretch{1.1}
114 %% Chapter Introduction moved to introduction.tex
115 \chapter{Introduction}
118 Xen is an open-source \emph{para-virtualizing} virtual machine monitor
119 (VMM), or ``hypervisor'', for the x86 processor architecture. Xen can
120 securely execute multiple virtual machines on a single physical system
121 with close-to-native performance. Xen facilitates enterprise-grade
122 functionality, including:
124 \begin{itemize}
125 \item Virtual machines with performance close to native hardware.
126 \item Live migration of running virtual machines between physical hosts.
127 \item Up to 32 virtual CPUs per guest virtual machine, with VCPU hotplug.
128 \item x86/32, x86/32 with PAE, and x86/64 platform support.
129 \item Intel Virtualization Technology (VT-x) for unmodified guest operating systems (including Microsoft Windows).
130 \item Excellent hardware support (supports almost all Linux device
131 drivers).
132 \end{itemize}
135 \section{Usage Scenarios}
137 Usage scenarios for Xen include:
139 \begin{description}
140 \item [Server Consolidation.] Move multiple servers onto a single
141 physical host with performance and fault isolation provided at the
142 virtual machine boundaries.
143 \item [Hardware Independence.] Allow legacy applications and operating
144 systems to exploit new hardware.
145 \item [Multiple OS configurations.] Run multiple operating systems
146 simultaneously, for development or testing purposes.
147 \item [Kernel Development.] Test and debug kernel modifications in a
148 sand-boxed virtual machine --- no need for a separate test machine.
149 \item [Cluster Computing.] Management at VM granularity provides more
150 flexibility than separately managing each physical host, but better
151 control and isolation than single-system image solutions,
152 particularly by using live migration for load balancing.
153 \item [Hardware support for custom OSes.] Allow development of new
154 OSes while benefiting from the wide-ranging hardware support of
155 existing OSes such as Linux.
156 \end{description}
159 \section{Operating System Support}
161 Para-virtualization permits very high performance virtualization, even
162 on architectures like x86 that are traditionally very hard to
163 virtualize.
165 This approach requires operating systems to be \emph{ported} to run on
166 Xen. Porting an OS to run on Xen is similar to supporting a new
167 hardware platform, however the process is simplified because the
168 para-virtual machine architecture is very similar to the underlying
169 native hardware. Even though operating system kernels must explicitly
170 support Xen, a key feature is that user space applications and
171 libraries \emph{do not} require modification.
173 With hardware CPU virtualization as provided by Intel VT and AMD
174 SVM technology, the ability to run an unmodified guest OS kernel
175 is available. No porting of the OS is required, although some
176 additional driver support is necessary within Xen itself. Unlike
177 traditional full virtualization hypervisors, which suffer a tremendous
178 performance overhead, the combination of Xen and VT or Xen and
179 Pacifica technology complement one another to offer superb performance
180 for para-virtualized guest operating systems and full support for
181 unmodified guests running natively on the processor. Full support for
182 VT and Pacifica chipsets will appear in early 2006.
184 Paravirtualized Xen support is available for increasingly many
185 operating systems: currently, mature Linux support is available and
186 included in the standard distribution. Other OS ports---including
187 NetBSD, FreeBSD and Solaris x86 v10---are nearing completion.
190 \section{Hardware Support}
192 Xen currently runs on the x86 architecture, requiring a ``P6'' or
193 newer processor (e.g.\ Pentium Pro, Celeron, Pentium~II, Pentium~III,
194 Pentium~IV, Xeon, AMD~Athlon, AMD~Duron). Multiprocessor machines are
195 supported, and there is support for HyperThreading (SMT). In
196 addition, ports to IA64 and Power architectures are in progress.
198 The default 32-bit Xen supports up to 4GB of memory. However Xen 3.0
199 adds support for Intel's Physical Addressing Extensions (PAE), which
200 enable x86/32 machines to address up to 64 GB of physical memory. Xen
201 3.0 also supports x86/64 platforms such as Intel EM64T and AMD Opteron
202 which can currently address up to 1TB of physical memory.
204 Xen offloads most of the hardware support issues to the guest OS
205 running in the \emph{Domain~0} management virtual machine. Xen itself
206 contains only the code required to detect and start secondary
207 processors, set up interrupt routing, and perform PCI bus
208 enumeration. Device drivers run within a privileged guest OS rather
209 than within Xen itself. This approach provides compatibility with the
210 majority of device hardware supported by Linux. The default XenLinux
211 build contains support for most server-class network and disk
212 hardware, but you can add support for other hardware by configuring
213 your XenLinux kernel in the normal way.
216 \section{Structure of a Xen-Based System}
218 A Xen system has multiple layers, the lowest and most privileged of
219 which is Xen itself.
221 Xen may host multiple \emph{guest} operating systems, each of which is
222 executed within a secure virtual machine. In Xen terminology, a
223 \emph{domain}. Domains are scheduled by Xen to make effective use of the
224 available physical CPUs. Each guest OS manages its own applications.
225 This management includes the responsibility of scheduling each
226 application within the time allotted to the VM by Xen.
228 The first domain, \emph{domain~0}, is created automatically when the
229 system boots and has special management privileges. Domain~0 builds
230 other domains and manages their virtual devices. It also performs
231 administrative tasks such as suspending, resuming and migrating other
232 virtual machines.
234 Within domain~0, a process called \emph{xend} runs to manage the system.
235 \Xend\ is responsible for managing virtual machines and providing access
236 to their consoles. Commands are issued to \xend\ over an HTTP interface,
237 via a command-line tool.
240 \section{History}
242 Xen was originally developed by the Systems Research Group at the
243 University of Cambridge Computer Laboratory as part of the XenoServers
244 project, funded by the UK-EPSRC\@.
246 XenoServers aim to provide a ``public infrastructure for global
247 distributed computing''. Xen plays a key part in that, allowing one to
248 efficiently partition a single machine to enable multiple independent
249 clients to run their operating systems and applications in an
250 environment. This environment provides protection, resource isolation
251 and accounting. The project web page contains further information along
252 with pointers to papers and technical reports:
253 \path{}
255 Xen has grown into a fully-fledged project in its own right, enabling us
256 to investigate interesting research issues regarding the best techniques
257 for virtualizing resources such as the CPU, memory, disk and network.
258 Project contributors now include XenSource, Intel, IBM, HP, AMD, Novell,
259 RedHat.
261 Xen was first described in a paper presented at SOSP in
262 2003\footnote{\tt
263}, and the first
264 public release (1.0) was made that October. Since then, Xen has
265 significantly matured and is now used in production scenarios on many
266 sites.
268 \section{What's New}
270 Xen 3.0.0 offers:
272 \begin{itemize}
273 \item Support for up to 32-way SMP guest operating systems
274 \item Intel (Physical Addressing Extensions) PAE to support 32-bit
275 servers with more than 4GB physical memory
276 \item x86/64 support (Intel EM64T, AMD Opteron)
277 \item Intel VT-x support to enable the running of unmodified guest
278 operating systems (Windows XP/2003, Legacy Linux)
279 \item Enhanced control tools
280 \item Improved ACPI support
281 \item AGP/DRM graphics
282 \end{itemize}
285 Xen 3.0 features greatly enhanced hardware support, configuration
286 flexibility, usability and a larger complement of supported operating
287 systems. This latest release takes Xen a step closer to being the
288 definitive open source solution for virtualization.
292 \part{Installation}
294 %% Chapter Basic Installation
295 \chapter{Basic Installation}
297 The Xen distribution includes three main components: Xen itself, ports
298 of Linux and NetBSD to run on Xen, and the userspace tools required to
299 manage a Xen-based system. This chapter describes how to install the
300 Xen~3.0 distribution from source. Alternatively, there may be pre-built
301 packages available as part of your operating system distribution.
304 \section{Prerequisites}
305 \label{sec:prerequisites}
307 The following is a full list of prerequisites. Items marked `$\dag$' are
308 required by the \xend\ control tools, and hence required if you want to
309 run more than one virtual machine; items marked `$*$' are only required
310 if you wish to build from source.
311 \begin{itemize}
312 \item A working Linux distribution using the GRUB bootloader and running
313 on a P6-class or newer CPU\@.
314 \item [$\dag$] The \path{iproute2} package.
315 \item [$\dag$] The Linux bridge-utils\footnote{Available from {\tt
316}} (e.g., \path{/sbin/brctl})
317 \item [$\dag$] The Linux hotplug system\footnote{Available from {\tt
318}} (e.g.,
319 \path{/sbin/hotplug} and related scripts). On newer distributions,
320 this is included alongside the Linux udev system\footnote{See {\tt
322 \item [$*$] Build tools (gcc v3.2.x or v3.3.x, binutils, GNU make).
323 \item [$*$] Development installation of zlib (e.g.,\ zlib-dev).
324 \item [$*$] Development installation of Python v2.2 or later (e.g.,\
325 python-dev).
326 \item [$*$] \LaTeX\ and transfig are required to build the
327 documentation.
328 \end{itemize}
330 Once you have satisfied these prerequisites, you can now install either
331 a binary or source distribution of Xen.
333 \section{Installing from Binary Tarball}
335 Pre-built tarballs are available for download from the XenSource downloads
336 page:
337 \begin{quote} {\tt}
338 \end{quote}
340 Once you've downloaded the tarball, simply unpack and install:
341 \begin{verbatim}
342 # tar zxvf xen-3.0-install.tgz
343 # cd xen-3.0-install
344 # sh ./
345 \end{verbatim}
347 Once you've installed the binaries you need to configure your system as
348 described in Section~\ref{s:configure}.
350 \section{Installing from RPMs}
351 Pre-built RPMs are available for download from the XenSource downloads
352 page:
353 \begin{quote} {\tt}
354 \end{quote}
356 Once you've downloaded the RPMs, you typically install them via the
357 RPM commands:
359 \verb|# rpm -iv rpmname|
361 See the instructions and the Release Notes for each RPM set referenced at:
362 \begin{quote}
363 {\tt}.
364 \end{quote}
366 \section{Installing from Source}
368 This section describes how to obtain, build and install Xen from source.
370 \subsection{Obtaining the Source}
372 The Xen source tree is available as either a compressed source tarball
373 or as a clone of our master Mercurial repository.
375 \begin{description}
376 \item[Obtaining the Source Tarball]\mbox{} \\
377 Stable versions and daily snapshots of the Xen source tree are
378 available from the Xen download page:
379 \begin{quote} {\tt \tt}
380 \end{quote}
381 \item[Obtaining the source via Mercurial]\mbox{} \\
382 The source tree may also be obtained via the public Mercurial
383 repository at:
384 \begin{quote}{\tt}
385 \end{quote} See the instructions and the Getting Started Guide
386 referenced at:
387 \begin{quote}
388 {\tt}
389 \end{quote}
390 \end{description}
392 % \section{The distribution}
393 %
394 % The Xen source code repository is structured as follows:
395 %
396 % \begin{description}
397 % \item[\path{tools/}] Xen node controller daemon (Xend), command line
398 % tools, control libraries
399 % \item[\path{xen/}] The Xen VMM.
400 % \item[\path{buildconfigs/}] Build configuration files
401 % \item[\path{linux-*-xen-sparse/}] Xen support for Linux.
402 % \item[\path{patches/}] Experimental patches for Linux.
403 % \item[\path{docs/}] Various documentation files for users and
404 % developers.
405 % \item[\path{extras/}] Bonus extras.
406 % \end{description}
408 \subsection{Building from Source}
410 The top-level Xen Makefile includes a target ``world'' that will do the
411 following:
413 \begin{itemize}
414 \item Build Xen.
415 \item Build the control tools, including \xend.
416 \item Download (if necessary) and unpack the Linux 2.6 source code, and
417 patch it for use with Xen.
418 \item Build a Linux kernel to use in domain~0 and a smaller unprivileged
419 kernel, which can be used for unprivileged virtual machines.
420 \end{itemize}
422 After the build has completed you should have a top-level directory
423 called \path{dist/} in which all resulting targets will be placed. Of
424 particular interest are the two XenLinux kernel images, one with a
425 ``-xen0'' extension which contains hardware device drivers and drivers
426 for Xen's virtual devices, and one with a ``-xenU'' extension that
427 just contains the virtual ones. These are found in
428 \path{dist/install/boot/} along with the image for Xen itself and the
429 configuration files used during the build.
431 %The NetBSD port can be built using:
432 %\begin{quote}
433 %\begin{verbatim}
434 %# make netbsd20
435 %\end{verbatim}\end{quote}
436 %NetBSD port is built using a snapshot of the netbsd-2-0 cvs branch.
437 %The snapshot is downloaded as part of the build process if it is not
438 %yet present in the \path{NETBSD\_SRC\_PATH} search path. The build
439 %process also downloads a toolchain which includes all of the tools
440 %necessary to build the NetBSD kernel under Linux.
442 To customize the set of kernels built you need to edit the top-level
443 Makefile. Look for the line:
444 \begin{quote}
445 \begin{verbatim}
446 KERNELS ?= linux-2.6-xen0 linux-2.6-xenU
447 \end{verbatim}
448 \end{quote}
450 You can edit this line to include any set of operating system kernels
451 which have configurations in the top-level \path{buildconfigs/}
452 directory.
454 %% Inspect the Makefile if you want to see what goes on during a
455 %% build. Building Xen and the tools is straightforward, but XenLinux
456 %% is more complicated. The makefile needs a `pristine' Linux kernel
457 %% tree to which it will then add the Xen architecture files. You can
458 %% tell the makefile the location of the appropriate Linux compressed
459 %% tar file by
460 %% setting the LINUX\_SRC environment variable, e.g. \\
461 %% \verb!# LINUX_SRC=/tmp/linux-2.6.11.tar.bz2 make world! \\ or by
462 %% placing the tar file somewhere in the search path of {\tt
463 %% LINUX\_SRC\_PATH} which defaults to `{\tt .:..}'. If the
464 %% makefile can't find a suitable kernel tar file it attempts to
465 %% download it from (this won't work if you're behind a
466 %% firewall).
468 %% After untaring the pristine kernel tree, the makefile uses the {\tt
469 %% mkbuildtree} script to add the Xen patches to the kernel.
471 %% \framebox{\parbox{5in}{
472 %% {\bf Distro specific:} \\
473 %% {\it Gentoo} --- if not using udev (most installations,
474 %% currently), you'll need to enable devfs and devfs mount at boot
475 %% time in the xen0 config. }}
477 \subsection{Custom Kernels}
479 % If you have an SMP machine you may wish to give the {\tt '-j4'}
480 % argument to make to get a parallel build.
482 If you wish to build a customized XenLinux kernel (e.g.\ to support
483 additional devices or enable distribution-required features), you can
484 use the standard Linux configuration mechanisms, specifying that the
485 architecture being built for is \path{xen}, e.g:
486 \begin{quote}
487 \begin{verbatim}
488 # cd linux-2.6.12-xen0
489 # make ARCH=xen xconfig
490 # cd ..
491 # make
492 \end{verbatim}
493 \end{quote}
495 You can also copy an existing Linux configuration (\path{.config}) into
496 e.g.\ \path{linux-2.6.12-xen0} and execute:
497 \begin{quote}
498 \begin{verbatim}
499 # make ARCH=xen oldconfig
500 \end{verbatim}
501 \end{quote}
503 You may be prompted with some Xen-specific options. We advise accepting
504 the defaults for these options.
506 Note that the only difference between the two types of Linux kernels
507 that are built is the configuration file used for each. The ``U''
508 suffixed (unprivileged) versions don't contain any of the physical
509 hardware device drivers, leading to a 30\% reduction in size; hence you
510 may prefer these for your non-privileged domains. The ``0'' suffixed
511 privileged versions can be used to boot the system, as well as in driver
512 domains and unprivileged domains.
514 \subsection{Installing Generated Binaries}
516 The files produced by the build process are stored under the
517 \path{dist/install/} directory. To install them in their default
518 locations, do:
519 \begin{quote}
520 \begin{verbatim}
521 # make install
522 \end{verbatim}
523 \end{quote}
525 Alternatively, users with special installation requirements may wish to
526 install them manually by copying the files to their appropriate
527 destinations.
529 %% Files in \path{install/boot/} include:
530 %% \begin{itemize}
531 %% \item \path{install/boot/xen-3.0.gz} Link to the Xen 'kernel'
532 %% \item \path{install/boot/vmlinuz-2.6-xen0} Link to domain 0
533 %% XenLinux kernel
534 %% \item \path{install/boot/vmlinuz-2.6-xenU} Link to unprivileged
535 %% XenLinux kernel
536 %% \end{itemize}
538 The \path{dist/install/boot} directory will also contain the config
539 files used for building the XenLinux kernels, and also versions of Xen
540 and XenLinux kernels that contain debug symbols such as
541 (\path{xen-syms-3.0.0} and \path{vmlinux-syms-}) which are
542 essential for interpreting crash dumps. Retain these files as the
543 developers may wish to see them if you post on the mailing list.
546 \section{Configuration}
547 \label{s:configure}
549 Once you have built and installed the Xen distribution, it is simple to
550 prepare the machine for booting and running Xen.
552 \subsection{GRUB Configuration}
554 An entry should be added to \path{grub.conf} (often found under
555 \path{/boot/} or \path{/boot/grub/}) to allow Xen / XenLinux to boot.
556 This file is sometimes called \path{menu.lst}, depending on your
557 distribution. The entry should look something like the following:
559 %% KMSelf Thu Dec 1 19:06:13 PST 2005 262144 is useful for RHEL/RH and
560 %% related Dom0s.
561 {\small
562 \begin{verbatim}
563 title Xen 3.0 / XenLinux 2.6
564 kernel /boot/xen-3.0.gz dom0_mem=262144
565 module /boot/vmlinuz-2.6-xen0 root=/dev/sda4 ro console=tty0
566 \end{verbatim}
567 }
569 The kernel line tells GRUB where to find Xen itself and what boot
570 parameters should be passed to it (in this case, setting the domain~0
571 memory allocation in kilobytes and the settings for the serial port).
572 For more details on the various Xen boot parameters see
573 Section~\ref{s:xboot}.
575 The module line of the configuration describes the location of the
576 XenLinux kernel that Xen should start and the parameters that should be
577 passed to it. These are standard Linux parameters, identifying the root
578 device and specifying it be initially mounted read only and instructing
579 that console output be sent to the screen. Some distributions such as
580 SuSE do not require the \path{ro} parameter.
582 %% \framebox{\parbox{5in}{
583 %% {\bf Distro specific:} \\
584 %% {\it SuSE} --- Omit the {\tt ro} option from the XenLinux
585 %% kernel command line, since the partition won't be remounted rw
586 %% during boot. }}
588 To use an initrd, add another \path{module} line to the configuration,
589 like: {\small
590 \begin{verbatim}
591 module /boot/my_initrd.gz
592 \end{verbatim}
593 }
595 %% KMSelf Thu Dec 1 19:05:30 PST 2005 Other configs as an appendix?
597 When installing a new kernel, it is recommended that you do not delete
598 existing menu options from \path{menu.lst}, as you may wish to boot your
599 old Linux kernel in future, particularly if you have problems.
601 \subsection{Serial Console (optional)}
603 Serial console access allows you to manage, monitor, and interact with
604 your system over a serial console. This can allow access from another
605 nearby system via a null-modem (``LapLink'') cable or remotely via a serial
606 concentrator.
608 You system's BIOS, bootloader (GRUB), Xen, Linux, and login access must
609 each be individually configured for serial console access. It is
610 \emph{not} strictly necessary to have each component fully functional,
611 but it can be quite useful.
613 For general information on serial console configuration under Linux,
614 refer to the ``Remote Serial Console HOWTO'' at The Linux Documentation
615 Project: \url{}
617 \subsubsection{Serial Console BIOS configuration}
619 Enabling system serial console output neither enables nor disables
620 serial capabilities in GRUB, Xen, or Linux, but may make remote
621 management of your system more convenient by displaying POST and other
622 boot messages over serial port and allowing remote BIOS configuration.
624 Refer to your hardware vendor's documentation for capabilities and
625 procedures to enable BIOS serial redirection.
628 \subsubsection{Serial Console GRUB configuration}
630 Enabling GRUB serial console output neither enables nor disables Xen or
631 Linux serial capabilities, but may made remote management of your system
632 more convenient by displaying GRUB prompts, menus, and actions over
633 serial port and allowing remote GRUB management.
635 Adding the following two lines to your GRUB configuration file,
636 typically either \path{/boot/grub/menu.lst} or \path{/boot/grub/grub.conf}
637 depending on your distro, will enable GRUB serial output.
639 \begin{quote}
640 {\small \begin{verbatim}
641 serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
642 terminal --timeout=10 serial console
643 \end{verbatim}}
644 \end{quote}
646 Note that when both the serial port and the local monitor and keyboard
647 are enabled, the text ``\emph{Press any key to continue}'' will appear
648 at both. Pressing a key on one device will cause GRUB to display to
649 that device. The other device will see no output. If no key is
650 pressed before the timeout period expires, the system will boot to the
651 default GRUB boot entry.
653 Please refer to the GRUB documentation for further information.
656 \subsubsection{Serial Console Xen configuration}
658 Enabling Xen serial console output neither enables nor disables Linux
659 kernel output or logging in to Linux over serial port. It does however
660 allow you to monitor and log the Xen boot process via serial console and
661 can be very useful in debugging.
663 %% kernel /boot/xen-2.0.gz dom0_mem=131072 console=com1,vga com1=115200,8n1
664 %% module /boot/vmlinuz-2.6-xen0 root=/dev/sda4 ro
666 In order to configure Xen serial console output, it is necessary to
667 add a boot option to your GRUB config; e.g.\ replace the previous
668 example kernel line with:
669 \begin{quote} {\small \begin{verbatim}
670 kernel /boot/xen.gz dom0_mem=131072 com1=115200,8n1
671 \end{verbatim}}
672 \end{quote}
674 This configures Xen to output on COM1 at 115,200 baud, 8 data bits, no
675 parity and 1 stop bit. Modify these parameters for your environment.
676 See Section~\ref{s:xboot} for an explanation of all boot parameters.
678 One can also configure XenLinux to share the serial console; to achieve
679 this append ``\path{console=ttyS0}'' to your module line.
682 \subsubsection{Serial Console Linux configuration}
684 Enabling Linux serial console output at boot neither enables nor
685 disables logging in to Linux over serial port. It does however allow
686 you to monitor and log the Linux boot process via serial console and can be
687 very useful in debugging.
689 To enable Linux output at boot time, add the parameter
690 \path{console=ttyS0} (or ttyS1, ttyS2, etc.) to your kernel GRUB line.
691 Under Xen, this might be:
692 \begin{quote}
693 {\footnotesize \begin{verbatim}
694 module /vmlinuz-2.6-xen0 ro root=/dev/VolGroup00/LogVol00 \
695 console=ttyS0, 115200
696 \end{verbatim}}
697 \end{quote}
698 to enable output over ttyS0 at 115200 baud.
702 \subsubsection{Serial Console Login configuration}
704 Logging in to Linux via serial console, under Xen or otherwise, requires
705 specifying a login prompt be started on the serial port. To permit root
706 logins over serial console, the serial port must be added to
707 \path{/etc/securetty}.
709 \newpage
710 To automatically start a login prompt over the serial port,
711 add the line: \begin{quote} {\small {\tt c:2345:respawn:/sbin/mingetty
712 ttyS0}} \end{quote} to \path{/etc/inittab}. Run \path{init q} to force
713 a reload of your inttab and start getty.
715 To enable root logins, add \path{ttyS0} to \path{/etc/securetty} if not
716 already present.
718 Your distribution may use an alternate getty; options include getty,
719 mgetty and agetty. Consult your distribution's documentation
720 for further information.
723 \subsection{TLS Libraries}
725 Users of the XenLinux 2.6 kernel should disable Thread Local Storage
726 (TLS) (e.g.\ by doing a \path{mv /lib/tls /lib/tls.disabled}) before
727 attempting to boot a XenLinux kernel\footnote{If you boot without first
728 disabling TLS, you will get a warning message during the boot process.
729 In this case, simply perform the rename after the machine is up and
730 then run \path{/sbin/ldconfig} to make it take effect.}. You can
731 always reenable TLS by restoring the directory to its original location
732 (i.e.\ \path{mv /lib/tls.disabled /lib/tls}).
734 The reason for this is that the current TLS implementation uses
735 segmentation in a way that is not permissible under Xen. If TLS is not
736 disabled, an emulation mode is used within Xen which reduces performance
737 substantially. To ensure full performance you should install a
738 `Xen-friendly' (nosegneg) version of the library.
741 \section{Booting Xen}
743 It should now be possible to restart the system and use Xen. Reboot and
744 choose the new Xen option when the Grub screen appears.
746 What follows should look much like a conventional Linux boot. The first
747 portion of the output comes from Xen itself, supplying low level
748 information about itself and the underlying hardware. The last portion
749 of the output comes from XenLinux.
751 You may see some error messages during the XenLinux boot. These are not
752 necessarily anything to worry about---they may result from kernel
753 configuration differences between your XenLinux kernel and the one you
754 usually use.
756 When the boot completes, you should be able to log into your system as
757 usual. If you are unable to log in, you should still be able to reboot
758 with your normal Linux kernel by selecting it at the GRUB prompt.
761 % Booting Xen
762 \chapter{Booting a Xen System}
764 Booting the system into Xen will bring you up into the privileged
765 management domain, Domain0. At that point you are ready to create
766 guest domains and ``boot'' them using the \texttt{xm create} command.
768 \section{Booting Domain0}
770 After installation and configuration is complete, reboot the system
771 and and choose the new Xen option when the Grub screen appears.
773 What follows should look much like a conventional Linux boot. The
774 first portion of the output comes from Xen itself, supplying low level
775 information about itself and the underlying hardware. The last
776 portion of the output comes from XenLinux.
778 %% KMSelf Wed Nov 30 18:09:37 PST 2005: We should specify what these are.
780 When the boot completes, you should be able to log into your system as
781 usual. If you are unable to log in, you should still be able to
782 reboot with your normal Linux kernel by selecting it at the GRUB prompt.
784 The first step in creating a new domain is to prepare a root
785 filesystem for it to boot. Typically, this might be stored in a normal
786 partition, an LVM or other volume manager partition, a disk file or on
787 an NFS server. A simple way to do this is simply to boot from your
788 standard OS install CD and install the distribution into another
789 partition on your hard drive.
791 To start the \xend\ control daemon, type
792 \begin{quote}
793 \verb!# xend start!
794 \end{quote}
796 If you wish the daemon to start automatically, see the instructions in
797 Section~\ref{s:xend}. Once the daemon is running, you can use the
798 \path{xm} tool to monitor and maintain the domains running on your
799 system. This chapter provides only a brief tutorial. We provide full
800 details of the \path{xm} tool in the next chapter.
802 % \section{From the web interface}
803 %
804 % Boot the Xen machine and start Xensv (see Chapter~\ref{cha:xensv}
805 % for more details) using the command: \\
806 % \verb_# xensv start_ \\
807 % This will also start Xend (see Chapter~\ref{cha:xend} for more
808 % information).
809 %
810 % The domain management interface will then be available at {\tt
811 % http://your\_machine:8080/}. This provides a user friendly wizard
812 % for starting domains and functions for managing running domains.
813 %
814 % \section{From the command line}
815 \section{Booting Guest Domains}
817 \subsection{Creating a Domain Configuration File}
819 Before you can start an additional domain, you must create a
820 configuration file. We provide two example files which you can use as
821 a starting point:
822 \begin{itemize}
823 \item \path{/etc/xen/xmexample1} is a simple template configuration
824 file for describing a single VM\@.
825 \item \path{/etc/xen/xmexample2} file is a template description that
826 is intended to be reused for multiple virtual machines. Setting the
827 value of the \path{vmid} variable on the \path{xm} command line
828 fills in parts of this template.
829 \end{itemize}
831 There are also a number of other examples which you may find useful.
832 Copy one of these files and edit it as appropriate. Typical values
833 you may wish to edit include:
835 \begin{quote}
836 \begin{description}
837 \item[kernel] Set this to the path of the kernel you compiled for use
838 with Xen (e.g.\ \path{kernel = ``/boot/vmlinuz-2.6-xenU''})
839 \item[memory] Set this to the size of the domain's memory in megabytes
840 (e.g.\ \path{memory = 64})
841 \item[disk] Set the first entry in this list to calculate the offset
842 of the domain's root partition, based on the domain ID\@. Set the
843 second to the location of \path{/usr} if you are sharing it between
844 domains (e.g.\ \path{disk = ['phy:your\_hard\_drive\%d,sda1,w' \%
845 (base\_partition\_number + vmid),
846 'phy:your\_usr\_partition,sda6,r' ]}
847 \item[dhcp] Uncomment the dhcp variable, so that the domain will
848 receive its IP address from a DHCP server (e.g.\ \path{dhcp=``dhcp''})
849 \end{description}
850 \end{quote}
852 You may also want to edit the {\bf vif} variable in order to choose
853 the MAC address of the virtual ethernet interface yourself. For
854 example:
856 \begin{quote}
857 \verb_vif = ['mac=00:16:3E:F6:BB:B3']_
858 \end{quote}
859 If you do not set this variable, \xend\ will automatically generate a
860 random MAC address from the range 00:16:3E:xx:xx:xx, assigned by IEEE to
861 XenSource as an OUI (organizationally unique identifier). XenSource
862 Inc. gives permission for anyone to use addresses randomly allocated
863 from this range for use by their Xen domains.
865 For a list of IEEE OUI assignments, see
866 \url{}
869 \subsection{Booting the Guest Domain}
871 The \path{xm} tool provides a variety of commands for managing
872 domains. Use the \path{create} command to start new domains. Assuming
873 you've created a configuration file \path{myvmconf} based around
874 \path{/etc/xen/xmexample2}, to start a domain with virtual machine
875 ID~1 you should type:
877 \begin{quote}
878 \begin{verbatim}
879 # xm create -c myvmconf vmid=1
880 \end{verbatim}
881 \end{quote}
883 The \path{-c} switch causes \path{xm} to turn into the domain's
884 console after creation. The \path{vmid=1} sets the \path{vmid}
885 variable used in the \path{myvmconf} file.
887 You should see the console boot messages from the new domain appearing
888 in the terminal in which you typed the command, culminating in a login
889 prompt.
892 \section{Starting / Stopping Domains Automatically}
894 It is possible to have certain domains start automatically at boot
895 time and to have dom0 wait for all running domains to shutdown before
896 it shuts down the system.
898 To specify a domain is to start at boot-time, place its configuration
899 file (or a link to it) under \path{/etc/xen/auto/}.
901 A Sys-V style init script for Red Hat and LSB-compliant systems is
902 provided and will be automatically copied to \path{/etc/init.d/}
903 during install. You can then enable it in the appropriate way for
904 your distribution.
906 For instance, on Red Hat:
908 \begin{quote}
909 \verb_# chkconfig --add xendomains_
910 \end{quote}
912 By default, this will start the boot-time domains in runlevels 3, 4
913 and 5.
915 You can also use the \path{service} command to run this script
916 manually, e.g:
918 \begin{quote}
919 \verb_# service xendomains start_
921 Starts all the domains with config files under /etc/xen/auto/.
922 \end{quote}
924 \begin{quote}
925 \verb_# service xendomains stop_
927 Shuts down all running Xen domains.
928 \end{quote}
932 \part{Configuration and Management}
934 %% Chapter Domain Management Tools and Daemons
935 \chapter{Domain Management Tools}
937 This chapter summarizes the management software and tools available.
940 \section{\Xend\ }
941 \label{s:xend}
944 The \Xend\ node control daemon performs system management functions
945 related to virtual machines. It forms a central point of control of
946 virtualized resources, and must be running in order to start and manage
947 virtual machines. \Xend\ must be run as root because it needs access to
948 privileged system management functions.
950 An initialization script named \texttt{/etc/init.d/xend} is provided to
951 start \Xend\ at boot time. Use the tool appropriate (i.e. chkconfig) for
952 your Linux distribution to specify the runlevels at which this script
953 should be executed, or manually create symbolic links in the correct
954 runlevel directories.
956 \Xend\ can be started on the command line as well, and supports the
957 following set of parameters:
959 \begin{tabular}{ll}
960 \verb!# xend start! & start \xend, if not already running \\
961 \verb!# xend stop! & stop \xend\ if already running \\
962 \verb!# xend restart! & restart \xend\ if running, otherwise start it \\
963 % \verb!# xend trace_start! & start \xend, with very detailed debug logging \\
964 \verb!# xend status! & indicates \xend\ status by its return code
965 \end{tabular}
967 A SysV init script called {\tt xend} is provided to start \xend\ at
968 boot time. {\tt make install} installs this script in
969 \path{/etc/init.d}. To enable it, you have to make symbolic links in
970 the appropriate runlevel directories or use the {\tt chkconfig} tool,
971 where available. Once \xend\ is running, administration can be done
972 using the \texttt{xm} tool.
974 \subsection{Logging}
976 As \xend\ runs, events will be logged to \path{/var/log/xend.log} and
977 (less frequently) to \path{/var/log/xend-debug.log}. These, along with
978 the standard syslog files, are useful when troubleshooting problems.
980 \subsection{Configuring \Xend\ }
982 \Xend\ is written in Python. At startup, it reads its configuration
983 information from the file \path{/etc/xen/xend-config.sxp}. The Xen
984 installation places an example \texttt{xend-config.sxp} file in the
985 \texttt{/etc/xen} subdirectory which should work for most installations.
987 See the example configuration file \texttt{xend-debug.sxp} and the
988 section 5 man page \texttt{xend-config.sxp} for a full list of
989 parameters and more detailed information. Some of the most important
990 parameters are discussed below.
992 An HTTP interface and a Unix domain socket API are available to
993 communicate with \Xend. This allows remote users to pass commands to the
994 daemon. By default, \Xend does not start an HTTP server. It does start a
995 Unix domain socket management server, as the low level utility
996 \texttt{xm} requires it. For support of cross-machine migration, \Xend\
997 can start a relocation server. This support is not enabled by default
998 for security reasons.
1000 Note: the example \texttt{xend} configuration file modifies the defaults and
1001 starts up \Xend\ as an HTTP server as well as a relocation server.
1003 From the file:
1005 \begin{verbatim}
1006 #(xend-http-server no)
1007 (xend-http-server yes)
1008 #(xend-unix-server yes)
1009 #(xend-relocation-server no)
1010 (xend-relocation-server yes)
1011 \end{verbatim}
1013 Comment or uncomment lines in that file to disable or enable features
1014 that you require.
1016 Connections from remote hosts are disabled by default:
1018 \begin{verbatim}
1019 # Address xend should listen on for HTTP connections, if xend-http-server is
1020 # set.
1021 # Specifying 'localhost' prevents remote connections.
1022 # Specifying the empty string '' (the default) allows all connections.
1023 #(xend-address '')
1024 (xend-address localhost)
1025 \end{verbatim}
1027 It is recommended that if migration support is not needed, the
1028 \texttt{xend-relocation-server} parameter value be changed to
1029 ``\texttt{no}'' or commented out.
1031 \section{Xm}
1032 \label{s:xm}
1034 The xm tool is the primary tool for managing Xen from the console. The
1035 general format of an xm command line is:
1037 \begin{verbatim}
1038 # xm command [switches] [arguments] [variables]
1039 \end{verbatim}
1041 The available \emph{switches} and \emph{arguments} are dependent on the
1042 \emph{command} chosen. The \emph{variables} may be set using
1043 declarations of the form {\tt variable=value} and command line
1044 declarations override any of the values in the configuration file being
1045 used, including the standard variables described above and any custom
1046 variables (for instance, the \path{xmdefconfig} file uses a {\tt vmid}
1047 variable).
1049 For online help for the commands available, type:
1051 \begin{quote}
1052 \begin{verbatim}
1053 # xm help
1054 \end{verbatim}
1055 \end{quote}
1057 This will list the most commonly used commands. The full list can be obtained
1058 using \verb_xm help --long_. You can also type \path{xm help $<$command$>$}
1059 for more information on a given command.
1061 \subsection{Basic Management Commands}
1063 One useful command is \verb_# xm list_ which lists all domains running in rows
1064 of the following format:
1065 \begin{center} {\tt name domid memory vcpus state cputime}
1066 \end{center}
1068 The meaning of each field is as follows:
1069 \begin{quote}
1070 \begin{description}
1071 \item[name] The descriptive name of the virtual machine.
1072 \item[domid] The number of the domain ID this virtual machine is
1073 running in.
1074 \item[memory] Memory size in megabytes.
1075 \item[vcpus] The number of virtual CPUs this domain has.
1076 \item[state] Domain state consists of 5 fields:
1077 \begin{description}
1078 \item[r] running
1079 \item[b] blocked
1080 \item[p] paused
1081 \item[s] shutdown
1082 \item[c] crashed
1083 \end{description}
1084 \item[cputime] How much CPU time (in seconds) the domain has used so
1085 far.
1086 \end{description}
1087 \end{quote}
1089 The \path{xm list} command also supports a long output format when the
1090 \path{-l} switch is used. This outputs the full details of the
1091 running domains in \xend's SXP configuration format.
1094 You can get access to the console of a particular domain using
1095 the \verb_# xm console_ command (e.g.\ \verb_# xm console myVM_).
1097 \subsection{Domain Scheduling Management Commands}
1099 The credit CPU scheduler automatically load balances guest VCPUs
1100 across all available physical CPUs on an SMP host. The user need
1101 not manually pin VCPUs to load balance the system. However, she
1102 can restrict which CPUs a particular VCPU may run on using
1103 the \path{xm vcpu-pin} command.
1105 Each guest domain is assigned a \path{weight} and a \path{cap}.
1107 A domain with a weight of 512 will get twice as much CPU as a
1108 domain with a weight of 256 on a contended host. Legal weights
1109 range from 1 to 65535 and the default is 256.
1111 The cap optionally fixes the maximum amount of CPU a guest will
1112 be able to consume, even if the host system has idle CPU cycles.
1113 The cap is expressed in percentage of one physical CPU: 100 is
1114 1 physical CPU, 50 is half a CPU, 400 is 4 CPUs, etc... The
1115 default, 0, means there is no upper cap.
1117 When you are running with the credit scheduler, you can check and
1118 modify your domains' weights and caps using the \path{xm sched-credit}
1119 command:
1121 \begin{tabular}{ll}
1122 \verb!xm sched-credit -d <domain>! & lists weight and cap \\
1123 \verb!xm sched-credit -d <domain> -w <weight>! & sets the weight \\
1124 \verb!xm sched-credit -d <domain> -c <cap>! & sets the cap
1125 \end{tabular}
1129 %% Chapter Domain Configuration
1130 \chapter{Domain Configuration}
1131 \label{cha:config}
1133 The following contains the syntax of the domain configuration files
1134 and description of how to further specify networking, driver domain
1135 and general scheduling behavior.
1138 \section{Configuration Files}
1139 \label{s:cfiles}
1141 Xen configuration files contain the following standard variables.
1142 Unless otherwise stated, configuration items should be enclosed in
1143 quotes: see the configuration scripts in \path{/etc/xen/}
1144 for concrete examples.
1146 \begin{description}
1147 \item[kernel] Path to the kernel image.
1148 \item[ramdisk] Path to a ramdisk image (optional).
1149 % \item[builder] The name of the domain build function (e.g.
1150 % {\tt'linux'} or {\tt'netbsd'}.
1151 \item[memory] Memory size in megabytes.
1152 \item[vcpus] The number of virtual CPUs.
1153 \item[console] Port to export the domain console on (default 9600 +
1154 domain ID).
1155 \item[vif] Network interface configuration. This may simply contain
1156 an empty string for each desired interface, or may override various
1157 settings, e.g.\
1158 \begin{verbatim}
1159 vif = [ 'mac=00:16:3E:00:00:11, bridge=xen-br0',
1160 'bridge=xen-br1' ]
1161 \end{verbatim}
1162 to assign a MAC address and bridge to the first interface and assign
1163 a different bridge to the second interface, leaving \xend\ to choose
1164 the MAC address. The settings that may be overridden in this way are
1165 type, mac, bridge, ip, script, backend, and vifname.
1166 \item[disk] List of block devices to export to the domain e.g.
1167 \verb_disk = [ 'phy:hda1,sda1,r' ]_
1168 exports physical device \path{/dev/hda1} to the domain as
1169 \path{/dev/sda1} with read-only access. Exporting a disk read-write
1170 which is currently mounted is dangerous -- if you are \emph{certain}
1171 you wish to do this, you can specify \path{w!} as the mode.
1172 \item[dhcp] Set to {\tt `dhcp'} if you want to use DHCP to configure
1173 networking.
1174 \item[netmask] Manually configured IP netmask.
1175 \item[gateway] Manually configured IP gateway.
1176 \item[hostname] Set the hostname for the virtual machine.
1177 \item[root] Specify the root device parameter on the kernel command
1178 line.
1179 \item[nfs\_server] IP address for the NFS server (if any).
1180 \item[nfs\_root] Path of the root filesystem on the NFS server (if
1181 any).
1182 \item[extra] Extra string to append to the kernel command line (if
1183 any)
1184 \end{description}
1186 Additional fields are documented in the example configuration files
1187 (e.g. to configure virtual TPM functionality).
1189 For additional flexibility, it is also possible to include Python
1190 scripting commands in configuration files. An example of this is the
1191 \path{xmexample2} file, which uses Python code to handle the
1192 \path{vmid} variable.
1195 %\part{Advanced Topics}
1198 \section{Network Configuration}
1200 For many users, the default installation should work ``out of the
1201 box''. More complicated network setups, for instance with multiple
1202 Ethernet interfaces and/or existing bridging setups will require some
1203 special configuration.
1205 The purpose of this section is to describe the mechanisms provided by
1206 \xend\ to allow a flexible configuration for Xen's virtual networking.
1208 \subsection{Xen virtual network topology}
1210 Each domain network interface is connected to a virtual network
1211 interface in dom0 by a point to point link (effectively a ``virtual
1212 crossover cable''). These devices are named {\tt
1213 vif$<$domid$>$.$<$vifid$>$} (e.g.\ {\tt vif1.0} for the first
1214 interface in domain~1, {\tt vif3.1} for the second interface in
1215 domain~3).
1217 Traffic on these virtual interfaces is handled in domain~0 using
1218 standard Linux mechanisms for bridging, routing, rate limiting, etc.
1219 Xend calls on two shell scripts to perform initial configuration of
1220 the network and configuration of new virtual interfaces. By default,
1221 these scripts configure a single bridge for all the virtual
1222 interfaces. Arbitrary routing / bridging configurations can be
1223 configured by customizing the scripts, as described in the following
1224 section.
1226 \subsection{Xen networking scripts}
1228 Xen's virtual networking is configured by two shell scripts (by
1229 default \path{network-bridge} and \path{vif-bridge}). These are called
1230 automatically by \xend\ when certain events occur, with arguments to
1231 the scripts providing further contextual information. These scripts
1232 are found by default in \path{/etc/xen/scripts}. The names and
1233 locations of the scripts can be configured in
1234 \path{/etc/xen/xend-config.sxp}.
1236 \begin{description}
1237 \item[network-bridge:] This script is called whenever \xend\ is started or
1238 stopped to respectively initialize or tear down the Xen virtual
1239 network. In the default configuration initialization creates the
1240 bridge `xen-br0' and moves eth0 onto that bridge, modifying the
1241 routing accordingly. When \xend\ exits, it deletes the Xen bridge
1242 and removes eth0, restoring the normal IP and routing configuration.
1244 %% In configurations where the bridge already exists, this script
1245 %% could be replaced with a link to \path{/bin/true} (for instance).
1247 \item[vif-bridge:] This script is called for every domain virtual
1248 interface and can configure firewalling rules and add the vif to the
1249 appropriate bridge. By default, this adds and removes VIFs on the
1250 default Xen bridge.
1251 \end{description}
1253 Other example scripts are available (\path{network-route} and
1254 \path{vif-route}, \path{network-nat} and \path{vif-nat}).
1255 For more complex network setups (e.g.\ where routing is required or
1256 integrate with existing bridges) these scripts may be replaced with
1257 customized variants for your site's preferred configuration.
1259 \section{Driver Domain Configuration}
1260 \label{s:ddconf}
1262 \subsection{PCI}
1263 \label{ss:pcidd}
1265 Individual PCI devices can be assigned to a given domain (a PCI driver domain)
1266 to allow that domain direct access to the PCI hardware.
1268 While PCI Driver Domains can increase the stability and security of a system
1269 by addressing a number of security concerns, there are some security issues
1270 that remain that you can read about in Section~\ref{s:ddsecurity}.
1272 \subsubsection{Compile-Time Setup}
1273 To use this functionality, ensure
1274 that the PCI Backend is compiled in to a privileged domain (e.g. domain 0)
1275 and that the domains which will be assigned PCI devices have the PCI Frontend
1276 compiled in. In XenLinux, the PCI Backend is available under the Xen
1277 configuration section while the PCI Frontend is under the
1278 architecture-specific "Bus Options" section. You may compile both the backend
1279 and the frontend into the same kernel; they will not affect each other.
1281 \subsubsection{PCI Backend Configuration - Binding at Boot}
1282 The PCI devices you wish to assign to unprivileged domains must be "hidden"
1283 from your backend domain (usually domain 0) so that it does not load a driver
1284 for them. Use the \path{pciback.hide} kernel parameter which is specified on
1285 the kernel command-line and is configurable through GRUB (see
1286 Section~\ref{s:configure}). Note that devices are not really hidden from the
1287 backend domain. The PCI Backend appears to the Linux kernel as a regular PCI
1288 device driver. The PCI Backend ensures that no other device driver loads
1289 for the devices by binding itself as the device driver for those devices.
1290 PCI devices are identified by hexadecimal slot/funciton numbers (on Linux,
1291 use \path{lspci} to determine slot/funciton numbers of your devices) and
1292 can be specified with or without the PCI domain: \\
1293 \centerline{ {\tt ({\em bus}:{\em slot}.{\em func})} example {\tt (02:1d.3)}} \\
1294 \centerline{ {\tt ({\em domain}:{\em bus}:{\em slot}.{\em func})} example {\tt (0000:02:1d.3)}} \\
1296 An example kernel command-line which hides two PCI devices might be: \\
1297 \centerline{ {\tt root=/dev/sda4 ro console=tty0 pciback.hide=(02:01.f)(0000:04:1d.0) } } \\
1299 \subsubsection{PCI Backend Configuration - Late Binding}
1300 PCI devices can also be bound to the PCI Backend after boot through the manual
1301 binding/unbinding facilities provided by the Linux kernel in sysfs (allowing
1302 for a Xen user to give PCI devices to driver domains that were not specified
1303 on the kernel command-line). There are several attributes with the PCI
1304 Backend's sysfs directory (\path{/sys/bus/pci/drivers/pciback}) that can be
1305 used to bind/unbind devices:
1307 \begin{description}
1308 \item[slots] lists all of the PCI slots that the PCI Backend will try to seize
1309 (or "hide" from Domain 0). A PCI slot must appear in this list before it can
1310 be bound to the PCI Backend through the \path{bind} attribute.
1311 \item[new\_slot] write the name of a slot here (in 0000:00:00.0 format) to
1312 have the PCI Backend seize the device in this slot.
1313 \item[remove\_slot] write the name of a slot here (same format as
1314 \path{new\_slot}) to have the PCI Backend no longer try to seize devices in
1315 this slot. Note that this does not unbind the driver from a device it has
1316 already seized.
1317 \item[bind] write the name of a slot here (in 0000:00:00.0 format) to have
1318 the Linux kernel attempt to bind the device in that slot to the PCI Backend
1319 driver.
1320 \item[unbind] write the name of a skit here (same format as \path{bind}) to have
1321 the Linux kernel unbind the device from the PCI Backend. DO NOT unbind a
1322 device while it is currently given to a PCI driver domain!
1323 \end{description}
1325 Some examples:
1327 Bind a device to the PCI Backend which is not bound to any other driver.
1328 \begin{verbatim}
1329 # # Add a new slot to the PCI Backend's list
1330 # echo -n 0000:01:04.d > /sys/bus/pci/drivers/pciback/new_slot
1331 # # Now that the backend is watching for the slot, bind to it
1332 # echo -n 0000:01:04.d > /sys/bus/pci/drivers/pciback/bind
1333 \end{verbatim}
1335 Unbind a device from its driver and bind to the PCI Backend.
1336 \begin{verbatim}
1337 # # Unbind a PCI network card from its network driver
1338 # echo -n 0000:05:02.0 > /sys/bus/pci/drivers/3c905/unbind
1339 # # And now bind it to the PCI Backend
1340 # echo -n 0000:05:02.0 > /sys/bus/pci/drivers/pciback/new_slot
1341 # echo -n 0000:05:02.0 > /sys/bus/pci/drivers/pciback/bind
1342 \end{verbatim}
1344 Note that the "-n" option in the example is important as it causes echo to not
1345 output a new-line.
1347 \subsubsection{PCI Frontend Configuration}
1348 To configure a domU to receive a PCI device:
1350 \begin{description}
1351 \item[Command-line:]
1352 Use the {\em pci} command-line flag. For multiple devices, use the option
1353 multiple times. \\
1354 \centerline{ {\tt xm create netcard-dd pci=01:00.0 pci=02:03.0 }} \\
1356 \item[Flat Format configuration file:]
1357 Specify all of your PCI devices in a python list named {\em pci}. \\
1358 \centerline{ {\tt pci=['01:00.0','02:03.0'] }} \\
1360 \item[SXP Format configuration file:]
1361 Use a single PCI device section for all of your devices (specify the numbers
1362 in hexadecimal with the preceding '0x'). Note that {\em domain} here refers
1363 to the PCI domain, not a virtual machine within Xen.
1364 {\small
1365 \begin{verbatim}
1366 (device (pci
1367 (dev (domain 0x0)(bus 0x3)(slot 0x1a)(func 0x1)
1368 (dev (domain 0x0)(bus 0x1)(slot 0x5)(func 0x0)
1370 \end{verbatim}
1372 \end{description}
1374 %% There are two possible types of privileges: IO privileges and
1375 %% administration privileges.
1380 % Chapter Storage and FileSytem Management
1381 \chapter{Storage and File System Management}
1383 Storage can be made available to virtual machines in a number of
1384 different ways. This chapter covers some possible configurations.
1386 The most straightforward method is to export a physical block device (a
1387 hard drive or partition) from dom0 directly to the guest domain as a
1388 virtual block device (VBD).
1390 Storage may also be exported from a filesystem image or a partitioned
1391 filesystem image as a \emph{file-backed VBD}.
1393 Finally, standard network storage protocols such as NBD, iSCSI, NFS,
1394 etc., can be used to provide storage to virtual machines.
1397 \section{Exporting Physical Devices as VBDs}
1398 \label{s:exporting-physical-devices-as-vbds}
1400 One of the simplest configurations is to directly export individual
1401 partitions from domain~0 to other domains. To achieve this use the
1402 \path{phy:} specifier in your domain configuration file. For example a
1403 line like
1404 \begin{quote}
1405 \verb_disk = ['phy:hda3,sda1,w']_
1406 \end{quote}
1407 specifies that the partition \path{/dev/hda3} in domain~0 should be
1408 exported read-write to the new domain as \path{/dev/sda1}; one could
1409 equally well export it as \path{/dev/hda} or \path{/dev/sdb5} should
1410 one wish.
1412 In addition to local disks and partitions, it is possible to export
1413 any device that Linux considers to be ``a disk'' in the same manner.
1414 For example, if you have iSCSI disks or GNBD volumes imported into
1415 domain~0 you can export these to other domains using the \path{phy:}
1416 disk syntax. E.g.:
1417 \begin{quote}
1418 \verb_disk = ['phy:vg/lvm1,sda2,w']_
1419 \end{quote}
1421 \begin{center}
1422 \framebox{\bf Warning: Block device sharing}
1423 \end{center}
1424 \begin{quote}
1425 Block devices should typically only be shared between domains in a
1426 read-only fashion otherwise the Linux kernel's file systems will get
1427 very confused as the file system structure may change underneath
1428 them (having the same ext3 partition mounted \path{rw} twice is a
1429 sure fire way to cause irreparable damage)! \Xend\ will attempt to
1430 prevent you from doing this by checking that the device is not
1431 mounted read-write in domain~0, and hasn't already been exported
1432 read-write to another domain. If you want read-write sharing,
1433 export the directory to other domains via NFS from domain~0 (or use
1434 a cluster file system such as GFS or ocfs2).
1435 \end{quote}
1438 \section{Using File-backed VBDs}
1440 It is also possible to use a file in Domain~0 as the primary storage
1441 for a virtual machine. As well as being convenient, this also has the
1442 advantage that the virtual block device will be \emph{sparse} ---
1443 space will only really be allocated as parts of the file are used. So
1444 if a virtual machine uses only half of its disk space then the file
1445 really takes up half of the size allocated.
1447 For example, to create a 2GB sparse file-backed virtual block device
1448 (actually only consumes 1KB of disk):
1449 \begin{quote}
1450 \verb_# dd if=/dev/zero of=vm1disk bs=1k seek=2048k count=1_
1451 \end{quote}
1453 Make a file system in the disk file:
1454 \begin{quote}
1455 \verb_# mkfs -t ext3 vm1disk_
1456 \end{quote}
1458 (when the tool asks for confirmation, answer `y')
1460 Populate the file system e.g.\ by copying from the current root:
1461 \begin{quote}
1462 \begin{verbatim}
1463 # mount -o loop vm1disk /mnt
1464 # cp -ax /{root,dev,var,etc,usr,bin,sbin,lib} /mnt
1465 # mkdir /mnt/{proc,sys,home,tmp}
1466 \end{verbatim}
1467 \end{quote}
1469 Tailor the file system by editing \path{/etc/fstab},
1470 \path{/etc/hostname}, etc.\ Don't forget to edit the files in the
1471 mounted file system, instead of your domain~0 filesystem, e.g.\ you
1472 would edit \path{/mnt/etc/fstab} instead of \path{/etc/fstab}. For
1473 this example put \path{/dev/sda1} to root in fstab.
1475 Now unmount (this is important!):
1476 \begin{quote}
1477 \verb_# umount /mnt_
1478 \end{quote}
1480 In the configuration file set:
1481 \begin{quote}
1482 \verb_disk = ['file:/full/path/to/vm1disk,sda1,w']_
1483 \end{quote}
1485 As the virtual machine writes to its `disk', the sparse file will be
1486 filled in and consume more space up to the original 2GB.
1488 {\bf Note that file-backed VBDs may not be appropriate for backing
1489 I/O-intensive domains.} File-backed VBDs are known to experience
1490 substantial slowdowns under heavy I/O workloads, due to the I/O
1491 handling by the loopback block device used to support file-backed VBDs
1492 in dom0. Better I/O performance can be achieved by using either
1493 LVM-backed VBDs (Section~\ref{s:using-lvm-backed-vbds}) or physical
1494 devices as VBDs (Section~\ref{s:exporting-physical-devices-as-vbds}).
1496 Linux supports a maximum of eight file-backed VBDs across all domains
1497 by default. This limit can be statically increased by using the
1498 \emph{max\_loop} module parameter if CONFIG\_BLK\_DEV\_LOOP is
1499 compiled as a module in the dom0 kernel, or by using the
1500 \emph{max\_loop=n} boot option if CONFIG\_BLK\_DEV\_LOOP is compiled
1501 directly into the dom0 kernel.
1504 \section{Using LVM-backed VBDs}
1505 \label{s:using-lvm-backed-vbds}
1507 A particularly appealing solution is to use LVM volumes as backing for
1508 domain file-systems since this allows dynamic growing/shrinking of
1509 volumes as well as snapshot and other features.
1511 To initialize a partition to support LVM volumes:
1512 \begin{quote}
1513 \begin{verbatim}
1514 # pvcreate /dev/sda10
1515 \end{verbatim}
1516 \end{quote}
1518 Create a volume group named `vg' on the physical partition:
1519 \begin{quote}
1520 \begin{verbatim}
1521 # vgcreate vg /dev/sda10
1522 \end{verbatim}
1523 \end{quote}
1525 Create a logical volume of size 4GB named `myvmdisk1':
1526 \begin{quote}
1527 \begin{verbatim}
1528 # lvcreate -L4096M -n myvmdisk1 vg
1529 \end{verbatim}
1530 \end{quote}
1532 You should now see that you have a \path{/dev/vg/myvmdisk1} Make a
1533 filesystem, mount it and populate it, e.g.:
1534 \begin{quote}
1535 \begin{verbatim}
1536 # mkfs -t ext3 /dev/vg/myvmdisk1
1537 # mount /dev/vg/myvmdisk1 /mnt
1538 # cp -ax / /mnt
1539 # umount /mnt
1540 \end{verbatim}
1541 \end{quote}
1543 Now configure your VM with the following disk configuration:
1544 \begin{quote}
1545 \begin{verbatim}
1546 disk = [ 'phy:vg/myvmdisk1,sda1,w' ]
1547 \end{verbatim}
1548 \end{quote}
1550 LVM enables you to grow the size of logical volumes, but you'll need
1551 to resize the corresponding file system to make use of the new space.
1552 Some file systems (e.g.\ ext3) now support online resize. See the LVM
1553 manuals for more details.
1555 You can also use LVM for creating copy-on-write (CoW) clones of LVM
1556 volumes (known as writable persistent snapshots in LVM terminology).
1557 This facility is new in Linux 2.6.8, so isn't as stable as one might
1558 hope. In particular, using lots of CoW LVM disks consumes a lot of
1559 dom0 memory, and error conditions such as running out of disk space
1560 are not handled well. Hopefully this will improve in future.
1562 To create two copy-on-write clones of the above file system you would
1563 use the following commands:
1565 \begin{quote}
1566 \begin{verbatim}
1567 # lvcreate -s -L1024M -n myclonedisk1 /dev/vg/myvmdisk1
1568 # lvcreate -s -L1024M -n myclonedisk2 /dev/vg/myvmdisk1
1569 \end{verbatim}
1570 \end{quote}
1572 Each of these can grow to have 1GB of differences from the master
1573 volume. You can grow the amount of space for storing the differences
1574 using the lvextend command, e.g.:
1575 \begin{quote}
1576 \begin{verbatim}
1577 # lvextend +100M /dev/vg/myclonedisk1
1578 \end{verbatim}
1579 \end{quote}
1581 Don't let the `differences volume' ever fill up otherwise LVM gets
1582 rather confused. It may be possible to automate the growing process by
1583 using \path{dmsetup wait} to spot the volume getting full and then
1584 issue an \path{lvextend}.
1586 In principle, it is possible to continue writing to the volume that
1587 has been cloned (the changes will not be visible to the clones), but
1588 we wouldn't recommend this: have the cloned volume as a `pristine'
1589 file system install that isn't mounted directly by any of the virtual
1590 machines.
1593 \section{Using NFS Root}
1595 First, populate a root filesystem in a directory on the server
1596 machine. This can be on a distinct physical machine, or simply run
1597 within a virtual machine on the same node.
1599 Now configure the NFS server to export this filesystem over the
1600 network by adding a line to \path{/etc/exports}, for instance:
1602 \begin{quote}
1603 \begin{small}
1604 \begin{verbatim}
1605 /export/vm1root (rw,sync,no_root_squash)
1606 \end{verbatim}
1607 \end{small}
1608 \end{quote}
1610 Finally, configure the domain to use NFS root. In addition to the
1611 normal variables, you should make sure to set the following values in
1612 the domain's configuration file:
1614 \begin{quote}
1615 \begin{small}
1616 \begin{verbatim}
1617 root = '/dev/nfs'
1618 nfs_server = '' # substitute IP address of server
1619 nfs_root = '/path/to/root' # path to root FS on the server
1620 \end{verbatim}
1621 \end{small}
1622 \end{quote}
1624 The domain will need network access at boot time, so either statically
1625 configure an IP address using the config variables \path{ip},
1626 \path{netmask}, \path{gateway}, \path{hostname}; or enable DHCP
1627 (\path{dhcp='dhcp'}).
1629 Note that the Linux NFS root implementation is known to have stability
1630 problems under high load (this is not a Xen-specific problem), so this
1631 configuration may not be appropriate for critical servers.
1634 \chapter{CPU Management}
1636 %% KMS Something sage about CPU / processor management.
1638 Xen allows a domain's virtual CPU(s) to be associated with one or more
1639 host CPUs. This can be used to allocate real resources among one or
1640 more guests, or to make optimal use of processor resources when
1641 utilizing dual-core, hyperthreading, or other advanced CPU technologies.
1643 Xen enumerates physical CPUs in a `depth first' fashion. For a system
1644 with both hyperthreading and multiple cores, this would be all the
1645 hyperthreads on a given core, then all the cores on a given socket,
1646 and then all sockets. I.e. if you had a two socket, dual core,
1647 hyperthreaded Xeon the CPU order would be:
1650 \begin{center}
1651 \begin{tabular}{l|l|l|l|l|l|l|r}
1652 \multicolumn{4}{c|}{socket0} & \multicolumn{4}{c}{socket1} \\ \hline
1653 \multicolumn{2}{c|}{core0} & \multicolumn{2}{c|}{core1} &
1654 \multicolumn{2}{c|}{core0} & \multicolumn{2}{c}{core1} \\ \hline
1655 ht0 & ht1 & ht0 & ht1 & ht0 & ht1 & ht0 & ht1 \\
1656 \#0 & \#1 & \#2 & \#3 & \#4 & \#5 & \#6 & \#7 \\
1657 \end{tabular}
1658 \end{center}
1661 Having multiple vcpus belonging to the same domain mapped to the same
1662 physical CPU is very likely to lead to poor performance. It's better to
1663 use `vcpus-set' to hot-unplug one of the vcpus and ensure the others are
1664 pinned on different CPUs.
1666 If you are running IO intensive tasks, its typically better to dedicate
1667 either a hyperthread or whole core to running domain 0, and hence pin
1668 other domains so that they can't use CPU 0. If your workload is mostly
1669 compute intensive, you may want to pin vcpus such that all physical CPU
1670 threads are available for guest domains.
1672 \chapter{Migrating Domains}
1674 \section{Domain Save and Restore}
1676 The administrator of a Xen system may suspend a virtual machine's
1677 current state into a disk file in domain~0, allowing it to be resumed at
1678 a later time.
1680 For example you can suspend a domain called ``VM1'' to disk using the
1681 command:
1682 \begin{verbatim}
1683 # xm save VM1 VM1.chk
1684 \end{verbatim}
1686 This will stop the domain named ``VM1'' and save its current state
1687 into a file called \path{VM1.chk}.
1689 To resume execution of this domain, use the \path{xm restore} command:
1690 \begin{verbatim}
1691 # xm restore VM1.chk
1692 \end{verbatim}
1694 This will restore the state of the domain and resume its execution.
1695 The domain will carry on as before and the console may be reconnected
1696 using the \path{xm console} command, as described earlier.
1698 \section{Migration and Live Migration}
1700 Migration is used to transfer a domain between physical hosts. There
1701 are two varieties: regular and live migration. The former moves a
1702 virtual machine from one host to another by pausing it, copying its
1703 memory contents, and then resuming it on the destination. The latter
1704 performs the same logical functionality but without needing to pause
1705 the domain for the duration. In general when performing live migration
1706 the domain continues its usual activities and---from the user's
1707 perspective---the migration should be imperceptible.
1709 To perform a live migration, both hosts must be running Xen / \xend\ and
1710 the destination host must have sufficient resources (e.g.\ memory
1711 capacity) to accommodate the domain after the move. Furthermore we
1712 currently require both source and destination machines to be on the same
1713 L2 subnet.
1715 Currently, there is no support for providing automatic remote access
1716 to filesystems stored on local disk when a domain is migrated.
1717 Administrators should choose an appropriate storage solution (i.e.\
1718 SAN, NAS, etc.) to ensure that domain filesystems are also available
1719 on their destination node. GNBD is a good method for exporting a
1720 volume from one machine to another. iSCSI can do a similar job, but is
1721 more complex to set up.
1723 When a domain migrates, it's MAC and IP address move with it, thus it is
1724 only possible to migrate VMs within the same layer-2 network and IP
1725 subnet. If the destination node is on a different subnet, the
1726 administrator would need to manually configure a suitable etherip or IP
1727 tunnel in the domain~0 of the remote node.
1729 A domain may be migrated using the \path{xm migrate} command. To live
1730 migrate a domain to another machine, we would use the command:
1732 \begin{verbatim}
1733 # xm migrate --live mydomain
1734 \end{verbatim}
1736 Without the \path{--live} flag, \xend\ simply stops the domain and
1737 copies the memory image over to the new node and restarts it. Since
1738 domains can have large allocations this can be quite time consuming,
1739 even on a Gigabit network. With the \path{--live} flag \xend\ attempts
1740 to keep the domain running while the migration is in progress, resulting
1741 in typical down times of just 60--300ms.
1743 For now it will be necessary to reconnect to the domain's console on the
1744 new machine using the \path{xm console} command. If a migrated domain
1745 has any open network connections then they will be preserved, so SSH
1746 connections do not have this limitation.
1749 %% Chapter Securing Xen
1750 \chapter{Securing Xen}
1752 This chapter describes how to secure a Xen system. It describes a number
1753 of scenarios and provides a corresponding set of best practices. It
1754 begins with a section devoted to understanding the security implications
1755 of a Xen system.
1758 \section{Xen Security Considerations}
1760 When deploying a Xen system, one must be sure to secure the management
1761 domain (Domain-0) as much as possible. If the management domain is
1762 compromised, all other domains are also vulnerable. The following are a
1763 set of best practices for Domain-0:
1765 \begin{enumerate}
1766 \item \textbf{Run the smallest number of necessary services.} The less
1767 things that are present in a management partition, the better.
1768 Remember, a service running as root in the management domain has full
1769 access to all other domains on the system.
1770 \item \textbf{Use a firewall to restrict the traffic to the management
1771 domain.} A firewall with default-reject rules will help prevent
1772 attacks on the management domain.
1773 \item \textbf{Do not allow users to access Domain-0.} The Linux kernel
1774 has been known to have local-user root exploits. If you allow normal
1775 users to access Domain-0 (even as unprivileged users) you run the risk
1776 of a kernel exploit making all of your domains vulnerable.
1777 \end{enumerate}
1779 \section{Driver Domain Security Considerations}
1780 \label{s:ddsecurity}
1782 Driver domains address a range of security problems that exist regarding
1783 the use of device drivers and hardware. On many operating systems in common
1784 use today, device drivers run within the kernel with the same privileges as
1785 the kernel. Few or no mechanisms exist to protect the integrity of the kernel
1786 from a misbehaving (read "buggy") or malicious device driver. Driver
1787 domains exist to aid in isolating a device driver within its own virtual
1788 machine where it cannot affect the stability and integrity of other
1789 domains. If a driver crashes, the driver domain can be restarted rather than
1790 have the entire machine crash (and restart) with it. Drivers written by
1791 unknown or untrusted third-parties can be confined to an isolated space.
1792 Driver domains thus address a number of security and stability issues with
1793 device drivers.
1795 However, due to limitations in current hardware, a number of security
1796 concerns remain that need to be considered when setting up driver domains (it
1797 should be noted that the following list is not intended to be exhaustive).
1799 \begin{enumerate}
1800 \item \textbf{Without an IOMMU, a hardware device can DMA to memory regions
1801 outside of its controlling domain.} Architectures which do not have an
1802 IOMMU (e.g. most x86-based platforms) to restrict DMA usage by hardware
1803 are vulnerable. A hardware device which can perform arbitrary memory reads
1804 and writes can read/write outside of the memory of its controlling domain.
1805 A malicious or misbehaving domain could use a hardware device it controls
1806 to send data overwriting memory in another domain or to read arbitrary
1807 regions of memory in another domain.
1808 \item \textbf{Shared buses are vulnerable to sniffing.} Devices that share
1809 a data bus can sniff (and possible spoof) each others' data. Device A that
1810 is assigned to Domain A could eavesdrop on data being transmitted by
1811 Domain B to Device B and then relay that data back to Domain A.
1812 \item \textbf{Devices which share interrupt lines can either prevent the
1813 reception of that interrupt by the driver domain or can trigger the
1814 interrupt service routine of that guest needlessly.} A devices which shares
1815 a level-triggered interrupt (e.g. PCI devices) with another device can
1816 raise an interrupt and never clear it. This effectively blocks other devices
1817 which share that interrupt line from notifying their controlling driver
1818 domains that they need to be serviced. A device which shares an
1819 any type of interrupt line can trigger its interrupt continually which
1820 forces execution time to be spent (in multiple guests) in the interrupt
1821 service routine (potentially denying time to other processes within that
1822 guest). System architectures which allow each device to have its own
1823 interrupt line (e.g. PCI's Message Signaled Interrupts) are less
1824 vulnerable to this denial-of-service problem.
1825 \item \textbf{Devices may share the use of I/O memory address space.} Xen can
1826 only restrict access to a device's physical I/O resources at a certain
1827 granularity. For interrupt lines and I/O port address space, that
1828 granularity is very fine (per interrupt line and per I/O port). However,
1829 Xen can only restrict access to I/O memory address space on a page size
1830 basis. If more than one device shares use of a page in I/O memory address
1831 space, the domains to which those devices are assigned will be able to
1832 access the I/O memory address space of each other's devices.
1833 \end{enumerate}
1836 \section{Security Scenarios}
1839 \subsection{The Isolated Management Network}
1841 In this scenario, each node has two network cards in the cluster. One
1842 network card is connected to the outside world and one network card is a
1843 physically isolated management network specifically for Xen instances to
1844 use.
1846 As long as all of the management partitions are trusted equally, this is
1847 the most secure scenario. No additional configuration is needed other
1848 than forcing Xend to bind to the management interface for relocation.
1851 \subsection{A Subnet Behind a Firewall}
1853 In this scenario, each node has only one network card but the entire
1854 cluster sits behind a firewall. This firewall should do at least the
1855 following:
1857 \begin{enumerate}
1858 \item Prevent IP spoofing from outside of the subnet.
1859 \item Prevent access to the relocation port of any of the nodes in the
1860 cluster except from within the cluster.
1861 \end{enumerate}
1863 The following iptables rules can be used on each node to prevent
1864 migrations to that node from outside the subnet assuming the main
1865 firewall does not do this for you:
1867 \begin{verbatim}
1868 # this command disables all access to the Xen relocation
1869 # port:
1870 iptables -A INPUT -p tcp --destination-port 8002 -j REJECT
1872 # this command enables Xen relocations only from the specific
1873 # subnet:
1874 iptables -I INPUT -p tcp -{}-source \
1875 --destination-port 8002 -j ACCEPT
1876 \end{verbatim}
1878 \subsection{Nodes on an Untrusted Subnet}
1880 Migration on an untrusted subnet is not safe in current versions of Xen.
1881 It may be possible to perform migrations through a secure tunnel via an
1882 VPN or SSH. The only safe option in the absence of a secure tunnel is to
1883 disable migration completely. The easiest way to do this is with
1884 iptables:
1886 \begin{verbatim}
1887 # this command disables all access to the Xen relocation port
1888 iptables -A INPUT -p tcp -{}-destination-port 8002 -j REJECT
1889 \end{verbatim}
1891 \part{Reference}
1893 %% Chapter Build and Boot Options
1894 \chapter{Build and Boot Options}
1896 This chapter describes the build- and boot-time options which may be
1897 used to tailor your Xen system.
1899 \section{Top-level Configuration Options}
1901 Top-level configuration is achieved by editing one of two
1902 files: \path{} and \path{Makefile}.
1904 The former allows the overall build target architecture to be
1905 specified. You will typically not need to modify this unless
1906 you are cross-compiling or if you wish to build a PAE-enabled
1907 Xen system. Additional configuration options are documented
1908 in the \path{} file.
1910 The top-level \path{Makefile} is chiefly used to customize the set of
1911 kernels built. Look for the line:
1912 \begin{quote}
1913 \begin{verbatim}
1914 KERNELS ?= linux-2.6-xen0 linux-2.6-xenU
1915 \end{verbatim}
1916 \end{quote}
1918 Allowable options here are any kernels which have a corresponding
1919 build configuration file in the \path{buildconfigs/} directory.
1923 \section{Xen Build Options}
1925 Xen provides a number of build-time options which should be set as
1926 environment variables or passed on make's command-line.
1928 \begin{description}
1929 \item[verbose=y] Enable debugging messages when Xen detects an
1930 unexpected condition. Also enables console output from all domains.
1931 \item[debug=y] Enable debug assertions. Implies {\bf verbose=y}.
1932 (Primarily useful for tracing bugs in Xen).
1933 \item[debugger=y] Enable the in-Xen debugger. This can be used to
1934 debug Xen, guest OSes, and applications.
1935 \item[perfc=y] Enable performance counters for significant events
1936 within Xen. The counts can be reset or displayed on Xen's console
1937 via console control keys.
1938 \end{description}
1941 \section{Xen Boot Options}
1942 \label{s:xboot}
1944 These options are used to configure Xen's behaviour at runtime. They
1945 should be appended to Xen's command line, either manually or by
1946 editing \path{grub.conf}.
1948 \begin{description}
1949 \item [ noreboot ] Don't reboot the machine automatically on errors.
1950 This is useful to catch debug output if you aren't catching console
1951 messages via the serial line.
1952 \item [ nosmp ] Disable SMP support. This option is implied by
1953 `ignorebiostables'.
1954 \item [ watchdog ] Enable NMI watchdog which can report certain
1955 failures.
1956 \item [ noirqbalance ] Disable software IRQ balancing and affinity.
1957 This can be used on systems such as Dell 1850/2850 that have
1958 workarounds in hardware for IRQ-routing issues.
1959 \item [ badpage=$<$page number$>$,$<$page number$>$, \ldots ] Specify
1960 a list of pages not to be allocated for use because they contain bad
1961 bytes. For example, if your memory tester says that byte 0x12345678
1962 is bad, you would place `badpage=0x12345' on Xen's command line.
1963 \item [ com1=$<$baud$>$,DPS,$<$io\_base$>$,$<$irq$>$
1964 com2=$<$baud$>$,DPS,$<$io\_base$>$,$<$irq$>$ ] \mbox{}\\
1965 Xen supports up to two 16550-compatible serial ports. For example:
1966 `com1=9600, 8n1, 0x408, 5' maps COM1 to a 9600-baud port, 8 data
1967 bits, no parity, 1 stop bit, I/O port base 0x408, IRQ 5. If some
1968 configuration options are standard (e.g., I/O base and IRQ), then
1969 only a prefix of the full configuration string need be specified. If
1970 the baud rate is pre-configured (e.g., by the bootloader) then you
1971 can specify `auto' in place of a numeric baud rate.
1972 \item [ console=$<$specifier list$>$ ] Specify the destination for Xen
1973 console I/O. This is a comma-separated list of, for example:
1974 \begin{description}
1975 \item[ vga ] Use VGA console (only until domain 0 boots, unless {\bf
1976 vga[keep] } is specified).
1977 \item[ com1 ] Use serial port com1.
1978 \item[ com2H ] Use serial port com2. Transmitted chars will have the
1979 MSB set. Received chars must have MSB set.
1980 \item[ com2L] Use serial port com2. Transmitted chars will have the
1981 MSB cleared. Received chars must have MSB cleared.
1982 \end{description}
1983 The latter two examples allow a single port to be shared by two
1984 subsystems (e.g.\ console and debugger). Sharing is controlled by
1985 MSB of each transmitted/received character. [NB. Default for this
1986 option is `com1,vga']
1987 \item [ sync\_console ] Force synchronous console output. This is
1988 useful if you system fails unexpectedly before it has sent all
1989 available output to the console. In most cases Xen will
1990 automatically enter synchronous mode when an exceptional event
1991 occurs, but this option provides a manual fallback.
1992 \item [ conswitch=$<$switch-char$><$auto-switch-char$>$ ] Specify how
1993 to switch serial-console input between Xen and DOM0. The required
1994 sequence is CTRL-$<$switch-char$>$ pressed three times. Specifying
1995 the backtick character disables switching. The
1996 $<$auto-switch-char$>$ specifies whether Xen should auto-switch
1997 input to DOM0 when it boots --- if it is `x' then auto-switching is
1998 disabled. Any other value, or omitting the character, enables
1999 auto-switching. [NB. Default switch-char is `a'.]
2000 \item [ nmi=xxx ]
2001 Specify what to do with an NMI parity or I/O error. \\
2002 `nmi=fatal': Xen prints a diagnostic and then hangs. \\
2003 `nmi=dom0': Inform DOM0 of the NMI. \\
2004 `nmi=ignore': Ignore the NMI.
2005 \item [ mem=xxx ] Set the physical RAM address limit. Any RAM
2006 appearing beyond this physical address in the memory map will be
2007 ignored. This parameter may be specified with a B, K, M or G suffix,
2008 representing bytes, kilobytes, megabytes and gigabytes respectively.
2009 The default unit, if no suffix is specified, is kilobytes.
2010 \item [ dom0\_mem=xxx ] Set the amount of memory to be allocated to
2011 domain0. In Xen 3.x the parameter may be specified with a B, K, M or
2012 G suffix, representing bytes, kilobytes, megabytes and gigabytes
2013 respectively; if no suffix is specified, the parameter defaults to
2014 kilobytes. In previous versions of Xen, suffixes were not supported
2015 and the value is always interpreted as kilobytes.
2016 \item [ tbuf\_size=xxx ] Set the size of the per-cpu trace buffers, in
2017 pages (default 0).
2018 \item [ sched=xxx ] Select the CPU scheduler Xen should use. The
2019 current possibilities are `sedf' (default), `credit', and `bvt'.
2020 \item [ apic\_verbosity=debug,verbose ] Print more detailed
2021 information about local APIC and IOAPIC configuration.
2022 \item [ lapic ] Force use of local APIC even when left disabled by
2023 uniprocessor BIOS.
2024 \item [ nolapic ] Ignore local APIC in a uniprocessor system, even if
2025 enabled by the BIOS.
2026 \item [ apic=bigsmp,default,es7000,summit ] Specify NUMA platform.
2027 This can usually be probed automatically.
2028 \end{description}
2030 In addition, the following options may be specified on the Xen command
2031 line. Since domain 0 shares responsibility for booting the platform,
2032 Xen will automatically propagate these options to its command line.
2033 These options are taken from Linux's command-line syntax with
2034 unchanged semantics.
2036 \begin{description}
2037 \item [ acpi=off,force,strict,ht,noirq,\ldots ] Modify how Xen (and
2038 domain 0) parses the BIOS ACPI tables.
2039 \item [ acpi\_skip\_timer\_override ] Instruct Xen (and domain~0) to
2040 ignore timer-interrupt override instructions specified by the BIOS
2041 ACPI tables.
2042 \item [ noapic ] Instruct Xen (and domain~0) to ignore any IOAPICs
2043 that are present in the system, and instead continue to use the
2044 legacy PIC.
2045 \end{description}
2048 \section{XenLinux Boot Options}
2050 In addition to the standard Linux kernel boot options, we support:
2051 \begin{description}
2052 \item[ xencons=xxx ] Specify the device node to which the Xen virtual
2053 console driver is attached. The following options are supported:
2054 \begin{center}
2055 \begin{tabular}{l}
2056 `xencons=off': disable virtual console \\
2057 `xencons=tty': attach console to /dev/tty1 (tty0 at boot-time) \\
2058 `xencons=ttyS': attach console to /dev/ttyS0
2059 \end{tabular}
2060 \end{center}
2061 The default is ttyS for dom0 and tty for all other domains.
2062 \end{description}
2065 %% Chapter Further Support
2066 \chapter{Further Support}
2068 If you have questions that are not answered by this manual, the
2069 sources of information listed below may be of interest to you. Note
2070 that bug reports, suggestions and contributions related to the
2071 software (or the documentation) should be sent to the Xen developers'
2072 mailing list (address below).
2075 \section{Other Documentation}
2077 For developers interested in porting operating systems to Xen, the
2078 \emph{Xen Interface Manual} is distributed in the \path{docs/}
2079 directory of the Xen source distribution.
2082 \section{Online References}
2084 The official Xen web site can be found at:
2085 \begin{quote} {\tt}
2086 \end{quote}
2088 This contains links to the latest versions of all online
2089 documentation, including the latest version of the FAQ.
2091 Information regarding Xen is also available at the Xen Wiki at
2092 \begin{quote} {\tt}\end{quote}
2093 The Xen project uses Bugzilla as its bug tracking system. You'll find
2094 the Xen Bugzilla at
2097 \section{Mailing Lists}
2099 There are several mailing lists that are used to discuss Xen related
2100 topics. The most widely relevant are listed below. An official page of
2101 mailing lists and subscription information can be found at \begin{quote}
2102 {\tt} \end{quote}
2104 \begin{description}
2105 \item[] Used for development
2106 discussions and bug reports. Subscribe at: \\
2107 {\small {\tt}}
2108 \item[] Used for installation and usage
2109 discussions and requests for help. Subscribe at: \\
2110 {\small {\tt}}
2111 \item[] Used for announcements only.
2112 Subscribe at: \\
2113 {\small {\tt}}
2114 \item[] Changelog feed
2115 from the unstable and 2.0 trees - developer oriented. Subscribe at: \\
2116 {\small {\tt}}
2117 \end{description}
2121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2123 \appendix
2125 \chapter{Unmodified (VMX) guest domains in Xen with Intel\textregistered Virtualization Technology (VT)}
2127 Xen supports guest domains running unmodified Guest operating systems using Virtualization Technology (VT) available on recent Intel Processors. More information about the Intel Virtualization Technology implementing Virtual Machine Extensions (VMX) in the processor is available on the Intel website at \\
2128 {\small {\tt}}
2130 \section{Building Xen with VT support}
2132 The following packages need to be installed in order to build Xen with VT support. Some Linux distributions do not provide these packages by default.
2134 \begin{tabular}{lp{11.0cm}}
2135 {\bfseries Package} & {\bfseries Description} \\
2137 dev86 & The dev86 package provides an assembler and linker for real mode 80x86 instructions. You need to have this package installed in order to build the BIOS code which runs in (virtual) real mode.
2139 If the dev86 package is not available on the x86\_64 distribution, you can install the i386 version of it. The dev86 rpm package for various distributions can be found at {\scriptsize {\tt\&submit=Search}} \\
2141 LibVNCServer & The unmodified guest's VGA display, keyboard, and mouse can be virtualized by the vncserver library. You can get the sources of libvncserver from {\small {\tt}}. Build and install the sources on the build system to get the libvncserver library. There is a significant performance degradation in 0.8 version. The current sources in the CVS tree have fixed this degradation. So it is highly recommended to download the latest CVS sources and install them.\\
2143 SDL-devel, SDL & Simple DirectMedia Layer (SDL) is another way of virtualizing the unmodified guest console. It provides an X window for the guest console.
2145 If the SDL and SDL-devel packages are not installed by default on the build system, they can be obtained from {\scriptsize {\tt\&amp;submit=Search}}
2146 , {\scriptsize {\tt\&submit=Search}} \\
2148 \end{tabular}
2150 \section{Configuration file for unmodified VMX guests}
2152 The Xen installation includes a sample configuration file, {\small {\tt /etc/xen/xmexample.vmx}}. There are comments describing all the options. In addition to the common options that are the same as those for paravirtualized guest configurations, VMX guest configurations have the following settings:
2154 \begin{tabular}{lp{11.0cm}}
2156 {\bfseries Parameter} & {\bfseries Description} \\
2158 kernel & The VMX firmware loader, {\small {\tt /usr/lib/xen/boot/vmxloader}}\\
2160 builder & The domain build function. The VMX domain uses the vmx builder.\\
2162 acpi & Enable VMX guest ACPI, default=0 (disabled)\\
2164 apic & Enable VMX guest APIC, default=0 (disabled)\\
2166 pae & Enable VMX guest PAE, default=0 (disabled)\\
2168 vif & Optionally defines MAC address and/or bridge for the network interfaces. Random MACs are assigned if not given. {\small {\tt type=ioemu}} means ioemu is used to virtualize the VMX NIC. If no type is specified, vbd is used, as with paravirtualized guests.\\
2170 disk & Defines the disk devices you want the domain to have access to, and what you want them accessible as. If using a physical device as the VMX guest's disk, each disk entry is of the form
2172 {\small {\tt phy:UNAME,ioemu:DEV,MODE,}}
2174 where UNAME is the device, DEV is the device name the domain will see, and MODE is r for read-only, w for read-write. ioemu means the disk will use ioemu to virtualize the VMX disk. If not adding ioemu, it uses vbd like paravirtualized guests.
2176 If using disk image file, its form should be like
2178 {\small {\tt file:FILEPATH,ioemu:DEV,MODE}}
2180 If using more than one disk, there should be a comma between each disk entry. For example:
2182 {\scriptsize {\tt disk = ['file:/var/images/image1.img,ioemu:hda,w', 'file:/var/images/image2.img,ioemu:hdb,w']}}\\
2184 cdrom & Disk image for CD-ROM. The default is {\small {\tt /dev/cdrom}} for Domain0. Inside the VMX domain, the CD-ROM will available as device {\small {\tt /dev/hdc}}. The entry can also point to an ISO file.\\
2186 boot & Boot from floppy (a), hard disk (c) or CD-ROM (d). For example, to boot from CD-ROM, the entry should be:
2188 boot='d'\\
2190 device\_model & The device emulation tool for VMX guests. This parameter should not be changed.\\
2192 sdl & Enable SDL library for graphics, default = 0 (disabled)\\
2194 vnc & Enable VNC library for graphics, default = 1 (enabled)\\
2196 vncviewer & Enable spawning of the vncviewer (only valid when vnc=1), default = 1 (enabled)
2198 If vnc=1 and vncviewer=0, user can use vncviewer to manually connect VMX from remote. For example:
2200 {\small {\tt vncviewer domain0\_IP\_address:VMX\_domain\_id}} \\
2202 ne2000 & Enable ne2000, default = 0 (disabled; use pcnet)\\
2204 serial & Enable redirection of VMX serial output to pty device\\
2206 localtime & Set the real time clock to local time [default=0, that is, set to UTC].\\
2208 enable-audio & Enable audio support. This is under development.\\
2210 full-screen & Start in full screen. This is under development.\\
2212 nographic & Another way to redirect serial output. If enabled, no 'sdl' or 'vnc' can work. Not recommended.\\
2214 \end{tabular}
2217 \section{Creating virtual disks from scratch}
2218 \subsection{Using physical disks}
2219 If you are using a physical disk or physical disk partition, you need to install a Linux OS on the disk first. Then the boot loader should be installed in the correct place. For example {\small {\tt dev/sda}} for booting from the whole disk, or {\small {\tt /dev/sda1}} for booting from partition 1.
2221 \subsection{Using disk image files}
2222 You need to create a large empty disk image file first; then, you need to install a Linux OS onto it. There are two methods you can choose. One is directly installing it using a VMX guest while booting from the OS installation CD-ROM. The other is copying an installed OS into it. The boot loader will also need to be installed.
2224 \subsubsection*{To create the image file:}
2225 The image size should be big enough to accommodate the entire OS. This example assumes the size is 1G (which is probably too small for most OSes).
2227 {\small {\tt \# dd if=/dev/zero of=hd.img bs=1M count=1 seek=1023}}
2229 \subsubsection*{To directly install Linux OS into an image file using a VMX guest:}
2231 Install Xen and create VMX with the original image file with booting from CD-ROM. Then it is just like a normal Linux OS installation. The VMX configuration file should have these two entries before creating:
2233 {\small {\tt cdrom='/dev/cdrom'
2234 boot='d'}}
2236 If this method does not succeed, you can choose the following method of copying an installed Linux OS into an image file.
2238 \subsubsection*{To copy a installed OS into an image file:}
2239 Directly installing is an easier way to make partitions and install an OS in a disk image file. But if you want to create a specific OS in your disk image, then you will most likely want to use this method.
2241 \begin{enumerate}
2242 \item {\bfseries Install a normal Linux OS on the host machine}\\
2243 You can choose any way to install Linux, such as using yum to install Red Hat Linux or YAST to install Novell SuSE Linux. The rest of this example assumes the Linux OS is installed in {\small {\tt /var/guestos/}}.
2245 \item {\bfseries Make the partition table}\\
2246 The image file will be treated as hard disk, so you should make the partition table in the image file. For example:
2248 {\scriptsize {\tt \# losetup /dev/loop0 hd.img\\
2249 \# fdisk -b 512 -C 4096 -H 16 -S 32 /dev/loop0\\
2250 press 'n' to add new partition\\
2251 press 'p' to choose primary partition\\
2252 press '1' to set partition number\\
2253 press "Enter" keys to choose default value of "First Cylinder" parameter.\\
2254 press "Enter" keys to choose default value of "Last Cylinder" parameter.\\
2255 press 'w' to write partition table and exit\\
2256 \# losetup -d /dev/loop0}}
2258 \item {\bfseries Make the file system and install grub}\\
2259 {\scriptsize {\tt \# ln -s /dev/loop0 /dev/loop\\
2260 \# losetup /dev/loop0 hd.img\\
2261 \# losetup -o 16384 /dev/loop1 hd.img\\
2262 \# mkfs.ext3 /dev/loop1\\
2263 \# mount /dev/loop1 /mnt\\
2264 \# mkdir -p /mnt/boot/grub\\
2265 \# cp /boot/grub/stage* /boot/grub/e2fs\_stage1\_5 /mnt/boot/grub\\
2266 \# umount /mnt\\
2267 \# grub\\
2268 grub> device (hd0) /dev/loop\\
2269 grub> root (hd0,0)\\
2270 grub> setup (hd0)\\
2271 grub> quit\\
2272 \# rm /dev/loop\\
2273 \# losetup -d /dev/loop0\\
2274 \# losetup -d /dev/loop1}}
2276 The {\small {\tt losetup}} option {\small {\tt -o 16384}} skips the partition table in the image file. It is the number of sectors times 512. We need {\small {\tt /dev/loop}} because grub is expecting a disk device \emph{name}, where \emph{name} represents the entire disk and \emph{name1} represents the first partition.
2278 \item {\bfseries Copy the OS files to the image}\\
2279 If you have Xen installed, you can easily use {\small {\tt lomount}} instead of {\small {\tt losetup}} and {\small {\tt mount}} when coping files to some partitions. {\small {\tt lomount}} just needs the partition information.
2281 {\scriptsize {\tt \# lomount -t ext3 -diskimage hd.img -partition 1 /mnt/guest\\
2282 \# cp -ax /var/guestos/\{root,dev,var,etc,usr,bin,sbin,lib\} /mnt/guest\\
2283 \# mkdir /mnt/guest/\{proc,sys,home,tmp\}}}
2285 \item {\bfseries Edit the {\small {\tt /etc/fstab}} of the guest image}\\
2286 The fstab should look like this:
2288 {\scriptsize {\tt \# vim /mnt/guest/etc/fstab\\
2289 /dev/hda1 / ext3 defaults 1 1\\
2290 none /dev/pts devpts gid=5,mode=620 0 0\\
2291 none /dev/shm tmpfs defaults 0 0\\
2292 none /proc proc defaults 0 0\\
2293 none /sys sysfs efaults 0 0}}
2295 \item {\bfseries umount the image file}\\
2296 {\small {\tt \# umount /mnt/guest}}
2297 \end{enumerate}
2299 Now, the guest OS image {\small {\tt hd.img}} is ready. You can also reference {\small {\tt}} for quickstart images. But make sure to install the boot loader.
2301 \subsection{Install Windows into an Image File using a VMX guest}
2302 In order to install a Windows OS, you should keep {\small {\tt acpi=0}} in your VMX configuration file.
2304 \section{VMX Guests}
2305 \subsection{Editing the Xen VMX config file}
2306 Make a copy of the example VMX configuration file {\small {\tt /etc/xen/xmeaxmple.vmx}} and edit the line that reads
2308 {\small {\tt disk = [ 'file:/var/images/\emph{guest.img},ioemu:hda,w' ]}}
2310 replacing \emph{guest.img} with the name of the guest OS image file you just made.
2312 \subsection{Creating VMX guests}
2313 Simply follow the usual method of creating the guest, using the -f parameter and providing the filename of your VMX configuration file:\\
2315 {\small {\tt \# xend start\\
2316 \# xm create /etc/xen/vmxguest.vmx}}
2318 In the default configuration, VNC is on and SDL is off. Therefore VNC windows will open when VMX guests are created. If you want to use SDL to create VMX guests, set {\small {\tt sdl=1}} in your VMX configuration file. You can also turn off VNC by setting {\small {\tt vnc=0}}.
2320 \subsection{Use mouse in VNC window}
2321 The default PS/2 mouse will not work properly in VMX by a VNC window. Summagraphics mouse emulation does work in this environment. A Summagraphics mouse can be enabled by reconfiguring 2 services:
2323 {\small {\tt 1. General Purpose Mouse (GPM). The GPM daemon is configured in different ways in different Linux distributions. On a Redhat distribution, this is accomplished by changing the file `/etc/sysconfig/mouse' to have the following:\\
2324 MOUSETYPE="summa"\\
2326 DEVICE=/dev/ttyS0\\
2327 \\
2328 2. X11. For all Linux distributions, change the Mouse0 stanza in `/etc/X11/xorg.conf' to:\\
2329 Section "InputDevice"\\
2330 Identifier "Mouse0"\\
2331 Driver "summa"\\
2332 Option "Device" "/dev/ttyS0"\\
2333 Option "InputFashion" "Tablet"\\
2334 Option "Mode" "Absolute"\\
2335 Option "Name" "EasyPen"\\
2336 Option "Compatible" "True"\\
2337 Option "Protocol" "Auto"\\
2338 Option "SendCoreEvents" "on"\\
2339 Option "Vendor" "GENIUS"\\
2340 EndSection}}
2342 If the Summagraphics mouse isn't the default mouse, you can manually kill 'gpm' and restart it with the command "gpm -m /dev/ttyS0 -t summa". Note that Summagraphics mouse makes no sense in an SDL window and is therefore not available in this environment.
2344 \subsection{Destroy VMX guests}
2345 VMX guests can be destroyed in the same way as can paravirtualized guests. We recommend that you type the command
2347 {\small {\tt poweroff}}
2349 in the VMX guest's console first to prevent data loss. Then execute the command
2351 {\small {\tt xm destroy \emph{vmx\_guest\_id} }}
2353 at the Domain0 console.
2355 \subsection{VMX window (X or VNC) Hot Key}
2356 If you are running in the X environment after creating a VMX guest, an X window is created. There are several hot keys for control of the VMX guest that can be used in the window.
2358 {\bfseries Ctrl+Alt+2} switches from guest VGA window to the control window. Typing {\small {\tt help }} shows the control commands help. For example, 'q' is the command to destroy the VMX guest.\\
2359 {\bfseries Ctrl+Alt+1} switches back to VMX guest's VGA.\\
2360 {\bfseries Ctrl+Alt+3} switches to serial port output. It captures serial output from the VMX guest. It works only if the VMX guest was configured to use the serial port. \\
2362 \subsection{Save/Restore and Migration}
2363 VMX guests currently cannot be saved and restored, nor migrated. These features are currently under active development.
2365 \chapter{Vnets - Domain Virtual Networking}
2367 Xen optionally supports virtual networking for domains using {\em vnets}.
2368 These emulate private LANs that domains can use. Domains on the same
2369 vnet can be hosted on the same machine or on separate machines, and the
2370 vnets remain connected if domains are migrated. Ethernet traffic
2371 on a vnet is tunneled inside IP packets on the physical network. A vnet is a virtual
2372 network and addressing within it need have no relation to addressing on
2373 the underlying physical network. Separate vnets, or vnets and the physical network,
2374 can be connected using domains with more than one network interface and
2375 enabling IP forwarding or bridging in the usual way.
2377 Vnet support is included in \texttt{xm} and \xend:
2378 \begin{verbatim}
2379 # xm vnet-create <config>
2380 \end{verbatim}
2381 creates a vnet using the configuration in the file \verb|<config>|.
2382 When a vnet is created its configuration is stored by \xend and the vnet persists until it is
2383 deleted using
2384 \begin{verbatim}
2385 # xm vnet-delete <vnetid>
2386 \end{verbatim}
2387 The vnets \xend knows about are listed by
2388 \begin{verbatim}
2389 # xm vnet-list
2390 \end{verbatim}
2391 More vnet management commands are available using the
2392 \texttt{vn} tool included in the vnet distribution.
2394 The format of a vnet configuration file is
2395 \begin{verbatim}
2396 (vnet (id <vnetid>)
2397 (bridge <bridge>)
2398 (vnetif <vnet interface>)
2399 (security <level>))
2400 \end{verbatim}
2401 White space is not significant. The parameters are:
2402 \begin{itemize}
2403 \item \verb|<vnetid>|: vnet id, the 128-bit vnet identifier. This can be given
2404 as 8 4-digit hex numbers separated by colons, or in short form as a single 4-digit hex number.
2405 The short form is the same as the long form with the first 7 fields zero.
2406 Vnet ids must be non-zero and id 1 is reserved.
2408 \item \verb|<bridge>|: the name of a bridge interface to create for the vnet. Domains
2409 are connected to the vnet by connecting their virtual interfaces to the bridge.
2410 Bridge names are limited to 14 characters by the kernel.
2412 \item \verb|<vnetif>|: the name of the virtual interface onto the vnet (optional). The
2413 interface encapsulates and decapsulates vnet traffic for the network and is attached
2414 to the vnet bridge. Interface names are limited to 14 characters by the kernel.
2416 \item \verb|<level>|: security level for the vnet (optional). The level may be one of
2417 \begin{itemize}
2418 \item \verb|none|: no security (default). Vnet traffic is in clear on the network.
2419 \item \verb|auth|: authentication. Vnet traffic is authenticated using IPSEC
2420 ESP with hmac96.
2421 \item \verb|conf|: confidentiality. Vnet traffic is authenticated and encrypted
2422 using IPSEC ESP with hmac96 and AES-128.
2423 \end{itemize}
2424 Authentication and confidentiality are experimental and use hard-wired keys at present.
2425 \end{itemize}
2426 When a vnet is created its configuration is stored by \xend and the vnet persists until it is
2427 deleted using \texttt{xm vnet-delete <vnetid>}. The interfaces and bridges used by vnets
2428 are visible in the output of \texttt{ifconfig} and \texttt{brctl show}.
2430 \section{Example}
2431 If the file \path{vnet97.sxp} contains
2432 \begin{verbatim}
2433 (vnet (id 97) (bridge vnet97) (vnetif vnif97)
2434 (security none))
2435 \end{verbatim}
2436 Then \texttt{xm vnet-create vnet97.sxp} will define a vnet with id 97 and no security.
2437 The bridge for the vnet is called vnet97 and the virtual interface for it is vnif97.
2438 To add an interface on a domain to this vnet set its bridge to vnet97
2439 in its configuration. In Python:
2440 \begin{verbatim}
2441 vif="bridge=vnet97"
2442 \end{verbatim}
2443 In sxp:
2444 \begin{verbatim}
2445 (dev (vif (mac aa:00:00:01:02:03) (bridge vnet97)))
2446 \end{verbatim}
2447 Once the domain is started you should see its interface in the output of \texttt{brctl show}
2448 under the ports for \texttt{vnet97}.
2450 To get best performance it is a good idea to reduce the MTU of a domain's interface
2451 onto a vnet to 1400. For example using \texttt{ifconfig eth0 mtu 1400} or putting
2452 \texttt{MTU=1400} in \texttt{ifcfg-eth0}.
2453 You may also have to change or remove cached config files for eth0 under
2454 \texttt{/etc/sysconfig/networking}. Vnets work anyway, but performance can be reduced
2455 by IP fragmentation caused by the vnet encapsulation exceeding the hardware MTU.
2457 \section{Installing vnet support}
2458 Vnets are implemented using a kernel module, which needs to be loaded before
2459 they can be used. You can either do this manually before starting \xend, using the
2460 command \texttt{vn insmod}, or configure \xend to use the \path{network-vnet}
2461 script in the xend configuration file \texttt{/etc/xend/xend-config.sxp}:
2462 \begin{verbatim}
2463 (network-script network-vnet)
2464 \end{verbatim}
2465 This script insmods the module and calls the \path{network-bridge} script.
2467 The vnet code is not compiled and installed by default.
2468 To compile the code and install on the current system
2469 use \texttt{make install} in the root of the vnet source tree,
2470 \path{tools/vnet}. It is also possible to install to an installation
2471 directory using \texttt{make dist}. See the \path{Makefile} in
2472 the source for details.
2474 The vnet module creates vnet interfaces \texttt{vnif0002},
2475 \texttt{vnif0003} and \texttt{vnif0004} by default. You can test that
2476 vnets are working by configuring IP addresses on these interfaces
2477 and trying to ping them across the network. For example, using machines
2478 hostA and hostB:
2479 \begin{verbatim}
2480 hostA# ifconfig vnif0004 up
2481 hostB# ifconfig vnif0004 up
2482 hostB# ping
2483 \end{verbatim}
2485 The vnet implementation uses IP multicast to discover vnet interfaces, so
2486 all machines hosting vnets must be reachable by multicast. Network switches
2487 are often configured not to forward multicast packets, so this often
2488 means that all machines using a vnet must be on the same LAN segment,
2489 unless you configure vnet forwarding.
2491 You can test multicast coverage by pinging the vnet multicast address:
2492 \begin{verbatim}
2493 # ping -b
2494 \end{verbatim}
2495 You should see replies from all machines with the vnet module running.
2496 You can see if vnet packets are being sent or received by dumping traffic
2497 on the vnet UDP port:
2498 \begin{verbatim}
2499 # tcpdump udp port 1798
2500 \end{verbatim}
2502 If multicast is not being forwaded between machines you can configure
2503 multicast forwarding using vn. Suppose we have machines hostA on
2504 and hostB on and that multicast is not forwarded between them.
2505 We use vn to configure each machine to forward to the other:
2506 \begin{verbatim}
2507 hostA# vn peer-add hostB
2508 hostB# vn peer-add hostA
2509 \end{verbatim}
2510 Multicast forwarding needs to be used carefully - you must avoid creating forwarding
2511 loops. Typically only one machine on a subnet needs to be configured to forward,
2512 as it will forward multicasts received from other machines on the subnet.
2514 %% Chapter Glossary of Terms moved to glossary.tex
2515 \chapter{Glossary of Terms}
2517 \begin{description}
2519 \item[BVT] The BVT scheduler is used to give proportional fair shares
2520 of the CPU to domains.
2522 \item[Domain] A domain is the execution context that contains a
2523 running {\bf virtual machine}. The relationship between virtual
2524 machines and domains on Xen is similar to that between programs and
2525 processes in an operating system: a virtual machine is a persistent
2526 entity that resides on disk (somewhat like a program). When it is
2527 loaded for execution, it runs in a domain. Each domain has a {\bf
2528 domain ID}.
2530 \item[Domain 0] The first domain to be started on a Xen machine.
2531 Domain 0 is responsible for managing the system.
2533 \item[Domain ID] A unique identifier for a {\bf domain}, analogous to
2534 a process ID in an operating system.
2536 \item[Full virtualization] An approach to virtualization which
2537 requires no modifications to the hosted operating system, providing
2538 the illusion of a complete system of real hardware devices.
2540 \item[Hypervisor] An alternative term for {\bf VMM}, used because it
2541 means `beyond supervisor', since it is responsible for managing
2542 multiple `supervisor' kernels.
2544 \item[Live migration] A technique for moving a running virtual machine
2545 to another physical host, without stopping it or the services
2546 running on it.
2548 \item[Paravirtualization] An approach to virtualization which requires
2549 modifications to the operating system in order to run in a virtual
2550 machine. Xen uses paravirtualization but preserves binary
2551 compatibility for user space applications.
2553 \item[Shadow pagetables] A technique for hiding the layout of machine
2554 memory from a virtual machine's operating system. Used in some {\bf
2555 VMMs} to provide the illusion of contiguous physical memory, in
2556 Xen this is used during {\bf live migration}.
2558 \item[Virtual Block Device] Persistant storage available to a virtual
2559 machine, providing the abstraction of an actual block storage device.
2560 {\bf VBD}s may be actual block devices, filesystem images, or
2561 remote/network storage.
2563 \item[Virtual Machine] The environment in which a hosted operating
2564 system runs, providing the abstraction of a dedicated machine. A
2565 virtual machine may be identical to the underlying hardware (as in
2566 {\bf full virtualization}, or it may differ, as in {\bf
2567 paravirtualization}).
2569 \item[VMM] Virtual Machine Monitor - the software that allows multiple
2570 virtual machines to be multiplexed on a single physical machine.
2572 \item[Xen] Xen is a paravirtualizing virtual machine monitor,
2573 developed primarily by the Systems Research Group at the University
2574 of Cambridge Computer Laboratory.
2576 \item[XenLinux] A name for the port of the Linux kernel that
2577 runs on Xen.
2579 \end{description}
2582 \end{document}
2585 %% Other stuff without a home
2587 %% Instructions Re Python API
2589 %% Other Control Tasks using Python
2590 %% ================================
2592 %% A Python module 'Xc' is installed as part of the tools-install
2593 %% process. This can be imported, and an 'xc object' instantiated, to
2594 %% provide access to privileged command operations:
2596 %% # import Xc
2597 %% # xc =
2598 %% # dir(xc)
2599 %% # help(xc.domain_create)
2601 %% In this way you can see that the class 'xc' contains useful
2602 %% documentation for you to consult.
2604 %% A further package of useful routines (xenctl) is also installed:
2606 %% # import xenctl.utils
2607 %% # help(xenctl.utils)
2609 %% You can use these modules to write your own custom scripts or you
2610 %% can customise the scripts supplied in the Xen distribution.
2614 % Explain about AGP GART
2617 %% If you're not intending to configure the new domain with an IP
2618 %% address on your LAN, then you'll probably want to use NAT. The
2619 %% 'xen_nat_enable' installs a few useful iptables rules into domain0
2620 %% to enable NAT. [NB: We plan to support RSIP in future]
2624 %% Installing the file systems from the CD
2625 %% =======================================
2627 %% If you haven't got an existing Linux installation onto which you
2628 %% can just drop down the Xen and Xenlinux images, then the file
2629 %% systems on the CD provide a quick way of doing an install. However,
2630 %% you would be better off in the long run doing a proper install of
2631 %% your preferred distro and installing Xen onto that, rather than
2632 %% just doing the hack described below:
2634 %% Choose one or two partitions, depending on whether you want a
2635 %% separate /usr or not. Make file systems on it/them e.g.:
2636 %% mkfs -t ext3 /dev/hda3
2637 %% [or mkfs -t ext2 /dev/hda3 && tune2fs -j /dev/hda3 if using an old
2638 %% version of mkfs]
2640 %% Next, mount the file system(s) e.g.:
2641 %% mkdir /mnt/root && mount /dev/hda3 /mnt/root
2642 %% [mkdir /mnt/usr && mount /dev/hda4 /mnt/usr]
2644 %% To install the root file system, simply untar /usr/XenDemoCD/root.tar.gz:
2645 %% cd /mnt/root && tar -zxpf /usr/XenDemoCD/root.tar.gz
2647 %% You'll need to edit /mnt/root/etc/fstab to reflect your file system
2648 %% configuration. Changing the password file (etc/shadow) is probably a
2649 %% good idea too.
2651 %% To install the usr file system, copy the file system from CD on
2652 %% /usr, though leaving out the "XenDemoCD" and "boot" directories:
2653 %% cd /usr && cp -a X11R6 etc java libexec root src bin dict kerberos
2654 %% local sbin tmp doc include lib man share /mnt/usr
2656 %% If you intend to boot off these file systems (i.e. use them for
2657 %% domain 0), then you probably want to copy the /usr/boot
2658 %% directory on the cd over the top of the current symlink to /boot
2659 %% on your root filesystem (after deleting the current symlink)
2660 %% i.e.:
2661 %% cd /mnt/root ; rm boot ; cp -a /usr/boot .