ia64/xen-unstable

changeset 8542:bb62be2a5080

Merged.
author emellor@leeni.uk.xensource.com
date Tue Jan 10 14:38:22 2006 +0000 (2006-01-10)
parents 0a69deed5e1f fa3a37839eb7
children 256bd634e2fc
files tools/libxc/xc_linux_build.c
line diff
     1.1 --- a/docs/src/user.tex	Tue Jan 10 14:37:25 2006 +0000
     1.2 +++ b/docs/src/user.tex	Tue Jan 10 14:38:22 2006 +0000
     1.3 @@ -1885,6 +1885,220 @@ mailing lists and subscription informati
     1.4  
     1.5  \appendix
     1.6  
     1.7 +\chapter{Unmodified (VMX) guest domains in Xen with Intel\textregistered Virtualization Technology (VT)}
     1.8 +
     1.9 +Xen supports guest domains running unmodified Guest operating systems using Virtualization Technology (VT) available on recent Intel Processors. More information about the Intel Virtualization Technology implementing Virtual Machine Extensions (VMX) in the processor is available on the Intel website at \\
    1.10 + {\small {\tt http://www.intel.com/technology/computing/vptech}}
    1.11 +
    1.12 +\section{Building Xen with VT support}
    1.13 +
    1.14 +The following packages need to be installed in order to build Xen with VT support. Some Linux distributions do not provide these packages by default.
    1.15 +
    1.16 +\begin{tabular}{lp{11.0cm}}
    1.17 +{\bfseries Package} & {\bfseries Description} \\
    1.18 +
    1.19 +dev86 & The dev86 package provides an assembler and linker for real mode 80x86 instructions. You need to have this package installed in order to build the BIOS code which runs in (virtual) real mode. 
    1.20 +
    1.21 +If the dev86 package is not available on the x86\_64 distribution, you can install the i386 version of it. The dev86 rpm package for various distributions can be found at {\scriptsize {\tt http://www.rpmfind.net/linux/rpm2html/search.php?query=dev86\&submit=Search}} \\
    1.22 +
    1.23 +LibVNCServer & The unmodified guest's VGA display, keyboard, and mouse are virtualized using the vncserver library provided by this package. You can get the sources of libvncserver from {\small {\tt http://sourceforge.net/projects/libvncserver}}. Build and install the sources on the build system to get the libvncserver library. The 0.8pre version of libvncserver is currently working well with Xen.\\
    1.24 +
    1.25 +SDL-devel, SDL & Simple DirectMedia Layer (SDL) is another way of virtualizing the unmodified guest console. It provides an X window for the guest console. 
    1.26 +
    1.27 +If the SDL and SDL-devel packages are not installed by default on the build system, they can be obtained from  {\scriptsize {\tt http://www.rpmfind.net/linux/rpm2html/search.php?query=SDL\&submit=Search}}
    1.28 +, {\scriptsize {\tt http://www.rpmfind.net/linux/rpm2html/search.php?query=SDL-devel\&submit=Search}} \\
    1.29 +
    1.30 +\end{tabular}
    1.31 +
    1.32 +\section{Configuration file for unmodified VMX guests}
    1.33 +
    1.34 +The Xen installation includes a sample configuration file, {\small {\tt /etc/xen/xmexample.vmx}}. There are comments describing all the options. In addition to the common options that are the same as those for paravirtualized guest configurations, VMX guest configurations have the following settings:
    1.35 +
    1.36 +\begin{tabular}{lp{11.0cm}}
    1.37 +
    1.38 +{\bfseries Parameter} & {\bfseries Description} \\
    1.39 +
    1.40 +kernel &        The VMX firmware loader, {\small {\tt /usr/lib/xen/boot/vmxloader}}\\
    1.41 +
    1.42 +builder &       The domain build function. The VMX domain uses the vmx builder.\\
    1.43 +
    1.44 +acpi & Enable VMX guest ACPI, default=0 (disabled)\\
    1.45 +
    1.46 +apic & Enable VMX guest APIC, default=0 (disabled)\\
    1.47 +
    1.48 +vif     & Optionally defines MAC address and/or bridge for the network interfaces. Random MACs are assigned if not given. {\small {\tt type=ioemu}} means ioemu is used to virtualize the VMX NIC. If no type is specified, vbd is used, as with paravirtualized guests.\\
    1.49 +
    1.50 +disk & Defines the disk devices you want the domain to have access to, and what you want them accessible as. If using a physical device as the VMX guest's disk, each disk entry is of the form 
    1.51 +
    1.52 +{\small {\tt phy:UNAME,ioemu:DEV,MODE,}}
    1.53 +
    1.54 +where UNAME is the device, DEV is the device name the domain will see, and MODE is r for read-only, w for read-write. ioemu means the disk will use ioemu to virtualize the VMX disk. If not adding ioemu, it uses vbd like paravirtualized guests.
    1.55 +
    1.56 +If using disk image file, its form should be like 
    1.57 +
    1.58 +{\small {\tt file:FILEPATH,ioemu:DEV,MODE}}
    1.59 +
    1.60 +If using more than one disk, there should be a comma between each disk entry. For example:
    1.61 +
    1.62 +{\scriptsize {\tt disk = ['file:/var/images/image1.img,ioemu:hda,w', 'file:/var/images/image2.img,ioemu:hdb,w']}}\\
    1.63 +
    1.64 +cdrom   & Disk image for CD-ROM. The default is {\small {\tt /dev/cdrom}} for Domain0. Inside the VMX domain, the CD-ROM will available as device {\small {\tt /dev/hdc}}. The entry can also point to an ISO file.\\
    1.65 +
    1.66 +boot & Boot from floppy (a), hard disk (c) or CD-ROM (d). For example, to boot from CD-ROM, the entry should be:
    1.67 +
    1.68 +boot='d'\\
    1.69 +
    1.70 +device\_model & The device emulation tool for VMX guests. This parameter should not be changed.\\
    1.71 +
    1.72 +sdl &   Enable SDL library for graphics, default = 0 (disabled)\\
    1.73 +
    1.74 +vnc &   Enable VNC library for graphics, default = 1 (enabled)\\
    1.75 +
    1.76 +vncviewer &     Enable spawning of the vncviewer (only valid when vnc=1), default = 1 (enabled)
    1.77 +
    1.78 +If vnc=1 and vncviewer=0, user can use vncviewer to manually connect VMX from remote. For example:
    1.79 +
    1.80 +{\small {\tt vncviewer domain0\_IP\_address:VMX\_domain\_id}} \\
    1.81 +
    1.82 +ne2000 &        Enable ne2000, default = 0 (disabled; use pcnet)\\
    1.83 +
    1.84 +serial &        Enable redirection of VMX serial output to pty device\\
    1.85 +
    1.86 +localtime &     Set the real time clock to local time [default=0, that is, set to UTC].\\
    1.87 +
    1.88 +enable-audio &  Enable audio support. This is under development.\\
    1.89 +
    1.90 +full-screen     & Start in full screen. This is under development.\\
    1.91 +
    1.92 +nographic &     Another way to redirect serial output. If enabled, no 'sdl' or 'vnc' can work. Not recommended.\\
    1.93 +
    1.94 +\end{tabular}
    1.95 +
    1.96 +
    1.97 +\section{Creating virtual disks from scratch}
    1.98 +\subsection{Using physical disks}
    1.99 +If you are using a physical disk or physical disk partition, you need to install a Linux OS on the disk first. Then the boot loader should be installed in the correct place. For example {\small {\tt dev/sda}} for booting from the whole disk, or {\small {\tt /dev/sda1}} for booting from partition 1.
   1.100 +
   1.101 +\subsection{Using disk image files}
   1.102 +You need to create a large empty disk image file first; then, you need to install a Linux OS onto it. There are two methods you can choose. One is directly installing it using a VMX guest while booting from the OS installation CD-ROM. The other is copying an installed OS into it. The boot loader will also need to be installed.
   1.103 +
   1.104 +\subsubsection*{To create the image file:}
   1.105 +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).
   1.106 +
   1.107 +{\small {\tt \# dd if=/dev/zero of=hd.img bs=1M count=1 seek=1023}}
   1.108 +
   1.109 +\subsubsection*{To directly install Linux OS into an image file using a VMX guest:}
   1.110 +
   1.111 +Install Xen and create VMX with the original image file with booting from CD-ROM. Then it is just like a normal Linux OS installation. The VMX configuration file should have these two entries before creating:
   1.112 +
   1.113 +{\small {\tt cdrom='/dev/cdrom'
   1.114 +boot='d'}}
   1.115 +
   1.116 +If this method does not succeed, you can choose the following method of copying an installed Linux OS into an image file.
   1.117 +
   1.118 +\subsubsection*{To copy a installed OS into an image file:}
   1.119 +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.
   1.120 +
   1.121 +\begin{enumerate}
   1.122 +\item {\bfseries Install a normal Linux OS on the host machine}\\
   1.123 +You can choose any way to install Linux, such as using yum to install Red Hat Linux or YAST to install Novell SuSE Linux. The rest of this example assumes the Linux OS is installed in {\small {\tt /var/guestos/}}.
   1.124 +
   1.125 +\item {\bfseries Make the partition table}\\
   1.126 +The image file will be treated as hard disk, so you should make the partition table in the image file. For example:
   1.127 +
   1.128 +{\scriptsize {\tt \# losetup /dev/loop0 hd.img\\
   1.129 +\# fdisk -b 512 -C 4096 -H 16 -S 32 /dev/loop0\\
   1.130 +press 'n' to add new partition\\
   1.131 +press 'p' to choose primary partition\\
   1.132 +press '1' to set partition number\\
   1.133 +press "Enter" keys to choose default value of "First Cylinder" parameter.\\
   1.134 +press "Enter" keys to choose default value of "Last Cylinder" parameter.\\
   1.135 +press 'w' to write partition table and exit\\
   1.136 +\# losetup -d /dev/loop0}}
   1.137 +
   1.138 +\item {\bfseries Make the file system and install grub}\\
   1.139 +{\scriptsize {\tt \# ln -s /dev/loop0 /dev/loop\\
   1.140 +\# losetup /dev/loop0 hd.img\\
   1.141 +\# losetup -o 16384 /dev/loop1 hd.img\\
   1.142 +\# mkfs.ext3 /dev/loop1\\
   1.143 +\# mount /dev/loop1 /mnt\\
   1.144 +\# mkdir -p /mnt/boot/grub\\
   1.145 +\# cp /boot/grub/stage* /boot/grub/e2fs\_stage1\_5 /mnt/boot/grub\\
   1.146 +\# umount /mnt\\
   1.147 +\# grub\\
   1.148 +grub> device (hd0) /dev/loop\\
   1.149 +grub> root (hd0,0)\\
   1.150 +grub> setup (hd0)\\
   1.151 +grub> quit\\
   1.152 +\# rm /dev/loop\\
   1.153 +\# losetup -d /dev/loop0\\
   1.154 +\# losetup -d /dev/loop1}}
   1.155 +
   1.156 +The {\small {\tt losetup}} option {\small {\tt -o 16384}} skips the partition table in the image file. It is the number of sectors times 512. We need {\small {\tt /dev/loop}} because grub is expecting a disk device \emph{name}, where \emph{name} represents the entire disk and \emph{name1} represents the first partition.
   1.157 +
   1.158 +\item {\bfseries Copy the OS files to the image}\\ 
   1.159 +If you have Xen installed, you can easily use {\small {\tt lomount}} instead of {\small {\tt losetup}} and {\small {\tt mount}} when coping files to some partitions. {\small {\tt lomount}} just needs the partition information.
   1.160 +
   1.161 +{\scriptsize {\tt \# lomount -t ext3 -diskimage hd.img -partition 1 /mnt/guest\\
   1.162 +\# cp -ax /var/guestos/\{root,dev,var,etc,usr,bin,sbin,lib\} /mnt/guest\\
   1.163 +\# mkdir /mnt/guest/\{proc,sys,home,tmp\}}}
   1.164 +
   1.165 +\item {\bfseries Edit the {\small {\tt /etc/fstab}} of the guest image}\\
   1.166 +The fstab should look like this:
   1.167 +
   1.168 +{\scriptsize {\tt \# vim /mnt/guest/etc/fstab\\
   1.169 +/dev/hda1       /               ext3            defaults 1 1\\
   1.170 +none            /dev/pts        devpts  gid=5,mode=620 0 0\\
   1.171 +none            /dev/shm        tmpfs           defaults 0 0\\
   1.172 +none            /proc           proc            defaults 0 0\\
   1.173 +none            /sys            sysfs           efaults 0 0}}
   1.174 +
   1.175 +\item {\bfseries umount the image file}\\
   1.176 +{\small {\tt \# umount /mnt/guest}}
   1.177 +\end{enumerate}
   1.178 +
   1.179 +Now, the guest OS image {\small {\tt hd.img}} is ready. You can also reference {\small {\tt http://free.oszoo.org}} for quickstart images. But make sure to install the boot loader.
   1.180 +
   1.181 +\subsection{Install Windows into an Image File using a VMX guest}
   1.182 +In order to install a Windows OS, you should keep {\small {\tt acpi=0}} in your VMX configuration file.
   1.183 +
   1.184 +\section{VMX Guests}
   1.185 +\subsection{Editing the Xen VMX config file}
   1.186 +Make a copy of the example VMX configuration file {\small {\tt /etc/xen/xmeaxmple.vmx}} and edit the line that reads
   1.187 +
   1.188 +{\small {\tt disk = [ 'file:/var/images/\emph{guest.img},ioemu:hda,w' ]}}
   1.189 +
   1.190 +replacing \emph{guest.img} with the name of the guest OS image file you just made.
   1.191 +
   1.192 +\subsection{Creating VMX guests}
   1.193 +Simply follow the usual method of creating the guest, using the -f parameter and providing the filename of your VMX configuration file:\\
   1.194 +
   1.195 +{\small {\tt \# xend start\\
   1.196 +\# xm create /etc/xen/vmxguest.vmx}}
   1.197 +
   1.198 +In the default configuration, VNC is on and SDL is off. Therefore VNC windows will open when VMX guests are created. If you want to use SDL to create VMX guests, set {\small {\tt sdl=1}} in your VMX configuration file. You can also turn off VNC by setting {\small {\tt vnc=0}}.
   1.199 + 
   1.200 +\subsection{Destroy VMX guests}
   1.201 +VMX guests can be destroyed in the same way as can paravirtualized guests. We recommend that you type the command 
   1.202 +
   1.203 +{\small {\tt poweroff}} 
   1.204 +
   1.205 +in the VMX guest's console first to prevent data loss. Then execute the command 
   1.206 +
   1.207 +{\small {\tt xm destroy \emph{vmx\_guest\_id} }} 
   1.208 +
   1.209 +at the Domain0 console.
   1.210 +
   1.211 +\subsection{VMX window (X or VNC) Hot Key}
   1.212 +If you are running in the X environment after creating a VMX guest, an X window is created. There are several hot keys for control of the VMX guest that can be used in the window.
   1.213 + 
   1.214 +{\bfseries Ctrl+Alt+2} switches from guest VGA window to the control window. Typing {\small {\tt help }} shows the control commands help. For example, 'q' is the command to destroy the VMX guest.\\
   1.215 +{\bfseries Ctrl+Alt+1} switches back to VMX guest's VGA.\\
   1.216 +{\bfseries Ctrl+Alt+3} switches to serial port output. It captures serial output from the VMX guest. It works only if the VMX guest was configured to use the serial port. \\
   1.217 +
   1.218 +\subsection{Save/Restore and Migration}
   1.219 +VMX guests currently cannot be saved and restored, nor migrated. These features are currently under active development.
   1.220 +
   1.221  %% Chapter Glossary of Terms moved to glossary.tex
   1.222  \chapter{Glossary of Terms}
   1.223  
     2.1 --- a/tools/guest-headers/Makefile	Tue Jan 10 14:37:25 2006 +0000
     2.2 +++ b/tools/guest-headers/Makefile	Tue Jan 10 14:38:22 2006 +0000
     2.3 @@ -2,6 +2,8 @@
     2.4  XEN_ROOT=../..
     2.5  linuxsparsetree = $(XEN_ROOT)/linux-2.6-xen-sparse
     2.6  
     2.7 +all:
     2.8 +
     2.9  check:
    2.10  
    2.11  install:
     3.1 --- a/tools/libxc/xc_linux_build.c	Tue Jan 10 14:37:25 2006 +0000
     3.2 +++ b/tools/libxc/xc_linux_build.c	Tue Jan 10 14:38:22 2006 +0000
     3.3 @@ -694,6 +694,7 @@ static int setup_guest(int xc_handle,
     3.4          start_info->mod_len      = initrd_len;
     3.5      }
     3.6      if (cmdline != NULL) {
     3.7 +    {
     3.8          strncpy((char *)start_info->cmd_line, cmdline, MAX_GUEST_CMDLINE);
     3.9          start_info->cmd_line[MAX_GUEST_CMDLINE-1] = '\0';
    3.10      } else
     4.1 --- a/tools/libxc/xg_private.c	Tue Jan 10 14:37:25 2006 +0000
     4.2 +++ b/tools/libxc/xg_private.c	Tue Jan 10 14:38:22 2006 +0000
     4.3 @@ -17,6 +17,9 @@ char *xc_read_kernel_image(const char *f
     4.4      char *image = NULL;
     4.5      unsigned int bytes;
     4.6  
     4.7 +    if ( filename == NULL )
     4.8 +        goto out;
     4.9 +
    4.10      if ( (kernel_fd = open(filename, O_RDONLY)) < 0 )
    4.11      {
    4.12          PERROR("Could not open kernel image");