Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 7651fddc6f54c25e982088c581bdd921 > files > 34

xen-doc-4.0.3-1.fc14.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 2008 (1.71)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>user</TITLE>
<META NAME="description" CONTENT="user">
<META NAME="keywords" CONTENT="user">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META NAME="Generator" CONTENT="LaTeX2HTML v2008">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="user.css">

</HEAD>

<BODY >

<P>

<DIV ALIGN="CENTER">
<BR>
<IMG
 WIDTH="463" HEIGHT="219" ALIGN="BOTTOM" BORDER="0"
 SRC="img1.png"
 ALT="\includegraphics{figs/xenlogo.eps}">

<TABLE CELLPADDING=3>
<TR><TD ALIGN="LEFT"><FONT SIZE="+4"><B>Users' Manual</B></FONT></TD>
</TR>
<TR><TD ALIGN="LEFT"><FONT SIZE="+3">Xen v3.3</FONT></TD>
</TR>
</TABLE>
</DIV>

<P>
<B>DISCLAIMER: This documentation is always under active development
and as such there may be mistakes and omissions -- watch out for
these and please report any you find to the developers' mailing list,
xen-devel@lists.xensource.com. The latest version is always available
on-line. Contributions of material, suggestions and corrections are
welcome.</B>

<P>

<P>

<P>
<BR>

<P>
Xen is Copyright &#169;2002-2008, Citrix Systems, Inc., University of Cambridge, UK, XenSource Inc., IBM Corp., Hewlett-Packard Co., Intel Corp., AMD Inc., and others.  All rights reserved.

<P>
Xen is an open-source project.  Most portions of Xen are licensed for copying
under the terms of the GNU General Public License, version 2.  Other portions
are licensed under the terms of the GNU Lesser General Public License, the
Zope Public License 2.0, or under ``BSD-style'' licenses.  Please refer to the
COPYING file for details.

<P>
Xen includes software by Christopher Clark.  This software is covered by the
following licence:

<P>
<BLOCKQUOTE>
Copyright (c) 2002, Christopher Clark.  All rights reserved.
</BLOCKQUOTE>
<P>
<BLOCKQUOTE>Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
</BLOCKQUOTE>
<P>
<UL>
<LI>Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

<P>
</LI>
<LI>Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

<P>
</LI>
<LI>Neither the name of the original author; nor the names of any
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
</LI>
</UL>
<P>
<BLOCKQUOTE>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

</BLOCKQUOTE>

<P>

<P>

 <BR>

<H2><A NAME="SECTION01000000000000000000">
Contents</A>
</H2>
<!--Table of Contents-->

<UL>
<LI><UL>
<LI><A NAME="tex2html131"
  HREF="user.html#SECTION01100000000000000000">1. Introduction</A>
<UL>
<LI><A NAME="tex2html132"
  HREF="user.html#SECTION01110000000000000000">1.1 Usage Scenarios</A>
<LI><A NAME="tex2html133"
  HREF="user.html#SECTION01120000000000000000">1.2 Operating System Support</A>
<LI><A NAME="tex2html134"
  HREF="user.html#SECTION01130000000000000000">1.3 Hardware Support</A>
<LI><A NAME="tex2html135"
  HREF="user.html#SECTION01140000000000000000">1.4 Structure of a Xen-Based System</A>
<LI><A NAME="tex2html136"
  HREF="user.html#SECTION01150000000000000000">1.5 History</A>
<LI><A NAME="tex2html137"
  HREF="user.html#SECTION01160000000000000000">1.6 What's New</A>
</UL>
</UL>
<BR>
<LI><A NAME="tex2html138"
  HREF="user.html#SECTION02000000000000000000">1 Installation</A>
<UL>
<LI><A NAME="tex2html139"
  HREF="user.html#SECTION02100000000000000000">2. Basic Installation</A>
<UL>
<LI><A NAME="tex2html140"
  HREF="user.html#SECTION02110000000000000000">2.1 Prerequisites</A>
<LI><A NAME="tex2html141"
  HREF="user.html#SECTION02120000000000000000">2.2 Installing from Binary Tarball</A>
<LI><A NAME="tex2html142"
  HREF="user.html#SECTION02130000000000000000">2.3 Installing from RPMs</A>
<LI><A NAME="tex2html143"
  HREF="user.html#SECTION02140000000000000000">2.4 Installing from Source</A>
<LI><A NAME="tex2html144"
  HREF="user.html#SECTION02150000000000000000">2.5 Configuration</A>
<LI><A NAME="tex2html145"
  HREF="user.html#SECTION02160000000000000000">2.6 Booting Xen</A>
</UL>
<LI><A NAME="tex2html146"
  HREF="user.html#SECTION02200000000000000000">3. Booting a Xen System</A>
<UL>
<LI><A NAME="tex2html147"
  HREF="user.html#SECTION02210000000000000000">3.1 Booting Domain0</A>
<LI><A NAME="tex2html148"
  HREF="user.html#SECTION02220000000000000000">3.2 Booting Guest Domains</A>
<LI><A NAME="tex2html149"
  HREF="user.html#SECTION02230000000000000000">3.3 Starting / Stopping Domains Automatically</A>
</UL>
</UL>
<BR>
<LI><A NAME="tex2html150"
  HREF="user.html#SECTION03000000000000000000">2 Configuration and Management</A>
<UL>
<LI><A NAME="tex2html151"
  HREF="user.html#SECTION03100000000000000000">4. Domain Management Tools</A>
<UL>
<LI><A NAME="tex2html152"
  HREF="user.html#SECTION03110000000000000000">4.1 Xend </A>
<LI><A NAME="tex2html153"
  HREF="user.html#SECTION03120000000000000000">4.2 Xm</A>
</UL>
<LI><A NAME="tex2html154"
  HREF="user.html#SECTION03200000000000000000">5. Domain Configuration</A>
<UL>
<LI><A NAME="tex2html155"
  HREF="user.html#SECTION03210000000000000000">5.1 Configuration Files</A>
<LI><A NAME="tex2html156"
  HREF="user.html#SECTION03220000000000000000">5.2 Network Configuration</A>
<LI><A NAME="tex2html157"
  HREF="user.html#SECTION03230000000000000000">5.3 Driver Domain Configuration</A>
<LI><A NAME="tex2html158"
  HREF="user.html#SECTION03240000000000000000">5.4 Support for virtual Trusted Platform Module (vTPM)</A>
</UL>
<LI><A NAME="tex2html159"
  HREF="user.html#SECTION03300000000000000000">6. Storage and File System Management</A>
<UL>
<LI><A NAME="tex2html160"
  HREF="user.html#SECTION03310000000000000000">6.1 Exporting Physical Devices as VBDs</A>
<LI><A NAME="tex2html161"
  HREF="user.html#SECTION03320000000000000000">6.2 Using File-backed VBDs</A>
<LI><A NAME="tex2html162"
  HREF="user.html#SECTION03330000000000000000">6.3 Using LVM-backed VBDs</A>
<LI><A NAME="tex2html163"
  HREF="user.html#SECTION03340000000000000000">6.4 Using NFS Root</A>
</UL>
<LI><A NAME="tex2html164"
  HREF="user.html#SECTION03400000000000000000">7. CPU Management</A>
<LI><A NAME="tex2html165"
  HREF="user.html#SECTION03500000000000000000">8. Migrating Domains</A>
<UL>
<LI><A NAME="tex2html166"
  HREF="user.html#SECTION03510000000000000000">8.1 Domain Save and Restore</A>
<LI><A NAME="tex2html167"
  HREF="user.html#SECTION03520000000000000000">8.2 Migration and Live Migration</A>
</UL>
<LI><A NAME="tex2html168"
  HREF="user.html#SECTION03600000000000000000">9. Securing Xen</A>
<UL>
<LI><A NAME="tex2html169"
  HREF="user.html#SECTION03610000000000000000">9.1 Xen Security Considerations</A>
<LI><A NAME="tex2html170"
  HREF="user.html#SECTION03620000000000000000">9.2 Driver Domain Security Considerations</A>
<LI><A NAME="tex2html171"
  HREF="user.html#SECTION03630000000000000000">9.3 Security Scenarios</A>
</UL>
<LI><A NAME="tex2html172"
  HREF="user.html#SECTION03700000000000000000">10. sHype/Xen Access Control</A>
<UL>
<LI><A NAME="tex2html173"
  HREF="user.html#SECTION03710000000000000000">10.1 Overview</A>
<LI><A NAME="tex2html174"
  HREF="user.html#SECTION03720000000000000000">10.2 Xen Workload Protection Step-by-Step</A>
<LI><A NAME="tex2html175"
  HREF="user.html#SECTION03730000000000000000">10.3 Xen Access Control Policy</A>
<LI><A NAME="tex2html176"
  HREF="user.html#SECTION03740000000000000000">10.4 Current Limitations</A>
</UL>
</UL>
<BR>
<LI><A NAME="tex2html177"
  HREF="user.html#SECTION04000000000000000000">3 Reference</A>
<UL>
<LI><A NAME="tex2html178"
  HREF="user.html#SECTION04100000000000000000">11. Build and Boot Options</A>
<UL>
<LI><A NAME="tex2html179"
  HREF="user.html#SECTION04110000000000000000">11.1 Top-level Configuration Options</A>
<LI><A NAME="tex2html180"
  HREF="user.html#SECTION04120000000000000000">11.2 Xen Build Options</A>
<LI><A NAME="tex2html181"
  HREF="user.html#SECTION04130000000000000000">11.3 Xen Boot Options</A>
<LI><A NAME="tex2html182"
  HREF="user.html#SECTION04140000000000000000">11.4 XenLinux Boot Options</A>
</UL>
<LI><A NAME="tex2html183"
  HREF="user.html#SECTION04200000000000000000">12. Further Support</A>
<UL>
<LI><A NAME="tex2html184"
  HREF="user.html#SECTION04210000000000000000">12.1 Other Documentation</A>
<LI><A NAME="tex2html185"
  HREF="user.html#SECTION04220000000000000000">12.2 Online References</A>
<LI><A NAME="tex2html186"
  HREF="user.html#SECTION04230000000000000000">12.3 Mailing Lists</A>
</UL>
<LI><A NAME="tex2html187"
  HREF="user.html#SECTION04300000000000000000">A. Unmodified (HVM) guest domains in Xen with Hardware support for Virtualization</A>
<UL>
<LI><A NAME="tex2html188"
  HREF="user.html#SECTION04310000000000000000">A.1 Building Xen with HVM support</A>
<LI><A NAME="tex2html189"
  HREF="user.html#SECTION04320000000000000000">A.2 Configuration file for unmodified HVM guests</A>
<LI><A NAME="tex2html190"
  HREF="user.html#SECTION04330000000000000000">A.3 Creating virtual disks from scratch</A>
<LI><A NAME="tex2html191"
  HREF="user.html#SECTION04340000000000000000">A.4 HVM Guests</A>
</UL>
<LI><A NAME="tex2html192"
  HREF="user.html#SECTION04400000000000000000">B. Vnets - Domain Virtual Networking</A>
<UL>
<LI><A NAME="tex2html193"
  HREF="user.html#SECTION04410000000000000000">B.1 Example</A>
<LI><A NAME="tex2html194"
  HREF="user.html#SECTION04420000000000000000">B.2 Installing vnet support</A>
</UL>
<LI><A NAME="tex2html195"
  HREF="user.html#SECTION04500000000000000000">C. Glossary of Terms</A>
</UL></UL>
<!--End of Table of Contents-->

<P>

=10000
=10000
1.1

<P>

<H1><A NAME="SECTION01100000000000000000">
1. Introduction</A>
</H1>

<P>
Xen is an open-source <I>para-virtualizing</I> virtual machine monitor
(VMM), or ``hypervisor'', for a variety of processor architectures including x86. Xen can securely execute multiple virtual machines on a single physical system with near native performance.  Xen facilitates enterprise-grade functionality, including:

<P>

<UL>
<LI>Virtual machines with performance close to native hardware.
</LI>
<LI>Live migration of running virtual machines between physical hosts.
</LI>
<LI>Up to 32<A NAME="tex2html1"
  HREF="#foot46"><SUP>1.1</SUP></A> virtual CPUs per guest virtual machine, with VCPU hotplug.
</LI>
<LI>x86/32 with PAE, x86/64, and IA64 platform support.
</LI>
<LI>Intel and AMD Virtualization Technology for unmodified guest operating systems (including Microsoft Windows).
</LI>
<LI>Excellent hardware support (supports almost all Linux device
  drivers). 
</LI>
</UL>

<P>

<H1><A NAME="SECTION01110000000000000000">
1.1 Usage Scenarios</A>
</H1>

<P>
Usage scenarios for Xen include:

<P>
<DL>
<DT><STRONG>Server Consolidation.</STRONG></DT>
<DD>Move multiple servers onto a single
  physical host with performance and fault isolation provided at the
  virtual machine boundaries.
</DD>
<DT><STRONG>Hardware Independence.</STRONG></DT>
<DD>Allow legacy applications and operating 
  systems to exploit new hardware.
</DD>
<DT><STRONG>Multiple OS configurations.</STRONG></DT>
<DD>Run multiple operating systems
  simultaneously, for development or testing purposes.
</DD>
<DT><STRONG>Kernel Development.</STRONG></DT>
<DD>Test and debug kernel modifications in a
  sand-boxed virtual machine -- no need for a separate test machine.
</DD>
<DT><STRONG>Cluster Computing.</STRONG></DT>
<DD>Management at VM granularity provides more
  flexibility than separately managing each physical host, but better
  control and isolation than single-system image solutions,
  particularly by using live migration for load balancing.
</DD>
<DT><STRONG>Hardware support for custom OSes.</STRONG></DT>
<DD>Allow development of new
  OSes while benefiting from the wide-ranging hardware support of
  existing OSes such as Linux.
</DD>
</DL>

<P>

<H1><A NAME="SECTION01120000000000000000">
1.2 Operating System Support</A>
</H1>

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

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

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

<P>
Paravirtualized Xen support is available for increasingly many
operating systems: currently, mature Linux support is available and
included in the standard distribution.  Other OS ports, including
NetBSD, FreeBSD and Solaris are also complete. 

<P>

<H1><A NAME="SECTION01130000000000000000">
1.3 Hardware Support</A>
</H1>

<P>
Xen currently runs on the IA64 and x86 architectures. Multiprocessor
machines are supported, and there is support for HyperThreading (SMT).

<P>
The default 32-bit Xen requires processor support for Physical
Addressing Extensions (PAE), which enables the hypervisor to address
up to 16GB of physical memory. Xen also supports x86/64 platforms
such as Intel EM64T and AMD Opteron which can currently address up to
1TB of physical memory.

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

<P>

<H1><A NAME="SECTION01140000000000000000">
1.4 Structure of a Xen-Based System</A>
</H1>

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

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

<P>
The first domain, <I>domain&nbsp;0</I>, is created automatically when the
system boots and has special management privileges. Domain&nbsp;0 builds
other domains and manages their virtual devices. It also performs
administrative tasks such as suspending, resuming and migrating other
virtual machines.

<P>
Within domain&nbsp;0, a process called <I>xend</I> runs to manage the system.
Xend is responsible for managing virtual machines and providing access
to their consoles. Commands are issued to xend over an HTTP interface,
via a command-line tool.

<P>

<H1><A NAME="SECTION01150000000000000000">
1.5 History</A>
</H1>

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

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

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

<P>
Xen was first described in a paper presented at SOSP in
2003<A NAME="tex2html2"
  HREF="#foot63"><SUP>1.2</SUP></A>, and the first
public release (1.0) was made that October. Since then, Xen has
significantly matured and is now used in production scenarios on many
sites.

<P>

<H1><A NAME="SECTION01160000000000000000">
1.6 What's New</A>
</H1>

<P>
Xen 3.3.0 offers:

<P>

<UL>
<LI>IO Emulation (stub domains) for HVM IO performance and scailability
</LI>
<LI>Replacement of Intel VT vmxassist by new 16b emulation code
</LI>
<LI>Improved VT-d device pass-through e.g. for graphics devices
</LI>
<LI>Enhanced C and P state power management
</LI>
<LI>Exploitation of multi-queue support on modern NICs
</LI>
<LI>Removal of domain lock for improved PV guest scalability
</LI>
<LI>2MB page support for HVM and PV guests
</LI>
<LI>CPU Portability
</LI>
</UL>

<P>
Xen 3.3 delivers the capabilities needed by enterprise customers and gives computing industry leaders a solid, secure platform to build upon for their virtualization solutions. This latest release establishes Xen as the definitive open source solution for virtualization.

<P>

<H1><A NAME="SECTION02000000000000000000">
1 Installation</A>
</H1>

<P>

<H1><A NAME="SECTION02100000000000000000">
2. Basic Installation</A>
</H1>

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

<P>

<H1><A NAME="SECTION02110000000000000000"></A>
<A NAME="sec:prerequisites"></A>
<BR>
2.1 Prerequisites
</H1>

<P>
The following is a full list of prerequisites. Items marked `<IMG
 WIDTH="12" HEIGHT="34" ALIGN="MIDDLE" BORDER="0"
 SRC="img2.png"
 ALT="$\dag $">' are
required by the xend control tools, and hence required if you want to
run more than one virtual machine; items marked `*' are only required
if you wish to build from source.
<DL COMPACT>
<DT>&nbsp;$$</DT>
<DD>A working Linux distribution using the GRUB bootloader and running
  on a P6-class or newer CPU.
</DD>
<DT><IMG
 WIDTH="12" HEIGHT="34" ALIGN="MIDDLE" BORDER="0"
 SRC="img2.png"
 ALT="$\dag $"></DT>
<DD>The <TT>iproute2</TT> package.
</DD>
<DT><IMG
 WIDTH="12" HEIGHT="34" ALIGN="MIDDLE" BORDER="0"
 SRC="img2.png"
 ALT="$\dag $"></DT>
<DD>The Linux bridge-utils<A NAME="tex2html3"
  HREF="#foot1238"><SUP>2.1</SUP></A> (e.g., <TT>/sbin/brctl</TT>)
</DD>
<DT><IMG
 WIDTH="12" HEIGHT="34" ALIGN="MIDDLE" BORDER="0"
 SRC="img2.png"
 ALT="$\dag $"></DT>
<DD>The Linux hotplug system<A NAME="tex2html4"
  HREF="#foot1239"><SUP>2.2</SUP></A> (e.g.,
      <TT>/sbin/hotplug</TT> and related scripts).  On newer distributions,
      this is included alongside the Linux udev system<A NAME="tex2html5"
  HREF="#foot1240"><SUP>2.3</SUP></A>.
</DD>
<DT>*</DT>
<DD>Build tools (gcc v3.2.x or v3.3.x, binutils, GNU make).
</DD>
<DT>*</DT>
<DD>Development installation of zlib (e.g., zlib-dev).
</DD>
<DT>*</DT>
<DD>Development installation of Python v2.2 or later (e.g.,   python-dev).
</DD>
<DT>*</DT>
<DD>L<SUP><SMALL>A</SMALL></SUP>T<SMALL>E</SMALL>X and transfig are required to build the
  documentation.
</DD>
</DL>

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

<P>

<H1><A NAME="SECTION02120000000000000000">
2.2 Installing from Binary Tarball</A>
</H1>

<P>
Pre-built tarballs are available for download from the XenSource downloads
page:
<BLOCKQUOTE>
<TT>http://www.xensource.com/downloads/</TT>

</BLOCKQUOTE>

<P>
Once you've downloaded the tarball, simply unpack and install:
<PRE>
# tar zxvf xen-3.0-install.tgz
# cd xen-3.0-install
# sh ./install.sh
</PRE>

<P>
Once you've installed the binaries you need to configure your system as
described in Section&nbsp;<A HREF="#s:configure">2.5</A>.

<P>

<H1><A NAME="SECTION02130000000000000000">
2.3 Installing from RPMs</A>
</H1>
Pre-built RPMs are available for download from the XenSource downloads
page:
<BLOCKQUOTE>
<TT>http://www.xensource.com/downloads/</TT>

</BLOCKQUOTE>

<P>
Once you've downloaded the RPMs, you typically install them via the 
RPM commands: 

<P>
<code># rpm -iv rpmname</code> 

<P>
See the instructions and the Release Notes for each RPM set referenced at:
  <BLOCKQUOTE>
<TT>http://www.xensource.com/downloads/</TT>.
  
</BLOCKQUOTE>

<P>

<H1><A NAME="SECTION02140000000000000000">
2.4 Installing from Source</A>
</H1>

<P>
This section describes how to obtain, build and install Xen from source.

<P>

<H2><A NAME="SECTION02141000000000000000">
2.4.1 Obtaining the Source</A>
</H2>

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

<P>
<DL>
<DT><STRONG>Obtaining the Source Tarball</STRONG></DT>
<DD> 
<BR>
Stable versions and daily snapshots of the Xen source tree are
  available from the Xen download page:
  <BLOCKQUOTE>
<TT><TT>http://www.xensource.com/downloads/</TT></TT>
  
</BLOCKQUOTE>
</DD>
<DT><STRONG>Obtaining the source via Mercurial</STRONG></DT>
<DD> 
<BR>
The source tree may also be obtained via the public Mercurial
  repository at:
  <BLOCKQUOTE>
<TT>http://xenbits.xensource.com</TT>
  
</BLOCKQUOTE> See the instructions and the Getting Started Guide
  referenced at:
  <BLOCKQUOTE>
<TT>http://www.xensource.com/downloads/</TT>
  
</BLOCKQUOTE>
</DD>
</DL>

<P>

<H2><A NAME="SECTION02142000000000000000">
2.4.2 Building from Source</A>
</H2>

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

<P>

<UL>
<LI>Build Xen.
</LI>
<LI>Build the control tools, including xend.
</LI>
<LI>Download (if necessary) and unpack the Linux 2.6 source code, and
  patch it for use with Xen.
</LI>
<LI>Build a Linux kernel to use in domain&nbsp;0 and a smaller unprivileged
  kernel, which can be used for unprivileged virtual machines.
</LI>
</UL>

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

<P>
To customize the set of kernels built you need to edit the top-level
Makefile. Look for the line:<PRE>
KERNELS ?= linux-2.6-xen0 linux-2.6-xenU
</PRE>

<P>
You can edit this line to include any set of operating system kernels
which have configurations in the top-level <TT>buildconfigs/</TT>
directory.

<P>

<H2><A NAME="SECTION02143000000000000000">
2.4.3 Custom Kernels</A>
</H2>

<P>
If you wish to build a customized XenLinux kernel (e.g. to support
additional devices or enable distribution-required features), you can
use the standard Linux configuration mechanisms, specifying that the
architecture being built for is <TT>xen</TT>, e.g:<PRE>
# cd linux-2.6.12-xen0
# make ARCH=xen xconfig
# cd ..
# make
</PRE>

<P>
You can also copy an existing Linux configuration (<TT>.config</TT>) into
e.g. <TT>linux-2.6.12-xen0</TT> and execute:<PRE>
# make ARCH=xen oldconfig
</PRE>

<P>
You may be prompted with some Xen-specific options. We advise accepting
the defaults for these options.

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

<P>

<H2><A NAME="SECTION02144000000000000000">
2.4.4 Installing Generated Binaries</A>
</H2>

<P>
The files produced by the build process are stored under the
<TT>dist/install/</TT> directory. To install them in their default
locations, do:<PRE>
# make install
</PRE>

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

<P>
The <TT>dist/install/boot</TT> directory will also contain the config
files used for building the XenLinux kernels, and also versions of Xen
and XenLinux kernels that contain debug symbols such as
(<TT>xen-syms-3.0.0</TT> and <TT>vmlinux-syms-2.6.12.6-xen0</TT>) which are
essential for interpreting crash dumps. Retain these files as the
developers may wish to see them if you post on the mailing list.

<P>

<H1><A NAME="SECTION02150000000000000000"></A>
<A NAME="s:configure"></A>
<BR>
2.5 Configuration
</H1>

<P>
Once you have built and installed the Xen distribution, it is simple to
prepare the machine for booting and running Xen.

<P>

<H2><A NAME="SECTION02151000000000000000">
2.5.1 GRUB Configuration</A>
</H2>

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

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

<P>
The kernel line tells GRUB where to find Xen itself and what boot
parameters should be passed to it (in this case, setting the domain&nbsp;0
memory allocation in kilobytes and the settings for the serial port).
For more details on the various Xen boot parameters see
Section&nbsp;<A HREF="#s:xboot">11.3</A>.

<P>
The module line of the configuration describes the location of the
XenLinux kernel that Xen should start and the parameters that should be
passed to it. These are standard Linux parameters, identifying the root
device and specifying it be initially mounted read only and instructing
that console output be sent to the screen. Some distributions such as
SuSE do not require the <TT>ro</TT> parameter.

<P>
To use an initrd, add another <TT>module</TT> line to the configuration,
like: <PRE>
  module /boot/my_initrd.gz
</PRE>

<P>
When installing a new kernel, it is recommended that you do not delete
existing menu options from <TT>menu.lst</TT>, as you may wish to boot your
old Linux kernel in future, particularly if you have problems.

<P>

<H2><A NAME="SECTION02152000000000000000">
2.5.2 Serial Console (optional)</A>
</H2>

<P>
Serial console access allows you to manage, monitor, and interact with
your system over a serial console.  This can allow access from another
nearby system via a null-modem (``LapLink'') cable or remotely via a serial
concentrator.

<P>
You system's BIOS, bootloader (GRUB), Xen, Linux, and login access must
each be individually configured for serial console access.  It is
<I>not</I> strictly necessary to have each component fully functional,
but it can be quite useful.

<P>
For general information on serial console configuration under Linux,
refer to the ``Remote Serial Console HOWTO'' at The Linux Documentation
Project: <TT><A NAME="tex2html6"
  HREF="http://www.tldp.org">http://www.tldp.org</A></TT> 

<P>

<H3><A NAME="SECTION02152100000000000000">
2.5.2.1 Serial Console BIOS configuration</A>
</H3>

<P>
Enabling system serial console output neither enables nor disables
serial capabilities in GRUB, Xen, or Linux, but may make remote
management of your system more convenient by displaying POST and other
boot messages over serial port and allowing remote BIOS configuration.

<P>
Refer to your hardware vendor's documentation for capabilities and
procedures to enable BIOS serial redirection.

<P>

<H3><A NAME="SECTION02152200000000000000">
2.5.2.2 Serial Console GRUB configuration</A>
</H3>

<P>
Enabling GRUB serial console output neither enables nor disables Xen or
Linux serial capabilities, but may made remote management of your system
more convenient by displaying GRUB prompts, menus, and actions over
serial port and allowing remote GRUB management.

<P>
Adding the following two lines to your GRUB configuration file,
typically either <TT>/boot/grub/menu.lst</TT> or <TT>/boot/grub/grub.conf</TT>
depending on your distro, will enable GRUB serial output.

<P>
<BLOCKQUOTE>
</BLOCKQUOTE><PRE>
  serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
  terminal --timeout=10 serial console
</PRE><BLOCKQUOTE>

</BLOCKQUOTE>

<P>
Note that when both the serial port and the local monitor and keyboard
are enabled, the text ``<I>Press any key to continue</I>'' will appear
at both.  Pressing a key on one device will cause GRUB to display to
that device.  The other device will see no output.  If no key is
pressed before the timeout period expires, the system will boot to the
default GRUB boot entry.

<P>
Please refer to the GRUB documentation for further information.

<P>

<H3><A NAME="SECTION02152300000000000000">
2.5.2.3 Serial Console Xen configuration</A>
</H3>

<P>
Enabling Xen serial console output neither enables nor disables Linux
kernel output or logging in to Linux over serial port.  It does however
allow you to monitor and log the Xen boot process via serial console and
can be very useful in debugging.

<P>
In order to configure Xen serial console output, it is necessary to
add a boot option to your GRUB config; e.g. replace the previous
example kernel line with:
<BLOCKQUOTE>
</BLOCKQUOTE><PRE>
   kernel /boot/xen.gz dom0_mem=131072 com1=115200,8n1 console=com1,vga
</PRE><BLOCKQUOTE>

