HOWTO XEN
Un article de Gentoo Linux Wiki.
| Méthodes d'installation • CD Live • Noyau et matériel • Portables et Notebooks • Portage • Système • Réseaux et Services • Serveur X • Logiciels fréquemment utilisés • Autres |
Sommaire |
[modifier] Présentation
Xen est un superviseur de para-virtualisation. En d'autres termes xen ne simule pas le physique de la machine par un programme mais organise et ordonnance simplement les accés simultannés de différents systèmes sur une même machine physique. Les pertes de performances des machines virtuelles sont estimées en moyenne à 3% sur des processeurs prévu pour l'utilisation de Xen tel que les processeurs équipés des technologies Intel Virtualization Technology (VT) ou AMD Secure Virtual Machine (SVM). Vous pouvez même attribuer des partitions de votre disque dur à vos machines virtuelles afin d'augmenter leurs performances.
[modifier] Vocabulaire
- Domaine = un domaine est une machine virtuelle dans l'environnement Xen
- Domaine 0 = le domaine 0 est la machine virtuelle lancé au demarrage de l'ordinateur
- Domaine U = le terme Domaine U représente l'ensemble des machines virtuelles qui ne sont pas le Domaine 0.
- Mode pont réseau = le mode pont réseau ou bridge relie plusieurs cartes réseaux (virtuelles ou non) entre elles par une sorte de cable virtuel.
- Virtual Machine = où VM représente un Domaine (environnement d'execution d'un systéme)
[modifier] Précisions
- Le domaine 0 est l'interface entre le materiel et les domaines U
- Il est conseillé que les systèmes linux sur les Dom U démarrent à l'aide du même noyau cela permet d'augmenter la performance et la compatibilité.
- vous devez spécifier dans le fichier de configuration de chacune de vos machines Xen une adresse MAC commençant par aa exemple: aa:00:00:00:00:01
- les options qui ne sont pas compilées dans le noyau Xen en Backend du Domaine 0 ne sont pas accesible dans les domaines U
- Vous pouvez définir des priorités d'execution entre les domaines
[modifier] Fonctionnement du réseau
Le fonctionnement du réseau virtuel est basé sur les bridges ou ponts réseau.
Chaque interface réseau de machine virtuelle eth0, eth1, ethX correspondant à une carte réseau virtuel nommé vifU.X ou U est le numéro du domaine et X le numéro de l'interface dans ce domaine.
Les bridges ou ponts réseau xenbr0, xenbr1, xenbrX ... représentent le cablage virtuel entre ces cartes.
Voici un schéma expliquant le fonctionnement :
[modifier] Installation
Si vous avez un processeur 32 bits, éditez votre fichier make.conf et ajoutez -mno-tls-direct-seg-refs à vos CFLAGS.
| Note: Le CFLAG '-mno-tls-direct-seg-refs' n'a pas de sens sur les systèmes 64bits. Pour ce type de système vous pouvez sauter la recompilation de tout le système, recompilez juste glibc |
Ensuite recompilez tout votre système avec ce nouveau flag :
emerge --emptytree --deep --ask --verbose world
(Vous devrez faire la même chose sur vos VM)
Démasquez Xen : Entrez les lignes suivantes et remplacez ~arch par votre architecture exemple: ~x86 ~amd64
| File: /etc/portage/package.keywords |
app-emulation/xen ~arch app-emulation/xen-tools ~arch sys-kernel/xen-sources ~arch |
Configurer les flags afin de compiler avec les options que vous désirez (- enlève l'option)
Cette exemple compile xen sans le support d'interface graphique:
Editez le fichier package.use et ajoutez:
| File: /etc/portage/package.use |
sys-kernel/xen-sources -build symlink hardened app-emulation/xen -hardened custom-cflags -debug -pae app-emulation/xen-tools -hardened custom-cflags -debug doc screen -sdl -vnc |
| Note: vous n'êtes pas obliger d'utiliser sdl et vnc si vous ne faite pas d'utilisation graphique. Par contre pour l'utilisation d'interface graphique sdl est obligatoire enlevez le - devant sdl |
| Note: Le flag Hardened pour Xen 3.0.2 ne compile pas (du moins sur architecture amd64) |
Sur amd64 vous devez aussi ajouter :
sys-devel/dev86
Installez Xen, le superviseur et les sources du noyau :
emerge -va app-emulation/xen app-emulation/xen-tools sys-kernel/xen-sources
Maintenant compilez le noyau pour le domaine0:
cd /usr/src/linux-2.*-xen make menuconfig
| Note: Xen conseil de pointer le noyau par défaut /usr/src/linux vers votre noyau xen sinon vous risquez d'avoir des problèmes.
Pour cela vous pouvez utiliser la commande kernel-config set linux-2.*-xen ou refaire le symlink avec ln -sf /usr/src/linux-2.*-xen /usr/src/linux |
Configurez les options suivantes :
| Configuration du noyau Linux : Xen kernel config (Domain 0) |
Processor type and features --->
[*] Enable Xen compatible kernel
XEN --->
[*] Privileged Guest (domain 0)
<*> PCI device backend driver
<*> Block-device backend driver
< > Block Tap support for backend driver (DANGEROUS)
<*> Network-device backend driver
[ ] Pipelined transmitter (DANGEROUS)
<*> Network-device loopback driver
< > TPM-device backend driver
< > Block-device frontend driver
<*> Network-device frontend driver
< > Block device tap driver
< > TPM-device frontend driver
[*] Scrub memory before freeing it to Xen
[ ] Disable serial port drivers
<*> Export Xen attributes in sysfs
Networking --->
Networking options --->
[*] IP: tunneling
[*] 802.1d Ethernet Bridging
|
| Note: Pensez a cocher le module tun/tap dans les network devices sinon les cartes réseaux ioemu sur les machines de type hvm ne foncionneront pas. Pensez aussi à activer le module en utilisant modprobe tun |
| Note: Si vous souhaitez que vos machines virtuelles obtiennent automatiquement une adresse ip sur votre réseau activez Network-device frontend driver dans le Dom0 la carte vif0.0 sera reliée aux cartes vifX.0 des machines virtuelles. Si vous souhaitez gérer un réseau privé entre les machines virtuelles décochez cette case.' |
Maintenant il faut le compiler puis le copier dans /boot :
make && make modules_install cp vmlinuz /boot/vmlinuz-2.6.x.y-xen0
Configurez maintenant Grub :
| File: /boot/grub/grub.conf |
title Xen 3.0 / Linux 2.6.x.y root (hd0,0) kernel /xen.gz dom0_mem=98M module /vmlinuz-2.6.x.y-xen0 root=/dev/md2 |
Rebootez avec ce noyau.
Si tout se passe bien, ajoutez xend au démarrage :
rc-update add xend default
| Note: Si vous utilisez ssh et l'adressage de vos machines virtuelles sur votre réseau, vous risquez d'avoir des pertes de connexion lors du lancemment de xend pour cela il faut redémarrer ssh aprés le lancemment de xend. Vous pouvez par exemple ajouter la dépendance xend dans /etc/init.d/sshd' |
[modifier] Configuration
[modifier] Réseau
Editez le fichier /etc/xen/xend-config.sxp.
| File: /etc/xen/xend-config.sxp |
# -*- sh -*- # # Xend configuration file. # # Les lignes commentées décrivent l'état par défaut de la ligne de configuration concerné. #(logfile /var/log/xend.log) #(loglevel DEBUG) #(xend-http-server no) #(xend-unix-server no) #(xend-tcp-xmlrpc-server no) #(xend-unix-xmlrpc-server yes) #(xend-relocation-server no) # Si vous souhaitez utiliser la migration des machines xen vous devez configurer vos machines pour # utiliser un disque système au travers du réseau comme NFS par exemple. # Sinon la machine qui est en mémoire va migrer mais elle ne trouvera plus son disque dur. #(xend-relocation-server yes) #(xend-unix-path /var/lib/xend/xend-socket) # Port xend pour l'interface HTTP, si xend-http-server vaut yes. #(xend-port 8000) # Port xen utilisé pour la relocation des machines virtuelles, si xend-relocation-server est # activé. #(xend-relocation-port 8002) # Adresse xend écoutée par l'interface HTTP, si xend-http-server est activé. # Spécifiez 'localhost' pour empécher les utilisations distantes. # Spécifiez '' (par default) pour autoriser tous types de connexion. #(xend-address '') #(xend-address localhost) # Adresse xend écoute pour les demandes de relocation des machines virtuelles, si # xend-relocation-server est activé. #(xend-relocation-address '') # The hosts allowed to talk to the relocation port. If this is empty (the # default), then all connections are allowed (assuming that the connection # arrives on a port and interface on which we are listening; see # xend-relocation-port and xend-relocation-address above). Otherwise, this # should be a space-separated sequence of regular expressions. Any host with # a fully-qualified domain name or an IP address that matches one of these # regular expressions will be accepted. # # For example: # (xend-relocation-hosts-allow '^localhost$ ^.*\.example\.org$') # #(xend-relocation-hosts-allow '') (xend-relocation-hosts-allow '^localhost$') # The limit (in kilobytes) on the size of the console buffer #(console-limit 1024) ## # Le mode bridgé réalise un pont (sorte de cable réseau logiciel) entre différentes # cartes réseau (virtuelles ou non) # Voici la configuration bridgé standard: # # dom0: fake eth0 -> vif0.0 -+ # | # bridge -> real eth0 -> the network # | # domU: fake eth0 -> vifN.0 -+ # ce système permet à vos machines virtuelles d'obtenir automatiquemment une adresse ip # à condition que vous attribuiez une adresse mac à chaque carte réseau eth0 de vos # machines virtuelles # # utilisez # #(network-script network-bridge) # # Votre carte réseau par defaut eth0 est utilisée comme passerelle pour les cartes des # machines virtuelles vers votre réseau local #si vous souhaitez spécifier une autre # carte réseau utilisez ceci # # (network-script 'network-bridge netdev=eth1') # # Le pont réseau par défaut est nommé xenbr0. Pour le renommer utilisez # # (network-script 'network-bridge bridge=<name>') # # It is possible to use the network-bridge script in more complicated # scenarios, such as having two outgoing interfaces, with two bridges, and # two fake interfaces per guest domain. To do things like this, write # yourself a wrapper script, and call network-bridge from it, as appropriate. # (network-script network-bridge) # The script used to control virtual interfaces. This can be overridden on a # per-vif basis when creating a domain or a configuring a new vif. The # vif-bridge script is designed for use with the network-bridge script, or # similar configurations. # # If you have overridden the bridge name using # (network-script 'network-bridge bridge=<name>') then you may wish to do the # same here. The bridge name can also be set when creating a domain or # configuring a new vif, but a value specified here would act as a default. # # Si vous utilisez un seul pont réseau (xenbr0) et que vous souhaitez que # vos domaineU soit automatiquemment # connectés à votre réseau local utilisez cette ligne # (vif-script vif-bridge) ## Use the following if network traffic is routed, as an alternative to the # settings for bridged networking given above. #(network-script network-route) #(vif-script vif-route) ## Use the following if network traffic is routed with NAT, as an alternative # to the settings for bridged networking given above. #(network-script network-nat) #(vif-script vif-nat) # Dom0 will balloon out when needed to free memory for domU. # dom0-min-mem is the lowest memory level (in MB) dom0 will get down to. # If dom0-min-mem=0, dom0 will never balloon out. (dom0-min-mem 196) # In SMP system, dom0 will use dom0-cpus # of CPUS # If dom0-cpus = 0, dom0 will take all cpus available #définit le nombre de processeurs réel qu'utilise le dom0 par défaut 0 signifie tous (dom0-cpus 0) # Whether to enable core-dumps when domains crash. #(enable-dump no) |
[modifier] Utilisation
[modifier] Installation Gentoo Domaine U
[modifier] Création Noyau Domaine U
Pour faire tourner des systèmes linux sur votre serveur xen vous devez dupliquer votre noyau xen.
cp -Rfv /usr/src/linux-2.*-xen /usr/src/linux-2.*-xenU
Utilisez exactemment la même configuration que votre domaine0 décochez simplement Privileged Guest (domain 0).
Pour éditer le menu du noyau tapez:
cd /usr/src/linux-2.*-xenU make menuconfig
| Configuration du noyau Linux : Xen kernel config (Domain U) |
Processor type and features --->
[*] Enable Xen compatible kernel
XEN --->
[ ] Privileged Guest (domain 0)
<*> PCI device backend driver
<*> Block-device backend driver
< > Block Tap support for backend driver (DANGEROUS)
<*> Network-device backend driver
[ ] Pipelined transmitter (DANGEROUS)
<*> Network-device loopback driver
< > TPM-device backend driver
< > Block-device frontend driver
<*> Network-device frontend driver
< > Block device tap driver
< > TPM-device frontend driver
[*] Scrub memory before freeing it to Xen
[ ] Disable serial port drivers
<*> Export Xen attributes in sysfs
Networking --->
Networking options --->
[*] IP: tunneling
[*] 802.1d Ethernet Bridging
|
Puis compilez le noyau pour les domaines U et placez le noyau domaine U dans boot.
make cp vmlinuz /boot/vmlinuz-2.6.x.y-xenU
[modifier] Fichier de configuration d'un domaine U
Vous devez faire un fichier de configuration par machine virtuelle que vous voulez lancer.
Voici un exemple pour une machine :
| File: /etc/xen/machineLinux |
# -*- mode: python; -*- #============================================================================ # Python configuration setup for 'xm create'. # This script sets the parameters used when a domain is created using 'xm create'. # You use a separate script for each domain you want to create, or # you can set the parameters for the domain on the xm command line. #============================================================================ #---------------------------------------------------------------------------- # Kernel image file. kernel = "/boot/vmlinuz-2.6.x.y-xenU" # Optional ramdisk. #ramdisk = "/boot/initrd.gz" # The domain build function. Default is 'linux'. #builder='linux' # Initial memory allocation (in megabytes) for the new domain. memory = 512 # A name for your domain. All domains must have different names. name = "machineLinux" # List of which CPUS this domain is allowed to use, default Xen picks #cpus = "" # leave to Xen to pick cpus = "0" # all vcpus run on CPU0 #cpus = "0-3,5,^1" # run on cpus 0,2,3,5 # Number of Virtual CPUS to use, default is 1 #vcpus = 1 #---------------------------------------------------------------------------- # Define network interfaces. # By default, no network interfaces are configured. You may have one created # with sensible defaults using an empty vif clause: # # vif = [ '' ] # # or optionally override backend, bridge, ip, mac, script, type, or vifname: # vous êtes obliger de spécifier une adresse mac commençant par aa pour que le réseau fonctionne vif = [ 'mac=aa:00:00:00:00:01' ] # # or more than one interface may be configured: # # vif = [ '', 'bridge=xenbr0' ] #vif = [ '' ] #---------------------------------------------------------------------------- # Define the disk devices you want the domain to have access to, and # what you want them accessible as. # Each disk entry is of the form phy:UNAME,DEV,MODE # 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. disk = [ 'file:/var/xen/machineLinux.img,hda1,w' ] #---------------------------------------------------------------------------- # Define to which TPM instance the user domain should communicate. # The vtpm entry is of the form 'instance=INSTANCE,backend=DOM' # where INSTANCE indicates the instance number of the TPM the VM # should be talking to and DOM provides the domain where the backend # is located. # Note that no two virtual machines should try to connect to the same # TPM instance. The handling of all TPM instances does require # some management effort in so far that VM configration files (and thus # a VM) should be associated with a TPM instance throughout the lifetime # of the VM / VM configuration file. The instance number must be # greater or equal to 1. #vtpm = [ 'instance=1,backend=0' ] #---------------------------------------------------------------------------- # Set the kernel command line for the new domain. # You only need to define the IP parameters and hostname if the domain's # IP config doesn't, e.g. in ifcfg-eth0 or via DHCP. # You can use 'extra' to set the runlevel and custom environment # variables used by custom rc scripts (e.g. VMID=, usr= ). # Set if you want dhcp to allocate the IP address. #ce system ne fonctionne pas en XEN 3.0.2 #dhcp="dhcp" # Set netmask. #netmask= # Set default gateway. #gateway= # Set the hostname. #hostname= "" # Set root device. root = "/dev/hda1 ro" # Root device for nfs. # vous devez impérativemment utiliser un disque dur NFS si vous souhaitez pouvoir migrer vos machines virtuels xen #durant leurs execution #root = "/dev/nfs" # The nfs server. #nfs_server = '169.254.1.0' # Root directory on the nfs server. #nfs_root = '/full/path/to/root/directory' # Sets runlevel 4. extra = "4" #---------------------------------------------------------------------------- # Configure the behaviour when a domain exits. There are three 'reasons' # for a domain to stop: poweroff, reboot, and crash. For each of these you # may specify: # # "destroy", meaning that the domain is cleaned up as normal; # "restart", meaning that a new domain is started in place of the old # one; # "preserve", meaning that no clean-up is done until the domain is # manually destroyed (using xm destroy, for example); or # "rename-restart", meaning that the old domain is not cleaned up, but is # renamed and a new domain started in its place. # # The default is # # on_poweroff = 'destroy' # on_reboot = 'restart' # on_crash = 'restart' # # For backwards compatibility we also support the deprecated option restart # # restart = 'onreboot' means on_poweroff = 'destroy' # on_reboot = 'restart' # on_crash = 'destroy' # # restart = 'always' means on_poweroff = 'restart' # on_reboot = 'restart' # on_crash = 'restart' # # restart = 'never' means on_poweroff = 'destroy' # on_reboot = 'destroy' # on_crash = 'destroy' #on_poweroff = 'destroy' #on_reboot = 'restart' #on_crash = 'restart' #============================================================================ |
[modifier] Création du disque dur système
nous allons créer un disque dur système de 4 Go :
dd if=/dev/zero of=/var/xen/machineLinux.img bs=1M seek=4095 count=1
Formattez le disque :
mkfs.ext3 /var/xen/machineLinux.img
Une fois le disque formatté l'installation de Gentoo est habituelle.
mkdir /mnt/gentoo mount -o loop /var/xen/machineLinux.img /mnt/gentoo cd /mnt/gentoo
Suivez le manuel d'installation à partir du désarchivage du stage 3 dans /mnt/gentoo.
| Note: Utilisez le même make file que votre Domaine 0 est conseillé. |
| Note: Sautez la partie concernant la configuration du noyau et le chargeur d'amorçage car le démarrage et le lancemment du noyau est fait par Xen en lisant le fichier de configuration machineLinux |
Une fois l'installation du système terminé, vous allez finir la configuration du noyau Xen.
cd /mnt/gentoo/usr/src cp -Rfv /usr/src/linux-2.*-xenU /mnt/gentoo/usr/src cd /mnt/gentoo/usr/src ln -sf linux-2.*-xenU linux cd /mnt/gentoo mount -t proc none proc mount -o bind /dev dev chroot . /bin/bash source /etc/profile env-update cd /usr/src/linux make modules_install exit cd / umount /mnt/gentoo/proc umount /mnt/gentoo/dev umount /mnt/gentoo
Voila votre disque virtuel est pret.
[modifier] Execution de la machine
Vous pouvez maintenant lancer la machine virtuelle
xm create machineLinux -c
| Note: Vous devez voir le démarrage de votre machine linux. Si vous avez activé le démarrage de l'interface net.eth0 au démarrage avec dhcpcd vous verrez une addresse ip attribuée par votre réseau. Lors du démarrage la carte eth0 de votre machine virtuelle s'ajoute automatiquemment dans le pont réseau xenbr0 sur le domaine 0. Vous pouvez le constater en tapant brctl show dans le Domaine 0. |
[modifier] Windows XP
| Note: Pour faire tourner Windows, vous devez avoir un processeur supportant la virtualisation matérielle.
Pour les processeurs Intel le flag vmx cat /proc/cpuinfo | grep vmx ou svm pour AMD cat /proc/cpuinfo | grep svm |
Nous allons créer un disque dur système de 4 Go :
dd if=/dev/zero of=/var/xen/machineWindows.img bs=1M seek=4095 count=1
Il faut maintenant créer le fichier de configuration du Domaine U :
| File: /etc/xen/winxp.hvm |
# -*- mode: python; -*- #============================================================================ # Python configuration setup for ‘xm create’. # This script sets the parameters used when a domain is created using ‘xm create’. # You use a separate script for each domain you want to create, or # you can set the parameters for the domain on the xm command line. #============================================================================ import os, re arch = os.uname()[4] if re.search(‘64’, arch): arch_libdir = ‘lib64’ else: arch_libdir = ‘lib’ #---------------------------------------------------------------------------- # Kernel image file. kernel = “/usr/lib/xen/boot/hvmloader” # The domain build function. HVM domain uses ‘hvm’. builder=’hvm’ # Initial memory allocation (in megabytes) for the new domain. memory = 512 # A name for your domain. All domains must have different names. name = “w2k3-001” vif = [ ‘type=ioemu, mac=aa:00:b0:00:00:11, bridge=xenbr0’ ] #---------------------------------------------------------------------------- # Define the disk devices you want the domain to have access to, and # what you want them accessible as. # Each disk entry is of the form phy:UNAME,DEV,MODE # 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. # This would be for using a QEMU qcow file as a virtual disk #disk = [ ‘file:/guests/1-w2k3/w2k3-demo-001.qcow,ioemu:hda,w’ ] # This is for using an LVM volume as a virtual disk disk = [ ‘phy:/dev/VG_Guests/w2k3-001,ioemu:hda,w’ ] # New stuff device_model = ‘/usr/’ + arch_libdir + ‘/xen/bin/qemu-dm’ #----------------------------------------------------------------------------- # Disk image for cdrom=”/tmp/WINDOWS_2003_STANDARD.ISO” #----------------------------------------------------------------------------- # boot on floppy (a), hard disk (c) or CD-ROM (d) boot=”d” #----------------------------------------------------------------------------- # write to temporary files instead of disk image files #snapshot=1 #---------------------------------------------------------------------------- # enable SDL library for graphics, default = 0 sdl=1 #---------------------------------------------------------------------------- # enable VNC library for graphics, default = 1 vnc=0 #---------------------------------------------------------------------------- # enable spawning vncviewer(only valid when vnc=1), default = 1 #vncviewer=1 vncviewer=0 #---------------------------------------------------------------------------- # no graphics, use serial port #nographic=0 #----------------------------------------------------------------------------- # serial port re-direct to pty deivce, /dev/pts/n # then xm console or minicom can connect #serial=’pty’ #---------------------------------------------------------------------------- # enable ne2000, default = 0(use pcnet) ne2000=0 #---------------------------------------------------------------------------- # #usb=1 #usbdevice=’tablet’ #----------------------------------------------------------------------------- # enable audio support #audio=1 #----------------------------------------------------------------------------- # set the real time clock to local time [default=0 i.e. set to utc] #localtime=1 #----------------------------------------------------------------------------- # start in full screen #full-screen=1 #stdvga=0 |
| Note:
Pour utiliser SDL vous devez avoir compilé xen et xen-tools avec le flag sdl. Mais vous devez aussi compiler SDL avec le flag X. Lancez la machine virtuel dans une interface graphique. |
| Note:
Pour utiliser VNC vous devez avoir compilé xen et xen-tools avec le flag vnc. Mais vous devez aussi compiler VNC avec le flag server. |
Mettez le CD d'installation de Windows XP dans le lecteur et lancez le domaine U :
xm create winxp.hvm
Vous pouvez maintenant installer Windows XP de maniére habituelle.
[modifier] Windows XP 64
| File: /etc/xen/winxp.hvm |
# -*- mode: python; -*-
#============================================================================
# Python configuration setup for 'xm create'.
# This script sets the parameters used when a domain is created using 'xm create'.
# You use a separate script for each domain you want to create, or
# you can set the parameters for the domain on the xm command line.
#============================================================================
import os, re
arch = os.uname()[4]
if re.search('64', arch):
arch_libdir = 'lib64'
else:
arch_libdir = 'lib'
#----------------------------------------------------------------------------
# Kernel image file.
kernel = "/usr/lib/xen/boot/hvmloader"
# The domain build function. HVM domain uses 'hvm'.
builder='hvm'
# Initial memory allocation (in megabytes) for the new domain.
#
# WARNING: Creating a domain with insufficient memory may cause out of
# memory errors. The domain needs enough memory to boot kernel
# and modules. Allocating less than 32MBs is not recommended.
memory = 512
# Shadow pagetable memory for the domain, in MB.
# Should be at least 2KB per MB of domain memory, plus a few MB per vcpu.
shadow_memory = 8
# A name for your domain. All domains must have different names.
name = "WindowsXP"
# 128-bit UUID for the domain. The default behavior is to generate a new UUID
# on each call to 'xm create'.
#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"
#-----------------------------------------------------------------------------
# The number of cpus guest platform has, default=1
vcpus=1
# Enable/disable HVM guest PAE, default=1 (enabled)
pae=1
# Enable/disable HVM guest ACPI, default=1 (enabled)
acpi=1
# Enable/disable HVM APIC mode, default=1 (enabled)
# Note that this option is ignored if vcpus > 1
apic=1
# List of which CPUS this domain is allowed to use, default Xen picks
#cpus = "" # leave to Xen to pick
#cpus = "0" # all vcpus run on CPU0
#cpus = "0-3,5,^1" # run on cpus 0,2,3,5
cpus = "0,1"
# Optionally define mac and/or bridge for the network interfaces.
# Random MACs are assigned if not given.
#vif = [ 'type=ioemu' ]
# type=ioemu specify the NIC is an ioemu device not netfront
vif = [ 'type=ioemu, bridge=xenbr0, mac=aa:bb:00:00:00:a0' ]
#----------------------------------------------------------------------------
# Define the disk devices you want the domain to have access to, and
# what you want them accessible as.
# Each disk entry is of the form phy:UNAME,DEV,MODE
# 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.
disk = [ 'phy:/dev/vg/WindowsXP,hda,w','phy:/dev/dvdrw,hdc:cdrom,r' ]
#'file:/usr/local/img/windows/Windows XP Professional with Service Pack 2 - French.iso,hdc:cdrom,r' ]
#----------------------------------------------------------------------------
# Configure the behaviour when a domain exits. There are three 'reasons'
# for a domain to stop: poweroff, reboot, and crash. For each of these you
# may specify:
#
# "destroy", meaning that the domain is cleaned up as normal;
# "restart", meaning that a new domain is started in place of the old
# one;
# "preserve", meaning that no clean-up is done until the domain is
# manually destroyed (using xm destroy, for example); or
# "rename-restart", meaning that the old domain is not cleaned up, but is
# renamed and a new domain started in its place.
#
# The default is
#
# on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# For backwards compatibility we also support the deprecated option restart
#
# restart = 'onreboot' means on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'destroy'
#
# restart = 'always' means on_poweroff = 'restart'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# restart = 'never' means on_poweroff = 'destroy'
# on_reboot = 'destroy'
# on_crash = 'destroy'
on_poweroff = 'restart'
on_reboot = 'restart'
on_crash = 'preserve'
#============================================================================
# New stuff
device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'
#device_model = "/usr/lib32/xen/bin/qemu-dm"
#-----------------------------------------------------------------------------
# boot on floppy (a), hard disk (c) or CD-ROM (d)
# default: hard disk, cd-rom, floppy
boot="dc"
#-----------------------------------------------------------------------------
# write to temporary files instead of disk image files
#snapshot=1
#----------------------------------------------------------------------------
# enable SDL library for graphics, default = 0
sdl=0
#----------------------------------------------------------------------------
# enable VNC library for graphics, default = 1
vnc=1
#----------------------------------------------------------------------------
# address that should be listened on for the VNC server if vnc is set.
# default is to use 'vnc-listen' setting from /etc/xen/xend-config.sxp
#vnclisten=""
#----------------------------------------------------------------------------
# set VNC display number, default = domid
#vncdisplay=1
#----------------------------------------------------------------------------
# try to find an unused port for the VNC server, default = 1
#vncunused=1
#----------------------------------------------------------------------------
# enable spawning vncviewer for domain's console
# (only valid when vnc=1), default = 0
#vncconsole=0
#----------------------------------------------------------------------------
# set password for domain's VNC console
# default is depents on vncpasswd in xend-config.sxp
#vncpasswd=''
#----------------------------------------------------------------------------
# no graphics, use serial port
#nographic=0
#----------------------------------------------------------------------------
# enable stdvga, default = 0 (use cirrus logic device model)
#stdvga=0
#-----------------------------------------------------------------------------
# serial port re-direct to pty deivce, /dev/pts/n
# then xm console or minicom can connect
serial='pty'
#-----------------------------------------------------------------------------
# enable sound card support, [sb16|es1370|all|..,..], default none
#soundhw='es1370'
#-----------------------------------------------------------------------------
# set the real time clock to local time [default=0 i.e. set to utc]
#localtime=1
#-----------------------------------------------------------------------------
# start in full screen
#fullscreen=1
#-----------------------------------------------------------------------------
# Enable USB support (specific devices specified at runtime through the
# monitor window)
usb=0
# Enable USB mouse support (only enable one of the following, `mouse' for
# PS/2 protocol relative mouse, `tablet' for
# absolute mouse)
#usbdevice='mouse'
#usbdevice='tablet'
#-----------------------------------------------------------------------------
# Set keyboard layout, default is en-us keyboard.
keymap='fr'
#-----------------------------------------------------------------------------
# network
ne2000=1
|
[modifier] Solaris x86
Solaris fonctionne correctement avec cette configuration.
Vous pouvez télécharge le dvd de solaris ici [[1]]
| File: /etc/xen/winxp.hvm |
# -*- mode: python; -*-
#============================================================================
# Python configuration setup for 'xm create'.
# This script sets the parameters used when a domain is created using 'xm create'.
# You use a separate script for each domain you want to create, or
# you can set the parameters for the domain on the xm command line.
#============================================================================
import os, re
arch = os.uname()[4]
if re.search('64', arch):
arch_libdir = 'lib64'
else:
arch_libdir = 'lib'
#----------------------------------------------------------------------------
# Kernel image file.
kernel = "/usr/lib/xen/boot/hvmloader"
# The domain build function. HVM domain uses 'hvm'.
builder='hvm'
# Initial memory allocation (in megabytes) for the new domain.
#
# WARNING: Creating a domain with insufficient memory may cause out of
# memory errors. The domain needs enough memory to boot kernel
# and modules. Allocating less than 32MBs is not recommended.
memory = 500
# Shadow pagetable memory for the domain, in MB.
# Should be at least 2KB per MB of domain memory, plus a few MB per vcpu.
shadow_memory = 8
# A name for your domain. All domains must have different names.
name = "solaris"
# 128-bit UUID for the domain. The default behavior is to generate a new UUID
# on each call to 'xm create'.
#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"
#-----------------------------------------------------------------------------
# The number of cpus guest platform has, default=1
vcpus=1
# Enable/disable HVM guest PAE, default=1 (enabled)
pae=0
# Enable/disable HVM guest ACPI, default=1 (enabled)
acpi=1
# Enable/disable HVM APIC mode, default=1 (enabled)
# Note that this option is ignored if vcpus > 1
apic=1
# List of which CPUS this domain is allowed to use, default Xen picks
#cpus = "" # leave to Xen to pick
#cpus = "0" # all vcpus run on CPU0
#cpus = "0-3,5,^1" # run on cpus 0,2,3,5
cpus = "0,1"
# Optionally define mac and/or bridge for the network interfaces.
# Random MACs are assigned if not given.
# vif = [ 'type=ioemu, bridge=xenbr1' ]
# type=ioemu specify the NIC is an ioemu device not netfront
# vif = [ 'mac=aa:00:00:00:00:08, bridge=xenbr1' ]
# vif = [ 'type=ioemu, bridge=xenbr0, vifname=vif1.0' ]
#vif = [ 'type=ioemu, bridge=xenbr1, mac=00:16:3e:00:00:11' ]
#----------------------------------------------------------------------------
# Define the disk devices you want the domain to have access to, and
# what you want them accessible as.
# Each disk entry is of the form phy:UNAME,DEV,MODE
# 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.
disk = [ 'phy:/dev/vg/solaris,hda,w' ]
#utilisez cette ligne à la place de celle du deçu pour l'installation
#disk = [ 'phy:/dev/vg/solaris,hda,w', 'file:/usr/local/img/solaris/sol-10-GA-x86-dvd-iso.iso,hdc:cdrom,r' ]
#----------------------------------------------------------------------------
# Configure the behaviour when a domain exits. There are three 'reasons'
# for a domain to stop: poweroff, reboot, and crash. For each of these you
# may specify:
#
# "destroy", meaning that the domain is cleaned up as normal;
# "restart", meaning that a new domain is started in place of the old
# one;
# "preserve", meaning that no clean-up is done until the domain is
# manually destroyed (using xm destroy, for example); or
# "rename-restart", meaning that the old domain is not cleaned up, but is
# renamed and a new domain started in its place.
#
# The default is
#
# on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# For backwards compatibility we also support the deprecated option restart
#
# restart = 'onreboot' means on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'destroy'
#
# restart = 'always' means on_poweroff = 'restart'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# restart = 'never' means on_poweroff = 'destroy'
# on_reboot = 'destroy'
# on_crash = 'destroy'
on_poweroff = 'preserve'
on_reboot = 'preserve'
on_crash = 'preserve'
#============================================================================
# New stuff
device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'
#device_model = "/usr/lib32/xen/bin/qemu-dm"
#-----------------------------------------------------------------------------
# boot on floppy (a), hard disk (c) or CD-ROM (d)
# default: hard disk, cd-rom, floppy
boot="cda"
#-----------------------------------------------------------------------------
# write to temporary files instead of disk image files
#snapshot=1
#----------------------------------------------------------------------------
# enable SDL library for graphics, default = 0
sdl=0
#----------------------------------------------------------------------------
# enable VNC library for graphics, default = 1
vnc=1
#----------------------------------------------------------------------------
# address that should be listened on for the VNC server if vnc is set.
# default is to use 'vnc-listen' setting from /etc/xen/xend-config.sxp
vnclisten="192.168.1.2"
#----------------------------------------------------------------------------
# set VNC display number, default = domid
#vncdisplay=1
#----------------------------------------------------------------------------
# try to find an unused port for the VNC server, default = 1
#vncunused=1
#----------------------------------------------------------------------------
# enable spawning vncviewer for domain's console
# (only valid when vnc=1), default = 0
#vncconsole=0
#----------------------------------------------------------------------------
# set password for domain's VNC console
# default is depents on vncpasswd in xend-config.sxp
vncpasswd='supinfo@Lex34'
#----------------------------------------------------------------------------
# no graphics, use serial port
#nographic=0
#----------------------------------------------------------------------------
# enable stdvga, default = 0 (use cirrus logic device model)
stdvga=0
#-----------------------------------------------------------------------------
# serial port re-direct to pty deivce, /dev/pts/n
# then xm console or minicom can connect
serial='pty'
#-----------------------------------------------------------------------------
# enable sound card support, [sb16|es1370|all|..,..], default none
#soundhw='sb16'
#-----------------------------------------------------------------------------
# set the real time clock to local time [default=0 i.e. set to utc]
#localtime=1
#-----------------------------------------------------------------------------
# start in full screen
#full-screen=1
#-----------------------------------------------------------------------------
# Enable USB support (specific devices specified at runtime through the
# monitor window)
#usb=1
# Enable USB mouse support (only enable one of the following, `mouse' for
# PS/2 protocol relative mouse, `tablet' for
# absolute mouse)
#usbdevice='mouse'
#usbdevice='tablet'
#-----------------------------------------------------------------------------
# Set keyboard layout, default is en-us keyboard.
keymap='fr'
#-----------------------------------------------------------------------------
# network
#ne2000=1
|
[modifier] Commandes
xm create nomMachine = démarre la machine virtuelle
xm shutdown nomMachine= demande au système virtualisé d'arréter la machine (soft off)
xm destroy nomMachine = arrète la machine de façon brutale (équivalent à uen coupure d'alimentation)
xm list = Affiche la liste des machines qui sont en cour d'execution et leurs états (ex: b=attente entrée/sortie,r=execution etc...)
xm top = affiche l'utilisation système pour chaque machine
xm console nomMachine= rattache la console de la machine virtuelle à votre console. Utilisez Ctrl+] pour la détacher. Suivant votre clavier cela peut correspondre à Ctrl+Alt Gr+la touche comportant °)].
[modifier] Problèmes
[modifier] Références
- (en) Processeurs avec support virtualisation
- (en) How To de Xen
- (en) Xen User Manual
- (en) Xen User Manual
- (en) HowTo Xen and Gentoo
- (en) HowTo Xen Servers and Gentoo
- (en) Xen Qemu and Gentoo