</BLOCKQUOTE>

<P>
This configures Xen to output on COM1 at 115,200 baud, 8 data bits, no
parity and 1 stop bit. Modify these parameters for your environment.
See Section&nbsp;<A HREF="#s:xboot">11.3</A> for an explanation of all boot parameters.

<P>
One can also configure XenLinux to share the serial console; to achieve
this append ``<TT>console=ttyS0</TT>'' to your module line.

<P>

<H3><A NAME="SECTION02152400000000000000">
2.5.2.4 Serial Console Linux configuration</A>
</H3>

<P>
Enabling Linux serial console output at boot neither enables nor
disables logging in to Linux over serial port.  It does however allow
you to monitor and log the Linux boot process via serial console and can be
very useful in debugging.

<P>
To enable Linux output at boot time, add the parameter
<TT>console=ttyS0</TT> (or ttyS1, ttyS2, etc.) to your kernel GRUB line.
Under Xen, this might be:
<BLOCKQUOTE>
</BLOCKQUOTE><PRE>
  module /vmlinuz-2.6-xen0 ro root=/dev/VolGroup00/LogVol00 \
  console=ttyS0, 115200
</PRE><BLOCKQUOTE>

</BLOCKQUOTE>
to enable output over ttyS0 at 115200 baud.

<P>

<H3><A NAME="SECTION02152500000000000000">
2.5.2.5 Serial Console Login configuration</A>
</H3>

<P>
Logging in to Linux via serial console, under Xen or otherwise, requires
specifying a login prompt be started on the serial port.  To permit root
logins over serial console, the serial port must be added to
<TT>/etc/securetty</TT>.

<P>
To automatically start a login prompt over the serial port, 
add the line: <BLOCKQUOTE>
<FONT SIZE="-1"><TT>c:2345:respawn:/sbin/mingetty
ttyS0</TT></FONT> 
</BLOCKQUOTE> to <TT>/etc/inittab</TT>.   Run <TT>init q</TT> to force
a reload of your inttab and start getty.

<P>
To enable root logins, add <TT>ttyS0</TT> to <TT>/etc/securetty</TT> if not
already present.

<P>
Your distribution may use an alternate getty; options include getty,
mgetty and agetty.  Consult your distribution's documentation
for further information.

<P>

<H2><A NAME="SECTION02153000000000000000">
2.5.3 TLS Libraries</A>
</H2>

<P>
Users of the XenLinux 2.6 kernel should disable Thread Local Storage
(TLS) (e.g. by doing a <TT>mv /lib/tls /lib/tls.disabled</TT>) before
attempting to boot a XenLinux kernel<A NAME="tex2html7"
  HREF="#foot1247"><SUP>2.4</SUP></A>. You can
always reenable TLS by restoring the directory to its original location
(i.e. <TT>mv /lib/tls.disabled /lib/tls</TT>).

<P>
The reason for this is that the current TLS implementation uses
segmentation in a way that is not permissible under Xen. If TLS is not
disabled, an emulation mode is used within Xen which reduces performance
substantially. To ensure full performance you should install a 
`Xen-friendly' (nosegneg) version of the library. 

<P>

<H1><A NAME="SECTION02160000000000000000">
2.6 Booting Xen</A>
</H1>

<P>
It should now be possible to restart the system and use Xen. Reboot and
choose the new Xen option when the Grub screen appears.

<P>
What follows should look much like a conventional Linux boot. The first
portion of the output comes from Xen itself, supplying low level
information about itself and the underlying hardware. The last portion
of the output comes from XenLinux.

<P>
You may see some error messages during the XenLinux boot. These are not
necessarily anything to worry about--they may result from kernel
configuration differences between your XenLinux kernel and the one you
usually use.

<P>
When the boot completes, you should be able to log into your system as
usual. If you are unable to log in, you should still be able to reboot
with your normal Linux kernel by selecting it at the GRUB prompt.

<P>

<H1><A NAME="SECTION02200000000000000000">
3. Booting a Xen System</A>
</H1>

<P>
Booting the system into Xen will bring you up into the privileged
management domain, Domain0. At that point you are ready to create
guest domains and ``boot'' them using the <TT>xm create</TT> command.

<P>

<H1><A NAME="SECTION02210000000000000000">
3.1 Booting Domain0</A>
</H1>

<P>
After installation and configuration is complete, reboot the system
and and choose the new Xen option when the Grub screen appears.

<P>
What follows should look much like a conventional Linux boot.  The
first portion of the output comes from Xen itself, supplying low level
information about itself and the underlying hardware.  The last
portion of the output comes from XenLinux.

<P>
When the boot completes, you should be able to log into your system as
usual.  If you are unable to log in, you should still be able to
reboot with your normal Linux kernel by selecting it at the GRUB prompt.

<P>
The first step in creating a new domain is to prepare a root
filesystem for it to boot.  Typically, this might be stored in a normal
partition, an LVM or other volume manager partition, a disk file or on
an NFS server.  A simple way to do this is simply to boot from your
standard OS install CD and install the distribution into another
partition on your hard drive.

<P>
To start the xend control daemon, type
<BLOCKQUOTE>
<code># xend start</code>

</BLOCKQUOTE>

<P>
If you wish the daemon to start automatically, see the instructions in
Section&nbsp;<A HREF="#s:xend">4.1</A>. Once the daemon is running, you can use the
<TT>xm</TT> tool to monitor and maintain the domains running on your
system. This chapter provides only a brief tutorial. We provide full
details of the <TT>xm</TT> tool in the next chapter.

<P>

<H1><A NAME="SECTION02220000000000000000">
3.2 Booting Guest Domains</A>
</H1>

<P>

<H2><A NAME="SECTION02221000000000000000">
3.2.1 Creating a Domain Configuration File</A>
</H2>

<P>
Before you can start an additional domain, you must create a
configuration file. We provide two example files which you can use as
a starting point:

<UL>
<LI><TT>/etc/xen/xmexample1</TT> is a simple template configuration
  file for describing a single VM.
</LI>
<LI><TT>/etc/xen/xmexample2</TT> file is a template description that
  is intended to be reused for multiple virtual machines.  Setting the
  value of the <TT>vmid</TT> variable on the <TT>xm</TT> command line
  fills in parts of this template.
</LI>
</UL>

<P>
There are also a number of other examples which you may find useful.
Copy one of these files and edit it as appropriate.  Typical values
you may wish to edit include:

<P><DL>
<DT><STRONG>kernel</STRONG></DT>
<DD>Set this to the path of the kernel you compiled for use
  with Xen (e.g. <TT>kernel = ``/boot/vmlinuz-2.6-xenU''</TT>)
</DD>
<DT><STRONG>memory</STRONG></DT>
<DD>Set this to the size of the domain's memory in megabytes
  (e.g. <TT>memory = 64</TT>)
</DD>
<DT><STRONG>disk</STRONG></DT>
<DD>Set the first entry in this list to calculate the offset
  of the domain's root partition, based on the domain ID.  Set the
  second to the location of <TT>/usr</TT> if you are sharing it between
  domains (e.g. <TT>disk = ['phy:your_hard_drive%d,sda1,w' %
    (base_partition_number + vmid),
    'phy:your_usr_partition,sda6,r' ]</TT>
</DD>
<DT><STRONG>dhcp</STRONG></DT>
<DD>Uncomment the dhcp variable, so that the domain will
  receive its IP address from a DHCP server (e.g. <TT>dhcp=``dhcp''</TT>)
</DD>
</DL>

<P>
You may also want to edit the <B>vif</B> variable in order to choose
the MAC address of the virtual ethernet interface yourself.  For
example:

<P>
<BLOCKQUOTE>
<code>vif = ['mac=00:16:3E:F6:BB:B3']</code>

</BLOCKQUOTE>
If you do not set this variable, xend will automatically generate a
random MAC address from the range 00:16:3E:xx:xx:xx, assigned by IEEE to
XenSource as an OUI (organizationally unique identifier).  XenSource
Inc. gives permission for anyone to use addresses randomly allocated
from this range for use by their Xen domains.

<P>
For a list of IEEE OUI assignments, see 
<TT><A NAME="tex2html8"
  HREF="http://standards.ieee.org/regauth/oui/oui.txt">http://standards.ieee.org/regauth/oui/oui.txt</A></TT> 

<P>

<H2><A NAME="SECTION02222000000000000000">
3.2.2 Booting the Guest Domain</A>
</H2>

<P>
The <TT>xm</TT> tool provides a variety of commands for managing
domains.  Use the <TT>create</TT> command to start new domains. Assuming
you've created a configuration file <TT>myvmconf</TT> based around
<TT>/etc/xen/xmexample2</TT>, to start a domain with virtual machine
ID&nbsp;1 you should type:

<P><PRE>
# xm create -c myvmconf vmid=1
</PRE>

<P>
The <TT>-c</TT> switch causes <TT>xm</TT> to turn into the domain's
console after creation.  The <TT>vmid=1</TT> sets the <TT>vmid</TT>
variable used in the <TT>myvmconf</TT> file.

<P>
You should see the console boot messages from the new domain appearing
in the terminal in which you typed the command, culminating in a login
prompt.

<P>

<H1><A NAME="SECTION02230000000000000000">
3.3 Starting / Stopping Domains Automatically</A>
</H1>

<P>
It is possible to have certain domains start automatically at boot
time and to have dom0 wait for all running domains to shutdown before
it shuts down the system.

<P>
To specify a domain is to start at boot-time, place its configuration
file (or a link to it) under <TT>/etc/xen/auto/</TT>.

<P>
A Sys-V style init script for Red Hat and LSB-compliant systems is
provided and will be automatically copied to <TT>/etc/init.d/</TT>
during install.  You can then enable it in the appropriate way for
your distribution.

<P>
For instance, on Red Hat:

<P>
<BLOCKQUOTE>
<code># chkconfig --add xendomains</code>

</BLOCKQUOTE>

<P>
By default, this will start the boot-time domains in runlevels 3, 4
and 5.

<P>
You can also use the <TT>service</TT> command to run this script
manually, e.g:

<P>
<BLOCKQUOTE>
<code># service xendomains start</code>
</BLOCKQUOTE>
<P>
<BLOCKQUOTE>Starts all the domains with config files under /etc/xen/auto/.

</BLOCKQUOTE>

<P>
<BLOCKQUOTE>
<code># service xendomains stop</code>
</BLOCKQUOTE>
<P>
<BLOCKQUOTE>Shuts down all running Xen domains.

</BLOCKQUOTE>

<P>

<H1><A NAME="SECTION03000000000000000000">
2 Configuration and Management</A>
</H1>

<P>

<H1><A NAME="SECTION03100000000000000000">
4. Domain Management Tools</A>
</H1>

<P>
This chapter summarizes the management software and tools available.

<P>

<H1><A NAME="SECTION03110000000000000000"></A>
<A NAME="s:xend"></A>
<BR>
4.1 Xend 
</H1>

<P>
The Xend node control daemon performs system management functions
related to virtual machines. It forms a central point of control of
virtualized resources, and must be running in order to start and manage
virtual machines. Xend must be run as root because it needs access to
privileged system management functions.

<P>
An initialization script named <TT>/etc/init.d/xend</TT> is provided to
start Xend at boot time. Use the tool appropriate (i.e. chkconfig) for
your Linux distribution to specify the runlevels at which this script
should be executed, or manually create symbolic links in the correct
runlevel directories.

<P>
Xend can be started on the command line as well, and supports the
following set of parameters:

<P>
<TABLE CELLPADDING=3>
<TR><TD ALIGN="LEFT"><code># xend start</code></TD>
<TD ALIGN="LEFT">start xend, if not already running</TD>
</TR>
<TR><TD ALIGN="LEFT"><code># xend stop</code></TD>
<TD ALIGN="LEFT">stop xend if already running</TD>
</TR>
<TR><TD ALIGN="LEFT"><code># xend restart</code></TD>
<TD ALIGN="LEFT">restart xend if running, otherwise start it</TD>
</TR>
<TR><TD ALIGN="LEFT"><code># xend status</code></TD>
<TD ALIGN="LEFT">indicates xend status by its return code</TD>
</TR>
</TABLE>

<P>
A SysV init script called <TT>xend</TT> is provided to start xend at
boot time. <TT>make install</TT> installs this script in
<TT>/etc/init.d</TT>. To enable it, you have to make symbolic links in
the appropriate runlevel directories or use the <TT>chkconfig</TT> tool,
where available.  Once xend is running, administration can be done
using the <TT>xm</TT> tool.

<P>

<H2><A NAME="SECTION03111000000000000000">
4.1.1 Logging</A>
</H2>

<P>
As xend runs, events will be logged to <TT>/var/log/xen/xend.log</TT> and
(less frequently) to <TT>/var/log/xen/xend-debug.log</TT>. These, along with
the standard syslog files, are useful when troubleshooting problems.

<P>

<H2><A NAME="SECTION03112000000000000000">
4.1.2 Configuring Xend </A>
</H2>

<P>
Xend is written in Python. At startup, it reads its configuration
information from the file <TT>/etc/xen/xend-config.sxp</TT>. The Xen
installation places an example <TT>xend-config.sxp</TT> file in the
<TT>/etc/xen</TT> subdirectory which should work for most installations.

<P>
See the example configuration file <TT>xend-debug.sxp</TT> and the
section 5 man page <TT>xend-config.sxp</TT> for a full list of
parameters and more detailed information. Some of the most important
parameters are discussed below.

<P>
An HTTP interface and a Unix domain socket API are available to
communicate with Xend. This allows remote users to pass commands to the
daemon. By default, Xend does not start an HTTP server. It does start a
Unix domain socket management server, as the low level utility
<TT>xm</TT> requires it. For support of cross-machine migration, Xend  can start a relocation server. This support is not enabled by default
for security reasons.

<P>
Note: the example <TT>xend</TT> configuration file modifies the defaults and
starts up Xend as an HTTP server as well as a relocation server.

<P>
From the file:

<P>
<PRE>
#(xend-http-server no)
(xend-http-server yes)
#(xend-unix-server yes)
#(xend-relocation-server no)
(xend-relocation-server yes)
</PRE>

<P>
Comment or uncomment lines in that file to disable or enable features
that you require.

<P>
Connections from remote hosts are disabled by default:

<P>
<PRE>
# Address xend should listen on for HTTP connections, if xend-http-server is
# set.
# Specifying 'localhost' prevents remote connections.
# Specifying the empty string '' (the default) allows all connections.
#(xend-address '')
(xend-address localhost)
</PRE>

<P>
It is recommended that if migration support is not needed, the
<TT>xend-relocation-server</TT> parameter value be changed to
``<TT>no</TT>'' or commented out.

<P>

<H1><A NAME="SECTION03120000000000000000"></A>
<A NAME="s:xm"></A>
<BR>
4.2 Xm
</H1>

<P>
The xm tool is the primary tool for managing Xen from the console. The
general format of an xm command line is:

<P>
<PRE>
# xm command [switches] [arguments] [variables]
</PRE>

<P>
The available <I>switches</I> and <I>arguments</I> are dependent on the
<I>command</I> chosen. The <I>variables</I> may be set using
declarations of the form <TT>variable=value</TT> and command line
declarations override any of the values in the configuration file being
used, including the standard variables described above and any custom
variables (for instance, the <TT>xmdefconfig</TT> file uses a <TT>vmid</TT>
variable).

<P>
For online help for the commands available, type:

<P><PRE>
# xm help
</PRE>

<P>
This will list the most commonly used commands.  The full list can be obtained
using <code>xm help --long</code>.  You can also type <TT>xm help &lt;command&gt;</TT>
for more information on a given command.

<P>

<H2><A NAME="SECTION03121000000000000000">
4.2.1 Basic Management Commands</A>
</H2>

<P>
One useful command is <code># xm list</code> which lists all domains running in rows
of the following format:
<DIV ALIGN="CENTER">
<TT>name domid memory vcpus state cputime</TT>

</DIV>

<P>
The meaning of each field is as follows: <DL>
<DT><STRONG>name</STRONG></DT>
<DD>The descriptive name of the virtual machine.
  
</DD>
<DT><STRONG>domid</STRONG></DT>
<DD>The number of the domain ID this virtual machine is
    running in.
  
</DD>
<DT><STRONG>memory</STRONG></DT>
<DD>Memory size in megabytes.
  
</DD>
<DT><STRONG>vcpus</STRONG></DT>
<DD>The number of virtual CPUs this domain has.
  
</DD>
<DT><STRONG>state</STRONG></DT>
<DD>Domain state consists of 5 fields:
    <DL>
<DT><STRONG>r</STRONG></DT>
<DD>running
    
</DD>
<DT><STRONG>b</STRONG></DT>
<DD>blocked
    
</DD>
<DT><STRONG>p</STRONG></DT>
<DD>paused
    
</DD>
<DT><STRONG>s</STRONG></DT>
<DD>shutdown
    
</DD>
<DT><STRONG>c</STRONG></DT>
<DD>crashed
    
</DD>
</DL>
  
</DD>
<DT><STRONG>cputime</STRONG></DT>
<DD>How much CPU time (in seconds) the domain has used so
    far.
  
</DD>
</DL>

<P>
The <TT>xm list</TT> command also supports a long output format when the
<TT>-l</TT> switch is used.  This outputs the full details of the
running domains in xend's SXP configuration format.

<P>
If you want to know how long your domains have been running for, then 
you can use the <code># xm uptime</code> command.

<P>
You can get access to the console of a particular domain using 
the <code># xm console</code> command  (e.g. <code># xm console myVM</code>). 

<P>

<H2><A NAME="SECTION03122000000000000000">
4.2.2 Domain Scheduling Management Commands</A>
</H2>

<P>
The credit CPU scheduler automatically load balances guest VCPUs
across all available physical CPUs on an SMP host. The user need
not manually pin VCPUs to load balance the system. However, she
can restrict which CPUs a particular VCPU may run on using
the <TT>xm vcpu-pin</TT> command.

<P>
Each guest domain is assigned a <TT>weight</TT> and a <TT>cap</TT>.

<P>
A domain with a weight of 512 will get twice as much CPU as a
domain with a weight of 256 on a contended host. Legal weights
range from 1 to 65535 and the default is 256.

<P>
The cap optionally fixes the maximum amount of CPU a guest will
be able to consume, even if the host system has idle CPU cycles.
The cap is expressed in percentage of one physical CPU: 100 is
1 physical CPU, 50 is half a CPU, 400 is 4 CPUs, etc... The
default, 0, means there is no upper cap.

<P>
When you are running with the credit scheduler, you can check and
modify your domains' weights and caps using the <TT>xm sched-credit</TT>
command:

<P>
<TABLE CELLPADDING=3>
<TR><TD ALIGN="LEFT"><code>xm sched-credit -d &lt;domain&gt;</code></TD>
<TD ALIGN="LEFT">lists weight and cap</TD>
</TR>
<TR><TD ALIGN="LEFT"><code>xm sched-credit -d &lt;domain&gt; -w &lt;weight&gt;</code></TD>
<TD ALIGN="LEFT">sets the weight</TD>
</TR>
<TR><TD ALIGN="LEFT"><code>xm sched-credit -d &lt;domain&gt; -c &lt;cap&gt;</code></TD>
<TD ALIGN="LEFT">sets the cap</TD>
</TR>
</TABLE>

<P>

<H1><A NAME="SECTION03200000000000000000"></A>
<A NAME="cha:config"></A>
<BR>
5. Domain Configuration
</H1>

<P>
The following contains the syntax of the domain configuration files
and description of how to further specify networking, driver domain
and general scheduling behavior.

<P>

<H1><A NAME="SECTION03210000000000000000"></A>
<A NAME="s:cfiles"></A>
<BR>
5.1 Configuration Files
</H1>

<P>
Xen configuration files contain the following standard variables.
Unless otherwise stated, configuration items should be enclosed in
quotes: see the configuration scripts in <TT>/etc/xen/</TT> 
for concrete examples. 

<P>
<DL>
<DT><STRONG>kernel</STRONG></DT>
<DD>Path to the kernel image.
</DD>
<DT><STRONG>ramdisk</STRONG></DT>
<DD>Path to a ramdisk image (optional).
  </DD>
<DT><STRONG>memory</STRONG></DT>
<DD>Memory size in megabytes.
</DD>
<DT><STRONG>vcpus</STRONG></DT>
<DD>The number of virtual CPUs. 
</DD>
<DT><STRONG>console</STRONG></DT>
<DD>Port to export the domain console on (default 9600 +
  domain ID).
</DD>
<DT><STRONG>vif</STRONG></DT>
<DD>Network interface configuration.  This may simply contain
an empty string for each desired interface, or may override various
settings, e.g. 
<PRE>
vif = [ 'mac=00:16:3E:00:00:11, bridge=xen-br0',
        'bridge=xen-br1' ]
</PRE>
  to assign a MAC address and bridge to the first interface and assign
  a different bridge to the second interface, leaving xend to choose
  the MAC address.  The settings that may be overridden in this way are
  type, mac, bridge, ip, script, backend, and vifname.
</DD>
<DT><STRONG>disk</STRONG></DT>
<DD>List of block devices to export to the domain e.g. 
  <code>disk = [ 'phy:hda1,sda1,r' ]</code> 
  exports physical device <TT>/dev/hda1</TT> to the domain as
  <TT>/dev/sda1</TT> with read-only access. Exporting a disk read-write
  which is currently mounted is dangerous - if you are <I>certain</I>
  you wish to do this, you can specify <TT>w!</TT> as the mode.
</DD>
<DT><STRONG>dhcp</STRONG></DT>
<DD>Set to <TT>`dhcp'</TT> if you want to use DHCP to configure
  networking.
</DD>
<DT><STRONG>netmask</STRONG></DT>
<DD>Manually configured IP netmask.
</DD>
<DT><STRONG>gateway</STRONG></DT>
<DD>Manually configured IP gateway.
</DD>
<DT><STRONG>hostname</STRONG></DT>
<DD>Set the hostname for the virtual machine.
</DD>
<DT><STRONG>root</STRONG></DT>
<DD>Specify the root device parameter on the kernel command
  line.
</DD>
<DT><STRONG>nfs_server</STRONG></DT>
<DD>IP address for the NFS server (if any).
</DD>
<DT><STRONG>nfs_root</STRONG></DT>
<DD>Path of the root filesystem on the NFS server (if
  any).
</DD>
<DT><STRONG>extra</STRONG></DT>
<DD>Extra string to append to the kernel command line (if
  any)
</DD>
</DL>

<P>
Additional fields are documented in the example configuration files 
(e.g. to configure virtual TPM functionality). 

<P>
For additional flexibility, it is also possible to include Python
scripting commands in configuration files.  An example of this is the
<TT>xmexample2</TT> file, which uses Python code to handle the
<TT>vmid</TT> variable.

<P>

<H1><A NAME="SECTION03220000000000000000">
5.2 Network Configuration</A>
</H1>

<P>
For many users, the default installation should work ``out of the
box''.  More complicated network setups, for instance with multiple
Ethernet interfaces and/or existing bridging setups will require some
special configuration.

<P>
The purpose of this section is to describe the mechanisms provided by
xend to allow a flexible configuration for Xen's virtual networking.

<P>

<H2><A NAME="SECTION03221000000000000000">
5.2.1 Xen virtual network topology</A>
</H2>

<P>
Each domain network interface is connected to a virtual network
interface in dom0 by a point to point link (effectively a ``virtual
crossover cable'').  These devices are named <TT>  vif&lt;domid&gt;.&lt;vifid&gt;</TT> (e.g. <TT>vif1.0</TT> for the first
interface in domain&nbsp;1, <TT>vif3.1</TT> for the second interface in
domain&nbsp;3).

<P>
Traffic on these virtual interfaces is handled in domain&nbsp;0 using
standard Linux mechanisms for bridging, routing, rate limiting, etc.
Xend calls on two shell scripts to perform initial configuration of
the network and configuration of new virtual interfaces.  By default,
these scripts configure a single bridge for all the virtual
interfaces.  Arbitrary routing / bridging configurations can be
configured by customizing the scripts, as described in the following
section.

<P>

<H2><A NAME="SECTION03222000000000000000">
5.2.2 Xen networking scripts</A>
</H2>

<P>
Xen's virtual networking is configured by two shell scripts (by
default <TT>network-bridge</TT> and <TT>vif-bridge</TT>).  These are called
automatically by xend when certain events occur, with arguments to
the scripts providing further contextual information.  These scripts
are found by default in <TT>/etc/xen/scripts</TT>.  The names and
locations of the scripts can be configured in
<TT>/etc/xen/xend-config.sxp</TT>.

<P>
<DL>
<DT><STRONG>network-bridge:</STRONG></DT>
<DD>This script is called whenever xend is started or
  stopped to respectively initialize or tear down the Xen virtual
  network. In the default configuration initialization creates the
  bridge `xen-br0' and moves eth0 onto that bridge, modifying the
  routing accordingly. When xend exits, it deletes the Xen bridge
  and removes eth0, restoring the normal IP and routing configuration.

<P>
</DD>
<DT><STRONG>vif-bridge:</STRONG></DT>
<DD>This script is called for every domain virtual
  interface and can configure firewalling rules and add the vif to the
  appropriate bridge. By default, this adds and removes VIFs on the
  default Xen bridge.
</DD>
</DL>

<P>
Other example scripts are available (<TT>network-route</TT> and
<TT>vif-route</TT>, <TT>network-nat</TT> and <TT>vif-nat</TT>).
For more complex network setups (e.g. where routing is required or
integrate with existing bridges) these scripts may be replaced with
customized variants for your site's preferred configuration.

<P>

<H1><A NAME="SECTION03230000000000000000"></A>
<A NAME="s:ddconf"></A>
<BR>
5.3 Driver Domain Configuration
</H1>

<P>

<H2><A NAME="SECTION03231000000000000000"></A>
<A NAME="ss:pcidd"></A>
<BR>
5.3.1 PCI
</H2>

<P>
Individual PCI devices can be assigned to a given domain (a PCI driver domain)
to allow that domain direct access to the PCI hardware.

<P>
While PCI Driver Domains can increase the stability and security of a system
by addressing a number of security concerns, there are some security issues
that remain that you can read about in Section&nbsp;<A HREF="#s:ddsecurity">9.2</A>.

<P>

<H3><A NAME="SECTION03231100000000000000">
5.3.1.1 Compile-Time Setup</A>
</H3>
To use this functionality, ensure
that the PCI Backend is compiled in to a privileged domain (e.g. domain 0)
and that the domains which will be assigned PCI devices have the PCI Frontend
compiled in. In XenLinux, the PCI Backend is available under the Xen
configuration section while the PCI Frontend is under the
architecture-specific "Bus Options" section. You may compile both the backend
and the frontend into the same kernel; they will not affect each other.

<P>

<H3><A NAME="SECTION03231200000000000000">
5.3.1.2 PCI Backend Configuration - Binding at Boot</A>
</H3>
The PCI devices you wish to assign to unprivileged domains must be "hidden"
from your backend domain (usually domain 0) so that it does not load a driver
for them. Use the <TT>pciback.hide</TT> kernel parameter which is specified on
the kernel command-line and is configurable through GRUB (see
Section&nbsp;<A HREF="#s:configure">2.5</A>). Note that devices are not really hidden from the
backend domain. The PCI Backend appears to the Linux kernel as a regular PCI
device driver. The PCI Backend ensures that no other device driver loads
for the devices by binding itself as the device driver for those devices.
PCI devices are identified by hexadecimal slot/function numbers (on Linux,
use <TT>lspci</TT> to determine slot/function numbers of your devices) and
can be specified with or without the PCI domain: 
<BR>
<DIV ALIGN="CENTER">
  <TT>(</TT><EM>bus</EM><TT>:</TT><EM>slot</EM><TT>.</TT><EM>func</EM><TT>)</TT> example <TT>(02:1d.3)</TT></DIV>
 
<BR>
<DIV ALIGN="CENTER">
  <TT>(</TT><EM>domain</EM><TT>:</TT><EM>bus</EM><TT>:</TT><EM>slot</EM><TT>.</TT><EM>func</EM><TT>)</TT> example <TT>(0000:02:1d.3)</TT></DIV>
 
<BR>
<P>
An example kernel command-line which hides two PCI devices might be: 
<BR>
<DIV ALIGN="CENTER">
 <TT>root=/dev/sda4 ro console=tty0 pciback.hide=(02:01.f)(0000:04:1d.0) </TT> </DIV>
 
<BR>
<P>

<H3><A NAME="SECTION03231300000000000000">
5.3.1.3 PCI Backend Configuration - Late Binding</A>
</H3>
PCI devices can also be bound to the PCI Backend after boot through the manual
binding/unbinding facilities provided by the Linux kernel in sysfs (allowing
for a Xen user to give PCI devices to driver domains that were not specified
on the kernel command-line). There are several attributes with the PCI
Backend's sysfs directory (<TT>/sys/bus/pci/drivers/pciback</TT>) that can be
used to bind/unbind devices:

<P>
<DL>
<DT><STRONG>slots</STRONG></DT>
<DD>lists all of the PCI slots that the PCI Backend will try to seize
  (or "hide" from Domain 0). A PCI slot must appear in this list before it can
  be bound to the PCI Backend through the <TT>bind</TT> attribute.
</DD>
<DT><STRONG>new_slot</STRONG></DT>
<DD>write the name of a slot here (in 0000:00:00.0 format) to
  have the PCI Backend seize the device in this slot.
</DD>
<DT><STRONG>remove_slot</STRONG></DT>
<DD>write the name of a slot here (same format as
  <TT>new_slot</TT>) to have the PCI Backend no longer try to seize devices in
  this slot. Note that this does not unbind the driver from a device it has
  already seized.
</DD>
<DT><STRONG>bind</STRONG></DT>
<DD>write the name of a slot here (in 0000:00:00.0 format) to have
  the Linux kernel attempt to bind the device in that slot to the PCI Backend
  driver.
</DD>
<DT><STRONG>unbind</STRONG></DT>
<DD>write the name of a skit here (same format as <TT>bind</TT>) to have
  the Linux kernel unbind the device from the PCI Backend. DO NOT unbind a
  device while it is currently given to a PCI driver domain!
</DD>
</DL>

<P>
Some examples:

<P>
Bind a device to the PCI Backend which is not bound to any other driver.
<PRE>
# # Add a new slot to the PCI Backend's list
# echo -n 0000:01:04.d &gt; /sys/bus/pci/drivers/pciback/new_slot
# # Now that the backend is watching for the slot, bind to it
# echo -n 0000:01:04.d &gt; /sys/bus/pci/drivers/pciback/bind
</PRE>

<P>
Unbind a device from its driver and bind to the PCI Backend.
<PRE>
# # Unbind a PCI network card from its network driver
# echo -n 0000:05:02.0 &gt; /sys/bus/pci/drivers/3c905/unbind
# # And now bind it to the PCI Backend
# echo -n 0000:05:02.0 &gt; /sys/bus/pci/drivers/pciback/new_slot
# echo -n 0000:05:02.0 &gt; /sys/bus/pci/drivers/pciback/bind
</PRE>

<P>
Note that the "-n" option in the example is important as it causes echo to not
output a new-line.

<P>

<H3><A NAME="SECTION03231400000000000000">
5.3.1.4 PCI Backend Configuration - User-space Quirks</A>
</H3>
Quirky devices (such as the Broadcom Tigon 3) may need write access to their
configuration space registers.  Xen can be instructed to allow specified PCI
devices write access to specific configuration space registers.  The policy may
be found in:

<P>
<DIV ALIGN="CENTER">
 <TT>/etc/xen/xend-pci-quirks.sxp</TT> </DIV>

<P>
The policy file is heavily commented and is intended to provide enough
documentation for developers to extend it.

<P>

<H3><A NAME="SECTION03231500000000000000">
5.3.1.5 PCI Backend Configuration - Permissive Flag</A>
</H3>
If the user-space quirks approach doesn't meet your needs you may want to enable
the permissive flag for that device.  To do so, first get the PCI domain, bus,
slot, and function information from dom0 via <TT>lspci</TT>.  Then augment the
user-space policy for permissive devices.  The permissive policy can be found
in:

<P>
<DIV ALIGN="CENTER">
 <TT>/etc/xen/xend-pci-permissive.sxp</TT> </DIV>

<P>
Currently, the only way to reset the permissive flag is to unbind the device
from the PCI Backend driver.

<P>

<H3><A NAME="SECTION03231600000000000000">
5.3.1.6 PCI Backend - Checking Status</A>
</H3>
There two important sysfs nodes that provide a mechanism to view specifics on
quirks and permissive devices:
<DL>
<DT></DT>
<DD><TT>/sys/bus/drivers/pciback/permissive</TT> 
<BR>
Use <TT>cat</TT> on this file to view a list of permissive slots.
</DD>
<DT></DT>
<DD><TT>/sys/bus/drivers/pciback/quirks</TT> 
<BR>
Use <TT>cat</TT> on this file view a hierarchical view of devices bound to the
PCI backend, their PCI vendor/device ID, and any quirks that are associated with
that particular slot.  
</DD>
</DL>

<P>
You may notice that every device bound to the PCI backend has 17 quirks standard 
"quirks" regardless of <TT>xend-pci-quirks.sxp</TT>.  These default entries are
necessary to support interactions between the PCI bus manager and the device bound
to it.  Even non-quirky devices should have these standard entries.  

<P>
In this case, preference was given to accuracy over aesthetics by choosing to
show the standard quirks in the quirks list rather than hide them from the
inquiring user 

<P>

<H3><A NAME="SECTION03231700000000000000">
5.3.1.7 PCI Frontend Configuration</A>
</H3>
To configure a domU to receive a PCI device:

<P>
<DL>
<DT><STRONG>Command-line:</STRONG></DT>
<DD>Use the <EM>pci</EM> command-line flag. For multiple devices, use the option
  multiple times. 
<BR>
<DIV ALIGN="CENTER">
  <TT>xm create netcard-dd pci=01:00.0 pci=02:03.0 </TT></DIV>
 
<BR>
<P>
</DD>
<DT><STRONG>Flat Format configuration file:</STRONG></DT>
<DD>Specify all of your PCI devices in a python list named <EM>pci</EM>. 
<BR>
<DIV ALIGN="CENTER">
  <TT>pci=['01:00.0','02:03.0'] </TT></DIV>
 
<BR>
<P>
</DD>
<DT><STRONG>SXP Format configuration file:</STRONG></DT>
<DD>Use a single PCI device section for all of your devices (specify the numbers
  in hexadecimal with the preceding '0x'). Note that <EM>domain</EM> here refers
  to the PCI domain, not a virtual machine within Xen.
<PRE>
(device (pci
    (dev (domain 0x0)(bus 0x3)(slot 0x1a)(func 0x1)
    (dev (domain 0x0)(bus 0x1)(slot 0x5)(func 0x0)
)
</PRE>
</DD>
</DL>

<P>

<H1><A NAME="SECTION03240000000000000000"></A>
<A NAME="ss:vtpm"></A>
<BR>
5.4 Support for virtual Trusted Platform Module (vTPM)
</H1>

<P>
Paravirtualized domains can be given access to a virtualized version
of a TPM. This enables applications in these domains to use the services
of the TPM device for example through a TSS stack
<A NAME="tex2html9"
  HREF="#foot400"><SUP>5.1</SUP></A>.
The Xen source repository provides the necessary software components to
enable virtual TPM access. Support is provided through several
different pieces. First, a TPM emulator has been modified to provide TPM's
functionality for the virtual TPM subsystem. Second, a virtual TPM Manager
coordinates the virtual TPMs efforts, manages their creation, and provides
protected key storage using the TPM. Third, a device driver pair providing
a TPM front- and backend is available for XenLinux to deliver TPM commands
from the domain to the virtual TPM manager, which dispatches it to a
software TPM. Since the TPM Manager relies on a HW TPM for protected key
storage, therefore this subsystem requires a Linux-supported hardware TPM.
For development purposes, a TPM emulator is available for use on non-TPM
enabled platforms.

<P>

<H3><A NAME="SECTION03240100000000000000">
5.4.0.1 Compile-Time Setup</A>
</H3>
To enable access to the virtual TPM, the virtual TPM backend driver must
be compiled for a privileged domain (e.g. domain 0). Using the XenLinux
configuration, the necessary driver can be selected in the Xen configuration
section. Unless the driver has been compiled into the kernel, its module
must be activated using the following command:

<P>
<PRE>
modprobe tpmbk
</PRE>

<P>
Similarly, the TPM frontend driver must be compiled for the kernel trying
to use TPM functionality. Its driver can be selected in the kernel
configuration section Device Driver / Character Devices / TPM Devices.
Along with that the TPM driver for the built-in TPM must be selected.
If the virtual TPM driver has been compiled as module, it
must be activated using the following command:

<P>
<PRE>
modprobe tpm_xenu
</PRE>

<P>
Furthermore, it is necessary to build the virtual TPM manager and software
TPM by making changes to entries in Xen build configuration files.
The following entry in the file Config.mk in the Xen root source
directory must be made:

<P>
<PRE>
VTPM_TOOLS ?= y
</PRE>

<P>
After a build of the Xen tree and a reboot of the machine, the TPM backend
drive must be loaded. Once loaded, the virtual TPM manager daemon
must be started before TPM-enabled guest domains may be launched.
To enable being the destination of a virtual TPM Migration, the virtual TPM
migration daemon must also be loaded.

<P>
<PRE>
vtpm_managerd
</PRE>
<PRE>
vtpm_migratord
</PRE>

<P>
Once the VTPM manager is running, the VTPM can be accessed by loading the
front end driver in a guest domain.

<P>

<H3><A NAME="SECTION03240200000000000000">
5.4.0.2 Development and Testing TPM Emulator</A>
</H3>
For development and testing on non-TPM enabled platforms, a TPM emulator
can be used in replacement of a platform TPM. First, the entry in the file
tools/vtpm/Rules.mk must look as follows:

<P>
<PRE>
BUILD_EMULATOR = y
</PRE>

<P>
Second, the entry in the file tool/vtpm_manager/Rules.mk must be uncommented
as follows:

<P>
<PRE>
# TCS talks to fifo's rather than /dev/tpm. TPM Emulator assumed on fifos
CFLAGS += -DDUMMY_TPM
</PRE>

<P>
Before starting the virtual TPM Manager, start the emulator by executing
the following in dom0:

<P>
<PRE>
tpm_emulator clear
</PRE>

<P>

<H3><A NAME="SECTION03240300000000000000">
5.4.0.3 vTPM Frontend Configuration</A>
</H3>
To provide TPM functionality to a user domain, a line must be added to
the virtual TPM configuration file using the following format:

<P>
<PRE>
vtpm = ['instance=&lt;instance number&gt;, backend=&lt;domain id&gt;']
</PRE>

<P>
The  <I>instance number</I> reflects the preferred virtual TPM instance
to associate with the domain. If the selected instance is
already associated with another domain, the system will automatically
select the next available instance. An instance number greater than
zero must be provided. It is possible to omit the instance
parameter from the configuration file.

<P>
The <I>domain id</I> provides the ID of the domain where the
virtual TPM backend driver and virtual TPM are running in. It should
currently always be set to '0'.

<P>
Examples for valid vtpm entries in the configuration file are

<P>
<PRE>
 vtpm = ['instance=1, backend=0']
</PRE>
and
<PRE>
 vtpm = ['backend=0'].
</PRE>

<P>

<H3><A NAME="SECTION03240400000000000000">
5.4.0.4 Using the virtual TPM</A>
</H3>

<P>
Access to TPM functionality is provided by the virtual TPM frontend driver.
Similar to existing hardware TPM drivers, this driver provides basic TPM
status information through the <I>sysfs</I> filesystem. In a Xen user domain
the sysfs entries can be found in /sys/devices/xen/vtpm-0.

<P>
Commands can be sent to the virtual TPM instance using the character
device /dev/tpm0 (major 10, minor 224).

<P>

<H1><A NAME="SECTION03300000000000000000">
6. Storage and File System Management</A>
</H1>

<P>
Storage can be made available to virtual machines in a number of
different ways.  This chapter covers some possible configurations.

<P>
The most straightforward method is to export a physical block device (a
hard drive or partition) from dom0 directly to the guest domain as a
virtual block device (VBD).

<P>
Storage may also be exported from a filesystem image or a partitioned
filesystem image as a <I>file-backed VBD</I>.

<P>
Finally, standard network storage protocols such as NBD, iSCSI, NFS,
etc., can be used to provide storage to virtual machines.

<P>

<H1><A NAME="SECTION03310000000000000000"></A>
<A NAME="s:exporting-physical-devices-as-vbds"></A>
<BR>
6.1 Exporting Physical Devices as VBDs
</H1>

<P>
One of the simplest configurations is to directly export individual
partitions from domain&nbsp;0 to other domains. To achieve this use the
<TT>phy:</TT> specifier in your domain configuration file. For example a
line like
<BLOCKQUOTE>
<code>disk = ['phy:hda3,sda1,w']</code>

</BLOCKQUOTE>
specifies that the partition <TT>/dev/hda3</TT> in domain&nbsp;0 should be
exported read-write to the new domain as <TT>/dev/sda1</TT>; one could
equally well export it as <TT>/dev/hda</TT> or <TT>/dev/sdb5</TT> should
one wish.

<P>
In addition to local disks and partitions, it is possible to export
any device that Linux considers to be ``a disk'' in the same manner.
For example, if you have iSCSI disks or GNBD volumes imported into
domain&nbsp;0 you can export these to other domains using the <TT>phy:</TT>
disk syntax. E.g.:
<BLOCKQUOTE>
<code>disk = ['phy:vg/lvm1,sda2,w']</code>

</BLOCKQUOTE>

<P>
<DIV ALIGN="CENTER">
<!-- MATH
 $\framebox{\bf Warning: Block device sharing}$
 -->
<IMG
 WIDTH="241" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
 SRC="img3.png"
 ALT="\framebox{\bf Warning: Block device sharing}">
</DIV>
<BLOCKQUOTE>
Block devices should typically only be shared between domains in a
  read-only fashion otherwise the Linux kernel's file systems will get
  very confused as the file system structure may change underneath
  them (having the same ext3 partition mounted <TT>rw</TT> twice is a
  sure fire way to cause irreparable damage)!  Xend will attempt to
  prevent you from doing this by checking that the device is not
  mounted read-write in domain&nbsp;0, and hasn't already been exported
  read-write to another domain.  If you want read-write sharing,
  export the directory to other domains via NFS from domain&nbsp;0 (or use
  a cluster file system such as GFS or ocfs2).

</BLOCKQUOTE>

<P>

<H1><A NAME="SECTION03320000000000000000">
6.2 Using File-backed VBDs</A>
</H1>

<P>
It is also possible to use a file in Domain&nbsp;0 as the primary storage
for a virtual machine.  As well as being convenient, this also has the
advantage that the virtual block device will be <I>sparse</I> --
space will only really be allocated as parts of the file are used.  So
if a virtual machine uses only half of its disk space then the file
really takes up half of the size allocated.

<P>
For example, to create a 2GB sparse file-backed virtual block device
(actually only consumes no disk space at all):
<BLOCKQUOTE>
<code># dd if=/dev/zero of=vm1disk bs=1k seek=2048k count=0</code>

</BLOCKQUOTE>

<P>
Make a file system in the disk file:
<BLOCKQUOTE>
<code># mkfs -t ext3 vm1disk</code>

</BLOCKQUOTE>

<P>
(when the tool asks for confirmation, answer `y')

<P>
Populate the file system e.g. by copying from the current root:<PRE>
# mount -o loop vm1disk /mnt
# cp -ax /{root,dev,var,etc,usr,bin,sbin,lib} /mnt
# mkdir /mnt/{proc,sys,home,tmp}
</PRE>

<P>
Tailor the file system by editing <TT>/etc/fstab</TT>,
<TT>/etc/hostname</TT>, etc. Don't forget to edit the files in the
mounted file system, instead of your domain&nbsp;0 filesystem, e.g. you
would edit <TT>/mnt/etc/fstab</TT> instead of <TT>/etc/fstab</TT>.  For
this example put <TT>/dev/sda1</TT> to root in fstab.

<P>
Now unmount (this is important!):
<BLOCKQUOTE>
<code># umount /mnt</code>

</BLOCKQUOTE>

<P>
In the configuration file set:
<BLOCKQUOTE>
<code>disk = ['tap:aio:/full/path/to/vm1disk,sda1,w']</code>

</BLOCKQUOTE>

<P>
As the virtual machine writes to its `disk', the sparse file will be
filled in and consume more space up to the original 2GB.

<P>
<EM>Note:</EM> Users that have worked with file-backed VBDs on Xen in previous
versions will be interested to know that this support is now provided through
the blktap driver instead of the loopback driver.  This change results in
file-based block devices that are higher-performance, more scalable, and which
provide better safety properties for VBD data.  All that is required to update
your existing file-backed VM configurations is to change VBD configuration
lines from:
<BLOCKQUOTE>
<code>disk = ['file:/full/path/to/vm1disk,sda1,w']</code>

</BLOCKQUOTE>
to:
<BLOCKQUOTE>
<code>disk = ['tap:aio:/full/path/to/vm1disk,sda1,w']</code>

</BLOCKQUOTE>

<P>

<H2><A NAME="SECTION03321000000000000000">
6.2.1 Loopback-mounted file-backed VBDs (deprecated)</A>
</H2>

<P>
<EM><B>Note:</B> Loopback mounted VBDs have now been replaced with
    blktap-based support for raw image files, as described above.  This
    section remains to detail a configuration that was used by older Xen
    versions.</EM>

<P>
Raw image file-backed VBDs may also be attached to VMs using the 
Linux loopback driver.  The only required change to the raw file 
instructions above are to specify the configuration entry as:
<BLOCKQUOTE>
<code>disk = ['file:/full/path/to/vm1disk,sda1,w']</code>

</BLOCKQUOTE>

<P>
<B>Note that loopback file-backed VBDs may not be appropriate for backing
  I/O-intensive domains.</B>  This approach is known to experience
substantial slowdowns under heavy I/O workloads, due to the I/O
handling by the loopback block device used to support file-backed VBDs
in dom0.  Loopback support remains for old Xen installations, and users
are strongly encouraged to use the blktap-based file support (using 
``<TT>tap:aio</TT>'' as described above).

<P>
Additionally, Linux supports a maximum of eight loopback file-backed 
VBDs across all domains by default.  This limit can be statically 
increased by using the <I>max_loop</I> module parameter if 
CONFIG_BLK_DEV_LOOP is compiled as a module in the dom0 kernel, or 
by using the <I>max_loop=n</I> boot option if CONFIG_BLK_DEV_LOOP 
is compiled directly into the dom0 kernel.  Again, users are encouraged
to use the blktap-based file support described above which scales to much 
larger number of active VBDs.

<P>

<H1><A NAME="SECTION03330000000000000000"></A>
<A NAME="s:using-lvm-backed-vbds"></A>
<BR>
6.3 Using LVM-backed VBDs
</H1>

<P>
A particularly appealing solution is to use LVM volumes as backing for
domain file-systems since this allows dynamic growing/shrinking of
volumes as well as snapshot and other features.

<P>
To initialize a partition to support LVM volumes:<PRE>
# pvcreate /dev/sda10
</PRE>

<P>
Create a volume group named `vg' on the physical partition:<PRE>
# vgcreate vg /dev/sda10
</PRE>

<P>
Create a logical volume of size 4GB named `myvmdisk1':<PRE>
# lvcreate -L4096M -n myvmdisk1 vg
</PRE>

<P>
You should now see that you have a <TT>/dev/vg/myvmdisk1</TT> Make a
filesystem, mount it and populate it, e.g.:<PRE>
# mkfs -t ext3 /dev/vg/myvmdisk1
# mount /dev/vg/myvmdisk1 /mnt
# cp -ax / /mnt
# umount /mnt
</PRE>

<P>
Now configure your VM with the following disk configuration:<PRE>
 disk = [ 'phy:vg/myvmdisk1,sda1,w' ]
</PRE>

<P>
LVM enables you to grow the size of logical volumes, but you'll need
to resize the corresponding file system to make use of the new space.
Some file systems (e.g. ext3) now support online resize.  See the LVM
manuals for more details.

<P>
You can also use LVM for creating copy-on-write (CoW) clones of LVM
volumes (known as writable persistent snapshots in LVM terminology).
This facility is new in Linux 2.6.8, so isn't as stable as one might
hope.  In particular, using lots of CoW LVM disks consumes a lot of
dom0 memory, and error conditions such as running out of disk space
are not handled well. Hopefully this will improve in future.

<P>
To create two copy-on-write clones of the above file system you would
use the following commands:

<P><PRE>
# lvcreate -s -L1024M -n myclonedisk1 /dev/vg/myvmdisk1
# lvcreate -s -L1024M -n myclonedisk2 /dev/vg/myvmdisk1
</PRE>

<P>
Each of these can grow to have 1GB of differences from the master
volume. You can grow the amount of space for storing the differences
using the lvextend command, e.g.:<PRE>
# lvextend +100M /dev/vg/myclonedisk1
</PRE>

<P>
Don't let the `differences volume' ever fill up otherwise LVM gets
rather confused. It may be possible to automate the growing process by
using <TT>dmsetup wait</TT> to spot the volume getting full and then
issue an <TT>lvextend</TT>.

<P>
In principle, it is possible to continue writing to the volume that
has been cloned (the changes will not be visible to the clones), but
we wouldn't recommend this: have the cloned volume as a `pristine'
file system install that isn't mounted directly by any of the virtual
machines.

<P>

<H1><A NAME="SECTION03340000000000000000">
6.4 Using NFS Root</A>
</H1>

<P>
First, populate a root filesystem in a directory on the server
machine. This can be on a distinct physical machine, or simply run
within a virtual machine on the same node.

<P>
Now configure the NFS server to export this filesystem over the
network by adding a line to <TT>/etc/exports</TT>, for instance:

<P><BLOCKQUOTE></BLOCKQUOTE><PRE>
/export/vm1root      192.0.2.4/24 (rw,sync,no_root_squash)
</PRE><BLOCKQUOTE>
</BLOCKQUOTE>

<P>
Finally, configure the domain to use NFS root.  In addition to the
normal variables, you should make sure to set the following values in
the domain's configuration file:

<P><BLOCKQUOTE></BLOCKQUOTE><PRE>
root       = '/dev/nfs'
nfs_server = '2.3.4.5'       # substitute IP address of server
nfs_root   = '/path/to/root' # path to root FS on the server
</PRE><BLOCKQUOTE>
</BLOCKQUOTE>

<P>
The domain will need network access at boot time, so either statically
configure an IP address using the config variables <TT>ip</TT>,
<TT>netmask</TT>, <TT>gateway</TT>, <TT>hostname</TT>; or enable DHCP
(<TT>dhcp='dhcp'</TT>).

<P>
Note that the Linux NFS root implementation is known to have stability
problems under high load (this is not a Xen-specific problem), so this
configuration may not be appropriate for critical servers.

<P>

<H1><A NAME="SECTION03400000000000000000">
7. CPU Management</A>
</H1>

<P>
Xen allows a domain's virtual CPU(s) to be associated with one or more
host CPUs.  This can be used to allocate real resources among one or
more guests, or to make optimal use of processor resources when
utilizing dual-core, hyperthreading, or other advanced CPU technologies.

<P>
Xen enumerates physical CPUs in a `depth first' fashion.  For a system
with both hyperthreading and multiple cores, this would be all the
hyperthreads on a given core, then all the cores on a given socket,
and then all sockets.  I.e.  if you had a two socket, dual core,
hyperthreaded Xeon the CPU order would be:

<P>
<DIV ALIGN="CENTER">
<TABLE CELLPADDING=3 BORDER="1">
<TR><TD ALIGN="CENTER" COLSPAN=4>socket0</TD>
<TD ALIGN="CENTER" COLSPAN=4>socket1</TD>
</TR>
<TR><TD ALIGN="CENTER" COLSPAN=2>core0</TD>
<TD ALIGN="CENTER" COLSPAN=2>core1</TD>
<TD ALIGN="CENTER" COLSPAN=2>core0</TD>
<TD ALIGN="CENTER" COLSPAN=2>core1</TD>
</TR>
<TR><TD ALIGN="LEFT">ht0</TD>
<TD ALIGN="LEFT">ht1</TD>
<TD ALIGN="LEFT">ht0</TD>
<TD ALIGN="LEFT">ht1</TD>
<TD ALIGN="LEFT">ht0</TD>
<TD ALIGN="LEFT">ht1</TD>
<TD ALIGN="LEFT">ht0</TD>
<TD ALIGN="RIGHT">ht1</TD>
</TR>
<TR><TD ALIGN="LEFT">#0</TD>
<TD ALIGN="LEFT">#1</TD>
<TD ALIGN="LEFT">#2</TD>
<TD ALIGN="LEFT">#3</TD>
<TD ALIGN="LEFT">#4</TD>
<TD ALIGN="LEFT">#5</TD>
<TD ALIGN="LEFT">#6</TD>
<TD ALIGN="RIGHT">#7</TD>
</TR>
</TABLE>
</DIV>

<P>
Having multiple vcpus belonging to the same domain mapped to the same
physical CPU is very likely to lead to poor performance. It's better to
use `vcpus-set' to hot-unplug one of the vcpus and ensure the others are
pinned on different CPUs.

<P>
If you are running IO intensive tasks, its typically better to dedicate
either a hyperthread or whole core to running domain 0, and hence pin
other domains so that they can't use CPU 0. If your workload is mostly
compute intensive, you may want to pin vcpus such that all physical CPU
threads are available for guest domains.

<P>

<H1><A NAME="SECTION03500000000000000000">
8. Migrating Domains</A>
</H1>

<P>

<H1><A NAME="SECTION03510000000000000000">
8.1 Domain Save and Restore</A>
</H1>

<P>
The administrator of a Xen system may suspend a virtual machine's
current state into a disk file in domain&nbsp;0, allowing it to be resumed at
a later time.

<P>
For example you can suspend a domain called ``VM1'' to disk using the
command:
<PRE>
# xm save VM1 VM1.chk
</PRE>

<P>
This will stop the domain named ``VM1'' and save its current state
into a file called <TT>VM1.chk</TT>.

<P>
To resume execution of this domain, use the <TT>xm restore</TT> command:
<PRE>
# xm restore VM1.chk
</PRE>

<P>
This will restore the state of the domain and resume its execution.
The domain will carry on as before and the console may be reconnected
using the <TT>xm console</TT> command, as described earlier.

<P>

<H1><A NAME="SECTION03520000000000000000">
8.2 Migration and Live Migration</A>
</H1>

<P>
Migration is used to transfer a domain between physical hosts. There
are two varieties: regular and live migration. The former moves a
virtual machine from one host to another by pausing it, copying its
memory contents, and then resuming it on the destination. The latter
performs the same logical functionality but without needing to pause
the domain for the duration. In general when performing live migration
the domain continues its usual activities and--from the user's
perspective--the migration should be imperceptible.

<P>
To perform a live migration, both hosts must be running Xen / xend and
the destination host must have sufficient resources (e.g. memory
capacity) to accommodate the domain after the move. Furthermore we
currently require both source and destination machines to be on the same
L2 subnet.

<P>
Currently, there is no support for providing automatic remote access
to filesystems stored on local disk when a domain is migrated.
Administrators should choose an appropriate storage solution (i.e. SAN, NAS, etc.) to ensure that domain filesystems are also available
on their destination node. GNBD is a good method for exporting a
volume from one machine to another. iSCSI can do a similar job, but is
more complex to set up.

<P>
When a domain migrates, it's MAC and IP address move with it, thus it is
only possible to migrate VMs within the same layer-2 network and IP
subnet. If the destination node is on a different subnet, the
administrator would need to manually configure a suitable etherip or IP
tunnel in the domain&nbsp;0 of the remote node.

<P>
A domain may be migrated using the <TT>xm migrate</TT> command. To live
migrate a domain to another machine, we would use the command:

<P>
<PRE>
# xm migrate --live mydomain destination.ournetwork.com
</PRE>

<P>
Without the <TT>-live</TT> flag, xend simply stops the domain and
copies the memory image over to the new node and restarts it. Since
domains can have large allocations this can be quite time consuming,
even on a Gigabit network. With the <TT>-live</TT> flag xend attempts
to keep the domain running while the migration is in progress, resulting
in typical down times of just 60-300ms.

<P>
For now it will be necessary to reconnect to the domain's console on the
new machine using the <TT>xm console</TT> command. If a migrated domain
has any open network connections then they will be preserved, so SSH
connections do not have this limitation.

<P>

<H1><A NAME="SECTION03600000000000000000">
9. Securing Xen</A>
</H1>

<P>
This chapter describes how to secure a Xen system. It describes a number
of scenarios and provides a corresponding set of best practices. It
begins with a section devoted to understanding the security implications
of a Xen system.

<P>

<H1><A NAME="SECTION03610000000000000000">
9.1 Xen Security Considerations</A>
</H1>

<P>
When deploying a Xen system, one must be sure to secure the management
domain (Domain-0) as much as possible. If the management domain is
compromised, all other domains are also vulnerable. The following are a
set of best practices for Domain-0:

<P>

<OL>
<LI><B>Run the smallest number of necessary services.</B> The less
  things that are present in a management partition, the better.
  Remember, a service running as root in the management domain has full
  access to all other domains on the system.
</LI>
<LI><B>Use a firewall to restrict the traffic to the management
    domain.</B> A firewall with default-reject rules will help prevent
  attacks on the management domain.
</LI>
<LI><B>Do not allow users to access Domain-0.</B> The Linux kernel
  has been known to have local-user root exploits. If you allow normal
  users to access Domain-0 (even as unprivileged users) you run the risk
  of a kernel exploit making all of your domains vulnerable.
</LI>
</OL>

<P>

<H1><A NAME="SECTION03620000000000000000"></A>
<A NAME="s:ddsecurity"></A>
<BR>
9.2 Driver Domain Security Considerations
</H1>

<P>
Driver domains address a range of security problems that exist regarding
the use of device drivers and hardware. On many operating systems in common
use today, device drivers run within the kernel with the same privileges as
the kernel. Few or no mechanisms exist to protect the integrity of the kernel
from a misbehaving (read "buggy") or malicious device driver. Driver
domains exist to aid in isolating a device driver within its own virtual
machine where it cannot affect the stability and integrity of other
domains. If a driver crashes, the driver domain can be restarted rather than
have the entire machine crash (and restart) with it. Drivers written by
unknown or untrusted third-parties can be confined to an isolated space.
Driver domains thus address a number of security and stability issues with
device drivers.

<P>
However, due to limitations in current hardware, a number of security
concerns remain that need to be considered when setting up driver domains (it
should be noted that the following list is not intended to be exhaustive).

<P>

<OL>
<LI><B>Without an IOMMU, a hardware device can DMA to memory regions
  outside of its controlling domain.</B> Architectures which do not have an
  IOMMU (e.g. most x86-based platforms) to restrict DMA usage by hardware
  are vulnerable. A hardware device which can perform arbitrary memory reads
  and writes can read/write outside of the memory of its controlling domain.
  A malicious or misbehaving domain could use a hardware device it controls
  to send data overwriting memory in another domain or to read arbitrary
  regions of memory in another domain.
</LI>
<LI><B>Shared buses are vulnerable to sniffing.</B> Devices that share
  a data bus can sniff (and possible spoof) each others' data. Device A that
  is assigned to Domain A could eavesdrop on data being transmitted by
  Domain B to Device B and then relay that data back to Domain A.
</LI>
<LI><B>Devices which share interrupt lines can either prevent the
  reception of that interrupt by the driver domain or can trigger the
  interrupt service routine of that guest needlessly.</B> A devices which shares
  a level-triggered interrupt (e.g. PCI devices) with another device can
  raise an interrupt and never clear it. This effectively blocks other devices
  which share that interrupt line from notifying their controlling driver
  domains that they need to be serviced. A device which shares an
  any type of interrupt line can trigger its interrupt continually which
  forces execution time to be spent (in multiple guests) in the interrupt
  service routine (potentially denying time to other processes within that
  guest). System architectures which allow each device to have its own
  interrupt line (e.g. PCI's Message Signaled Interrupts) are less
  vulnerable to this denial-of-service problem.
</LI>
<LI><B>Devices may share the use of I/O memory address space.</B> Xen can
  only restrict access to a device's physical I/O resources at a certain
  granularity. For interrupt lines and I/O port address space, that
  granularity is very fine (per interrupt line and per I/O port). However,
  Xen can only restrict access to I/O memory address space on a page size
  basis. If more than one device shares use of a page in I/O memory address
  space, the domains to which those devices are assigned will be able to
  access the I/O memory address space of each other's devices.
</LI>
</OL>

<P>

<H1><A NAME="SECTION03630000000000000000">
9.3 Security Scenarios</A>
</H1>

<P>

<H2><A NAME="SECTION03631000000000000000">
9.3.1 The Isolated Management Network</A>
</H2>

<P>
In this scenario, each node has two network cards in the cluster. One
network card is connected to the outside world and one network card is a
physically isolated management network specifically for Xen instances to
use.

<P>
As long as all of the management partitions are trusted equally, this is
the most secure scenario. No additional configuration is needed other
than forcing Xend to bind to the management interface for relocation.

<P>

<H2><A NAME="SECTION03632000000000000000">
9.3.2 A Subnet Behind a Firewall</A>
</H2>

<P>
In this scenario, each node has only one network card but the entire
cluster sits behind a firewall. This firewall should do at least the
following:

<P>

<OL>
<LI>Prevent IP spoofing from outside of the subnet.
</LI>
<LI>Prevent access to the relocation port of any of the nodes in the
  cluster except from within the cluster.
</LI>
</OL>

<P>
The following iptables rules can be used on each node to prevent
migrations to that node from outside the subnet assuming the main
firewall does not do this for you:

<P>
<PRE>
# this command disables all access to the Xen relocation
# port:
iptables -A INPUT -p tcp --destination-port 8002 -j REJECT

# this command enables Xen relocations only from the specific
# subnet:
iptables -I INPUT -p tcp -{}-source 192.0.2.0/24 \
    --destination-port 8002 -j ACCEPT
</PRE>

<P>

<H2><A NAME="SECTION03633000000000000000">
9.3.3 Nodes on an Untrusted Subnet</A>
</H2>

<P>
Migration on an untrusted subnet is not safe in current versions of Xen.
It may be possible to perform migrations through a secure tunnel via an
VPN or SSH. The only safe option in the absence of a secure tunnel is to
disable migration completely. The easiest way to do this is with
iptables:

<P>
<PRE>
# this command disables all access to the Xen relocation port
iptables -A INPUT -p tcp -{}-destination-port 8002 -j REJECT
</PRE>

<P>

<H1><A NAME="SECTION03700000000000000000">
10. sHype/Xen Access Control</A>
</H1>
The Xen mandatory access control framework is an implementation of the
sHype Hypervisor Security Architecture
(www.research.ibm.com/ssd_shype). It permits or denies communication
and resource access of domains based on a security policy. The
mandatory access controls are enforced in addition to the Xen core
controls, such as memory protection.  They are designed to remain
transparent during normal operation of domains (policy-conform
behavior) but to intervene when domains move outside their intended
sharing behavior.  This chapter will describe how the sHype access
controls in Xen can be configured to prevent viruses from spilling
over from one into another workload type and secrets from leaking from
one workload type to another. sHype/Xen depends on the correct
behavior of Domain-0 (cf previous chapter).

<P>
Benefits of configuring sHype/ACM in Xen include:

<UL>
<LI>robust workload and resource protection effective against rogue
  user domains
</LI>
<LI>simple, platform- and operating system-independent security
  policies (ideal for heterogeneous distributed environments)
</LI>
<LI>safety net with minimal performance overhead in case operating
  system security is missing, does not scale, or fails
</LI>
</UL>

<P>
These benefits are very valuable because today's operating systems
become increasingly complex and often have no or insufficient
mandatory access controls.  (Discretionary access controls, supported
by most operating systems, are not effective against viruses or
misbehaving programs.)  Where mandatory access control exists (e.g.,
SELinux), they usually deploy platform-specific, complex, and difficult
to understand security policies.  Multi-tier applications in business
environments typically require different operating systems
(e.g., AIX, Windows, Linux) in different tiers. Related distributed
transactions and workloads cannot be easily protected on the OS level.
The Xen access control framework steps in to offer a coarse-grained
but very robust and consistent security layer and safety net across
different platforms and operating systems.

<P>
To control sharing between domains, Xen mediates all inter-domain
communication (shared memory, events) as well as the access of domains
to resources such as storage disks. Thus, Xen can confine distributed
workloads (domain payloads) by permitting sharing among domains
running the same type of workload and denying sharing between pairs of
domains that run different workload types. We assume that-from a Xen
perspective-only one workload type is running per user domain. To
enable Xen to associate domains and resources with workload types,
security labels including the workload types are attached to domains
and resources. These labels and the hypervisor sHype controls cannot
be manipulated or bypassed by user domains and are effective even
against compromised or rogue domains.

<P>

<H1><A NAME="SECTION03710000000000000000">
10.1 Overview</A>
</H1>
This section gives an overview of how workloads can be protected using
the sHype mandatory access control framework in Xen.
Figure&nbsp;<A HREF="#fig:acmoverview">10.1</A> shows the necessary steps in activating
the Xen workload protection. These steps are described in detail in
Section&nbsp;<A HREF="#section:acmexample">10.2</A>.

<P>

<DIV ALIGN="CENTER"><A NAME="fig:acmoverview"></A><A NAME="607"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 10.1:</STRONG>
Overview of activating sHype workload protection in Xen.
  Section numbers point to representative examples.</CAPTION>
<TR><TD>
<DIV ALIGN="CENTER"><IMG
 WIDTH="588" HEIGHT="336" ALIGN="BOTTOM" BORDER="0"
 SRC="img4.png"
 ALT="\includegraphics[width=13cm]{figs/acm_overview.eps}">
</DIV></TD></TR>
</TABLE>
</DIV>

<P>
First, the sHype/ACM access control must be enabled in the Xen
distribution and the distribution must be built and installed (cf
Subsection&nbsp;<A HREF="#subsection:acmexampleconfigure">10.2.1</A>). Before we can
enforce security, a Xen security policy must be created (cf
Subsection&nbsp;<A HREF="#subsection:acmexamplecreate">10.2.2</A>) and deployed (cf
Subsection&nbsp;<A HREF="#subsection:acmexampleinstall">10.2.3</A>).  This policy defines
the workload types differentiated during access control. It also
defines the rules that compare workload types of domains and resources
to decide about access requests. Workload types are represented by
security labels that can be securely associated to domains and resources (cf
Subsections&nbsp;<A HREF="#subsection:acmexamplelabeldomains">10.2.4</A>
and&nbsp;<A HREF="#subsection:acmexamplelabelresources">10.2.5</A>).  The functioning of
the active sHype/Xen workload protection is demonstrated using simple
resource assignment, and domain creation tests in
Subsection&nbsp;<A HREF="#subsection:acmexampletest">10.2.6</A>.
Section&nbsp;<A HREF="#section:acmpolicy">10.3</A> describes the syntax and semantics of
the sHype/Xen security policy in detail and introduces briefly the
tools that are available to help you create your own sHype security policies.

<P>
The next section describes all the necessary steps to create, deploy,
and test a simple workload protection policy. It is meant to enable
Xen users and developers to quickly try out the sHype/Xen workload
protection. Those readers who are interested in learning more about
how the sHype access control in Xen works and how it is configured
using the XML security policy should read Section&nbsp;<A HREF="#section:acmpolicy">10.3</A>
as well. Section&nbsp;<A HREF="#section:acmlimitations">10.4</A> concludes this chapter with
current limitations of the sHype implementation for Xen.

<P>

<H1><A NAME="SECTION03720000000000000000"></A>
<A NAME="section:acmexample"></A>
<BR>
10.2 Xen Workload Protection Step-by-Step
</H1>

<P>
You are about to configure and deploy the Xen sHype workload protection
by following 5 simple steps:

<UL>
<LI>configure and install sHype/Xen
</LI>
<LI>create a simple workload protection security policy
</LI>
<LI>deploy the sHype/Xen security policy
</LI>
<LI>associate domains and resources with workload labels,
</LI>
<LI>test the workload protection
</LI>
</UL>
The essential commands to create and deploy an sHype/Xen security
policy are numbered throughout the following sections. If you want a
quick-guide or return at a later time to go quickly through this
demonstration, simply look for the numbered commands and apply them in
order.

<P>

<H2><A NAME="SECTION03721000000000000000"></A>
<A NAME="subsection:acmexampleconfigure"></A>
<BR>
10.2.1 Configuring/Building sHype Support into Xen
</H2>
First, we need to configure the access control module in Xen and
install the ACM-enabled Xen hypervisor. This step installs security
tools and compiles sHype/ACM controls into the Xen hypervisor.

<P>
To enable sHype/ACM in Xen, please edit the Config.mk file in the top
Xen directory.

<P>
<PRE>
  (1) In Config.mk
        Change: XSM_ENABLE ?= n
            To: XSM_ENABLE ?= y

        Change: ACM_SECURITY ?= n
            To: ACM_SECURITY ?= y
</PRE>

<P>
Then install the security-enabled Xen environment as follows:

<P>
<PRE>
  (2) # make world
      # make install
</PRE>

<P>
Reboot into the security-enabled Xen hypervisor.

<P>
<PRE>
  (3) # reboot
</PRE>

<P>
Xen will boot into the default security policy. After reboot,
you can explore the simple DEFAULT policy.
<PRE>
# xm getpolicy
Supported security subsystems   : ACM
Policy name           : DEFAULT
Policy type           : ACM
Version of XML policy : 1.0
Policy configuration  : loaded

# xm labels
SystemManagement

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
Domain-0   0   941     1     r-----     38.1  ACM:DEFAULT:SystemManagement
</PRE>

<P>
In this state, no domains can be started.
Now, a policy can be created and loaded into the hypervisor.

<P>

<H2><A NAME="SECTION03722000000000000000"></A>
<A NAME="subsection:acmexamplecreate"></A>
<BR>
10.2.2 Creating A WLP Policy in 3 Simple Steps with ezPolicy
</H2>

<P>
We will use the ezPolicy tool to quickly create a policy that protects
workloads.  You will need both the Python and wxPython packages to run
this tool.  To run the tool in Domain-0, you can download the wxPython
package from www.wxpython.org or use the command <code>yum install wxPython</code>
in Redhat/Fedora. To run the tool on MS Windows, you also need to download
the Python package from www.python.org. After these packages are installed,
start the ezPolicy tool with the following command:

<P>
<PRE>
  (4) # xensec_ezpolicy
</PRE>

<P>
Figure&nbsp;<A HREF="#fig:acmezpolicy">10.2</A> shows a screen-shot of the tool. The
following steps illustrate how you can create the workload definition
shown in Figure&nbsp;<A HREF="#fig:acmezpolicy">10.2</A>.  You can use <code>&lt;CTRL&gt;-h</code> to
pop up a help window at any time. The indicators (a), (b), and (c) in
Figure&nbsp;<A HREF="#fig:acmezpolicy">10.2</A> show the buttons that are used during the
3 steps of creating a policy:

<OL>
<LI>defining workloads
</LI>
<LI>defining run-time conflicts
</LI>
<LI>translating the workload definition into an sHype/Xen access
  control policy
</LI>
</OL>

<P>

<H4><A NAME="SECTION03722010000000000000">
10.2.2.0.1 Defining workloads.</A>
</H4> Workloads are defined for each
organization and department that you enter in the left panel.

<P>
To ease the transition from an unlabeled to a fully labeled workload-protection
environment, we have added support to sHype/Xen to run unlabeled domains accessing
unlabeled resources in addition to labeled domains accessing labeled resources.

<P>
Support for running unlabeled domains on sHype/Xen is enabled by adding the
predefined workload type and label <code>__UNLABELED__</code> to the security
policy. (This is a double underscore
followed by the string ''<code>UNLABELED</code>'' followed by a double underscore.)
The ezPolicy tool automatically adds this organization-level workload type
to a new workload definition (cf Figure&nbsp;<A HREF="#fig:acmezpolicy">10.2</A>). It can simply be
deleted from the workload definition if no such support is desired. If unlabeled domains
are supported in the policy, then any domain or resource that has no label will implicitly
inherit this label when access control decisions are made. In effect, unlabeled
domains and resources define a new workload type <code>__UNLABELED__</code>, which is
confined from any other labeled workload.

<P>
Please use now the ``New Org'' button to add the organization workload types
``A-Bank'', ``B-Bank'', and ``AutoCorp''.

<P>
You can refine an organization to differentiate between multiple
department workloads by right-clicking the organization and selecting
<code>Add Department</code> (or selecting an organization and pressing
<code>&lt;CRTL&gt;-a</code>). Create department workloads ``SecurityUnderwriting'',
and ``MarketAnalysis'' for the ``A-Bank''. The resulting layout of the
tool should be similar to the left panel shown in
Figure&nbsp;<A HREF="#fig:acmezpolicy">10.2</A>.

<P>

<DIV ALIGN="CENTER"><A NAME="fig:acmezpolicy"></A><A NAME="649"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 10.2:</STRONG>
Final layout including workload definition and Run-time Exclusion rules.</CAPTION>
<TR><TD>
<DIV ALIGN="CENTER"><IMG
 WIDTH="588" HEIGHT="314" ALIGN="BOTTOM" BORDER="0"
 SRC="img5.png"
 ALT="\includegraphics[width=13cm]{figs/acm_ezpolicy_gui.eps}">
</DIV></TD></TR>
</TABLE>
</DIV>

<P>

<H4><A NAME="SECTION03722020000000000000">
10.2.2.0.2 Defining run-time conflicts.</A>
</H4> Workloads that shall be
prohibited from running concurrently on the same hypervisor platform
are grouped into ``Run-time Exclusion rules'' on the right panel of
the window. Cautious users should include the <code>__UNLABELED__</code>
workload type in all run-time exclusion rules because any workload
could run inside unlabeled domains.

<P>
To prevent A-Bank and B-Bank workloads (including their
departmental workloads) from running simultaneously on the same
hypervisor system, select the organization ``A-Bank'' and, while
pressing the <code>&lt;CTRL&gt;</code>-key, select the organization ``B-Bank''.
Being cautious, we also prevent unlabeled workloads from running with
any of those workloads by pressing the <code>&lt;CTRL&gt;</code>-key and selecting
``__UNLABELED__''. Now press the button named ``Create run-time exclusion
rule from selection''. A popup window will ask for the name for this run-time
exclusion rule (enter a name or just hit <code>&lt;ENTER&gt;</code>). A rule will
appear on the right panel. The name is used as reference only and does
not affect access control decisions.

<P>
Please repeat this process to create another run-time exclusion rule
for the department workloads ``A-Bank.SecurityUnderwriting'',
``A-Bank.MarketAnalysis''. Also add the ``__UNLABELED__''
workload type to this conflict set.

<P>
The resulting layout of your window should be similar to
Figure&nbsp;<A HREF="#fig:acmezpolicy">10.2</A>. Save this workload definition by
selecting ``Save Workload Definition as ...'' in the ``File'' menu.
This workload definition can be later refined if required.

<P>

<H4><A NAME="SECTION03722030000000000000">
10.2.2.0.3 Translating the workload definition into an sHype/Xen access
  control policy.</A>
</H4> To translate the workload definition into a access
control policy understood by Xen, please select the ``Save as Xen ACM
Security Policy'' in the ``File'' menu. Enter the following policy
name in the popup window: <code>mytest</code>. If you are running ezPolicy in
Domain-0, the resulting policy file mytest_security-policy.xml will
automatically be placed into the right directory (/etc/xen/acm-security/policies/).
If you run the tool on another system, then you need to copy the
resulting policy file into Domain-0 before continuing.  See
Section&nbsp;<A HREF="#subsection:acmnaming">10.3.1</A> for naming conventions of security
policies.

<P>
<FONT SIZE="-2"><B>Note:</B> The support for <code>__UNLABELED__</code> domains and
resources is meant to help transitioning from an uncontrolled
environment to a workload-protected environment by starting with
unlabeled domains and resources and then step-by-step labeling domains
and resources. Once all workloads are labeled, the <code>__UNLABELED__</code>
type can simply be removed from the Domain-0 label or from the policy
through a policy update. Section&nbsp;<A HREF="#subsection:acmpolicymanagement">10.3.5</A> will
show how unlabeled domains can be disabled by updating the
<code>mytest</code> policy at run-time.
</FONT>

<P>

<H2><A NAME="SECTION03723000000000000000"></A>
<A NAME="subsection:acmexampleinstall"></A>
<BR>
10.2.3 Deploying a WLP Policy
</H2>
To deploy the workload protection policy we created in
Section&nbsp;<A HREF="#subsection:acmexamplecreate">10.2.2</A>, we create a policy
representation (mytest.bin), load it into the Xen
hypervisor, and configure Xen to also load this policy during
reboot.

<P>
The following command translates the source policy representation
into a format that can be loaded into Xen with sHype/ACM support,
activates the policy, and configures this policy for future boot
cycles into the boot sequence. Please refer to the <code>xm</code>
man page for further details:

<P>
<PRE>
  (5) # xm setpolicy ACM mytest
      Successfully set the new policy.
      Supported security subsystems   : ACM
      Policy name           : mytest
      Policy type           : ACM
      Version of XML policy : 1.0
      Policy configuration  : loaded, activated for boot
</PRE>

<P>
Alternatively, if installing the policy fails (e.g., because it cannot
identify the Xen boot entry), you can manually install the policy in 3
steps a-c.

<P>
(<I>Alternatively to 5 - step a</I>) Manually copy the policy binary
file into the boot directory:

<P>
<PRE>
# cp /etc/xen/acm-security/policies/mytest.bin /boot/mytest.bin
</PRE>

<P>
(<I>Alternatively to 5 - step b</I>) Manually add a module line to your
Xen boot entry so that grub loads this policy file during startup:

<P>
<PRE>
title XEN Devel with 2.6.18.8
     kernel /xen.gz
     module /vmlinuz-2.6.18.8-xen root=/dev/sda3 ro console=tty0
     module /initrd-2.6.18.8-xen.img
     module /mytest.bin
</PRE>

<P>
(<I>Alternatively to 5 - step c</I>) Reboot. Xen will choose the
bootstrap label defined in the policy as Domain-0 label during reboot.
After reboot, you can re-label Domain-0 at run-time,
cf Section&nbsp;<A HREF="#subsection:acmlabeldom0">10.2.7</A>.

<P>
Assuming that command (5) succeeded or you followed the alternative
instructions above, you should see the new policy and label appear
when listing domains:

<P>
<PRE>
# xm list --label
Name      ID   Mem VCPUs     State   Time(s) Label
Domain-0   0   941     1     r-----    81.5  ACM:mytest:SystemManagement
</PRE>

<P>
If the security label at the end of the line says ``INACTIVE'' then the
security is not enabled. Verify the previous steps. Note: Domain-0 is
assigned a default label (see <code>bootstrap</code> policy attribute
explained in Section&nbsp;<A HREF="#section:acmpolicy">10.3</A>). All other domains must
be explicitly labeled, which we describe in detail below.

<P>

<H2><A NAME="SECTION03724000000000000000"></A>
<A NAME="subsection:acmexamplelabeldomains"></A>
<BR>
10.2.4 Labeling Unmanaged User Domains
</H2>

<P>
Unmanaged domains are started in Xen by using a configuration
file. Please refer to Section&nbsp;<A HREF="#subsection:acmlabelmanageddomains">10.2.8</A>
if you are using managed domains.

<P>
The following configuration file defines <code>domain1</code>:

<P>
<PRE>
# cat domain1.xm
kernel= "/boot/vmlinuz-2.6.18.8-xen"
memory = 128
name = "domain1"
vif = ['']
dhcp = "dhcp"
disk = ['file:/home/xen/dom_fc5/fedora.fc5.img,sda1,w', \
        'file:/home/xen/dom_fc5/fedora.fc5.swap,sda2,w']
root = "/dev/sda1 ro xencons=tty"
</PRE>

<P>
Every domain must be associated with a security label before it can start
on sHype/Xen. Otherwise, sHype/Xen would not be able to enforce the policy
consistently. Our <code>mytest</code> policy is configured so that Xen
assigns a default label <code>__UNLABELED__</code> to domains and resources that
have no label and supports them in a controlled manner. Since neither the domain,
nor the resources are (yet) labeled, this domain can start under the <code>mytest</code>
policy:

<P>
<PRE>
# xm create domain1.xm
Using config file "./domain1.xm".
Started domain domain1

# xm list --label
Name     ID   Mem VCPUs      State   Time(s) Label
domain1   1   128     1     -b----      0.7  ACM:mytest:__UNLABELED__
Domain-0  0   875     1     r-----     84.6  ACM:mytest:SystemManagement
</PRE>

<P>
Please shutdown domain1 so that we can move it into the protection
domain of workload <code>A-Bank</code>.

<P>
<PRE>
# xm shutdown domain1
(wait some seconds until the domain has shut down)

#xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
Domain-0   0   875     1     r-----     86.4  ACM:mytest:SystemManagement
</PRE>

<P>
We assume that the processing in domain1 contributes to the <code>A-Bank</code> workload.
We explore now how to transition this domain into the ``A-Bank'' workload-protection.
The following command prints all domain labels available in the active policy:

<P>
<PRE>
# xm labels
A-Bank
A-Bank.MarketAnalysis
A-Bank.SecurityUnderwriting
AutoCorp
B-Bank
SystemManagement
__UNLABELED__
</PRE>

<P>
Now label <code>domain1</code> with the A-Bank label and another <code>domain2</code>
with the B-Bank label. Please refer to the xm man page for
further information.

<P>
<PRE>
  (6) # xm addlabel A-Bank dom domain1.xm
      # xm addlabel B-Bank dom domain2.xm
</PRE>

<P>
Let us try to start the domain again:

<P>
<PRE>
# xm create domain1.xm
Using config file "./domain1.xm".
Error: VM's access to block device 'file:/home/xen/dom_fc5/fedora.fc5.img' denied
</PRE>

<P>
This error indicates that <code>domain1</code>, if started, would not be able to
access its image and swap files because they are not labeled.  This
makes sense because to confine workloads, access of domains to
resources must be controlled.  Otherwise, domains that are not allowed
to communicate or run simultaneously could share data through storage
resources.

<P>

<H2><A NAME="SECTION03725000000000000000"></A>
<A NAME="subsection:acmexamplelabelresources"></A>
<BR>
10.2.5 Labeling Resources
</H2>
You can use the <code>xm labels type=res</code> command to list available
resource labels. Let us assign the A-Bank resource label to the
<code>domain1</code> image file representing <code>/dev/sda1</code> and to its swap file:

<P>
<PRE>
  (7) # xm addlabel A-Bank res \
      file:/home/xen/dom_fc5/fedora.fc5.img

      # xm addlabel A-Bank res \
      file:/home/xen/dom_fc5/fedora.fc5.swap
</PRE>

<P>
The following command lists all labeled resources on the system, e.g.,
to lookup or verify the labeling:

<P>
<PRE>
# xm resources
file:/home/xen/dom_fc5/fedora.fc5.swap
      type: ACM
    policy: mytest
     label: A-Bank
file:/home/xen/dom_fc5/fedora.fc5.img
      type: ACM
    policy: mytest
     label: A-Bank
</PRE>

<P>
Starting <code>domain1</code> will now succeed:

<P>
<PRE>
# xm create domain1.xm
Using config file "./domain1.xm".
Started domain domain1

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
domain1    3   128     1     -b----      0.8  ACM:mytest:A-Bank
Domain-0   0   875     1     r-----     90.9  ACM:mytest:SystemManagement
</PRE>

<P>
Currently, if a labeled resource is moved to another location, the
label must first be manually removed, and after the move re-attached
using the xm commands <code>rmlabel</code> and <code>addlabel</code>
respectively.  Please see Section&nbsp;<A HREF="#section:acmlimitations">10.4</A> for
further details.

<P>
<PRE>
  (8) Label the resources of domain2 as B-Bank
      but please do not start this domain yet.
</PRE>

<P>

<H2><A NAME="SECTION03726000000000000000"></A>
<A NAME="subsection:acmexampletest"></A>
<BR>
10.2.6 Testing The Xen Workload Protection
</H2>

<P>
We are about to demonstrate the sHype/Xen workload protection by verifying

<UL>
<LI>that user domains with conflicting workloads cannot run
  simultaneously
</LI>
<LI>that user domains cannot access resources of workloads other than the
	one they are associated with
</LI>
<LI>that user domains cannot exchange network packets if they are not
  associated with the same workload type (not yet supported in Xen)
</LI>
</UL>

<P>

<H4><A NAME="SECTION03726010000000000000">
10.2.6.0.1 Test 1: Run-time exclusion rules.</A>
</H4> We assume that <code>domain1</code>
with the A-Bank label is still running. While <code>domain1</code> is running,
the run-time exclusion set of our policy implies that <code>domain2</code> cannot
start because the label of <code>domain1</code> includes the CHWALL type A-Bank
and the label of <code>domain2</code> includes the CHWALL type B-Bank. The
run-time exclusion rule of our policy enforces that A-Bank and
B-Bank cannot run at the same time on the same hypervisor platform.
Once domain1 is stopped, saved, or migrated to another platform,
<code>domain2</code> can start. Once <code>domain2</code> is started, however,
<code>domain1</code> can no longer start or resume on this system. When creating the
Chinese Wall types for the workload labels, the ezPolicy tool policy
translation component ensures that department workloads inherit all the
organization types (and with it any organization exclusions).

<P>
<PRE>
# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
domain1    3   128     1     -b----      0.8  ACM:mytest:A-Bank
Domain-0   0   875     1     r-----     90.9  ACM:mytest:SystemManagement

# xm create domain2.xm
Using config file "./domain2.xm".
Error: 'Domain in conflict set with running domains'

# xm shutdown domain1
(wait some seconds until domain 1 is shut down)

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
Domain-0   0   873     1     r-----     95.3  ACM:mytest:SystemManagement

# xm create domain2.xm
Using config file "./domain2.xm".
Started domain domain2

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
domain2    5   164     1     -b----      0.3  ACM:mytest:B-Bank
Domain-0   0   839     1     r-----     96.4  ACM:mytest:SystemManagement

# xm create domain1.xm
Using config file "domain1.xm".
Error: 'Domain in conflict with running domains'

# xm shutdown domain2
# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
Domain-0   0   839     1     r-----     97.8  ACM:mytest:SystemManagement
</PRE>

<P>
You can verify that domains with AutoCorp label can run together with
domains labeled A-Bank or B-Bank.

<P>

<H4><A NAME="SECTION03726020000000000000">
10.2.6.0.2 Test2: Resource access.</A>
</H4> In this test, we will re-label the
swap file for <code>domain1</code> with the <code>B-Bank</code> resource label. In a
real environment, the swap file must be sanitized (scrubbed/zeroed) before
it is reassigned to prevent data leaks from the A-Bank to the B-Bank workload
through the swap file.

<P>
We expect that <code>domain1</code> will no longer start because it cannot access
this resource. This test checks the sharing abilities of domains, which are
defined by the Simple Type Enforcement Policy component.

<P>
<PRE>
# xm rmlabel res file:/home/xen/dom_fc5/fedora.fc5.swap

# xm addlabel B-Bank res file:/home/xen/dom_fc5/fedora.fc5.swap

# xm resources
file:/home/xen/dom_fc5/fedora.fc5.swap
      type: ACM
    policy: mytest
     label: B-Bank
file:/home/xen/dom_fc5/fedora.fc5.img
      type: ACM
    policy: mytest
     label: A-Bank

# xm create domain1.xm
Using config file "./domain1.xm".
Error:
VM's access to block device 'file:/home/xen/dom_fc5/fedora.fc5.swap' denied
</PRE>

<P>
The resource authorization checks are performed before the domain is actually started
so that failures during the startup are prevented. A domain is only started if all
the resources specified in its configuration are accessible.

<P>

<H4><A NAME="SECTION03726030000000000000">
10.2.6.0.3 Test 3: Communication.</A>
</H4> In this test we would verify that
two domains with labels A-Bank and B-Bank cannot exchange network packets
by using the 'ping' connectivity test. It is also related to the STE
policy. <B>Note:</B> sHype/Xen does control direct communication between
domains. However, domains associated with different workloads can
currently still communicate through the Domain-0 virtual network. We
are working on the sHype/ACM controls for local and remote network
traffic through Domain-0. Please monitor the xen-devel mailing list
for updated information.

<P>

<H2><A NAME="SECTION03727000000000000000"></A>
<A NAME="subsection:acmlabeldom0"></A>
<BR>
10.2.7 Labeling Domain-0 -or- Restricting System Authorization
</H2>
The major use case for explicitly labeling or relabeling Domain-0 is to restrict
or extend which workload types can run on a virtualized Xen system. This enables
flexible partitioning of the physical infrastructure as well as the workloads
running on it in a multi-platform environment.

<P>
In case no Domain-0 label is explicitly stated, we automatically assigned Domain-0
the <code>SystemManagement</code> label, which includes all STE (workload) types that
are known to the policy. In effect, the Domain-0 label authorizes the Xen system
to run only those workload types, whose STE types are included in the Domain-0
label. Hence, choosing the <code>SystemManagement</code> label for Domain-0 permits any
labeled domain to run. Resetting the label for Domain-0 at boot or run-time to
a label with a subset of the known STE workload types restricts which user domains
can run on this system. If Domain-0 is relabeled at run-time, then the new label
must at least include all STE types of those domains that are currently running.
The operation fails otherwise. This requirement ensures that the system remains
in a valid security configuration after re-labelling.

<P>
Restricting the Domain-0 authorization through the label creates a flexible
policy-driven way to strongly partition the physical infrastructure and the
workloads running on it. This partitioning will be automatically enforced during
migration, start, or resume of domains and simplifies the security management
considerably. Strongly competing workloads can be forced to run on separate physical
infrastructure and become less depend on the domain isolation capabilities
of the hypervisor.

<P>
First, we relabel the swap image back to A-Bank and then start up domain1:
<PRE>
# xm rmlabel res file:/home/xen/dom_fc5/fedora.fc5.swap

# xm addlabel A-Bank res file:/home/xen/dom_fc5/fedora.fc5.swap

# xm create domain1.xm
Using config file "./domain1.xm".
Started domain domain1

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
domain1    7   128     1     -b----      0.7  ACM:mytest:A-Bank
Domain-0   0   839     1     r-----    103.1  ACM:mytest:SystemManagement
</PRE>

<P>
The following command will restrict the Xen system to only run STE types
included in the A-Bank label.

<P>
<PRE>
# xm addlabel A-Bank mgt Domain-0
Successfully set the label of domain 'Domain-0' to 'A-Bank'.

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
Domain-0   0   839     1     r-----    103.7  ACM:mytest:A-Bank
domain1    7   128     1     -b----      0.7  ACM:mytest:A-Bank
</PRE>

<P>
In our example policy in Figure&nbsp;<A HREF="#fig:acmxmlfileb">10.4</A>, this means that
only <code>A-Bank</code> domains and workloads (types) can run after the
successful completion of this command because the <code>A-Bank</code> label
includes only a single STE type, namely <code>A-Bank</code>. This command
fails if any running domain has an STE type in its label that is not
included in the A-Bank label.

<P>
If we now label a domain3 with AutoCorp, it cannot start because Domain-0 is
no longer authorized to run the workload type <code>AutoCorp</code>.
<PRE>
# xm addlabel AutoCorp dom domain3.xm
  (remember to label its resources, too)

# xm create domain3.xm
Using config file "./domain3.xm".
Error: VM is not authorized to run.

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
Domain-0   0   839     1     r-----    104.7  ACM:mytest:A-Bank
domain1    7   128     1     -b----      0.7  ACM:mytest:A-Bank
</PRE>

<P>
At this point, unlabeled domains cannot start either. Let domain4.xm
describe an unlabeled domain, then trying to start domain4
will fail:
<PRE>
# xm getlabel dom domain4.xm
Error: 'Domain not labeled'

# xm create domain4.xm
Using config file "./domain4.xm".
Error: VM is not authorized to run.
</PRE>

<P>
Relabeling Domain-0 with the SystemManagement label will enable domain3 to start.
<PRE>
# xm addlabel SystemManagement mgt Domain-0
Successfully set the label of domain 'Domain-0' to 'SystemManagement'.

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
domain1    7   128     1     -b----      0.8  ACM:mytest:A-Bank
Domain-0   0   839     1     r-----    106.6  ACM:mytest:SystemManagement

# xm create domain3.xm
Using config file "./domain3.xm".
Started domain domain3

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
domain1    7   128     1     -b----      0.8 ACM:mytest:A-Bank
domain3    8   164     1     -b----      0.3 ACM:mytest:AutoCorp
Domain-0   0   711     1     r-----    107.6 ACM:mytest:SystemManagement
</PRE>

<P>

<H2><A NAME="SECTION03728000000000000000"></A>
<A NAME="subsection:acmlabelmanageddomains"></A>
<BR>
10.2.8 Labeling Managed User Domains
</H2>

<P>
Xend has been extended with functionality to manage domains along with their
configuration information. Such domains are configured and started via Xen-API
calls. Since managed domains do not have an associated xm configuration file,
the existing <code>addlabel</code> command, which adds the security label into a
domain's configuration file, will not work for such managed domains.

<P>
Therefore, we have extended the <code>xm addlabel</code> and <code>xm rmlabel</code>
subcommands to enable adding security labels to and removing security
labels from managed domain configurations. The following example shows how
the <code>A-Bank</code> label can be assigned to the xend-managed
domain configuration of <code>domain1</code>. Removing labels from managed user
domain configurations works similarly.

<P>
Below, we show a dormant configuration of the managed domain1
with ID <code>"-1"</code> and state <code>"-----"</code> before labeling:
<PRE>
# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
domain1   -1   128     1     ------      0.0 ACM:mytest:__UNLABELED__
Domain-0   0   711     1     r-----    128.4 ACM:mytest:SystemManagement
</PRE>

<P>
Now we label the managed domain:
<PRE>
# xm addlabel A-Bank mgt domain1
Successfully set the label of the dormant domain 'domain1' to 'A-Bank'.
</PRE>

<P>
After labeling, you can see that the security label is part of the
domain configuration:
<PRE>
# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
domain1   -1   128     1     ------      0.0  ACM:mytest:A-Bank
Domain-0   0   711     1     r-----    129.7  ACM:mytest:SystemManagement
</PRE>

<P>
This command extension does not support relabeling of individual running user domains
for several reasons. For one, because of the difficulty to revoke resources
in cases where a running domain's new label does not permit access to resources
that were accessible under the old label. Another reason is that changing the
label of a single domain of a workload is rarely a good choice and will affect
the workload isolation properties of the overall workload.

<P>
However, the name and contents of the label associated with running domains can
be indirectly changed through a global policy change, which will update the whole
workload consistently (domains and resources), cf.
Section&nbsp;<A HREF="#subsection:acmpolicymanagement">10.3.5</A>.

<P>

<H1><A NAME="SECTION03730000000000000000"></A>
<A NAME="section:acmpolicy"></A>
<BR>
10.3 Xen Access Control Policy
</H1>

<P>
This section describes the sHype/Xen access control policy in detail.
It gives enough information to enable the reader to write custom
access control policies and to use the available Xen policy tools. The
policy language is expressive enough to specify most symmetric access
relationships between domains and resources efficiently.

<P>
The Xen access control policy consists of two policy components.  The
first component, called Simple Type Enforcement (STE) policy, controls
the sharing between running domains, i.e., communication or access to
shared resources. The second component, called Chinese Wall (CHWALL)
policy, controls which domains can run simultaneously on the same
virtualized platform. The CHWALL and STE policy components complement
each other. The XML policy file includes all information
needed by Xen to enforce those policies.

<P>
Figures&nbsp;<A HREF="#fig:acmxmlfilea">10.3</A> and <A HREF="#fig:acmxmlfileb">10.4</A> show the fully
functional but very simple example Xen security policy that is created
by ezPolicy as shown in Figure&nbsp;<A HREF="#fig:acmezpolicy">10.2</A>. The policy can
distinguish the 6 workload types shown in lines 11-17 in
Fig.&nbsp;<A HREF="#fig:acmxmlfilea">10.3</A>. The whole XML Security Policy consists of
four parts:

<OL>
<LI>Policy header including the policy name
</LI>
<LI>Simple Type Enforcement block
</LI>
<LI>Chinese Wall Policy block
</LI>
<LI>Label definition block
</LI>
</OL>

<P>

<DIV ALIGN="CENTER"><A NAME="fig:acmxmlfilea"></A><A NAME="789"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 10.3:</STRONG>
Example XML security policy file - Part I: Types and Rules Definition.</CAPTION>
<TR><TD><IMG
 WIDTH="456" HEIGHT="629" BORDER="0"
 SRC="img6.png"
 ALT="\begin{figure}\begin{scriptsize}
\begin{verbatim}01 &lt;?xml version=''1.0'' ?&gt;
0...
...41 &lt;/ConflictSets&gt;
42 &lt;/ChineseWall&gt;\end{verbatim}
\end{scriptsize}
\end{figure}"></TD></TR>
</TABLE>
</DIV>

<P>

<H2><A NAME="SECTION03731000000000000000"></A>
<A NAME="subsection:acmnaming"></A>
<BR>
10.3.1 Policy Header and Policy Name
</H2>
Lines 1-2 (cf Figure&nbsp;<A HREF="#fig:acmxmlfilea">10.3</A>) include the usual XML
header. The security policy definition starts in Line 3 and refers to
the policy schema. The XML-Schema definition for the Xen policy can be
found in the file
<I>/etc/xen/acm-security/policies/security-policy.xsd</I>. Examples
for security policies can be found in the example subdirectory. The
acm-security directory is only installed if ACM security is configured
during installation (cf Section&nbsp;<A HREF="#subsection:acmexampleconfigure">10.2.1</A>).

<P>
The <code>Policy Header</code> spans lines 4-8. It includes a date field and
defines the policy name <code>mytest</code> as well
as the version of the XML. It can also include optional fields that are
not shown and are for future use (see schema definition).

<P>
The policy name serves two purposes: First, it provides a unique name
for the security policy. This name is also exported by the Xen
hypervisor to the Xen management tools in order to ensure that both
the Xen hypervisor and Domain-0 enforce the same policy.
We plan to extend the policy name with a
digital fingerprint of the policy contents to better protect this
correlation.  Second, it implicitly points the xm tools to the
location where the XML policy file is stored on the Xen system.
Replacing the colons in the policy name by slashes yields the local
path to the policy file starting from the global policy directory
<code>/etc/xen/acm-security/policies</code>. The last part of the policy
name is the prefix for the XML policy file name, completed by
<code>-security_policy.xml</code>. Our example policy with the name
<code>mytest</code> can be found in the XML policy file named
<code>mytest-security_policy.xml</code> that is stored under the global
policy directory. Another, preinstalled example policy named
<code>example.test</code> can be found in the <code>test-security_policy.xml</code>
under <code>/etc/xen/acm-security/policies/example</code>.

<P>

<H2><A NAME="SECTION03732000000000000000">
10.3.2 Simple Type Enforcement Policy Component</A>
</H2>

<P>
The Simple Type Enforcement (STE) policy controls which domains can
communicate or share resources. This way, Xen can enforce confinement
of workload types by confining the domains running those workload
types and their resources. The mandatory access control framework
enforces its policy when
domains access intended communication or cooperation means (shared
memory, events, shared resources such as block devices). It builds on
top of the core hypervisor isolation, which restricts the ways of
inter-communication to those intended means.  STE does not protect or
intend to protect from covert channels in the hypervisor or hardware;
this is an orthogonal problem that can be mitigated by using the
Run-time Exclusion rules described above or by fixing the problem leading
to those covert channels in the core hypervisor or hardware platform.

<P>
Xen controls sharing between domains on the resource and domain level
because this is the abstraction the hypervisor and its management
understand naturally. While this is coarse-grained, it is also very
reliable and robust and it requires minimal changes to implement
mandatory access controls in the hypervisor. It enables platform- and
operating system-independent policies as part of a layered security
approach.

<P>
Lines 11-17 (cf Figure&nbsp;<A HREF="#fig:acmxmlfilea">10.3</A>) define the Simple Type
Enforcement policy component.  Essentially, they define the workload
type names <code>SystemManagement</code>, <code>A-Bank</code>,
<code>AutoCorp</code> etc. that are available in the STE policy component. The
policy rules are implicit: Xen permits two domains to communicate with
each other if and only if their security labels have at least one STE type in
common.  Similarly, Xen permits a user domain to access a
resource if and only if the labels of the domain and the resource
have at least one STE workload type in common.

<P>

<H2><A NAME="SECTION03733000000000000000">
10.3.3 Chinese Wall Policy Component</A>
</H2>

<P>
The Chinese Wall security policy interpretation of sHype enables users
to prevent certain workloads from running simultaneously on the same
hypervisor platform.  Run-time Exclusion rules (RER), also called
Conflict Sets or Anti-Collocation rules, define a set of workload types
that are not permitted to run simultaneously on the same virtualized
platform. Of all the workloads specified in a Run-time
Exclusion rule, at most one type can run on the same hypervisor
platform at a time.  Run-time Exclusion Rules implement a less
rigorous variant of the original Chinese Wall security component. They
do not implement the *-property of the policy, which would require to
restrict also types that are not part of an exclusion rule once they
are running together with a type in an exclusion rule
(http://www.gammassl.co.uk/topics/chinesewall.html provides more information
on the original Chinese Wall policy).

<P>
Xen considers the <code>ChineseWallTypes</code> part of the label for the
enforcement of the Run-time Exclusion rules.  It is illegal to define
labels including conflicting Chinese Wall types.

<P>
Lines 20-41 (cf Figure&nbsp;<A HREF="#fig:acmxmlfilea">10.3</A>) define the Chinese Wall
policy component. Lines 22-28 define the known Chinese Wall types,
which coincide here with the STE types defined above. This usually
holds if the criteria for sharing among domains and sharing of the
hardware platform are the same. Lines 30-41 define one Run-time
Exclusion rules, the first of which is depicted below:

<P>
<PRE>
31  &lt;Conflict name="RER"&gt;
32    &lt;Type&gt;A-Bank&lt;/Type&gt;
33    &lt;Type&gt;B-Bank&lt;/Type&gt;
34    &lt;Type&gt;__UNLABELED__&lt;/Type&gt;
35  &lt;/Conflict&gt;
</PRE>

<P>
Based on this rule, Xen enforces that only one of the types
<code>A-Bank</code>, <code>B-Bank</code>, or <code>__UNLABELED__</code> will run
on a single hypervisor platform at a time. For example, once a domain assigned a
<code>A-Bank</code> workload type is started, domains with the
<code>B-Bank</code> type or unlabeled domains will be denied to start.
When the former domain stops and no other domains with the <code>A-Bank</code>
type are running, then domains with the <code>B-Bank</code> type or unlabeled domains
can start.

<P>
Xen maintains reference counts on each running workload type to keep
track of which workload types are running. Every time a domain starts
or resumes, the reference count on those Chinese Wall types that are
referenced in the domain's label are incremented. Every time a domain
is destroyed or saved, the reference counts of its Chinese Wall types
are decremented. sHype in Xen fully supports migration and live-migration,
which is subject to access control the same way as saving a domain on
the source platform and resuming it on the destination platform.

<P>
Here are some reasons why users might want to restrict workloads or domains
from sharing the system hardware simultaneously:

<P>

<UL>
<LI>Imperfect resource management or control might enable a compromised
  user domain to starve other domains and the workload running in them.
</LI>
<LI>Redundant user domains might run the same workload to increase
  availability; such domains should not run on the same hardware to
  avoid single points of failure.
</LI>
<LI>Imperfect Xen core domain isolation might enable two rogue
  domains running different workload types to use unintended and
  unknown ways (covert channels) to exchange some bits of information.
  This way, they bypass the policed Xen access control mechanisms.  Such
  imperfections cannot be completely eliminated and are a result of
  trade-offs between security and other design requirements. For a
  simple example of a covert channel see
  http://www.multicians.org/timing-chn.html. Such covert channels
  exist also between workloads running on different platforms if they
  are connected through networks. The Xen Chinese Wall policy provides
  an approximated ``air-gap'' between selected workload types.
</LI>
</UL>

<P>

<H2><A NAME="SECTION03734000000000000000">
10.3.4 Security Labels</A>
</H2>

<P>
To enable Xen to associate domains with workload types running in
them, each domain is assigned a security label that includes the
workload types of the domain.

<P>

<DIV ALIGN="CENTER"><A NAME="fig:acmxmlfileb"></A><A NAME="827"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 10.4:</STRONG>
Example XML security policy file - Part II: Label Definition.</CAPTION>
<TR><TD><TABLE CELLPADDING=3 BORDER="1" ALIGN="CENTER" WIDTH="100%">
<TR><TD ALIGN="LEFT">&nbsp;</TD><TD ALIGN="LEFT"><TABLE  WIDTH="48%">
<TR><TD>
		<PRE>
&lt;SecurityLabelTemplate&gt;
  &lt;SubjectLabels bootstrap="SystemManagement"&gt;
  &lt;VirtualMachineLabel&gt;
    &lt;Name&gt;SystemManagement&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;SystemManagement&lt;/Type&gt;
      &lt;Type&gt;__UNLABELED__&lt;/Type&gt;
      &lt;Type&gt;A-Bank&lt;/Type&gt;
      &lt;Type&gt;A-Bank.SecurityUnderwriting&lt;/Type&gt;
      &lt;Type&gt;A-Bank.MarketAnalysis&lt;/Type&gt;
      &lt;Type&gt;B-Bank&lt;/Type&gt;
      &lt;Type&gt;AutoCorp&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
    &lt;ChineseWallTypes&gt;
      &lt;Type&gt;SystemManagement&lt;/Type&gt;
    &lt;/ChineseWallTypes&gt;
  &lt;/VirtualMachineLabel&gt;
  &lt;VirtualMachineLabel&gt;
    &lt;Name&gt;__UNLABELED__&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;__UNLABELED__&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
    &lt;ChineseWallTypes&gt;
      &lt;Type&gt;__UNLABELED__&lt;/Type&gt;
    &lt;/ChineseWallTypes&gt;
  &lt;/VirtualMachineLabel&gt;
  &lt;VirtualMachineLabel&gt;
    &lt;Name&gt;A-Bank&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;A-Bank&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
    &lt;ChineseWallTypes&gt;
      &lt;Type&gt;A-Bank&lt;/Type&gt;
    &lt;/ChineseWallTypes&gt;
  &lt;/VirtualMachineLabel&gt;
  &lt;VirtualMachineLabel&gt;
    &lt;Name&gt;A-Bank.SecurityUnderwriting&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;A-Bank.SecurityUnderwriting&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
    &lt;ChineseWallTypes&gt;
      &lt;Type&gt;A-Bank&lt;/Type&gt;
      &lt;Type&gt;A-Bank.SecurityUnderwriting&lt;/Type&gt;
    &lt;/ChineseWallTypes&gt;
  &lt;/VirtualMachineLabel&gt;
  &lt;VirtualMachineLabel&gt;
    &lt;Name&gt;A-Bank.MarketAnalysis&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;A-Bank.MarketAnalysis&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
    &lt;ChineseWallTypes&gt;
      &lt;Type&gt;A-Bank&lt;/Type&gt;
      &lt;Type&gt;A-Bank.MarketAnalysis&lt;/Type&gt;
    &lt;/ChineseWallTypes&gt;
  &lt;/VirtualMachineLabel&gt;
  &lt;VirtualMachineLabel&gt;
    &lt;Name&gt;B-Bank&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;B-Bank&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
    &lt;ChineseWallTypes&gt;
      &lt;Type&gt;B-Bank&lt;/Type&gt;
    &lt;/ChineseWallTypes&gt;
  &lt;/VirtualMachineLabel&gt;
</PRE></TD></TR>
</TABLE></TD>
<TD ALIGN="LEFT"><TABLE  WIDTH="48%">
<TR><TD>
<PRE>
  &lt;VirtualMachineLabel&gt;
    &lt;Name&gt;AutoCorp&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;AutoCorp&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
    &lt;ChineseWallTypes&gt;
      &lt;Type&gt;AutoCorp&lt;/Type&gt;
    &lt;/ChineseWallTypes&gt;
  &lt;/VirtualMachineLabel&gt;
  &lt;/SubjectLabels&gt;
  &lt;ObjectLabels&gt;
  &lt;ResourceLabel&gt;
    &lt;Name&gt;SystemManagement&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;SystemManagement&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
  &lt;/ResourceLabel&gt;
  &lt;ResourceLabel&gt;
    &lt;Name&gt;__UNLABELED__&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;__UNLABELED__&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
  &lt;/ResourceLabel&gt;
  &lt;ResourceLabel&gt;
    &lt;Name&gt;A-Bank&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;A-Bank&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
  &lt;/ResourceLabel&gt;
  &lt;ResourceLabel&gt;
    &lt;Name&gt;A-Bank.SecurityUnderwriting&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;A-Bank.SecurityUnderwriting&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
  &lt;/ResourceLabel&gt;
  &lt;ResourceLabel&gt;
    &lt;Name&gt;A-Bank.MarketAnalysis&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;A-Bank.MarketAnalysis&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
  &lt;/ResourceLabel&gt;
  &lt;ResourceLabel&gt;
    &lt;Name&gt;B-Bank&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;B-Bank&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
  &lt;/ResourceLabel&gt;
  &lt;ResourceLabel&gt;
    &lt;Name&gt;AutoCorp&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;AutoCorp&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
  &lt;/ResourceLabel&gt;
  &lt;/ObjectLabels&gt;
&lt;/SecurityLabelTemplate&gt;
&lt;/SecurityPolicyDefinition&gt;
</PRE></TD></TR>
</TABLE></TD>
</TR>
</TABLE></TD></TR>
</TABLE>
</DIV>
The <code>SecurityLabelTemplate</code> (cf Figure&nbsp;<A HREF="#fig:acmxmlfileb">10.4</A>) defines
the security labels that can be associated with domains and resources when
this policy is active (use the <code>xm labels type=any</code> command described in
Section&nbsp;<A HREF="#subsection:acmexamplelabeldomains">10.2.4</A> to list all available labels).

<P>
The domain labels include
Chinese Wall types while resource labels do not include Chinese Wall types.
The <code>SubjectLabels</code> policy section defines the labels that can be
assigned to domains. The VM label
<code>A-Bank.SecurityUnderwriting</code> in Figure&nbsp;<A HREF="#fig:acmxmlfileb">10.4</A>)
associates the domain that carries it with the workload STE type
<code>A-Bank.SecurityUnderwriting</code> and with the CHWALL types <code>A-Bank</code>
and <code>A-Bank.SecurityUnderwriting</code>. The ezPolicy tool
assumes that any department workload will inherit any conflict set that
is specified for its organization, i.e., if <code>B-Bank</code> is running, not
only <code>A-Bank</code> but also all its departmental workloads are prevented
from running by this first run-time exclusion set. The separation of STE
and CHWALL types in the label definition ensures that
all departmental workloads are isolated from each other and from their generic
organization workloads, while they are sharing CHWALL types to
simplify the formulation of run-time exclusion sets.

<P>
The <code>bootstrap</code> attribute of the <code>&lt;SubjectLabels&gt;</code> XML node
in our example policy shown in Figure&nbsp;<A HREF="#fig:acmxmlfileb">10.4</A> names
the label <code>SystemManagement</code> as the label that Xen will assign
to Domain-0 at boot time (if this policy is installed as boot policy). The
label of Domain-0 can be persistently changed at run-time with the
<code>addlabel</code> command, which adds an overriding option to the grub.conf
boot entry (cf Section&nbsp;<A HREF="#subsection:acmlabeldom0">10.2.7</A>).
All user domains are assigned labels according to their domain configuration
(see Section&nbsp;<A HREF="#subsection:acmexamplelabeldomains">10.2.4</A> for examples of
how to label domains).

<P>
The <code>ObjectLabels</code> depicted in Figure&nbsp;<A HREF="#fig:acmxmlfileb">10.4</A> can be
assigned to resources when this policy is active.

<P>
In general, user domains should be assigned labels that have only a
single SimpleTypeEnforcement workload type. This way, workloads remain
confined even if user domains become rogue. Any domain that is
assigned a label with multiple STE types must be trusted to keep
information belonging to the different STE types separate (confined).
For example, Domain-0 is assigned the bootstrap label
<code>SystemManagement</code>, which includes all existing STE types.
Therefore, Domain-0 must take care not to enable unauthorized
information flow (eg. through block devices or virtual networking)
between domains or resources that are assigned different STE types.

<P>
Security administrators simply use the name of a label (specified in
the <code>&lt;Name&gt;</code> field) to associate a label with a domain (cf.
Section&nbsp;<A HREF="#subsection:acmexamplelabeldomains">10.2.4</A>). The types inside the
label are used by the Xen access control enforcement.  While the name
can be arbitrarily chosen (as long as it is unique), it is advisable
to choose the label name in accordance to the security types included.
Similarly, the STE and CHWALL types should be named according to the
workloads they represent. While the XML representation of the label
in the above example seems unnecessary flexible, labels in general
must be able to include multiple types.

<P>
We assume in the following example, that <code>A-Bank.SecurityUnderwriting</code> and
<code>A-Bank.MarketAnalysis</code> workloads use virtual disks that are provided
by a virtual I/O domain hosting a physical storage device and carrying
the following label:

<P>
<PRE>
        &lt;VirtualMachineLabel&gt;
          &lt;Name&gt;VIOServer&lt;/Name&gt;
          &lt;SimpleTypeEnforcementTypes&gt;
              &lt;Type&gt;A-Bank&lt;/Type&gt;
              &lt;Type&gt;A-Bank.SecurityUnderwriting&lt;/Type&gt;
              &lt;Type&gt;A-Bank.MarketAnalysis&lt;/Type&gt;
              &lt;Type&gt;VIOServer&lt;/Type&gt;
          &lt;/SimpleTypeEnforcementTypes&gt;
          &lt;ChineseWallTypes&gt;
              &lt;Type&gt;VIOServer&lt;/Type&gt;
          &lt;/ChineseWallTypes&gt;
        &lt;/VirtualMachineLabel&gt;
</PRE>

<P>
This Virtual I/O domain (VIO) exports its virtualized disks by
communicating to all domains labeled with the
<code>A-Bank.SecurityUnderwriting</code>, the <code>A-Bank</code>, or the
<code>A-Bank.MarketAnalysis</code> label. This requires the
VIO domain to carry those STE types. In addition, this label includes a
new <code>VIOServer</code> type that can be used to restrict direct access to the
physical storage resource to the VIODomain.

<P>
In this example, the confinement of  these A-Bank workloads depends on the
VIO domain that must keep the data of those different workloads separate.
The virtual disks are labeled as well to keep track of their assignments
to workload types (see Section&nbsp;<A HREF="#subsection:acmexamplelabelresources">10.2.5</A>
for labeling resources) and enforcement functions inside the VIO
domain must ensure that the labels of the domain mounting a virtual
disk and the virtual disk label share a common STE type. The VIO label
carrying its own VIOServer CHWALL type introduces the flexibility to
permit the trusted VIO server to run together with <code>A-Bank.SecurityUnderwriting</code>
or <code>A-Bank.MarketAnalysis</code> workloads.

<P>
Alternatively, a system that has two hard-drives does not need a VIO
domain but can directly assign one hardware storage device to each of
the workloads if the platform offers an IO-MMU, cf
Section&nbsp;<A HREF="#s:ddsecurity">9.2</A>.  Sharing hardware through virtualized devices
is a trade-off between the amount of trusted code (size of the trusted
computing base) and the amount of acceptable over-provisioning. This
holds both for peripherals and for system platforms.

<P>

<H2><A NAME="SECTION03735000000000000000"></A>
<A NAME="subsection:acmpolicymanagement"></A>
<BR>
10.3.5 Managing sHype/Xen Security Policies at Run-time
</H2>

<P>

<H3><A NAME="SECTION03735100000000000000">
10.3.5.1 Removing the sHype/Xen Security Policy</A>
</H3>
When resetting the policy, no labeled domains can be running.
Please stop or shutdown all running labeled domains. Then you can reset
the policy to the default policy using the <code>resetpolicy</code> command:

<P>
<PRE>
# xm getpolicy
Supported security subsystems   : ACM
Policy name           : mytest
Policy type           : ACM
Version of XML policy : 1.0
Policy configuration  : loaded, activated for boot

# xm resetpolicy
Successfully reset the system's policy.

# xm getpolicy
Supported security subsystems   : ACM
Policy name           : DEFAULT
Policy type           : ACM
Version of XML policy : 1.0
Policy configuration  : loaded

# xm resources
file:/home/xen/dom_fc5/fedora.fc5.swap
      type: INV_ACM
    policy: mytest
     label: A-Bank
file:/home/xen/dom_fc5/fedora.fc5.img
      type: INV_ACM
    policy: mytest
     label: A-Bank
</PRE>

<P>
As the <code>xm resources</code> output shows, all resource labels have
invalidated type information but their semantics remain associated
with the resources so that they can later on either be relabeled
with semantically equivalent labels or sanitized and reused
(storage resources).

<P>
At this point, the system is in the same initial state as after
configuring XSM and sHype/ACM and rebooting the system without
a specific policy. No user domains can run.

<P>

<H3><A NAME="SECTION03735200000000000000">
10.3.5.2 Changing to a Different sHype/Xen Security Policy</A>
</H3>
The easiest way to change to a different, unrelated policy is to reset the system
policy and then set the new policy. Please consider that the existing
domain and resource labels become invalid at this point. Please refer
to the next section for an example of how to seamlessly update an
active policy at run-time without invalidating labels.

<P>
<PRE>
# xm resetpolicy
Successfully reset the system's policy.

# xm setpolicy ACM example.test
Successfully set the new policy.
Supported security subsystems   : ACM
Policy name           : example.test
Policy type           : ACM
Version of XML policy : 1.0
Policy configuration  : loaded, activated for boot

# xm labels
CocaCola
PepsiCo
SystemManagement
VIO
# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
Domain-0   0   873     1     r-----     56.3  ACM:example.test:SystemManagement

# xm resetpolicy
Successfully reset the system's policy.

# xm getpolicy
Supported security subsystems   : ACM
Policy name           : DEFAULT
Policy type           : ACM
Version of XML policy : 1.0
Policy configuration  : loaded

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
Domain-0   0   873     1     r-----     57.2  ACM:DEFAULT:SystemManagement

# xm setpolicy ACM mytest
Successfully set the new policy.
Supported security subsystems   : ACM
Policy name           : mytest
Policy type           : ACM
Version of XML policy : 1.0
Policy configuration  : loaded, activated for boot

# xm labels
A-Bank
A-Bank.MarketAnalysis
A-Bank.SecurityUnderwriting
AutoCorp
B-Bank
SystemManagement
__UNLABELED__

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
Domain-0   0   873     1     r-----     58.0  ACM:mytest:SystemManagement
</PRE>

<P>
The described way of changing policies by resetting the existing
policy is useful for testing different policies. For real deployment
environments, a policy update as described in the following section
is more appropriate and can be applied seamlessly at run-time while
user domains are running.

<P>

<H3><A NAME="SECTION03735300000000000000">
10.3.5.3 Update an sHype/Xen Security Policy at Run-time</A>
</H3>

<P>
Once an ACM security policy is activated (loaded into the Xen
hypervisor), the policy may be updated at run-time without the
need to re-boot the system. The XML update-policy contains several
additional information fields that are required to safely link the
new policy contents to the old policy and ensure a consistent
transformation of the system security state from the old to the
new policy. Those additional fields are required for policies that
are updating an existing policy at run-time.

<P>
The major benefit of policy updates is the ability to add, delete,
or rename workload types, labels, and conflict sets (run-time
exclusion rules) to accommodate changes in the managed virtual
environment without the need to reboot the Xen system. When a
new policy renames labels of the current policy, the labels
attached to resources and domains are automatically updated
during a successful policy update.

<P>
We have manually crafted an update policy for the <code>mytest</code>
security policy and stored it in the file mytest_update-security_policy.xml
in the policies directory. We will discuss this policy in detail before
using it to update a running sHype/Xen system. The following figures contain
the whole contents of the update policy file.

<P>
Figure&nbsp;<A HREF="#fig:acmupdateheader">10.5</A> shows the policy
header of an update-policy and the new <code>FromPolicy</code> XML
node. For the policy update to succeed, the policy name and the
policy version fields of the <code>FromPolicy</code> XML node must
exactly match those of the currently enforced policy. This
ensures a controlled update path of the policy.

<P>

<DIV ALIGN="CENTER"><A NAME="fig:acmupdateheader"></A><A NAME="863"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 10.5:</STRONG>
XML security policy update - Part I: Updated Policy Header.</CAPTION>
<TR><TD><IMG
 WIDTH="511" HEIGHT="208" BORDER="0"
 SRC="img7.png"
 ALT="\begin{figure}\begin{scriptsize}
\begin{verbatim}&lt;?xml version=''1.0'' encodin...
...ion&gt;
&lt;/FromPolicy&gt;
&lt;/PolicyHeader&gt;\end{verbatim}
\end{scriptsize}
\end{figure}"></TD></TR>
</TABLE>
</DIV>

<P>
The version number of the new policy, which is shown in the
node following the <code>Date</code> node, must be a logical increment
to the current policy's version. Therefore at least the minor
number of the policy version must be incremented. This ensures
that a policy update is applied only to exactly the policy for
which this update was created and minimizes unforseen side-effects
 of policy updates.

<P>

<H4><A NAME="SECTION03735310000000000000">
10.3.5.3.1 Types and Conflic Sets</A>
</H4>
The type names and the assignment of types to labels or conflict
sets (run-time exclusion rules) can
simply be changed consistently throughout the policy. Types,
as opposed to labels, are not directly associated or referenced
outside the policy so they do not need to carry their history
in a ``From'' field. The figure below shows the update for the
types and conflict sets. The <code>__UNLABELED__</code> type is removed
to disable support for running unlabeled domains. Additionally,
we have renamed the two <code>A-Bank</code> department types with
abbreviated names <code>A-Bank.SU</code> and <code>A-Bank.MA</code>. You
can also see how those type names are
consistently changed within the conflict set definition.

<P>

<DIV ALIGN="CENTER"><A NAME="fig:acmupdatetypesnrules"></A><A NAME="872"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 10.6:</STRONG>
XML security policy update - Part II: Updated Types and Conflict Sets.</CAPTION>
<TR><TD><IMG
 WIDTH="358" HEIGHT="478" BORDER="0"
 SRC="img8.png"
 ALT="\begin{figure}\begin{scriptsize}
\begin{verbatim}&lt;SimpleTypeEnforcement&gt;
&lt;Si...
...ct&gt;
&lt;/ConflictSets&gt;
&lt;/ChineseWall&gt;\end{verbatim}
\end{scriptsize}
\end{figure}"></TD></TR>
</TABLE>
</DIV>

<P>
In the same way, new types can be introduced and new conflict sets
can be defined by simply adding the types or conflict sets to the
update policy.

<P>

<H4><A NAME="SECTION03735320000000000000">
10.3.5.3.2 Labels</A>
</H4> Virtual machine and resource labels of an existing policy can be
deleted through a policy update simply by omitting them in the
update-policy. However, if a currently running virtual machine
or a currently used resource is labeled with a label not stated
in the update-policy, then the policy update is rejected. This
ensures that a policy update leaves the system in a consistent
security state.

<P>
A policy update also enables the renaming of virtual machine and
resource labels. Linking the old label name with the new label
name is achieved through the <code>from</code> attribute in the
<code>VirtualMachineLabel</code> or <code>ResourceLabel</code> nodes in the
update-policy. Figure&nbsp;<A HREF="#fig:acmupdatelabels">10.7</A> shown how subject
and resource labels
are updated from their old name <code>A-Bank.SecurityUnterwriting</code>
to their new name <code>A-Bank.SU</code> using the <code>from</code> attribute.

<P>

<DIV ALIGN="CENTER"><A NAME="fig:acmupdatelabels"></A><A NAME="896"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 10.7:</STRONG>
XML security policy update - Part III: Updated Label Definition.</CAPTION>
<TR><TD><TABLE CELLPADDING=3 BORDER="1" ALIGN="CENTER" WIDTH="100%">
<TR><TD ALIGN="LEFT">&nbsp;</TD><TD ALIGN="LEFT"><TABLE  WIDTH="48%">
<TR><TD>
<PRE>
&lt;SecurityLabelTemplate&gt;
  &lt;SubjectLabels bootstrap="SystemManagement"&gt;
  &lt;VirtualMachineLabel&gt;
    &lt;Name&gt;SystemManagement&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;SystemManagement&lt;/Type&gt;
      &lt;Type&gt;A-Bank&lt;/Type&gt;
      &lt;Type&gt;A-Bank.SU&lt;/Type&gt;
      &lt;Type&gt;A-Bank.MA&lt;/Type&gt;
      &lt;Type&gt;B-Bank&lt;/Type&gt;
      &lt;Type&gt;AutoCorp&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
    &lt;ChineseWallTypes&gt;
      &lt;Type&gt;SystemManagement&lt;/Type&gt;
    &lt;/ChineseWallTypes&gt;
  &lt;/VirtualMachineLabel&gt;
  &lt;VirtualMachineLabel&gt;
    &lt;Name&gt;A-Bank-WL&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;SystemManagement&lt;/Type&gt;
      &lt;Type&gt;A-Bank&lt;/Type&gt;
      &lt;Type&gt;A-Bank.SU&lt;/Type&gt;
      &lt;Type&gt;A-Bank.MA&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
    &lt;ChineseWallTypes&gt;
      &lt;Type&gt;SystemManagement&lt;/Type&gt;
    &lt;/ChineseWallTypes&gt;
  &lt;/VirtualMachineLabel&gt;
  &lt;VirtualMachineLabel&gt;
    &lt;Name&gt;A-Bank&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;A-Bank&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
    &lt;ChineseWallTypes&gt;
      &lt;Type&gt;A-Bank&lt;/Type&gt;
    &lt;/ChineseWallTypes&gt;
  &lt;/VirtualMachineLabel&gt;
  &lt;VirtualMachineLabel&gt;
    &lt;Name from="A-Bank.SecurityUnderwriting"&gt;
            A-Bank.SU&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;A-Bank.SU&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
    &lt;ChineseWallTypes&gt;
      &lt;Type&gt;A-Bank&lt;/Type&gt;
      &lt;Type&gt;A-Bank.SU&lt;/Type&gt;
    &lt;/ChineseWallTypes&gt;
   &lt;/VirtualMachineLabel&gt;
  &lt;VirtualMachineLabel&gt;
    &lt;Name from="A-Bank.MarketAnalysis"&gt;
            A-Bank.MA&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;A-Bank.MA&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
    &lt;ChineseWallTypes&gt;
      &lt;Type&gt;A-Bank&lt;/Type&gt;
      &lt;Type&gt;A-Bank.MA&lt;/Type&gt;
    &lt;/ChineseWallTypes&gt;
  &lt;/VirtualMachineLabel&gt;
</PRE></TD></TR>
</TABLE></TD>
<TD ALIGN="LEFT"><TABLE  WIDTH="48%">
<TR><TD>
<PRE>
  &lt;VirtualMachineLabel&gt;
    &lt;Name&gt;B-Bank&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;B-Bank&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
    &lt;ChineseWallTypes&gt;
      &lt;Type&gt;B-Bank&lt;/Type&gt;
    &lt;/ChineseWallTypes&gt;
  &lt;/VirtualMachineLabel&gt;
  &lt;VirtualMachineLabel&gt;
    &lt;Name&gt;AutoCorp&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;AutoCorp&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
    &lt;ChineseWallTypes&gt;
      &lt;Type&gt;AutoCorp&lt;/Type&gt;
    &lt;/ChineseWallTypes&gt;
  &lt;/VirtualMachineLabel&gt;
&lt;/SubjectLabels&gt;

&lt;ObjectLabels&gt;
  &lt;ResourceLabel&gt;
    &lt;Name&gt;SystemManagement&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;SystemManagement&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
  &lt;/ResourceLabel&gt;
  &lt;ResourceLabel&gt;
    &lt;Name&gt;A-Bank&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;A-Bank&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
  &lt;/ResourceLabel&gt;
  &lt;ResourceLabel&gt;
    &lt;Name from="A-Bank.SecurityUnderwriting"&gt;
            A-Bank.SU&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;A-Bank.SU&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
  &lt;/ResourceLabel&gt;
  &lt;ResourceLabel&gt;
    &lt;Name from="A-Bank.MarketAnalysis"&gt;
            A-Bank.MA&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;A-Bank.MA&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
  &lt;/ResourceLabel&gt;
  &lt;ResourceLabel&gt;
    &lt;Name&gt;B-Bank&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;B-Bank&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
  &lt;/ResourceLabel&gt;
  &lt;ResourceLabel&gt;
    &lt;Name&gt;AutoCorp&lt;/Name&gt;
    &lt;SimpleTypeEnforcementTypes&gt;
      &lt;Type&gt;AutoCorp&lt;/Type&gt;
    &lt;/SimpleTypeEnforcementTypes&gt;
  &lt;/ResourceLabel&gt;
  &lt;/ObjectLabels&gt;
&lt;/SecurityLabelTemplate&gt;
&lt;/SecurityPolicyDefinition&gt;
</PRE></TD></TR>
</TABLE></TD>
</TR>
</TABLE></TD></TR>
</TABLE>
</DIV>

<P>
The updated label definition also includes a new label <code>A-Bank-WL</code>
that includes all STE types related to A-Bank. Its CHWALL type
is <code>SystemManagement</code>. This indicates that this label is designed
as Domain-0 label. A Xen system can be restricted to only run A-Bank
related workloads by relabeling Domain-0 with the <code>A-Bank-WL</code> label.

<P>
We assume that the update-policy shown in
Figures&nbsp;<A HREF="#fig:acmupdateheader">10.5</A>, <A HREF="#fig:acmupdatetypesnrules">10.6</A>
and <A HREF="#fig:acmupdatelabels">10.7</A>
is stored in the XML file mytest_update-security_policy.xml located
in the ACM policy directory. See Section&nbsp;<A HREF="#subsection:acmnaming">10.3.1</A>
for information about policy names and locations.

<P>
The following <code>xm setpolicy</code> command updates the active ACM
security policy at run-time.

<P>
<PRE>
# xm list --label
Name      ID   Mem VCPUs    State  Time(s) Label
domain1    2   128     1   -b----     0.6  ACM:mytest:A-Bank
domain4    3   164     1   -b----     0.3  ACM:mytest:A-Bank.SecurityUnderwriting
Domain-0   0   711     1   r-----    71.8  ACM:mytest:SystemManagement

# xm resources
file:/home/xen/dom_fc5/fedora.fc5.swap
      type: ACM
    policy: mytest
    label:  A-Bank
file:/home/xen/dom_fc5/fedora.fc5.img
      type: ACM
    policy: mytest
    label:  A-Bank

# xm setpolicy ACM mytest_update
Successfully set the new policy.
Supported security subsystems   : ACM
Policy name           : mytest
Policy type           : ACM
Version of XML policy : 1.1
Policy configuration  : loaded, activated for boot

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
domain1    2   128     1     -b----      0.7  ACM:mytest:A-Bank
domain4    3   164     1     -b----      0.3  ACM:mytest:A-Bank.SU
Domain-0   0   711     1     r-----     72.8  ACM:mytest:SystemManagement

# xm labels
A-Bank
A-Bank-WL
A-Bank.MA
A-Bank.SU
AutoCorp
B-Bank

# xm resources
file:/home/xen/dom_fc5/fedora.fc5.swap
      type: ACM
    policy: mytest
     label: A-Bank
file:/home/xen/dom_fc5/fedora.fc5.img
      type: ACM
    policy: mytest
     label: A-Bank
</PRE>

<P>
After successful completion of this command, <code>xm list --label</code>
shows that the labels of running domains changed to their new names.
<code>xm labels</code> shows that new labels <code>A-Bank.SU</code> and <code>A-Bank.AM</code>
are now available in the policy. The resource labels remain valid after
the successful update as <code>xm resources</code> confirms.

<P>
The <code>setpolicy</code> command fails if the new policy is inconsistent
with the current one or the policy is inconsistent internally (e.g., types
are renamed in the type definition but not in the label definition part of
the policy). In this case, the old policy remains active.

<P>
After relabeling Domain-0 with the new <code>A-Bank-WL</code> label, we can no
longer run domains labeled <code>B-Bank</code> or <code>AutoCorp</code> since their
STE types are not a subset of the new Domain-0 label.

<P>
<PRE>
# xm addlabel A-Bank-WL mgt Domain-0
Successfully set the label of domain 'Domain-0' to 'A-Bank-WL'.

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
domain1    2   128     1     -b----      0.8  ACM:mytest:A-Bank
Domain-0   0   711     1     r-----     74.5  ACM:mytest:A-Bank-WL
domain4    3   164     1     -b----      0.3  ACM:mytest:A-Bank.SU

# xm getlabel dom domain3.xm
policytype=ACM,policy=mytest,label=AutoCorp

# xm create domain3.xm
Using config file "./domain3.xm".
Error: VM is not authorized to run.

# xm addlabel SystemManagement mgt Domain-0
Successfully set the label of domain 'Domain-0' to 'SystemManagement'.

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
domain1    2   128     1     -b----      0.8  ACM:mytest:A-Bank
domain4    3   164     1     -b----      0.3  ACM:mytest:A-Bank.SU
Domain-0   0   709     1     r-----     76.4  ACM:mytest:SystemManagement

# xm create domain3.xm
Using config file "./domain3.xm".
Started domain domain3

# xm list --label
Name      ID   Mem VCPUs      State   Time(s) Label
domain1    2   128     1     -b----      0.8  ACM:mytest:A-Bank
domain4    3   164     1     -b----      0.3  ACM:mytest:A-Bank.SU
domain3    4   164     1     -b----      0.3  ACM:mytest:AutoCorp
Domain-0   0   547     1     r-----     77.5  ACM:mytest:SystemManagement
</PRE>

<P>
In the same manner, you can add new labels to support new workloads and
add, delete, or rename workload types (STE and/or CHWALL types) simply
by changing the composition of labels. Another use case is to add new
workload types to the current Domain-0 label to enable them to run.
Conflict sets (run-time exclusion rules) can be simply omitted or added.
The policy and label changes become active at once and new workloads
can be run in protected mode without rebooting the Xen system.

<P>
In all these cases, if any running user domain would-under the new policy-not
be allowed to run or would not be allowed to access any of the resources
it currently uses, then the policy update is rejected. In this case, you
can stop domains that conflict with the new policy and update the policy
afterwards. The old policy remains active until a policy update succeeds
or Xen is re-booted into a new policy.

<P>

<H2><A NAME="SECTION03736000000000000000">
10.3.6 Tools For Creating sHype/Xen Security Policies</A>
</H2>
To create a security policy for Xen, you can use one of the following
tools:

<UL>
<LI><code>ezPolicy</code> GUI tool - start writing policies
</LI>
<LI><code>xensec_gen</code> tool - refine policies created with <code>ezPolicy</code>
</LI>
<LI>text or XML editor
</LI>
</UL>

<P>
We use the <code>ezPolicy</code> tool in
Section&nbsp;<A HREF="#subsection:acmexamplecreate">10.2.2</A> to quickly create a workload
protection policy. If desired, the resulting XML policy file can be
loaded into the <code>xensec_gen</code> tool to refine it. It can also be
directly edited using an XML editor. Any XML policy file is verified
against the security policy schema when it is translated (see
Subsection&nbsp;<A HREF="#subsection:acmexampleinstall">10.2.3</A>).

<P>

<H1><A NAME="SECTION03740000000000000000"></A>
<A NAME="section:acmlimitations"></A>
<BR>
10.4 Current Limitations
</H1>

<P>
The sHype/ACM configuration for Xen is work in progress. There is
ongoing work for protecting virtualized resources and planned and
ongoing work for protecting access to remote resources and domains.
The following sections describe limitations of some of the areas into
which access control is being extended.

<P>

<H2><A NAME="SECTION03741000000000000000">
10.4.1 Network Traffic</A>
</H2>
Local and remote network traffic is currently not controlled.
Solutions to add sHype/ACM policy enforcement to the virtual network
exist but need to be discussed before they can become part of Xen.
Subjecting external network traffic to the ACM security policy is work
in progress. Manually setting up filters in domain 0 is required for
now but does not scale well.

<P>

<H2><A NAME="SECTION03742000000000000000">
10.4.2 Resource Access and Usage Control</A>
</H2>

<P>
Enforcing the security policy across multiple hypervisor systems and
on access to remote shared resources is work in progress. Extending
access control to new types of resources is ongoing work (e.g. network
storage).

<P>
On a single Xen system, information about the association of resources
and security labels is stored in
<code>/var/lib/xend/security/policies/resource_labels</code>. This file relates
a full resource path with a security label. This association is weak
and will break if resources are moved or renamed without adapting the
label file. Improving the protection of label-resource relationships
is ongoing work.

<P>
Controlling resource usage and enforcing resource limits in general is
ongoing work in the Xen community.

<P>

<H2><A NAME="SECTION03743000000000000000">
10.4.3 Domain Migration</A>
</H2>

<P>
Labels on domains are enforced during domain migration and the
destination hypervisor will ensure that the domain label is valid and
the domain is permitted to run (considering the Chinese Wall policy
rules) before it accepts the migration.  However, the network between
the source and destination hypervisor as well as both hypervisors must
be trusted. Architectures and prototypes exist that both protect the
network connection and ensure that the hypervisors enforce access
control consistently but patches are not yet available for the main
stream.

<P>

<H2><A NAME="SECTION03744000000000000000">
10.4.4 Covert Channels</A>
</H2>

<P>
The sHype access control aims at system independent security policies.
It builds on top of the core hypervisor isolation. Any covert channels
that exist in the core hypervisor or in the hardware (e.g., shared
processor cache) will be inherited. If those covert channels are not
the result of trade-offs between security and other system properties,
then they are most effectively minimized or eliminated where they are
caused. sHype offers however some means to mitigate their impact, e.g.,
run-time exclusion rules (cf Section&nbsp;<A HREF="#subsection:acmexamplecreate">10.2.2</A>)
or limiting the system authorization (cf Section&nbsp;<A HREF="#subsection:acmlabeldom0">10.2.7</A>).

<P>

<H1><A NAME="SECTION04000000000000000000">
3 Reference</A>
</H1>

<P>

<H1><A NAME="SECTION04100000000000000000">
11. Build and Boot Options</A>
</H1> 

<P>
This chapter describes the build- and boot-time options which may be
used to tailor your Xen system.

<P>

<H1><A NAME="SECTION04110000000000000000">
11.1 Top-level Configuration Options</A>
</H1> 

<P>
Top-level configuration is achieved by editing one of two 
files: <TT>Config.mk</TT> and <TT>Makefile</TT>. 

<P>
The former allows the overall build target architecture to be 
specified. You will typically not need to modify this unless 
you are cross-compiling. Additional configuration options are
documented in the <TT>Config.mk</TT> file. 

<P>
The top-level <TT>Makefile</TT> is chiefly used to customize the set of
kernels built. Look for the line: <PRE>
KERNELS ?= linux-2.6-xen0 linux-2.6-xenU
</PRE>

<P>
Allowable options here are any kernels which have a corresponding 
build configuration file in the <TT>buildconfigs/</TT> directory. 

<P>

<H1><A NAME="SECTION04120000000000000000">
11.2 Xen Build Options</A>
</H1>

<P>
Xen provides a number of build-time options which should be set as
environment variables or passed on make's command-line.

<P>
<DL>
<DT><STRONG>verbose=y</STRONG></DT>
<DD>Enable debugging messages when Xen detects an
  unexpected condition.  Also enables console output from all domains.
</DD>
<DT><STRONG>debug=y</STRONG></DT>
<DD>Enable debug assertions.  Implies <B>verbose=y</B>.
  (Primarily useful for tracing bugs in Xen).
</DD>
<DT><STRONG>debugger=y</STRONG></DT>
<DD>Enable the in-Xen debugger. This can be used to
  debug Xen, guest OSes, and applications.
</DD>
<DT><STRONG>perfc=y</STRONG></DT>
<DD>Enable performance counters for significant events
  within Xen. The counts can be reset or displayed on Xen's console
  via console control keys.
</DD>
</DL>

<P>

<H1><A NAME="SECTION04130000000000000000"></A>
<A NAME="s:xboot"></A>
<BR>
11.3 Xen Boot Options
</H1>

<P>
These options are used to configure Xen's behaviour at runtime.  They
should be appended to Xen's command line, either manually or by
editing <TT>grub.conf</TT>.

<P>
<DL>
<DT><STRONG>noreboot </STRONG></DT>
<DD>Don't reboot the machine automatically on errors.
  This is useful to catch debug output if you aren't catching console
  messages via the serial line.
</DD>
<DT><STRONG>nosmp </STRONG></DT>
<DD>Disable SMP support.  This option is implied by
  `ignorebiostables'.
</DD>
<DT><STRONG>watchdog </STRONG></DT>
<DD>Enable NMI watchdog which can report certain
  failures.
</DD>
<DT><STRONG>noirqbalance </STRONG></DT>
<DD>Disable software IRQ balancing and affinity.
  This can be used on systems such as Dell 1850/2850 that have
  workarounds in hardware for IRQ-routing issues.
</DD>
<DT><STRONG>badpage=&lt;page number&gt;,&lt;page number&gt;, ...</STRONG></DT>
<DD>Specify
  a list of pages not to be allocated for use because they contain bad
  bytes. For example, if your memory tester says that byte 0x12345678
  is bad, you would place `badpage=0x12345' on Xen's command line.
</DD>
<DT><STRONG>serial_tx_buffer=&lt;size&gt; </STRONG></DT>
<DD>Size of serial transmit
  buffers. Default is 16kB.
</DD>
<DT><STRONG>com1=&lt;baud&gt;,DPS,&lt;io_base&gt;,&lt;irq&gt;
  com2=&lt;baud&gt;,DPS,&lt;io_base&gt;,&lt;irq&gt; </STRONG></DT>
<DD>
<BR>
Xen supports up to two 16550-compatible serial ports.  For example:
  `com1=9600, 8n1, 0x408, 5' maps COM1 to a 9600-baud port, 8 data
  bits, no parity, 1 stop bit, I/O port base 0x408, IRQ 5.  If some
  configuration options are standard (e.g., I/O base and IRQ), then
  only a prefix of the full configuration string need be specified. If
  the baud rate is pre-configured (e.g., by the bootloader) then you
  can specify `auto' in place of a numeric baud rate.
</DD>
<DT><STRONG>console=&lt;specifier list&gt; </STRONG></DT>
<DD>Specify the destination for Xen
  console I/O.  This is a comma-separated list of, for example:
  <DL>
<DT><STRONG> vga </STRONG></DT>
<DD>Use VGA console (until domain 0 boots, unless <B>  vga=...keep </B> is specified).
  
</DD>
<DT><STRONG> com1 </STRONG></DT>
<DD>Use serial port com1.
  
</DD>
<DT><STRONG> com2H </STRONG></DT>
<DD>Use serial port com2. Transmitted chars will have the
    MSB set. Received chars must have MSB set.
  
</DD>
<DT><STRONG> com2L</STRONG></DT>
<DD>Use serial port com2. Transmitted chars will have the
    MSB cleared. Received chars must have MSB cleared.
  
</DD>
</DL>
  The latter two examples allow a single port to be shared by two
  subsystems (e.g. console and debugger). Sharing is controlled by
  MSB of each transmitted/received character.  [NB. Default for this
  option is `com1,vga']
</DD>
<DT><STRONG>vga=&lt;mode&gt;(,keep) </STRONG></DT>
<DD>The mode is one of the following options:
  <DL>
<DT><STRONG> ask </STRONG></DT>
<DD>Display a vga menu allowing manual selection of video
  mode.
  
</DD>
<DT><STRONG> current </STRONG></DT>
<DD>Use existing vga mode without modification.
  
</DD>
<DT><STRONG> text-&lt;mode&gt; </STRONG></DT>
<DD>Select text-mode resolution, where mode is
  one of 80x25, 80x28, 80x30, 80x34, 80x43, 80x50, 80x60.
  
</DD>
<DT><STRONG> gfx-&lt;mode&gt; </STRONG></DT>
<DD>Select VESA graphics mode
  &lt;width&gt;x&lt;height&gt;x&lt;depth&gt; (e.g., `vga=gfx-1024x768x32').
  
</DD>
<DT><STRONG> mode-&lt;mode&gt; </STRONG></DT>
<DD>Specify a mode number as discovered by `vga
  ask'. Note that the numbers are displayed in hex and hence must be
  prefixed by `0x' here (e.g., `vga=mode-0x0335').
  
</DD>
</DL>
The mode may optionally be followed by `<B>,keep</B>' to cause Xen to keep
writing to the VGA console after domain 0 starts booting (e.g., `vga=text-80x50,keep').
</DD>
<DT><STRONG>no-real-mode </STRONG></DT>
<DD>(x86 only) Do not execute real-mode bootstrap
  code when booting Xen. This option should not be used except for
  debugging. It will effectively disable the <B>vga</B> option, which
  relies on real mode to set the video mode.
</DD>
<DT><STRONG>edid=no,force </STRONG></DT>
<DD>(x86 only) Either force retrieval of monitor
  EDID information via VESA DDC, or disable it (edid=no). This option
  should not normally be required except for debugging purposes.
</DD>
<DT><STRONG>edd=off,on,skipmbr </STRONG></DT>
<DD>(x86 only) Control retrieval of Extended
  Disc Data (EDD) from the BIOS during boot.
</DD>
<DT><STRONG>console_to_ring </STRONG></DT>
<DD>Place guest console output into the
  hypervisor console ring buffer. This is disabled by default.
  When enabled, both hypervisor output and guest console output
  is available from the ring buffer. This can be useful for logging
  and/or remote presentation of console data.
</DD>
<DT><STRONG>sync_console </STRONG></DT>
<DD>Force synchronous console output. This is
  useful if you system fails unexpectedly before it has sent all
  available output to the console. In most cases Xen will
  automatically enter synchronous mode when an exceptional event
  occurs, but this option provides a manual fallback.
</DD>
<DT><STRONG>conswitch=&lt;switch-char&gt;&lt;auto-switch-char&gt; </STRONG></DT>
<DD>Specify how
  to switch serial-console input between Xen and DOM0. The required
  sequence is CTRL-&lt;switch-char&gt; pressed three times. Specifying
  the backtick character disables switching.  The
  &lt;auto-switch-char&gt; specifies whether Xen should auto-switch
  input to DOM0 when it boots -- if it is `x' then auto-switching is
  disabled.  Any other value, or omitting the character, enables
  auto-switching.  [NB. Default switch-char is `a'.]
</DD>
<DT><STRONG>loglvl=&lt;level&gt;/&lt;level&gt; </STRONG></DT>
<DD>Specify logging level. Messages of the specified severity level (and
  higher) will be printed to the Xen console. Valid levels are `none',
  `error', `warning', `info', `debug', and `all'. The second level
  specifier is optional: it is used to specify message severities
  which are to be rate limited. Default is `loglvl=warning'.
</DD>
<DT><STRONG>guest_loglvl=&lt;level&gt;/&lt;level&gt; </STRONG></DT>
<DD>As for loglvl, but
  applies to messages relating to guests. Default is
  `guest_loglvl=none/warning'. 
</DD>
<DT><STRONG>console_timestamps </STRONG></DT>
<DD>Adds a timestamp prefix to each line of Xen console output.
</DD>
<DT><STRONG>nmi=xxx </STRONG></DT>
<DD>Specify what to do with an NMI parity or I/O error. 
<BR>  `nmi=fatal':  Xen prints a diagnostic and then hangs. 
<BR>  `nmi=dom0':   Inform DOM0 of the NMI. 
<BR>  `nmi=ignore': Ignore the NMI.
</DD>
<DT><STRONG>mem=xxx </STRONG></DT>
<DD>Set the physical RAM address limit. Any RAM
  appearing beyond this physical address in the memory map will be
  ignored. This parameter may be specified with a B, K, M or G suffix,
  representing bytes, kilobytes, megabytes and gigabytes respectively.
  The default unit, if no suffix is specified, is kilobytes.
</DD>
<DT><STRONG>dom0_mem=&lt;specifier list&gt; </STRONG></DT>
<DD>Set the amount of memory to
  be allocated to domain 0. This is a comma-separated list containing
  the following optional components:
  <DL>
<DT><STRONG> min:&lt;min_amt&gt; </STRONG></DT>
<DD>Minimum amount to allocate to domain 0
  
</DD>
<DT><STRONG> max:&lt;min_amt&gt; </STRONG></DT>
<DD>Maximum amount to allocate to domain 0
  
</DD>
<DT><STRONG> &lt;amt&gt; </STRONG></DT>
<DD>Precise amount to allocate to domain 0
  
</DD>
</DL>
  Each numeric parameter may be specified with a B, K, M or
  G suffix, representing bytes, kilobytes, megabytes and gigabytes
  respectively; if no suffix is specified, the parameter defaults to
  kilobytes. Negative values are subtracted from total available
  memory. If &lt;amt&gt; is not specified, it defaults to all available
  memory less a small amount (clamped to 128MB) for uses such as DMA
  buffers.
</DD>
<DT><STRONG>dom0_vcpus_pin </STRONG></DT>
<DD>Pins domain 0 VCPUs on their respective
  physical CPUS (default=false).
</DD>
<DT><STRONG>tbuf_size=xxx </STRONG></DT>
<DD>Set the size of the per-cpu trace buffers, in
  pages (default 0).  
</DD>
<DT><STRONG>sched=xxx </STRONG></DT>
<DD>Select the CPU scheduler Xen should use.  The
  current possibilities are `credit' (default), and `sedf'.
</DD>
<DT><STRONG>apic_verbosity=debug,verbose </STRONG></DT>
<DD>Print more detailed
  information about local APIC and IOAPIC configuration.
</DD>
<DT><STRONG>lapic </STRONG></DT>
<DD>Force use of local APIC even when left disabled by
  uniprocessor BIOS.
</DD>
<DT><STRONG>nolapic </STRONG></DT>
<DD>Ignore local APIC in a uniprocessor system, even if
  enabled by the BIOS.
</DD>
<DT><STRONG>apic=bigsmp,default,es7000,summit </STRONG></DT>
<DD>Specify NUMA platform.
  This can usually be probed automatically.
</DD>
<DT><STRONG>dma_bits=xxx </STRONG></DT>
<DD>Specify width of DMA addresses in bits. This
  is used in NUMA systems to prevent this special DMA memory from
  being exhausted in one node when remote nodes have available memory.
</DD>
<DT><STRONG>vcpu_migration_delay=&lt;minimum_time&gt;</STRONG></DT>
<DD>Set minimum time of 
  vcpu migration in microseconds (default 0). This parameter avoids agressive
  vcpu migration. For example, the linux kernel uses 0.5ms by default.
</DD>
</DL>

<P>
In addition, the following options may be specified on the Xen command
line. Since domain 0 shares responsibility for booting the platform,
Xen will automatically propagate these options to its command line.
These options are taken from Linux's command-line syntax with
unchanged semantics.

<P>
<DL>
<DT><STRONG>acpi=off,force,strict,ht,noirq,...</STRONG></DT>
<DD>Modify how Xen (and
  domain 0) parses the BIOS ACPI tables.
</DD>
<DT><STRONG>acpi_skip_timer_override </STRONG></DT>
<DD>Instruct Xen (and domain&nbsp;0) to
  ignore timer-interrupt override instructions specified by the BIOS
  ACPI tables.
</DD>
<DT><STRONG>noapic </STRONG></DT>
<DD>Instruct Xen (and domain&nbsp;0) to ignore any IOAPICs
  that are present in the system, and instead continue to use the
  legacy PIC.
</DD>
</DL> 

<P>

<H1><A NAME="SECTION04140000000000000000">
11.4 XenLinux Boot Options</A>
</H1>

<P>
In addition to the standard Linux kernel boot options, we support:
<DL>
<DT><STRONG> xencons=xxx </STRONG></DT>
<DD>Specify the device node to which the Xen virtual
  console driver is attached. The following options are supported:
  <DIV ALIGN="CENTER">
<TABLE CELLPADDING=3>
<TR><TD ALIGN="LEFT">`xencons=off': disable virtual console</TD>
</TR>
<TR><TD ALIGN="LEFT">`xencons=tty': attach console to /dev/tty1 (tty0 at boot-time)</TD>
</TR>
<TR><TD ALIGN="LEFT">`xencons=ttyS': attach console to /dev/ttyS0</TD>
</TR>
<TR><TD ALIGN="LEFT">`xencons=xvc': attach console to /dev/xvc0</TD>
</TR>
</TABLE>
</DIV>
The default is ttyS for dom0 and xvc for all other domains.
</DD>
</DL>

<P>

<H1><A NAME="SECTION04200000000000000000">
12. Further Support</A>
</H1>

<P>
If you have questions that are not answered by this manual, the
sources of information listed below may be of interest to you.  Note
that bug reports, suggestions and contributions related to the
software (or the documentation) should be sent to the Xen developers'
mailing list (address below).

<P>

<H1><A NAME="SECTION04210000000000000000">
12.1 Other Documentation</A>
</H1>

<P>
For developers interested in porting operating systems to Xen, the
<I>Xen Interface Manual</I> is distributed in the <TT>docs/</TT>
directory of the Xen source distribution.

<P>

<H1><A NAME="SECTION04220000000000000000">
12.2 Online References</A>
</H1>

<P>
The official Xen web site can be found at:
<BLOCKQUOTE>
<TT>http://www.xen.org</TT>

</BLOCKQUOTE>

<P>
This contains links to the latest versions of all online
documentation, including the latest version of the FAQ.

<P>
Information regarding Xen is also available at the Xen Wiki at
<BLOCKQUOTE>
<TT>http://wiki.xensource.com/xenwiki/</TT>
</BLOCKQUOTE>
The Xen project uses Bugzilla as its bug tracking system. You'll find
the Xen Bugzilla at http://bugzilla.xensource.com/bugzilla/.

<P>

<H1><A NAME="SECTION04230000000000000000">
12.3 Mailing Lists</A>
</H1>

<P>
There are several mailing lists that are used to discuss Xen related
topics. The most widely relevant are listed below. An official page of
mailing lists and subscription information can be found at <BLOCKQUOTE>
<TT>http://lists.xensource.com/</TT> 
</BLOCKQUOTE>

<P>
<DL>
<DT><STRONG>xen-devel@lists.xensource.com</STRONG></DT>
<DD>Used for development
  discussions and bug reports.  Subscribe at: 
<BR>  <FONT SIZE="-1"><TT>http://lists.xensource.com/xen-devel</TT></FONT>
</DD>
<DT><STRONG>xen-users@lists.xensource.com</STRONG></DT>
<DD>Used for installation and usage
  discussions and requests for help.  Subscribe at: 
<BR>  <FONT SIZE="-1"><TT>http://lists.xensource.com/xen-users</TT></FONT>
</DD>
<DT><STRONG>xen-announce@lists.xensource.com</STRONG></DT>
<DD>Used for announcements only.
  Subscribe at: 
<BR>  <FONT SIZE="-1"><TT>http://lists.xensource.com/xen-announce</TT></FONT>
</DD>
<DT><STRONG>xen-changelog@lists.xensource.com</STRONG></DT>
<DD>Changelog feed
  from the unstable and 3.x trees - developer oriented.  Subscribe at: 
<BR>  <FONT SIZE="-1"><TT>http://lists.xensource.com/xen-changelog</TT></FONT>
</DD>
</DL>

<P>

<P>

<H1><A NAME="SECTION04300000000000000000">
A. Unmodified (HVM) guest domains in Xen with Hardware support for Virtualization</A>
</H1>

<P>
Xen supports guest domains running unmodified guest operating systems using
virtualization extensions available on recent processors. Currently processors
featuring the Intel Virtualization Extension (Intel-VT) or the AMD extension
(AMD-V) are supported. The technology covering both implementations is
called HVM (for Hardware Virtual Machine) in Xen. More information about the
virtualization extensions are available on the respective websites:
 <FONT SIZE="-1"><TT>http://www.intel.com/technology/computing/vptech</TT></FONT>

<P>
<FONT SIZE="-1"><TT>http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/24593.pdf</TT></FONT>

<P>

<H1><A NAME="SECTION04310000000000000000">
A.1 Building Xen with HVM support</A>
</H1>

<P>
The following packages need to be installed in order to build Xen with HVM support. Some Linux distributions do not provide these packages by default.

<P>
<TABLE CELLPADDING=3>
<TR><TD ALIGN="LEFT"><B>Package</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312><B>Description</B></TD>
</TR>
<TR><TD ALIGN="LEFT">dev86</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>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. 

<P>
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 <FONT SIZE="-2"><TT>http://www.rpmfind.net/linux/rpm2html/search.php?query=dev86&amp;submit=Search</TT></FONT></TD>
</TR>
<TR><TD ALIGN="LEFT">SDL-devel, SDL</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>Simple DirectMedia Layer (SDL) is another way of virtualizing the unmodified guest console. It provides an X window for the guest console. 

<P>
If the SDL and SDL-devel packages are not installed by default on the build system, they can be obtained from  <FONT SIZE="-2"><TT>http://www.rpmfind.net/linux/rpm2html/search.php?query=SDL&amp;amp;submit=Search</TT></FONT>

<P>
<FONT SIZE="-2"><TT>http://www.rpmfind.net/linux/rpm2html/search.php?query=SDL-devel&amp;submit=Search</TT></FONT></TD>
</TR>
</TABLE>

<P>

<H1><A NAME="SECTION04320000000000000000">
A.2 Configuration file for unmodified HVM guests</A>
</H1>

<P>
The Xen installation includes a sample configuration file, <FONT SIZE="-1"><TT>/etc/xen/xmexample.hvm</TT></FONT>. There are comments describing all the options. In addition to the common options that are the same as those for paravirtualized guest configurations, HVM guest configurations have the following settings:

<P>
<TABLE CELLPADDING=3>
<TR><TD ALIGN="LEFT"><B>Parameter</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312><B>Description</B></TD>
</TR>
<TR><TD ALIGN="LEFT">kernel</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>The HVM firmware loader, <FONT SIZE="-1"><TT>/usr/lib/xen/boot/hvmloader</TT></FONT></TD>
</TR>
<TR><TD ALIGN="LEFT">builder</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>The domain build function. The HVM domain uses the 'hvm' builder.</TD>
</TR>
<TR><TD ALIGN="LEFT">acpi</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>Enable HVM guest ACPI, default=1 (enabled)</TD>
</TR>
<TR><TD ALIGN="LEFT">apic</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>Enable HVM guest APIC, default=1 (enabled)</TD>
</TR>
<TR><TD ALIGN="LEFT">pae</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>Enable HVM guest PAE, default=1 (enabled)</TD>
</TR>
<TR><TD ALIGN="LEFT">hap</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>Enable hardware-assisted paging support, such as AMD-V's nested paging
or Intel<IMG
 WIDTH="20" HEIGHT="27" ALIGN="MIDDLE" BORDER="0"
 SRC="img9.png"
 ALT="\textregistered">VT's extended paging. If available, Xen will
use hardware-assisted paging instead of shadow paging for this guest's memory
management.</TD>
</TR>
<TR><TD ALIGN="LEFT">vif</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>Optionally defines MAC address and/or bridge for the network interfaces. Random MACs are assigned if not given. <FONT SIZE="-1"><TT>type=ioemu</TT></FONT> means ioemu is used to virtualize the HVM NIC. If no type is specified, vbd is used, as with paravirtualized guests.</TD>
</TR>
<TR><TD ALIGN="LEFT">disk</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>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 HVM guest's disk, each disk entry is of the form 

<P>
<FONT SIZE="-1"><TT>phy:UNAME,ioemu:DEV,MODE,</TT></FONT>

<P>
where UNAME is the host device file, 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 HVM disk. If not adding ioemu, it uses vbd like paravirtualized guests.

<P>
If using disk image file, its form should be like 

<P>
<FONT SIZE="-1"><TT>file:FILEPATH,ioemu:DEV,MODE</TT></FONT>

<P>
Optical devices can be emulated by appending cdrom to the device type

<P>
<FONT SIZE="-1"><TT>',hdc:cdrom,r'</TT></FONT>

<P>
If using more than one disk, there should be a comma between each disk entry. For example:

<P>
<FONT SIZE="-2"><TT>disk = ['file:/var/images/image1.img,ioemu:hda,w', 'phy:hda1,hdb1,w', 'file:/var/images/install1.iso,hdc:cdrom,r']</TT></FONT></TD>
</TR>
<TR><TD ALIGN="LEFT">boot</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>Boot from floppy (a), hard disk (c) or CD-ROM (d). For example, to boot from CD-ROM and fallback to HD, the entry should be:

<P>
boot='dc'</TD>
</TR>
<TR><TD ALIGN="LEFT">device_model</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>The device emulation tool for HVM guests. This parameter should not be changed.</TD>
</TR>
<TR><TD ALIGN="LEFT">sdl</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>Enable SDL library for graphics, default = 0 (disabled)</TD>
</TR>
<TR><TD ALIGN="LEFT">vnc</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>Enable VNC library for graphics, default = 1 (enabled)</TD>
</TR>
<TR><TD ALIGN="LEFT">vncconsole</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>Enable spawning of the vncviewer (only valid when vnc=1), default = 0 (disabled)

<P>
If vnc=1 and vncconsole=0, user can use vncviewer to manually connect HVM from remote. For example:

<P>
<FONT SIZE="-1"><TT>vncviewer domain0_IP_address:HVM_domain_id</TT></FONT></TD>
</TR>
<TR><TD ALIGN="LEFT">serial</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=312>Enable redirection of HVM serial output to pty device</TD>
</TR>
</TABLE>

<P>
<TABLE CELLPADDING=3>
<TR><TD ALIGN="LEFT">usb</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=283>Enable USB support without defining a specific USB device.
This option defaults to 0 (disabled) unless the option usbdevice is
specified in which case this option then defaults to 1 (enabled).</TD>
</TR>
<TR><TD ALIGN="LEFT">usbdevice</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=283>Enable USB support and also enable support for the given
device.  Devices that can be specified are <FONT SIZE="-1"><TT>mouse</TT></FONT> (a PS/2 style
mouse), <FONT SIZE="-1"><TT>tablet</TT></FONT> (an absolute pointing device) and
<FONT SIZE="-1"><TT>host:id1:id2</TT></FONT> (a physical USB device on the host machine whose
ids are <FONT SIZE="-1"><TT>id1</TT></FONT> and <FONT SIZE="-1"><TT>id2</TT></FONT>).  The advantage
of <FONT SIZE="-1"><TT>tablet</TT></FONT> is that Windows guests will automatically recognize
and support this device so specifying the config line

<P>
<FONT SIZE="-1"><PRE>
    usbdevice='tablet'
</PRE></FONT>

<P>
will create a mouse that works transparently with Windows guests under VNC.
Linux doesn't recognize the USB tablet yet so Linux guests under VNC will
still need the Summagraphics emulation.
Details about mouse emulation are provided in section <B>A.4.3</B>.</TD>
</TR>
<TR><TD ALIGN="LEFT">localtime</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=283>Set the real time clock to local time [default=0, that is, set to UTC].</TD>
</TR>
<TR><TD ALIGN="LEFT">soundhw</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=283>Enable sound card support and specify the hardware to emulate. Values can be sb16, es1370 or all. Default is none.</TD>
</TR>
<TR><TD ALIGN="LEFT">full-screen</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=283>Start in full screen.</TD>
</TR>
<TR><TD ALIGN="LEFT">nographic</TD>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=283>Another way to redirect serial output. If enabled, no 'sdl' or 'vnc' can work. Not recommended.</TD>
</TR>
</TABLE>

<P>

<H1><A NAME="SECTION04330000000000000000">
A.3 Creating virtual disks from scratch</A>
</H1>

<H2><A NAME="SECTION04331000000000000000">
A.3.1 Using physical disks</A>
</H2>
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 <FONT SIZE="-1"><TT>dev/sda</TT></FONT> for booting from the whole disk, or <FONT SIZE="-1"><TT>/dev/sda1</TT></FONT> for booting from partition 1.

<P>

<H2><A NAME="SECTION04332000000000000000">
A.3.2 Using disk image files</A>
</H2>
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 HVM 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.

<P>

<H3><A NAME="SECTION04332100000000000000">
To create the image file:</A>
</H3>
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).

<P>
<FONT SIZE="-1"><TT># dd if=/dev/zero of=hd.img bs=1M count=0 seek=1024</TT></FONT>

<P>

<H3><A NAME="SECTION04332200000000000000">
To directly install Linux OS into an image file using a HVM guest:</A>
</H3>

<P>
Install Xen and create HVM with the original image file with booting from CD-ROM. Then it is just like a normal Linux OS installation. The HVM configuration file should have a stanza for the CD-ROM as well as a boot device specification:

<P>
<FONT SIZE="-1"><TT>disk=['file:/var/images/your-hd.img,hda,w', ',hdc:cdrom,r' ]
boot='d'</TT></FONT>

<P>
If this method does not succeed, you can choose the following method of copying an installed Linux OS into an image file.

<P>

<H3><A NAME="SECTION04332300000000000000">
To copy a installed OS into an image file:</A>
</H3>
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.

<P>

<OL>
<LI><B>Install a normal Linux OS on the host machine</B>
<BR>
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 <FONT SIZE="-1"><TT>/var/guestos/</TT></FONT>.

<P>
</LI>
<LI><B>Make the partition table</B>
<BR>
The image file will be treated as hard disk, so you should make the partition table in the image file. For example:

<P>
<FONT SIZE="-2"><TT># losetup /dev/loop0 hd.img
<BR># fdisk -b 512 -C 4096 -H 16 -S 32 /dev/loop0
<BR>
press 'n' to add new partition
<BR>
press 'p' to choose primary partition
<BR>
press '1' to set partition number
<BR>
press "Enter" keys to choose default value of "First Cylinder" parameter.
<BR>
press "Enter" keys to choose default value of "Last Cylinder" parameter.
<BR>
press 'w' to write partition table and exit
<BR># losetup -d /dev/loop0</TT></FONT>

<P>
</LI>
<LI><B>Make the file system and install grub</B>
<BR><FONT SIZE="-2"><TT># ln -s /dev/loop0 /dev/loop
<BR># losetup /dev/loop0 hd.img
<BR># losetup -o 16384 /dev/loop1 hd.img
<BR># mkfs.ext3 /dev/loop1
<BR># mount /dev/loop1 /mnt
<BR># mkdir -p /mnt/boot/grub
<BR># cp /boot/grub/stage* /boot/grub/e2fs_stage1_5 /mnt/boot/grub
<BR># umount /mnt
<BR># grub
<BR>
grub&gt; device (hd0) /dev/loop
<BR>
grub&gt; root (hd0,0)
<BR>
grub&gt; setup (hd0)
<BR>
grub&gt; quit
<BR># rm /dev/loop
<BR># losetup -d /dev/loop0
<BR># losetup -d /dev/loop1</TT></FONT>

<P>
The <FONT SIZE="-1"><TT>losetup</TT></FONT> option <FONT SIZE="-1"><TT>-o 16384</TT></FONT> skips the partition table in the image file. It is the number of sectors times 512. We need <FONT SIZE="-1"><TT>/dev/loop</TT></FONT> because grub is expecting a disk device <I>name</I>, where <I>name</I> represents the entire disk and <I>name1</I> represents the first partition.

<P>
</LI>
<LI><B>Copy the OS files to the image</B>
<BR>
If you have Xen installed, you can easily use <FONT SIZE="-1"><TT>lomount</TT></FONT> instead of <FONT SIZE="-1"><TT>losetup</TT></FONT> and <FONT SIZE="-1"><TT>mount</TT></FONT> when coping files to some partitions. <FONT SIZE="-1"><TT>lomount</TT></FONT> just needs the partition information.

<P>
<FONT SIZE="-2"><TT># lomount -t ext3 -diskimage hd.img -partition 1 /mnt/guest
<BR># cp -ax /var/guestos/{root,dev,var,etc,usr,bin,sbin,lib} /mnt/guest
<BR># mkdir /mnt/guest/{proc,sys,home,tmp}</TT></FONT>

<P>
</LI>
<LI><B>Edit the <FONT SIZE="-1"><TT>/etc/fstab</TT></FONT> of the guest image</B>
<BR>
The fstab should look like this:

<P>
<FONT SIZE="-2"><TT># vim /mnt/guest/etc/fstab
<BR>/dev/hda1       /               ext3            defaults 1 1
<BR>
none            /dev/pts        devpts  gid=5,mode=620 0 0
<BR>
none            /dev/shm        tmpfs           defaults 0 0
<BR>
none            /proc           proc            defaults 0 0
<BR>
none            /sys            sysfs           efaults 0 0</TT></FONT>

<P>
</LI>
<LI><B>umount the image file</B>
<BR><FONT SIZE="-1"><TT># umount /mnt/guest</TT></FONT>
</LI>
</OL>

<P>
Now, the guest OS image <FONT SIZE="-1"><TT>hd.img</TT></FONT> is ready. You can also reference <FONT SIZE="-1"><TT>http://free.oszoo.org</TT></FONT> for quickstart images. But make sure to install the boot loader.

<P>

<H1><A NAME="SECTION04340000000000000000">
A.4 HVM Guests</A>
</H1>

<H2><A NAME="SECTION04341000000000000000">
A.4.1 Editing the Xen HVM config file</A>
</H2>
Make a copy of the example HVM configuration file <FONT SIZE="-1"><TT>/etc/xen/xmexample.hvm</TT></FONT> and edit the line that reads

<P>
<FONT SIZE="-1"><TT>disk = [ 'file:/var/images/<I>min-el3-i386.img</I>,hda,w' ]</TT></FONT>

<P>
replacing <I>min-el3-i386.img</I> with the name of the guest OS image file you just made.

<P>

<H2><A NAME="SECTION04342000000000000000">
A.4.2 Creating HVM guests</A>
</H2>
Simply follow the usual method of creating the guest, providing the filename of your HVM configuration file:
<BR>
<P>
<FONT SIZE="-1"><TT># xend start
<BR># xm create /etc/xen/hvmguest.hvm</TT></FONT>

<P>
In the default configuration, VNC is on and SDL is off. Therefore VNC windows will open when HVM guests are created. If you want to use SDL to create HVM guests, set <FONT SIZE="-1"><TT>sdl=1</TT></FONT> in your HVM configuration file. You can also turn off VNC by setting <FONT SIZE="-1"><TT>vnc=0</TT></FONT>.

<P>

<H2><A NAME="SECTION04343000000000000000">
A.4.3 Mouse issues, especially under VNC</A>
</H2>
Mouse handling when using VNC is a little problematic.
The problem is that the VNC viewer provides a virtual pointer which is
located at an absolute location in the VNC window and only absolute
coordinates are provided.
The HVM device model converts these absolute mouse coordinates
into the relative motion deltas that are expected by the PS/2
mouse driver running in the guest.
Unfortunately,
it is impossible to keep these generated mouse deltas
accurate enough for the guest cursor to exactly match
the VNC pointer.
This can lead to situations where the guest's cursor
is in the center of the screen and there's no way to
move that cursor to the left
(it can happen that the VNC pointer is at the left
edge of the screen and,
therefore,
there are no longer any left mouse deltas that
can be provided by the device model emulation code.)

<P>
To deal with these mouse issues there are 4 different
mouse emulations available from the HVM device model:

<P>
<DL>
<DT><STRONG>PS/2 mouse over the PS/2 port.</STRONG></DT>
<DD>This is the default mouse
that works perfectly well under SDL.
Under VNC the guest cursor will get
out of sync with the VNC pointer.
When this happens you can re-synchronize
the guest cursor to the VNC pointer by
holding down the
<B>left-ctl</B>
and
<B>left-alt</B>
keys together.
While these keys are down VNC pointer motions
will not be reported to the guest so
that the VNC pointer can be moved
to a place where it is possible
to move the guest cursor again.

<P>
</DD>
<DT><STRONG>Summagraphics mouse over the serial port.</STRONG></DT>
<DD>The device model also provides emulation
for a Summagraphics tablet,
an absolute pointer device.
This emulation is provided over the second
serial port,
<B>/dev/ttyS1</B>
for Linux guests and
<B>COM2</B>
for Windows guests.
Unfortunately,
neither Linux nor Windows provides
default support for the Summagraphics
tablet so the guest will have to be
manually configured for this mouse.

<P>
<B>Linux configuration.</B>

<P>
First,
configure the GPM service to use the Summagraphics tablet.
This can vary between distributions but,
typically,
all that needs to be done is modify the file
<TT>/etc/sysconfig/mouse</TT> to contain the lines:

<P>
<PRE>
    MOUSETYPE="summa"
    XMOUSETYPE="SUMMA"
    DEVICE=/dev/ttyS1
</PRE>

<P>
and then restart the GPM daemon.

<P>
Next,
modify the X11 config
<TT>/etc/X11/xorg.conf</TT>
to support the Summgraphics tablet by replacing
the input device stanza with the following:

<P>
<PRE>
    Section "InputDevice"
        Identifier "Mouse0"
        Driver "summa"
        Option "Device" "/dev/ttyS1"
        Option "InputFashion" "Tablet"
        Option "Mode" "Absolute"
        Option "Name" "EasyPen"
        Option "Compatible" "True"
        Option "Protocol" "Auto"
        Option "SendCoreEvents" "on"
        Option "Vendor" "GENIUS"
    EndSection
</PRE>

<P>
Restart X and the X cursor should now properly
track the VNC pointer.

<P>
<B>Windows configuration.</B>

<P>
Get the file
<TT>http://www.cad-plan.de/files/download/tw2k.exe</TT>
and execute that file on the guest,
answering the questions as follows:

<P>

<OL>
<LI>When the program asks for <B>model</B>,
scroll down and select <B>SummaSketch (MM Compatible)</B>.

<P>
</LI>
<LI>When the program asks for <B>COM Port</B> specify <B>com2</B>.

<P>
</LI>
<LI>When the programs asks for a <B>Cursor Type</B> specify
<B>4 button cursor/puck</B>.

<P>
</LI>
<LI>The guest system will then reboot and,
when it comes back up,
the guest cursor will now properly track
the VNC pointer.
</LI>
</OL>

<P>
</DD>
<DT><STRONG>PS/2 mouse over USB port.</STRONG></DT>
<DD>This is just the same PS/2 emulation except it is
provided over a USB port.
This emulation is enabled by the configuration flag:
<PRE>
    usbdevice='mouse'
</PRE>

<P>
</DD>
<DT><STRONG>USB tablet over USB port.</STRONG></DT>
<DD>The USB tablet is an absolute pointing device
that has the advantage that it is automatically
supported under Windows guests,
although Linux guests still require some
manual configuration.
This mouse emulation is enabled by the
configuration flag:
<PRE>
    usbdevice='tablet'
</PRE>

<P>
<B>Linux configuration.</B>

<P>
Unfortunately,
there is no GPM support for the
USB tablet at this point in time.
If you intend to use a GPM pointing
device under VNC you should
configure the guest for Summagraphics
emulation.

<P>
Support for X11 is available by following
the instructions at
<BR><code>http://stz-softwaretechnik.com/~ke/touchscreen/evtouch.html</code>
<BR>
with one minor change.
The
<TT>xorg.conf</TT>
given in those instructions
uses the wrong values for the X &amp; Y minimums and maximums,
use the following config stanza instead:

<P>
<PRE>
    Section "InputDevice"
        Identifier      "Tablet"
        Driver          "evtouch"
        Option          "Device" "/dev/input/event2"
        Option          "DeviceName" "touchscreen"
        Option          "MinX" "0"
        Option          "MinY" "0"
        Option          "MaxX" "32256"
        Option          "MaxY" "32256"
        Option          "ReportingMode" "Raw"
        Option          "Emulate3Buttons"
        Option          "Emulate3Timeout" "50"
        Option          "SendCoreEvents" "On"
    EndSection
</PRE>

<P>
<B>Windows configuration.</B>

<P>
Just enabling the USB tablet in the
guest's configuration file is sufficient,
Windows will automatically recognize and
configure device drivers for this
pointing device.

<P>
</DD>
</DL>

<P>

<H2><A NAME="SECTION04344000000000000000">
A.4.4 USB Support</A>
</H2>
There is support for an emulated USB mouse,
an emulated USB tablet
and physical low speed USB devices
(support for high speed USB 2.0 devices is
still under development).

<P>
<DL>
<DT><STRONG>USB PS/2 style mouse.</STRONG></DT>
<DD>Details on the USB mouse emulation are
given in sections
<B>A.2</B>
and
<B>A.4.3</B>.
Enabling USB PS/2 style mouse emulation
is just a matter of adding the line

<P>
<PRE>
    usbdevice='mouse'
</PRE>

<P>
to the configuration file.
</DD>
<DT><STRONG>USB tablet.</STRONG></DT>
<DD>Details on the USB tablet emulation are
given in sections
<B>A.2</B>
and
<B>A.4.3</B>.
Enabling USB tablet emulation
is just a matter of adding the line

<P>
<PRE>
    usbdevice='tablet'
</PRE>

<P>
to the configuration file.
</DD>
<DT><STRONG>USB physical devices.</STRONG></DT>
<DD>Access to a physical (low speed) USB device
is enabled by adding a line of the form

<P>
<PRE>
    usbdevice='host:vid:pid'
</PRE>

<P>
into the the configuration file.<A NAME="tex2html17"
  HREF="#foot1321"><SUP>A.1</SUP></A><B>vid</B>
and
<B>pid</B>
are a
product id and
vendor id
that uniquely identify
the USB device.
These ids can be identified
in two ways:

<P>

<OL>
<LI>Through the control window.
As described in section
<B>A.4.6</B>
the control window
is activated by pressing
<B>ctl-alt-2</B>
in the guest VGA window.
As long as USB support is
enabled in the guest by including
the config file line
<PRE>
    usb=1
</PRE>
then executing the command
<PRE>
    info usbhost
</PRE>
in the control window
will display a list of all
usb devices and their ids.
For example,
this output:
<PRE>
    Device 1.3, speed 1.5 Mb/s
      Class 00: USB device 04b3:310b
</PRE>
was created from a USB mouse with
vendor id
<B>04b3</B>
and product id
<B>310b</B>.
This device could be made available
to the HVM guest by including the
config file entry
<PRE>
    usbdevice='host:04be:310b'
</PRE>

<P>
It is also possible to
enable access to a USB
device dynamically through
the control window.
The control window command
<PRE>
    usb_add host:vid:pid
</PRE>
will also allow access to a
USB device with vendor id
<B>vid</B>
and product id
<B>pid</B>.
</LI>
<LI>Through the
<TT>/proc</TT> file system.
The contents of the pseudo file
<TT>/proc/bus/usb/devices</TT>
can also be used to identify
vendor and product ids.
Looking at this file,
the line starting with
<B>P:</B>
has a field
<B>Vendor</B>
giving the vendor id and
another field
<B>ProdID</B>
giving the product id.
The contents of
<TT>/proc/bus/usb/devices</TT>
for the example mouse is as
follows:
<PRE>
T:  Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#=  3 Spd=1.5 MxCh= 0
D:  Ver= 2.00 Cls=00(&gt;ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=04b3 ProdID=310b Rev= 1.60
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=02 Driver=(none)
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=10ms
</PRE>
Note that the
<B>P:</B>
line correctly identifies the
vendor id and product id
for this mouse as
<B>04b3:310b</B>.
</LI>
</OL>
There is one other issue to
be aware of when accessing a
physical USB device from the guest.
The Dom0 kernel must not have
a device driver loaded for
the device that the guest wishes
to access.
This means that the Dom0
kernel must not have that
device driver compiled into
the kernel or,
if using modules,
that driver module must
not be loaded.
Note that this is the device
specific USB driver that must
not be loaded,
either the
<B>UHCI</B>
or
<B>OHCI</B>
USB controller driver must
still be loaded.

<P>
Going back to the USB mouse
as an example,
if <B>lsmod</B>
gives the output:

<P>
<PRE>
Module                  Size  Used by
usbmouse                4128  0 
usbhid                 28996  0
uhci_hcd               35409  0
</PRE>

<P>
then the USB mouse is being
used by the Dom0 kernel and is
not available to the guest.
Executing the command
<B>rmmod usbhid</B><A NAME="tex2html18"
  HREF="#foot1329"><SUP>A.2</SUP></A>will remove the USB mouse
driver from the Dom0 kernel
and the mouse will now be
accessible by the HVM guest.

<P>
Be aware the the Linux USB
hotplug system will reload
the drivers if a USB device
is removed and plugged back
in.
This means that just unloading
the driver module might not
be sufficient if the USB device
is removed and added back.
A more reliable technique is
to first
<B>rmmod</B>
the driver and then rename the
driver file in the
<TT>/lib/modules</TT>
directory,
just to make sure it doesn't get
reloaded.
</DD>
</DL>

<P>

<H2><A NAME="SECTION04345000000000000000">
A.4.5 Destroy HVM guests</A>
</H2>
HVM guests can be destroyed in the same way as can paravirtualized guests. We recommend that you shut-down the guest using the guest OS' provided method, for Linux, type the command

<P>
<FONT SIZE="-1"><TT>poweroff</TT></FONT> 

<P>
in the HVM guest's console, for Windows use Start -&gt; Shutdown first to prevent
data loss. Depending on the configuration the guest will be automatically
destroyed, otherwise execute the command 

<P>
<FONT SIZE="-1"><TT>xm destroy <I>vmx_guest_id</I> </TT></FONT> 

<P>
at the Domain0 console.

<P>

<H2><A NAME="SECTION04346000000000000000">
A.4.6 HVM window (X or VNC) Hot Key</A>
</H2>
If you are running in the X environment after creating a HVM guest, an X window is created. There are several hot keys for control of the HVM guest that can be used in the window.

<P>
<B>Ctrl+Alt+2</B> switches from guest VGA window to the control window. Typing <FONT SIZE="-1"><TT>help </TT></FONT> shows the control commands help. For example, 'q' is the command to destroy the HVM guest.
<BR><B>Ctrl+Alt+1</B> switches back to HVM guest's VGA.
<BR><B>Ctrl+Alt+3</B> switches to serial port output. It captures serial output from the HVM guest. It works only if the HVM guest was configured to use the serial port. 
<BR>
<P>

<H1><A NAME="SECTION04400000000000000000">
B. Vnets - Domain Virtual Networking</A>
</H1>

<P>
Xen optionally supports virtual networking for domains using <EM>vnets</EM>.
These emulate private LANs that domains can use. Domains on the same
vnet can be hosted on the same machine or on separate machines, and the
vnets remain connected if domains are migrated. Ethernet traffic 
on a vnet is tunneled inside IP packets on the physical network. A vnet is a virtual
network and addressing within it need have no relation to addressing on 
the underlying physical network. Separate vnets, or vnets and the physical network,
can be connected using domains with more than one network interface and
enabling IP forwarding or bridging in the usual way.

<P>
Vnet support is included in <TT>xm</TT> and xend:
<PRE>
# xm vnet-create &lt;config&gt;
</PRE>
creates a vnet using the configuration in the file <code>&lt;config&gt;</code>.
When a vnet is created its configuration is stored by xend and the vnet persists until it is
deleted using
<PRE>
# xm vnet-delete &lt;vnetid&gt;
</PRE>
The vnets xend knows about are listed by
<PRE>
# xm vnet-list
</PRE>
More vnet management commands are available using the
<TT>vn</TT> tool included in the vnet distribution.

<P>
The format of a vnet configuration file is
<PRE>
(vnet (id       &lt;vnetid&gt;)
      (bridge   &lt;bridge&gt;)
      (vnetif   &lt;vnet interface&gt;)
      (security &lt;level&gt;))
</PRE>
White space is not significant. The parameters are:

<UL>
<LI><code>&lt;vnetid&gt;</code>: vnet id, the 128-bit vnet identifier. This can be given
    as 8 4-digit hex numbers separated by colons, or in short form as a single 4-digit hex number.
    The short form is the same as the long form with the first 7 fields zero.
    Vnet ids must be non-zero and id 1 is reserved.

<P>
</LI>
<LI><code>&lt;bridge&gt;</code>: the name of a bridge interface to create for the vnet. Domains
    are connected to the vnet by connecting their virtual interfaces to the bridge.
    Bridge names are limited to 14 characters by the kernel.

<P>
</LI>
<LI><code>&lt;vnetif&gt;</code>: the name of the virtual interface onto the vnet (optional). The
    interface encapsulates and decapsulates vnet traffic for the network and is attached
    to the vnet bridge. Interface names are limited to 14 characters by the kernel.

<P>
</LI>
<LI><code>&lt;level&gt;</code>: security level for the vnet (optional). The level may be one of 
      
<UL>
<LI><code>none</code>: no security (default). Vnet traffic is in clear on the network.
</LI>
<LI><code>auth</code>: authentication. Vnet traffic is authenticated using IPSEC
           ESP with hmac96.
</LI>
<LI><code>conf</code>: confidentiality. Vnet traffic is authenticated and encrypted
           using IPSEC ESP with hmac96 and AES-128.
      
</LI>
</UL>
      Authentication and confidentiality are experimental and use hard-wired keys at present.
</LI>
</UL>
When a vnet is created its configuration is stored by xend and the vnet persists until it is
deleted using <TT>xm vnet-delete &lt;vnetid&gt;</TT>. The interfaces and bridges used by vnets
are visible in the output of <TT>ifconfig</TT> and <TT>brctl show</TT>.

<P>

<H1><A NAME="SECTION04410000000000000000">
B.1 Example</A>
</H1>
If the file <TT>vnet97.sxp</TT> contains
<PRE>
(vnet (id 97) (bridge vnet97) (vnetif vnif97)
      (security none))
</PRE>
Then <TT>xm vnet-create vnet97.sxp</TT> will define a vnet with id 97 and no security.
The bridge for the vnet is called vnet97 and the virtual interface for it is vnif97.
To add an interface on a domain to this vnet set its bridge to vnet97
in its configuration. In Python:
<PRE>
vif="bridge=vnet97"
</PRE>
In sxp:
<PRE>
(dev (vif (mac aa:00:00:01:02:03) (bridge vnet97)))
</PRE>
Once the domain is started you should see its interface in the output of <TT>brctl show</TT>
under the ports for <TT>vnet97</TT>.

<P>
To get best performance it is a good idea to reduce the MTU of a domain's interface
onto a vnet to 1400. For example using <TT>ifconfig eth0 mtu 1400</TT> or putting
<TT>MTU=1400</TT> in <TT>ifcfg-eth0</TT>.
You may also have to change or remove cached config files for eth0 under
<TT>/etc/sysconfig/networking</TT>. Vnets work anyway, but performance can be reduced
by IP fragmentation caused by the vnet encapsulation exceeding the hardware MTU.

<P>

<H1><A NAME="SECTION04420000000000000000">
B.2 Installing vnet support</A>
</H1>
Vnets are implemented using a kernel module, which needs to be loaded before
they can be used. You can either do this manually before starting xend, using the
command <TT>vn insmod</TT>, or configure xend to use the <TT>network-vnet</TT>
script in the xend configuration file <TT>/etc/xend/xend-config.sxp</TT>:
<PRE>
(network-script        network-vnet)
</PRE>
This script insmods the module and calls the <TT>network-bridge</TT> script.

<P>
The vnet code is not compiled and installed by default.
To compile the code and install on the current system
use <TT>make install</TT> in the root of the vnet source tree,
<TT>tools/vnet</TT>. It is also possible to install to an installation
directory using <TT>make dist</TT>. See the <TT>Makefile</TT> in
the source for details.

<P>
The vnet module creates vnet interfaces <TT>vnif0002</TT>,
<TT>vnif0003</TT> and <TT>vnif0004</TT> by default. You can test that
vnets are working by configuring IP addresses on these interfaces
and trying to ping them across the network. For example, using machines
hostA and hostB:
<PRE>
hostA# ifconfig vnif0004 192.0.2.100 up
hostB# ifconfig vnif0004 192.0.2.101 up
hostB# ping 192.0.2.100
</PRE>

<P>
The vnet implementation uses IP multicast to discover vnet interfaces, so
all machines hosting vnets must be reachable by multicast. Network switches
are often configured not to forward multicast packets, so this often
means that all machines using a vnet must be on the same LAN segment,
unless you configure vnet forwarding.

<P>
You can test multicast coverage by pinging the vnet multicast address:
<PRE>
# ping -b 224.10.0.1
</PRE>
You should see replies from all machines with the vnet module running.
You can see if vnet packets are being sent or received by dumping traffic
on the vnet UDP port:
<PRE>
# tcpdump udp port 1798
</PRE>

<P>
If multicast is not being forwarded between machines you can configure
multicast forwarding using vn. Suppose we have machines hostA on 192.0.2.200
and hostB on 192.0.2.211 and that multicast is not forwarded between them.
We use vn to configure each machine to forward to the other:
<PRE>
hostA# vn peer-add hostB
hostB# vn peer-add hostA
</PRE>
Multicast forwarding needs to be used carefully - you must avoid creating forwarding
loops. Typically only one machine on a subnet needs to be configured to forward,
as it will forward multicasts received from other machines on the subnet.

<P>

<H1><A NAME="SECTION04500000000000000000">
C. Glossary of Terms</A>
</H1>

<P>
<DL>
<DT><STRONG>Domain</STRONG></DT>
<DD>A domain is the execution context that contains a
  running <B>virtual machine</B>.  The relationship between virtual
  machines and domains on Xen is similar to that between programs and
  processes in an operating system: a virtual machine is a persistent
  entity that resides on disk (somewhat like a program).  When it is
  loaded for execution, it runs in a domain.  Each domain has a <B>    domain ID</B>.

<P>
</DD>
<DT><STRONG>Domain 0</STRONG></DT>
<DD>The first domain to be started on a Xen machine.
  Domain 0 is responsible for managing the system.

<P>
</DD>
<DT><STRONG>Domain ID</STRONG></DT>
<DD>A unique identifier for a <B>domain</B>, analogous to
  a process ID in an operating system.

<P>
</DD>
<DT><STRONG>Full virtualization</STRONG></DT>
<DD>An approach to virtualization which
  requires no modifications to the hosted operating system, providing
  the illusion of a complete system of real hardware devices.

<P>
</DD>
<DT><STRONG>Hypervisor</STRONG></DT>
<DD>An alternative term for <B>VMM</B>, used because it
  means `beyond supervisor', since it is responsible for managing
  multiple `supervisor' kernels.

<P>
</DD>
<DT><STRONG>Live migration</STRONG></DT>
<DD>A technique for moving a running virtual machine
  to another physical host, without stopping it or the services
  running on it.

<P>
</DD>
<DT><STRONG>Paravirtualization</STRONG></DT>
<DD>An approach to virtualization which requires
  modifications to the operating system in order to run in a virtual
  machine.  Xen uses paravirtualization but preserves binary
  compatibility for user space applications.

<P>
</DD>
<DT><STRONG>Shadow pagetables</STRONG></DT>
<DD>A technique for hiding the layout of machine
  memory from a virtual machine's operating system.  Used in some <B>  VMMs</B> to provide the illusion of contiguous physical memory, in
  Xen this is used during <B>live migration</B>.

<P>
</DD>
<DT><STRONG>Virtual Block Device</STRONG></DT>
<DD>Persistent storage available to a virtual
  machine, providing the abstraction of an actual block storage device.
  <B>VBD</B>s may be actual block devices, filesystem images, or
  remote/network storage.

<P>
</DD>
<DT><STRONG>Virtual Machine</STRONG></DT>
<DD>The environment in which a hosted operating
  system runs, providing the abstraction of a dedicated machine.  A
  virtual machine may be identical to the underlying hardware (as in
  <B>full virtualization</B>, or it may differ, as in <B>  paravirtualization</B>).

<P>
</DD>
<DT><STRONG>VMM</STRONG></DT>
<DD>Virtual Machine Monitor - the software that allows multiple
  virtual machines to be multiplexed on a single physical machine.

<P>
</DD>
<DT><STRONG>Xen</STRONG></DT>
<DD>Xen is a paravirtualizing virtual machine monitor,
  developed primarily by the Systems Research Group at the University
  of Cambridge Computer Laboratory.

<P>
</DD>
<DT><STRONG>XenLinux</STRONG></DT>
<DD>A name for the port of the Linux kernel that
  runs on Xen.

<P>
</DD>
</DL>

<P>
<BR><HR><H4>Footnotes</H4>
<DL>
<DT><A NAME="foot46">... 32</A><A
 HREF="user.html#tex2html1"><SUP>1.1</SUP></A></DT>
<DD>IA64 supports up to 64 virtual CPUs per guest virtual machine

</DD>
<DT><A NAME="foot63">...
2003</A><A
 HREF="user.html#tex2html2"><SUP>1.2</SUP></A></DT>
<DD><TT>http://www.cl.cam.ac.uk/netos/papers/2003-xensosp.pdf</TT>

</DD>
<DT><A NAME="foot1238">... bridge-utils</A><A
 HREF="user.html#tex2html3"><SUP>2.1</SUP></A></DT>
<DD>Available from <TT>http://bridge.sourceforge.net</TT>

</DD>
<DT><A NAME="foot1239">... system</A><A
 HREF="user.html#tex2html4"><SUP>2.2</SUP></A></DT>
<DD>Available from <TT>http://linux-hotplug.sourceforge.net/</TT>

</DD>
<DT><A NAME="foot1240">... system</A><A
 HREF="user.html#tex2html5"><SUP>2.3</SUP></A></DT>
<DD>See <TT>http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html/</TT>

</DD>
<DT><A NAME="foot1247">... kernel</A><A
 HREF="user.html#tex2html7"><SUP>2.4</SUP></A></DT>
<DD>If you boot without first
  disabling TLS, you will get a warning message during the boot process.
  In this case, simply perform the rename after the machine is up and
  then run <TT>/sbin/ldconfig</TT> to make it take effect.

</DD>
<DT><A NAME="foot400">... stack</A><A
 HREF="user.html#tex2html9"><SUP>5.1</SUP></A></DT>
<DD>Trousers TSS stack: http://sourceforge.net/projects/trousers

</DD>
<DT><A NAME="foot1321">... file.</A><A
 HREF="user.html#tex2html17"><SUP>A.1</SUP></A></DT>
<DD>
There is an alternate
way of specifying a USB device that
uses the syntax
<B>host:bus.addr</B>
but this syntax suffers from
a major problem that makes
it effectively useless.
The problem is that the
<B>addr</B>
portion of this address
changes every time the USB device
is plugged into the system.
For this reason this addressing
scheme is not recommended and
will not be documented further.


</DD>
<DT><A NAME="foot1329">... usbhid</A><A
 HREF="user.html#tex2html18"><SUP>A.2</SUP></A></DT>
<DD>
Turns out the
<B>usbhid</B>
driver is the significant
one for the USB mouse,
the presence or absence of
the module
<B>usbmouse</B>
has no effect on whether or
not the guest can see a USB mouse.

</DD>
</DL>
<BR><HR>
<ADDRESS>

2011-10-23
</ADDRESS>
</BODY>
</HTML>