Edizione 5.8
1801 Varsity Drive
Raleigh, NC 27606-2072 USA
Phone: +1 919 754 3700
Phone: 888 733 4281
Fax: +1 919 754 3701
ftpd
Neretto monospazio
Per visualizzare i contenuti del filemy_next_bestselling_novel
nella vostra directory di lavoro corrente, inserire il comandocat my_next_bestselling_novel
al prompt della shell e premere Invio per eseguire il comando.
Premere Invio per eseguire il comando.Premere Ctrl+Alt+F2 per smistarsi sul primo virtual terminal. Premere Ctrl+Alt+F1 per ritornare alla sessione X-Windows.
neretto monospazio
. Per esempio:
Le classi relative ad un file includonofilesystem
per file system,file
per file, edir
per directory. Ogni classe possiede il proprio set associato di permessi.
Selezionare Preferenze del Mouse. Nella scheda Pulsanti, fate clic sulla casella di dialogo mouse per mancini, e successivamente fate clic su per cambiare il pulsante primario del mouse da sinistra a destra (rendendo così il mouse idoneo per un utilizzo con la mano sinistra).→ → dalla barra del menu principale per lanciarePer inserire un carattere speciale in un file gedit, selezionare → → dalla barra menu principale. Successivamente, selezionare → dalla barra del menu Mappa carattere, inserire il nome del carattere nel campo Cerca e cliccare . Il carattere ricercato verrà evidenziato nella Tabella caratteri. Fare un doppio clic sul carattere evidenziato per posizionarlo nel campo Testo da copiare, e successivamente fare clic sul pulsante . Ritornare ora al documento e selezionare → dalla barra del menu di gedit.
Corsivo neretto monospazio
o Corsivo neretto proporzionale
Per collegarsi ad una macchina remota utilizzando ssh, digitaressh
al prompt della shell. Se la macchina remota èusername
@domain.name
example.com
ed il nome utente sulla macchina interessata è john, digitaressh john@example.com
.Il comandomount -o remount
rimonta il file system indicato. Per esempio, per rimontare il file systemfile-system
/home
, il comando èmount -o remount /home
.Per visualizzare la versione di un pacchetto attualmente installato, utilizzare il comandorpm -q
. Esso ritornerà il seguente risultato:package
.
package-version-release
Publican è un sistema di pubblicazione per DocBook.
tondo monospazio
e così presentato:
books Desktop documentation drafts mss photos stuff svn books_tests Desktop1 downloads images notes scripts svgs
tondo monospazio
ma vengono presentati ed evidenziati nel modo seguente:
package org.jboss.book.jca.ex1; import javax.naming.InitialContext; public class ExClient { public static void main(String args[]) throws Exception { InitialContext iniCtx = new InitialContext(); Object ref = iniCtx.lookup("EchoBean"); EchoHome home = (EchoHome) ref; Echo echo = home.create(); System.out.println("Created Echo"); System.out.println("Echo.echo('Hello') = " + echo.echo("Hello")); } }
5
.
NFS
, FTP
o HTTP
.
/var/lib/libvirt/images/
directory by default. If you use a different directory you must label the new directory according to SELinux policy. Refer to Sezione 18.2, «SELinux e virtualizzazione» for details.
yum
for more information.
grub.conf
file.
virtio
sono dispositivi PCI. Al momento i guest sono limitati ad un massimo di 32 dispositivi PCI. Alcuni dispositivi PCI sono critici per l'esecuzione del guest e per questo motivo non possono essere rimossi. I dispositivi necessari predefiniti sono:
fstab
file, the initrd
file or used by the kernel command line. If less privileged users, especially virtualized guests, have write access to whole partitions or LVM volumes the host system could be compromised.
/dev/sdb
). Virtualized guests with access to block devices may be able to access other block devices on the system or modify volume labels which can be used to compromise the host system. Use partitions (for example, /dev/sdb1
) or LVM volumes to prevent this issue.
phy
se possiede risorse sufficienti.
/etc/modprobe.conf
aggiungete la seguente riga:
options loop max_loop=64
# rmmod loop # modprobe loop
Indice
yum
e Red Hat Network (RHN).
virt-manager
, libvirt
e virt-viewer
e tutte le dipendenze per l'installazione.
Personalizzare i pacchetti (se necessario)
%packages
del file kickstart aggiungere il seguente gruppo di pacchetti:
%packages @xen
xen-ia64-guest-firmware
rhn_register
seguendo le prompt successive.
yum
xen
e kernel-xen
. Il pacchetto xen
contiene l'hypervisor insieme ai suoi tool di base. Il pacchetto kernel-xen
contiene un kernel di Linux modificato eseguito come un guest della macchina virtuale sull'hypervisor.
xen
e kernel-xen
eseguite:
# yum install xen kernel-xen
xen-ia64-guest-firmware
) presente nel DVD d'installazione aggiuntivo. Questo pacchetto può essere anche installato da RHN con il comando yum
:
# yum install xen-ia64-guest-firmware
python-virtinst
virt-install
per la creazione delle macchine virtuali.
libvirt
libvirt
è una libreria API per l'interazione con gli hypervisor. libvirt
utilizza il framework di virtualizzazione xm
ed il tool della linea di comando virsh
per gestire e controllare le macchine virtuali.
libvirt-python
libvirt
.
virt-manager
virt-manager
conosciuto anche come Virtual Machine Manager, fornisce un tool grafico per l'amministrazione delle macchine virtuali. Come API di gestione viene usata la libreria libvirt
.
# yum install virt-manager libvirt libvirt-python python-virtinst
virt-manager
, libvirt
e virt-viewer
per l'installazione.
Personalizzare i pacchetti (se necessario)
%packages
del file kickstart aggiungere il seguente gruppo di pacchetti:
%packages @kvm
rhn_register
seguendo le prompt successive.
yum
kvm
. Il pacchetto kvm
contiene il modulo del kernel KVM che fornisce l'hypervisor KVM sul kernel di Red Hat Enterprise Linux predefinito.
kvm
eseguite:
# yum install kvm
python-virtinst
virt-install
per la creazione delle macchine virtuali.
libvirt
libvirt
è una libreria API per l'interazione con gli hypervisor. libvirt
utilizza il framework di virtualizzazione xm
ed il tool della linea di comando virsh
per gestire e controllare le macchine virtuali.
libvirt-python
libvirt
.
virt-manager
virt-manager
conosciuto anche come Virtual Machine Manager, fornisce un tool grafico per l'amministrazione delle macchine virtuali. Come API di gestione viene usata la libreria libvirt
.
# yum install virt-manager libvirt libvirt-python python-virtinst
virt-install
. Entrambi i metodi sono presenti all'interno di questo capitolo.
virt-install
per la creazione di guest virtualizzati dalla linea di comando. virt-install
può essere usato in modo interattivo o in uno script in modo da automatizzare la creazione di macchine virtuali. Utilizzando virt-install
con file kickstart, sarà possibile eseguire una installazione delle macchine virtuali senza alcun intervento dell'utente.
virt-install
fornisce un numero di opzioni passabili sulla linea di comando. Per visualizzare un elenco completo di opzioni:
$ virt-install --help
virt-install
documenta ogni opzione del comando e le variabili importanti.
qemu-img
è un comando che può essere usato prima di virt-install
per configurare le opzioni di storage.
--vnc
option which opens a graphical window for the guest's installation.
rhel3support
, da un CD-ROM con networking virtuale e con una immagine del dispositivo a blocchi basato sul file di 5GB. In questo esempio viene usato un hypervisor KVM.
# virt-install --accelerate --hvm --connect qemu:///system \ --network network:default \ --name rhel3support --ram=756\ --file=/var/lib/libvirt/images/rhel3support.img \ --file-size=6 --vnc --cdrom=/dev/sr0
# virt-install --name fedora11 --ram 512 --file=/var/lib/libvirt/images/fedora11.img \ --file-size=3 --vnc --cdrom=/var/lib/libvirt/images/fedora11.iso
virt-manager
conosciuto come Virtual Machine Manager, è un tool grafico per la creazione e la gestione dei guest virtualizzati.
Open virt-manager
virt-manager
. Launch the application from the menu and submenu. Alternatively, run the virt-manager
command as root.
Optional: Open a remote hypervisor
Create a new guest
New guest wizard
Name the virtual machine
Choose virtualization method
kernel-xen
non è il kernel attualmente in esecuzione.
Select the installation method
.iso
file).
HTTP
, FTP
or NFS
.
HTTP
, FTP
or NFS
. The installation media URL must contain a Red Hat Enterprise Linux installation tree. This tree is hosted using NFS
, FTP
or HTTP
.
Installation media selection
ISO image or physical media installation
Network install tree installation
NFS
, FTP
or HTTP
. Optionally, a kickstart file can be specified to automated the installation. Kernel parameters can also be specified if required.
Network boot (PXE)
Storage setup
/var/lib/libvirt/images/
directory by default. In the default configuration, other directory locations for file-based images are prohibited by SELinux. If you use a different directory you must label the new directory according to SELinux policy. Refer to Sezione 18.2, «SELinux e virtualizzazione» for details.
/var/lib/libvirt/images/
. If you are using a different location (such as /images/
in this example) make sure it is added to your SELinux policy and relabeled before you continue with the installation (later in the document you will find information on how to modify your SELinux policy).
Network setup
Memory and CPU allocation
Verify and start guest installation
virt-manager
. Capitolo 8, Procedure per l'installazione del sistema operativo guest contains step-by-step instructions to installing a variety of common operating systems.
Creazione di un nuovo bridge
/etc/sysconfig/network-scripts/
. In questo esempio viene creato un file chiamato ifcfg-installation
il quale crea un bridge installation
.
# cd /etc/sysconfig/network-scripts/ # vim ifcfg-installation DEVICE=installation TYPE=Bridge BOOTPROTO=dhcp ONBOOT=yes
TYPE=Bridge
, is case-sensitive. It must have uppercase 'B' and lower case 'ridge'.
ifup installation
command can start the individual bridge but it is safer to test the entire network restarts properly.
# service network restart
brctl show
per visualizzare le informazioni sui bridge di rete presenti sul sistema.
# brctl show bridge name bridge id STP enabled interfaces installation 8000.000000000000 no virbr0 8000.000000000000 yes
virbr0
è il bridge predefinito usato da libvirt
per il Network Address Translation (NAT) sul dispositivo ethernet predefinito.
Aggiungere una interfaccia al nuovo bridge
BRIDGE
al file di configurazione con il nome del bridge creato nelle fasi precedenti.
# Intel Corporation Gigabit Network Connection DEVICE=eth1 BRIDGE=installation BOOTPROTO=dhcp HWADDR=00:13:20:F7:6E:8E ONBOOT=yes
# service network restart
brctl show
:
# brctl show bridge name bridge id STP enabled interfaces installation 8000.001320f76e8e no eth1 virbr0 8000.000000000000 yes
Configurazione della sicurezza
iptables
in modo da inoltrare tutto il traffico attraverso il bridge.
# iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT # service iptables save # service iptables restart
iptables
. In /etc/sysctl.conf
aggiungere le seguenti righe:
net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0
sysctl
.
# sysctl -p /etc/sysctl.conf
Riavviare libvirt prima dell'installazione
libvirt
.
# service libvirtd reload
virt-install
aggiungere il parametro d'installazione --network=bridge:installation
dove installation
è il nome del vostro bridge. Per le installazioni PXE usare il parametro --pxe
.
# virt-install --accelerate --hvm --connect qemu:///system \ --network=bridge:installation --pxe\ --name EL10 --ram=756 \ --vcpus=4 --os-type=linux --os-variant=rhel5 --file=/var/lib/libvirt/images/EL10.img \
Selezione di PXE
Selezione del bridge
Inizio dell'installazione
virsh update-device Guest1 ~/Guest1.xml
(substituting your guest's name and XML file), and select OK to continue past this step.
kernel-xen
.
virt-manager
, refer to the procedure in Sezione 7.2, «Creazione di un guest con virt-manager».
virt-install
basato sulla linea di comando. L'opzione --vnc
mostra l'installazione grafica. Il nome del guest all'interno dell'esempio è rhel5PV
, l'immagine del disco è rhel5PV.dsk
ed il mirror locale dell'albero d'installazione per Red Hat Enterprise Linux 5 è ftp://10.1.1.1/trees/RHEL5-B2-Server-i386/
. Sostituire quei valori con valori accurati per il sistema e la rete.
# virt-install -nrhel5PV
-r 500 \ -f /var/lib/libvirt/images/rhel5PV.dsk
-s 3 --vnc -p \ -lftp://10.1.1.1/trees/RHEL5-B2-Server-i386/
DHCP
(as shown below) or a static IP address:
Installation Number
:
rhn_register
. Il comando rhn_register
richiede un accesso root.
virt-install
in Sezione 8.1, «Installazione di Red Hat Enterprise Linux 5 come guest para-virtualizzato». If you used the default example the name is rhel5PV
.
virsh
per riavviare il guest:
# virsh reboot rhel5PV
virt-manager
, selezionate il nome del guest e fate clic su , successivamente selezionate .
kdump
. The use of kdump
is unsupported on para-virtualized guests.
yum
command or RHN. Click .
Aprire virt-manager
virt-manager
. Lanciare l'applicazione dal menu fate clic su . Alternativamente eseguire il comando virt-manager
come utente root.
Selezionare un hypervisor
qemu
.
Avvio del nuovo wizard della macchina virtuale
Conferire un nome alla macchina virtuale
Scegliere un metodo per la virtualizzazione
Selezionare il metodo d'installazione
Individuazione del dispositivo d'installazione
/var/lib/libvirt/images/
directory. Any other location may require additional configuration for SELinux, refer to Sezione 18.2, «SELinux e virtualizzazione» for details.
Impostazione dello storage
/var/lib/libvirt/images/
directory. Assign sufficient space for your virtualized guest and any applications the guest requires.
Impostazioni di rete
Assegnazione CPU e memoria
Verifica ed installazione dell'installazione del guest
Installazione di Red Hat Enterprise Linux
Avvio di virt-manager
Come nominare il vostro sistema virtuale
Selezione di un metodo di virtualizzazione
Selezione di un metodo d'installazione
/var/lib/libvirt/images/
directory. Any other location may require additional configuration for SELinux, refer to Sezione 18.2, «SELinux e virtualizzazione» for details.
Choose installation image
/var/lib/libvirt/images/
directory by default. In the default configuration, other directory locations for file-based images are prohibited by SELinux. If you use a different directory you must label the new directory according to SELinux policy. Refer to Sezione 18.2, «SELinux e virtualizzazione» for details.
/var/lib/xen/images/
, per le immagini della macchina virtuale. Se utilizzate una posizione diversa (come ad esempio /images/
) assicuratevi di aggiungerla alla vostra politica di SELinux e di rietichettarla prima di continuare con l'installazione (più avanti nella documentazione troverete le informazioni su come modificare la vostra politica di SELinux)
Impostazione della rete
HAL
, once you get the dialog box in the Windows install select the 'Generic i486 Platform
' tab. Scroll through selections with the Up and Down arrows.
# virsh start WindowsGuest
WindowsGuest
è il nome della macchina virtuale.
virsh reboot WindowsGuestName
. Durante il riavvio della macchina virtuale è possibile visualizzare il messaggio Setup is being restarted
:
virt-install
command. virt-install
can be used instead of virt-manager
This process is similar to the Windows XP installation covered in Sezione 8.3, «Installazione di Windows XP come guest completamente virtualizzato».
virt-install
for installing Windows Server 2003 as the console for the Windows guest opens the virt-viewer
window promptly. The examples below installs a Windows Server 2003 guest with the virt-install
command.
Xen virt-install
# virt-install --virt-type=xen -hvm \ --name windows2003sp1 --file=/var/lib/libvirt/images/windows2003sp2.img \ --file-size=6 \ --cdrom=/var/lib/libvirt/images/ISOs/WIN/en_windows_server_2003_sp1.iso \ --vnc --ram=1024
KVM virt-install
# virt-install --accelerate --hvm --connect qemu:///system \ --name rhel3support \ --network network:default \ --file=/var/lib/libvirt/images/windows2003sp2.img \ --file-size=6 \ --cdrom=/var/lib/libvirt/images/ISOs/WIN/en_windows_server_2003_sp1.iso \ --vnc --ram=1024
Standard PC
come Tipo di computer. La modifica del Tipo di computer è necessaria per i guest virtualizzati di Windows Server 2003.
Aprire il virt-manager
virt-manager
. Lanciare l'applicazione dal menu e . Alternativamente eseguire il comando virt-manager
come utente root.
Selezionare un hypervisor
qemu
.
Avviare il nuovo wizard della macchina virtuale
Come chiamare una macchina virtuale
Selezione di un metodo per la virtualizzazione
Selezione del metodo d'installazione
Come localizzare il dispositivo d'installazione
/var/lib/libvirt/images/
directory. Any other location may require additional configuration for SELinux, refer to Sezione 18.2, «SELinux e virtualizzazione» for details.
Impostazione dello Storage
/var/lib/libvirt/images/
directory. Assign sufficient space for your virtualized guest and any applications the guest requires.
Impostazione della rete
Assegnazione della CPU e della memoria
Verifica ed avvio dell'installazione del guest
Installazione di Windows
Indice
/dev/xvd[a to z][1 to 15]
/dev/xvdb13
/dev/xvd[a to i][a to z][1 to 15]
/dev/xvdbz13
/dev/sd[a to p][1 to 15]
/dev/sda1
/dev/hd[a to t][1 to 63]
/dev/hdd3
dd
command. Replace /dev/fd0
with the name of a floppy device and name the disk appropriately.
# dd if=/dev/fd0 of=~/legacydrivers.img
virt-manager
sul quale viene eseguita una installazione completamente virtualizzata di Red Hat Enterprise Linux, con l'immagine posizionata in /var/lib/libvirt/images/rhel5FV.img
. In questo esempio viene utilizzato l'Hypervisor Xen.
virsh
su di un guest in esecuzione.
# virsh dumpxml rhel5FV > rhel5FV.xml
# dd if=/dev/zero of=/var/lib/libvirt/images/rhel5FV-floppy.img bs=512 count=2880
<disk type='file' device='floppy'> <source file='/var/lib/libvirt/images/rhel5FV-floppy.img'/> <target dev='fda'/> </disk>
virsh shutdown
command instead.
# virsh destroy rhel5FV
# virsh create rhel5FV.xml
dd
. L'utilizzo di sparse file non è consigliato a causa di alcune problematiche relative all'integrità dei dati ed alle prestazioni che ne possono derivare. Essi possono essere creati più velocemente ed usati per l'effettuazioni di test ma non in ambienti di produzione.
# dd if=/dev/zero of=/var/lib/libvirt/images/FileName.img bs=1M seek=4096 count=0
# dd if=/dev/zero of=/var/lib/libvirt/images/FileName.img bs=1M count=4096
Guest1
ed il file viene salvato nella home directory degli utenti.
# virsh dumpxmlGuest1
> ~/Guest1
.xml
Guest1.xml
) e andate alla ricerca delle voci che iniziano con <disk>
. La voce in questione potrebbe somigliare alla seguente:
<disk type='file' device='disk'> <driver name='tap' type='aio'/> <source file='/var/lib/libvirt/images/Guest1.img'/> <target dev='xvda'/> </disk>
<disk>
. Assicuratevi di aver specificato un nome del dispositivo per gli attributi del dispositivo a blocchi virtuale. Questi attributi devono essere unici per ogni file di configurazione del guest. Di seguito viene riportato un esempio di voce il quale aggiunge un file chiamato FileName.img
come container di storage basato sul file:
<disk type='file' device='disk'> <driver name='tap' type='aio'/> <source file='/var/lib/libvirt/images/Guest1.img'/> <target dev='xvda'/> </disk> <disk type='file' device='disk'> <driver name='tap' type='aio'/> <source file='/var/lib/libvirt/images/FileName.img'/> <target dev='hda'/> </disk>
# virsh create Guest1.xml
FileName.img
as the device called /dev/sdb
. This device requires formatting from the guest. On the guest, partition the device into one primary partition for the entire device then format the device.
n
per una nuova partizione.
# fdisk /dev/sdb Command (m for help):
p
per una partizione primaria.
Command action e extended p primary partition (1-4)
1
.
Partition number (1-4): 1
Enter
.
First cylinder (1-400, default 1):
Enter
.
Last cylinder or +size or +sizeM or +sizeK (2-400, default 400):
t
.
Command (m for help): t
1
.
Partition number (1-4): 1
83
per una partizione linux.
Hex code (type L to list codes): 83
Command (m for help):w
Command (m for help):q
ext3
.
# mke2fs -j /dev/sdb1
# mount /dev/sdb1 /myfiles
fstab
file, the initrd
file or used by the kernel command line. If less privileged users, especially virtualized guests, have write access to whole partitions or LVM volumes the host system could be compromised.
/dev/sdb
). Virtualized guests with access to block devices may be able to access other block devices on the system or modify volume labels which can be used to compromise the host system. Use partitions (for example, /dev/sdb1
) or LVM volumes to prevent this issue.
multipath
e la persistenza sull'host se necessario.
virsh attach
command. Replace: myguest
with your guest's name, /dev/sdb1
with the device to add, and sdc
with the location for the device on the guest. The sdc
must be an unused device name. Use the sd*
notation for Windows guests as well, the guest will recognize the device correctly.
--type cdrom
parameter to the command for CD-ROM or DVD devices.
--type floppy
al comando per i dispositivi floppy.
# virsh attach-diskmyguest
/dev/sdb1
sdc
--driver tap --mode readonly
/dev/sdb
on Linux or D: drive
, or similar, on Windows. This device may require formatting.
multipath
must use Configurazione di un percorso singolo. Systems running multipath
can use Configurazione di percorsi multipli.
udev
. Only use this procedure for hosts which are not using multipath
.
/etc/scsi_id.config
.
options=-b
sia commentata.
# options=-b
options=-g
udev
in modo da assumere che tutti i dispositivi SCSI ritorneranno un UUID.
scsi_id -g -s /block/sd*
. Per esempio:
# scsi_id -g -s /block/sd* 3600a0b800013275100000015427b625e
/dev/sdc
.
scsi_id -g -s /block/sd*
sia identico a quello del computer che accede al dispositivo.
20-names.rules
nella directory /etc/udev/rules.d
. A questo punto le nuove regole dovranno essere aggiunte al file. Tutte le regole sono aggiunte allo stesso file utilizzando lo stesso formato. Le regole dovranno avere il seguente formato:
KERNEL=="sd[a-z]", BUS=="scsi", PROGRAM="/sbin/scsi_id -g -s /block/%k", RESULT="UUID
", NAME="devicename
"
UUID
e devicename
con l'UUID sopra indicato e con il nome desiderato per il dispositivo. Nell'esempio la regola somiglierà a quanto di seguito riportato:
KERNEL="sd*", BUS="scsi", PROGRAM="/sbin/scsi_id -g -s", RESULT="3600a0b800013275100000015427b625e", NAME="rack4row16"
udev
ora andrà alla ricerca di tutti i dispositivi chiamati /dev/sd*
per l'UUID presente nella regola. Una volta che il dispositivo corrispondente è stato collegato al sistema, esso verrà assegnato allo stesso il nome della regola. Un dispositivo con un UUID di 3600a0b800013275100000015427b625e apparirà come /dev/rack4row16
.
/etc/rc.local
:
/sbin/start_udev
/etc/scsi_id.config
, /etc/udev/rules.d/20-names.rules
, e /etc/rc.local
su tutti gli host rilevanti.
/sbin/start_udev
multipath
viene usato per sistemi con più di un percorso fisico dal computer ai dispositivi di storage. multipath
fornisce condizioni di elevata resistenza 'fault tolerant', fail-over, e migliori prestazioni per i dispositivi di storage della rete collegati ai sistemi di Red Hat Enterprise Linux.
multipath
environment requires defined alias names for your multipath devices. Each storage device has a UUID which acts as a key for the aliased names. Identify a device's UUID using the scsi_id
command.
# scsi_id -g -s /block/sdc
/dev/mpath
. Nell'esempio di seguito riportato sono stati definiti 4 dispositivi in /etc/multipath.conf
:
multipaths { multipath { wwid 3600805f30015987000000000768a0019 alias oramp1 } multipath { wwid 3600805f30015987000000000d643001a alias oramp2 } mulitpath { wwid 3600805f3001598700000000086fc001b alias oramp3 } mulitpath { wwid 3600805f300159870000000000984001c alias oramp4 } }
/dev/mpath/oramp1
, /dev/mpath/oramp2
, /dev/mpath/oramp3
and /dev/mpath/oramp4
. Once entered, the mapping of the devices' WWID to their new names are now persistent after rebooting.
virsh
with the attach-disk
parameter.
# virsh attach-disk [domain-id] [source] [target] --driver file --type cdrom --mode readonly
The source
and target
parameters are paths for the files and devices, on the host and guest respectively. The source
parameter can be a path to an ISO file or the device from the /dev
directory.
libvirt
installation provides NAT based connectivity to virtual machines out of the box. This is the so called 'default virtual network'. Verify that it is available with the virsh net-list --all
command.
# virsh net-list --all Name State Autostart ----------------------------------------- default active yes
# virsh net-define /usr/share/libvirt/networks/default.xml
/usr/share/libvirt/networks/default.xml
# virsh net-autostart default Network default marked as autostarted
# virsh net-start default Network default started
libvirt
verrà visualizzato un dispositivo bridge isolato. Il suddetto dispositivo non avrà alcuna interfaccia fisica ad esso aggiunta poichè verrà utilzzato l'IP forwarding e NAT per collegarsi con l'esterno. Non aggiungere nuove interfacce.
# brctl show bridge name bridge id STP enabled interfaces virbr0 8000.000000000000 yes
libvirt
aggiunge le regole iptables
le quali abilitano il traffico da e per i guest collegati al dispositivo virbr0
nelle catene INPUT
, FORWARD
, OUTPUT
e POSTROUTING
. Successivamente libvirt
cerca di abilitare il parametro ip_forward
. Altre applicazioni potrebbero disabilitare ip_forward
e per questo motivo l'opzione migliore è quella di aggiungere quanto segue a /etc/sysctl.conf
.
net.ipv4.ip_forward = 1
<interface type='network'> <source network='default'/> </interface>
<interface type='network'> <source network='default'/> <mac address='00:16:3e:1a:b3:4a'/> </interface>
/etc/xen/xend-config.sxp
ed in particolare la riga:
(network-script network-bridge)
(network-script /bin/true)
/etc/sysconfig/network-scripts/
directory):
# chkconfig NetworkManager off # chkconfig network on # service NetworkManager stop # service network start
NM_CONTROLLED=no
" to the ifcfg-*
scripts used in the examples. If you do not either set this parameter or disable NetworkManager entirely, any bridge configuration will be overwritten and lost when NetworkManager next starts.
/etc/sysconfig/network-scripts
:
# cd /etc/sysconfig/network-scripts
ifcfg-eth0
definisce l'interfaccia di rete fisica impostata come parte di un bridge:
DEVICE=eth0 # change the hardware address to match the hardware address your NIC uses HWADDR=00:16:76:D6:C9:45 ONBOOT=yes BRIDGE=br0
MTU
variable to the end of the configuration file.
MTU=9000
/etc/sysconfig/network-scripts
chiamato ifcfg-br0
o simile. br0
è il nome del bridge, può essere qualsiasi cosa se il nome del file è uguale al parametro del DISPOSITIVO.
DEVICE=br0 TYPE=Bridge BOOTPROTO=dhcp ONBOOT=yes DELAY=0
ifcfg-br0
file). Network access will not function as expected if IP address details are configured on the physical interface that the bridge is connected to.
TYPE=Bridge
, is case-sensitive. It must have uppercase 'B' and lower case 'ridge'.
# service network restart
iptables
per permettere a tutto il traffico di essere inoltrato verso il bridge.
# iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT # service iptables save # service iptables restart
iptables
. In /etc/sysctl.conf
aggiungete le seguenti righe:
net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0
sysctl
.
# sysctl -p /etc/sysctl.conf
libvirt
.
# service libvirtd reload
# brctl show bridge name bridge id STP enabled interfaces virbr0 8000.000000000000 yes br0 8000.000e0cb30550 no eth0
virbr0
. È consigliato non collegare un dispositivo fisico a virbr0
. Il bridge virbr0
è solo per la connettività Network Address Translation (NAT).
virsh
(Capitolo 25, Gestione dei guest con virsh) and virt-manager
(Capitolo 26, Gestione dei guest con Virtual Machine Manager (virt-manager)). Those chapters provide a detailed description of the networking configuration tasks using both tools.
system-config-network
oppure create un nuovo file di configurazione chiamato ifcfg-ethX
in /etc/sysconfig/network-scripts/
dove X
può essere qualsiasi numero non precedentemente utilizzato. Di seguito viene riportato un esempio sul file di configurazione per una seconda interfaccia di rete chiamata eth1
$ cat /etc/sysconfig/network-scripts/ifcfg-eth1 DEVICE=eth1 BOOTPROTO=static ONBOOT=yes USERCTL=no IPV6INIT=no PEERDNS=yes TYPE=Ethernet NETMASK=255.255.255.0 IPADDR=10.1.1.1 GATEWAY=10.1.1.254 ARP=yes
/etc/xen/scripts/network-bridge
su /etc/xen/scripts/network-bridge.xen
.
/etc/xen/xend-config.sxp
and add the line (network-xen-multi-bridge)
. A typical xend-config.sxp
file should have the following line. Comment this line out. Use the # symbol to comment out lines.
network-script network-bridge
network-xen-multi-bridge
parameter to enable multiple network bridges.
#network-script network-bridge network-script network-xen-multi-bridge
network-xen-multi-bridge.sh
in the /etc/xen/scripts/
directory. A sample scripts is below, this example script will create two Xen network bridges (xenbr0 and xenbr1) one will be attached to eth1 and the other one to eth0. If you want to create additional bridges just follow the example in the script and copy nad paste the lines as required:
#!/bin/sh # network-xen-multi-bridge # Exit if anything goes wrong. set -e # First arg is the operation. OP=$1 shift script=/etc/xen/scripts/network-bridge.xen case ${OP} in start) $script start vifnum=1 bridge=xenbr1 netdev=eth1 $script start vifnum=0 bridge=xenbr0 netdev=eth0 ;; stop) $script stop vifnum=1 bridge=xenbr1 netdev=eth1 $script stop vifnum=0 bridge=xenbr0 netdev=eth0 ;; status) $script status vifnum=1 bridge=xenbr1 netdev=eth1 $script status vifnum=0 bridge=xenbr0 netdev=eth0 ;; *) echo 'Unknown command: ' ${OP} echo 'Valid commands are: start, stop, status' exit 1 esac
# chmod +x /etc/xen/scripts/network-xen-multi-bridge.sh
# service network restart
virt-manager
. NetworkManager funziona con i dispositivi di rete virtuali per impostazione predefinita in Red Hat Enterprise Linux 5.1 o nelle versioni più recenti.
<interface type='network'> <mac address='AA:AA:AA:AA:AA:AA'/> <source network='default'/> <target dev='vnet0'/> <model type='virtio'/> </interface>
xm
i dispositivi di rete sono etichettati "vif
".
ifup
or ifdown
calls to the network interface it is using. In addition wireless network cards do not work well in a virtualization environment due to Xen's (default) bridged network usage.
dummy0
. This will also allow you to use a hidden IP address space for your guests.
/etc/modprobe.conf
alias dummy0 dummy options dummy numdummies=1
/etc/sysconfig/network-scripts/ifcfg-dummy0
:
DEVICE=dummy0 BOOTPROTO=none ONBOOT=yes USERCTL=no IPV6INIT=no PEERDNS=yes TYPE=Ethernet NETMASK=255.255.255.0 IPADDR=10.1.1.1 ARP=yes
xenbr0
con dummy0
, in questo modo sarete in grado di utilizzare il networking anche quando non siete collegati ad una rete fisica. Modificate /etc/xen/xend-config.sxp
in modo da includere la voce netdev=dummy0
:
(network-script 'network-bridge bridge=xenbr0 netdev=dummy0')
/etc/sysconfig/network
in the guest and modify the default gateway to point to dummy0
. If you are using a static IP, set the guest's IP address to exist on the same subnet as dummy0
.
NETWORKING=yes HOSTNAME=localhost.localdomain GATEWAY=10.1.1.1 IPADDR=10.1.1.10 NETMASK=255.255.255.0
/etc/init.d/xenLaptopNAT
e create un soft link per /etc/rc3.d/S99xenLaptopNAT
. Tale operazione avvia automaticamente NAT al momento dell'avvio.
#!/bin/bash PATH=/usr/bin:/sbin:/bin:/usr/sbin export PATH GATEWAYDEV=`ip route | grep default | awk {'print $5'}` iptables -F case "$1" in start) if test -z "$GATEWAYDEV"; then echo "No gateway device found" else echo "Masquerading using $GATEWAYDEV" /sbin/iptables -t nat -A POSTROUTING -o $GATEWAYDEV -j MASQUERADE fi echo "Enabling IP forwarding" echo 1 > /proc/sys/net/ipv4/ip_forward echo "IP forwarding set to `cat /proc/sys/net/ipv4/ip_forward`" echo "done." ;; *) echo "Usage: $0 {start|restart|status}" ;; esac
dnsmasq
su laptop in grado di eseguire la virtualizzazione:
dnsmasq.tgz
. The tar archive includes the following files:
nm-dnsmasq
può essere utilizzato come dispatcher script per NetworkManager. Esso verrà eseguito ogni qualvota NetworkManager rileva una modifica del collegamento forzando un riavvio/ricaricamento di dnsmasq. Copiatelo su /etc/NetworkManager/dispatcher.d/nm-dnsmasq
xenDNSmasq
può essere usato come script principale d'avvio o di arresto per /etc/init.d/xenDNSmasq
dnsmasq.conf
è un file di configurazione d'esempio per /etc/dnsmasq.conf
dnsmasq
è l'immagine binaria per /usr/local/sbin/dnsmasq
/usr/local/sbin/dnsmasq
) sarà necessario modificare il file di configurazione del vostro dnsmasq. Il file si trova in /etc/dnsmaqs.conf
interface
permette a dnsmasq
di essere in ascolto per le richieste DHCP
e DNS
solo su interfacce specifiche, come ad esempio interfacce dummy ma non sulle vostre interfacce pubbliche e di loopback. Aggiungete un'altra riga interface
per più di una interfaccia. Un esempio potrebbe essere interface=dummy0
il quale indica l'ascolto sull'interfaccia dummy0
.
dhcp-range
per abilitare il server DHCP
integrato sarà necessario fornire la gamma di indirizzi disponibili per il lease,e facoltativamente un lease time. Se siete in possesso di più di una rete sarà necessario ripetere questo processo per ogni rete alla quale desiderate fornire il servizio DHCP
. Un esempio potrebbe essere (per la rete 10.1.1.* ed un lease time di 12 ore): dhcp-range=10.1.1.10,10.1.1.50,255.255.255.0,12h
dhcp-option
per sovrascrivere l'instradamento predefinito fornito da dnsmasq il quale assume che il router sia la stessa macchina che esegue dnsmasq. Un esempio potrebbe essere dhcp-option=3,10.1.1.1
xenDNSmasq
su /etc/init.d
chkconfig --add xenDNSmasq
chkconfig --levels 345 xenDNSmasq on
dnsmasq
al riavvio ogni qualvolta NetworkManager rileva un cambiamento della connettività, utilizzate il seguente script nm-dnsmasq
.
nm-dnsmasq
su /etc/NetworkManager/dispatcher.d/
dnsmasq
rileverà anche le modifiche nel vostro /etc/resolv.conf
e le ricaricherà automaticamente (per esempio se avviate una sessione VPN).
nm-dnsmasq
e xenDNSmasq
imposteranno NAT se i guest virtuali si trovano in una rete nascosta per garantire loro un accesso alla rete pubblica.
pv-on-hvm
, nel pacchetto del kernel predefinito. Ciò significa che i driver paravirtualizzati sono disponibili per Red Hat Enterprise Linux 4.7 e versioni più recenti o 5.3 e versioni più recenti.
kmod-xenpv
.
kmod-xenpv
,
modules-init-tools
(for versions prior to Red Hat Enterprise Linux 4.6z you require modules-init-tools-3.1-0.pre5.3.4.el4_6.1
or greater), and
modversions
.
kmod-xenpv
.
/lib
file system.
# rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' kernel
Architettura del kernel | Red Hat Enterprise Linux 3 | Red Hat Enterprise Linux 4 | Red Hat Enterprise Linux 5 |
---|---|---|---|
athlon | Supportato (AMD) | ||
athlon-SMP | Supportato (AMD) | ||
i32e | Supportato (Intel) | ||
i686 | Supportato (Intel) | Supportato | Supportato |
i686-PAE | Supportato | ||
i686-SMP | Supportato (Intel) | Supportato | |
i686-HUGEMEM | Supportato (Intel) | Supportato | |
x86_64 | Supportato (AMD) | Supportato | Supportato |
x86_64-SMP | Supportato (AMD) | Supportato | |
x86_64-LARGESMP | Supportato | ||
Itanium (IA64) | Supportato |
# rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' kernel
kernel-PAE-2.6.18-53.1.4.el5.i686
GRUB
GRUB
), o le immagini initrd
del kernel. Cioè qualsiasi disco che contiene la directory /boot
o partizione non può utilizzare i driver del dispositivo a blocchi para-virtualizzato.
xen-pci-platform
fallirà.
Tipo di kernel guest | Tipo di kernel host necessario |
---|---|
ia32e (UP e SMP) | x86_64 |
i686 | i686 |
i686-SMP | i686 |
i686-HUGEMEM | i686 |
Tipo di kernel guest | Tipo di kernel host necessario |
---|---|
athlon | i686 |
athlon-SMP | i686 |
x86_64 | x86_64 |
x86_64-SMP | x86_64 |
MBR
ed il boot loader (GRUB
), e per la partizione /boot
. Questa partizione può essere molto piccola poichè deve avere una capacità sufficiente per contenere la partizione /boot
.
/
, /usr
) o volumi logici.
/boot
.
rpm
o yum
per installare i pacchetti. L'utilità rpm
installerà quattro nuovi moduli del kernel in /lib/modules/[%kversion][%kvariant]/extra/xenpv/%release
:
xen_platform_pci.ko
,
xen_balloon.ko
,
xen_vbd.ko
,
xen_vnif.ko
.
xen-vbd
) disk driver.
<disk type='file' device='disk'> <driver name='file'/> <source file='/dev/hda6'/> <target dev='hda'/> </disk>
<disk type='file' device='disk'> <driver name='tap' type='aio'/> <source file='/dev/hda6'/> <target dev='xvda'/> </disk>
# xm start YourGuestName
YourGuestName
is the name of the configuration file or the guest operating system's name as defined in its configuration file in the name = "os_name" parameter.
kernel-2.4.21-60.EL
for all the required headers.
kmod-xenpv
corrispondente alla vostra architettura hardware e variante del kernel sul vostro sistema operativo guest.
rpm
per installare i pacchetti RPM. Assicuratevi di aver identificato correttamente il pacchetto necessario per la variante e l'architettura del sistema operativo del vostro guest.
[root@rhel3]# rpm -ivh kmod-xenpv*
[root@rhel3]# mkdir -p /lib/modules/'uname -r'/extra/xenpv [root@rhel3]# cp -R /lib/modules/2.4.21-52.EL[%kvariant]/extra/xenpv/%release \ /lib/modules/'uname -r'/extra/xenpv [root@rhel3]# depmod -ae [root@rhel3]# modprobe xen-vbd [root@rhel3]# modprobe xen-vnif
insmod
alcuni messaggi di avvertimento. Tali messaggi vengono generati poichè MODVERSIONS è abilitato su Red Hat Enterprise Linux 3. I suddetti messaggi possono essere ignorati.
/etc/modules.conf
ed assicuratevi di avere un alias per eth0
simile a quello di seguito riportato. Se desiderate configurare alcune interfacce multiple, aggiungete una riga supplementare per ogni interfaccia.
alias eth0 xen-vnif
/etc/rc.local
ed aggiungete la riga:
insmod /lib/modules/'uname -r'/extra/xenpv/%release/xen-vbd.o
#shutdown -h now
” all'interno del guest).
/etc/xen/YourGuestName
with a text editor, performing the following changes:
type=ioemu
” da “vif=
”.
xen-vbd
).
<disk type='file' device='disk'> <driver name='file'/> <source file='/dev/hda6'/> <target dev='hda'/> </disk>
<disk type='file' device='disk'> <driver name='tap' type='aio'/> <source file='/dev/hda6'/> <target dev='xvda'/> </disk>
# xm start YourGuestName
YourGuestName
is the name of the configuration file or the guest operating system's name as defined in its configuration file in the name = "os_name" parameter.
weak-modules
e modversions
non è presente con Red Hat Enterprise Linux 3. Per inserire il modulo eseguite il seguente comando.
insmod xen_vbd.ko
xen-vbd
. Le fasi di seguito riportate affronteranno il metodo attraverso il quale è possibile creare e registrare i dispositivi a blocchi para-virtualizzati.
#!/bin/sh module="xvd" mode="664" major=`awk "\\$2==\"$module\" {print \\$1}" /proc/devices` # < mknod for as many or few partitions on xvd disk attached to FV guest > # change/add xvda to xvdb, xvbd, etc. for 2nd, 3rd, etc., disk added in # in xen config file, respectively. mknod /dev/xvdb b $major 16 mknod /dev/xvdb1 b $major 17 mknod /dev/xvdb2 b $major 18 chgrp disk /dev/xvd* chmod 0660 /dev/xvd*
# mknod /dev/xvdc b $major 16 # mknod /dev/xvdc1 b $major 17
# mknod /dev/xvdd b $major 32 # mknod /dev/xvdd1 b $major 33
[root@rhel3]# cat /proc/partitions major minor #blocks name 3 0 10485760 hda 3 1 104391 hda1 3 2 10377990 hda2 202 16 64000 xvdb 202 17 32000 xvdb1 202 18 32000 xvdb2 253 0 8257536 dm-0 253 1 2031616 dm-1
xvdb
” sia disponibile al sistema.
[root@rhel3]# mkdir /mnt/pvdisk_p1 [root@rhel3]# mkdir /mnt/pvdisk_p2
[root@rhel3]# mount /dev/xvdb1 /mnt/pvdisk_p1 [root@rhel3]# mount /dev/xvdb2 /mnt/pvdisk_p2
[root@rhel3]# df /mnt/pvdisk_p1 Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvdb1 32000 15 31985 1% /mnt/pvdisk_p1
/etc/fstab
all'interno del guest per montare i dispositivi durante la sequenza d'avvio. Aggiungere le seguenti righe:
/dev/xvdb1 /mnt/pvdisk_p1 ext3 defaults 1 2 /dev/xvdb2 /mnt/pvdisk_p2 ext3 defaults 1 2
dom0
), the "noapic
" parameter should be added to the kernel boot line in your virtual guest's /boot/grub/grub.conf
entry as seen below. Keep in mind your architecture and kernel version may be different.
kernel /vmlinuz-2.6.9-67.EL ro root=/dev/VolGroup00/rhel4_x86_64 rhgb noapic
kmod-xenpv
, modules-init-tools
e modversions
corrispondenti alla vostra architettura hardware e variante del kernel sul vostro sistema operativo guest.
rpm
per installare i pacchetti RPM. Assicuratevi di aver identificato correttamente il pacchetto necessario per l'architettura e la variante del vostro sistema operativo guest. Un module-init-tools aggiornato sarà necessario per questo pacchetto, esso è disponibile con il kernel di Red Hat Enterprise Linux4-6-z e versioni più recenti.
[root@rhel4]# rpm -ivh modversions [root@rhel4]# rpm -Uvh module-init-tools [root@rhel4]# rpm -ivh kmod-xenpv*
cat /etc/modprobe.conf
to verify you have an alias for eth0
like the one below. If you are planning to configure multiple interfaces add an additional line for each interface. If it does not look like the entry below change it.
alias eth0 xen-vnif
#shutdown -h now
” all'interno del guest).
/etc/xen/YourGuestsName
nel modo seguente:
type=ioemu
” da “vif=
”.
xen-vbd
).
disk=
” nel file di configurazione del guest. La voce originale “disk=
” potrebbe anche somigliare alla seguente.
disk = [ "file:/var/lib/libvirt/images/rhel4_64_fv.dsk,hda,w"]
disk = [ "file:/var/lib/libvirt/images/rhel3_64_fv.dsk,hda,w", "tap:aio:/var/lib/libvirt/images/UserStorage.dsk,xvda,w" ]
tap:aio
” per il dispositivo paravirtualizzato se usate una immagine basata sul file.
virsh
:
# virsh start YourGuestName
kudzu
vi chiederà se "Mantenere o cancellare il dispositivo di rete Realtek" e di "Configurare il dispositivo xen-bridge". A questo punto dovreste configurare xen-bridge
e cancellare il dispositivo di rete Realtek.
dom0
), the "noapic
" parameter should be added to the kernel boot line in your virtual guest's /boot/grub/grub.conf
entry as seen below. Keep in mind your architecture and kernel version may be different.
kernel /vmlinuz-2.6.9-67.EL ro root=/dev/VolGroup00/rhel4_x86_64 rhgb noapic
[root@rhel4]# cat /proc/partitions major minor #blocks name 3 0 10485760 hda 3 1 104391 hda1 3 2 10377990 hda2 202 0 64000 xvdb 202 1 32000 xvdb1 202 2 32000 xvdb2 253 0 8257536 dm-0 253 1 2031616 dm-1
xvdb
” sia disponibile al sistema.
[root@rhel4]# mkdir /mnt/pvdisk_p1 [root@rhel4]# mkdir /mnt/pvdisk_p2
[root@rhel4]# mount /dev/xvdb1 /mnt/pvdisk_p1 [root@rhel4]# mount /dev/xvdb2 /mnt/pvdisk_p2
[root@rhel4]# df /mnt/pvdisk_p1 Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvdb1 32000 15 31985 1% /mnt/pvdisk_p1
/etc/fstab
all'interno del guest per poter montare i dispositivi durante la sequenza d'avvio. Aggiungere le seguenti righe:
/dev/xvdb1 /mnt/pvdisk_p1 ext3 defaults 1 2 /dev/xvdb2 /mnt/pvdisk_p2 ext3 defaults 1 2
xen-vbd
potrebbe non essere caricato automaticamente. Eseguire il seguente comando dal terminale del guest, sostituite %release con la versione della release corretta per i driver paravirtualizzati.
# insmod /lib/modules/'uname -r'/weak-updates/xenpv/%release/xen_vbd.ko
#shutdown -h now
” all'interno del guest).
/etc/xen/<Your GuestsName>
nel modo seguente:
type=ioemu
” da “vif=
”.
xen-vbd
).
disk=
” nel file di configurazione del guest. La voce originale “disk=
” potrebbe anche somigliare alla seguente.
disk = [ "file:/var/lib/libvirt/images/rhel4_64_fv.dsk,hda,w"]
disk = [ "file:/var/lib/libvirt/images/rhel3_64_fv.dsk,hda,w", "tap:aio:/var/lib/libvirt/images/UserStorage.dsk,xvda,w" ]
tap:aio
” per il dispositivo paravirtualizzato se usate una immagine basata sul file.
virsh
:
# virsh start YourGuestName
[root@rhel5]# ifconfig eth0
[root@rhel5]# cat /proc/partitions major minor #blocks name 3 0 10485760 hda 3 1 104391 hda1 3 2 10377990 hda2 202 0 64000 xvdb 202 1 32000 xvdb1 202 2 32000 xvdb2 253 0 8257536 dm-0 253 1 2031616 dm-1
xvdb
” sia disponibile al sistema.
[root@rhel5]# mkdir /mnt/pvdisk_p1 [root@rhel5]# mkdir /mnt/pvdisk_p2
[root@rhel5]# mount /dev/xvdb1 /mnt/pvdisk_p1 [root@rhel5]# mount /dev/xvdb2 /mnt/pvdisk_p2
[root@rhel5]# df /mnt/pvdisk_p1 Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvdb1 32000 15 31985 1% /mnt/pvdisk_p1
/etc/fstab
all'interno del guest per poter montare i dispositivi durante la sequenza d'avvio. Aggiungere le seguenti righe:
/dev/xvdb1 /mnt/pvdisk_p1 ext3 defaults 1 2 /dev/xvdb2 /mnt/pvdisk_p2 ext3 defaults 1 2
dom0
), the "noapic
" parameter should be added to the kernel boot line in your virtual guest's /boot/grub/grub.conf
entry as seen below. Keep in mind your architecture and kernel version may be different.
kernel /vmlinuz-2.6.9-67.EL ro root=/dev/VolGroup00/rhel4_x86_64 rhgb noapic
/etc/modprobe.d/blacklist
file. Blacklist 8139cp
and 8139too
for the RealTek 8139 and e1000
for the virtualized Intel e1000 NIC.
8139cp
8139too
e1000
/etc/sysconfig/network-scripts
directory.
xen_emul_unplug=never
virt-manager
aprite la finestra della console per il guest ed eseguite il login come root
.
/etc/modprobe.conf
contenga la riga “alias eth0 xen-vnif
”.
# cat /etc/modprobe.conf alias eth0 xen-vnif
eth0
execute “# ifconfig eth0
”. If you receive an error about the device not existing you should load the modules manually as outlined in Sezione 36.4, «Caricamento manuale dei driver para-virtualizzati».
ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:00:00:6A:27:3A BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:630150 errors:0 dropped:0 overruns:0 frame:0 TX packets:9 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:109336431 (104.2 MiB) TX bytes:846 (846.0 b)
# system-config-network
”. Click on the “ ” button to start the network card configuration.
ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:16:3E:49:E4:E0 inet addr:192.168.78.180 Bcast:192.168.79.255 Mask:255.255.252.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:630150 errors:0 dropped:0 overruns:0 frame:0 TX packets:501209 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:109336431 (104.2 MiB) TX bytes:46265452 (44.1 MiB)
/etc/xen/YourGuestName
, sostituendo YourGuestName
con il nome del vostro guest.
vif = [ "mac=00:16:3e:2e:c5:a9,bridge=xenbr0" ]
vif=
” del file di configurazione, simile a quella riportata qui di seguito.
vif = [ "mac=00:16:3e:2e:c5:a9,bridge=xenbr0", "mac=00:16:3e:2f:d5:a9,bridge=xenbr0" ]
# echo 'import virtinst.util ; print virtinst.util.randomMAC()' | python
/etc/modules.conf
in Red Hat Enterprise Linux 3 o /etc/modprobe.conf
in Red Hat Enterprise Linux 4 e Red Hat Enterprise Linux 5. Inserire un nuovo alias per ogni nuova interfaccia aggiunta.
alias eth1 xen-vnif
# ifconfig eth1
redhat-config-network
su Red Hat Enterprise Linux 3, oppure system-config-network
su Red Hat Enterprise Linux 4 e Red Hat Enterprise Linux 5.
/etc/xen/YourGuestName
, sostituendo YourGuestName
con il nome del vostro guest. La entry originale potrebbe somigliare alla seguente.
disk = [ "file:/var/lib/libvirt/images/rhel5_64_fv.dsk,hda,w"]
disk=
” del file di configurazione. Le entity relative allo storage che utilizzano il driver para-virtualizzato somigliano alla voce di seguito riportata. Il parametro “tap:aio
” indica all'hypervisor di usare il driver para-virtualizzato.
disk = [ "file:/var/lib/libvirt/images/rhel5_64_fv.dsk,hda,w", "tap:aio:/var/lib/libvirt/images/UserStorage1.dsk,xvda,w" ]
disk=
” separate da una virgola.
xvd
' device, that is for your second storage entity it would be 'xvdb
' instead of 'xvda
'.
disk = [ "file:/var/lib/libvirt/images/rhel5_64_fv.dsk,hda,w", "tap:aio:/var/lib/libvirt/images/UserStorage1.dsk,xvda,w", "tap:aio:/var/lib/libvirt/images/UserStorage2.dsk,xvdb,w" ]
# cat /proc/partitions major minor #blocks name 3 0 10485760 hda 3 1 104391 hda1 3 2 10377990 hda2 202 0 64000 xvda 202 1 64000 xvdb 253 0 8257536 dm-0 253 1 2031616 dm-1
xvdb
” risulta essere disponibile al sistema.
/etc/fstab
all'interno del guest, in modo da montare i dispositivi e le partizioni al momento dell'avvio.
# mkdir /mnt/pvdisk_xvda # mkdir /mnt/pvdisk_xvdb # mount /dev/xvda /mnt/pvdisk_xvda # mount /dev/xvdb /mnt/pvdisk_xvdb # df /mnt Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvda 64000 15 63985 1% /mnt/pvdisk_xvda /dev/xvdb 64000 15 63985 1% /mnt/pvdisk_xvdb
Scaricare i driver
yum
command.
# yum install virtio-win
virtio-win.iso
) nella directory /usr/share/virtio-win/
.
Installare i driver para-virtualizzati
virt-manager
per il montaggio di una immagine CD-ROM per un guest di Windows» to add a CD-ROM image with virt-manager
and then install the drivers.
virt-manager
per il montaggio di una immagine CD-ROM per un guest di WindowsOpen virt-manager and the virtualized guest
virt-manager
, select your virtualized guest from the list by double clicking the guest name.
Open the hardware tab
Select the device type
Select the ISO file
/usr/share/virtio-win/virtio-win.iso
.
Disc assigned
Reboot
Open My Computer
Select the correct installation files
RHEV-Block.msi
for 32-bit guests or RHEV-Block64.msi
for 64-bit guests),
RHEV-Network.msi
for 32-bit guests or RHEV-Block64.msi
for 64-bit guests),
Install the block device driver
Start the block device driver installation
RHEV-Block.msi
or RHEV-Block64.msi
.
Confirm the exception
Finish
Install the network device driver
Start the network device driver installation
RHEV-Network.msi
or RHEV-Network64.msi
.
Performance setting
Value | Action |
---|---|
0 | Disable TCP timestamps and window scaling. |
1 | Enable TCP window scaling. |
2 | Enable TCP timestamps. |
3 | Enable TCP timestamps and window scaling. |
Confirm the exception
Finish
Reboot
viostor.vfd
come floppy
Windows Server 2003
Windows Server 2008
virtio
driver instead of virtualized IDE driver. This example edits libvirt configuration files. Alternatively, virt-manager
, virsh attach-disk
or virsh attach-interface
can add a new device using the para-virtualized drivers Sezione 13.4, «Utilizzo dei driver paravirtualizzati KVM per nuovi dispositivi».
<disk type='file' device='disk'> <source file='/var/lib/libvirt/images/disk1.img'/> <target dev='vda' bus='ide'/> </disk>
virtio
.
<disk type='file' device='disk'>
<source file='/var/lib/libvirt/images/disk1.img'/>
<target dev='vda' bus='virtio'/>
</disk>
virt-manager
.
virsh attach-disk
o virsh attach-interface
possono essere usati per collegare i dispositivi utilizzando i driver paravirtualizzati.
virt-manager
.
Enable the Intel VT-d extensions
Activate Intel VT-d in the kernel
intel_iommu=on
parameter to the kernel line of the kernel line in the /boot/grub/grub.conf
file.
grub.conf
file with Intel VT-d activated.
default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Red Hat Enterprise Linux Server (2.6.18-190.el5) root (hd0,0) kernel /vmlinuz-2.6.18-190.el5 ro root=/dev/VolGroup00/LogVol00 intel_iommu=on initrd /initrd-2.6.18-190.el5.img
Ready to use
Enable AMD IOMMU extensions
iommu=on
parameter to the hypervisor command line. Modify the /boot/grub/grub.conf
file as follows to enable PCI passthrough:
default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Red Hat Enterprise Linux Server (2.6.18-192.el5) root (hd0,0) kernel /xen.gz-2.6.18-192.el5 iommu=on module /vmlinuz-2.6.18-192.el5xen ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.18-190.el5xen.img
pci_8086_3a6c
, and a fully virtualized guest named win2k3
.
Identify the device
virsh nodedev-list
command lists all devices attached to the system. The --tree
option is useful for identifying devices attached to the PCI device (for example, disk controllers and USB controllers).
# virsh nodedev-list --tree
# virsh nodedev-list | grep pci
****
is a four digit hexadecimal code):
pci_8086_****
lspci
output to lspci -n
(which turns off name resolution) output can assist in deriving which device has which device identifier code.
virsh nodedev-dumpxml
command:
# virsh nodedev-dumpxml pci_8086_3a6c <device> <name>pci_8086_3a6c</name> <parent>computer</parent> <capability type='pci'> <domain>0</domain> <bus>0</bus> <slot>26</slot> <function>7</function> <id='0x3a6c'>82801JD/DO (ICH10 Family) USB2 EHCI Controller #2</product> <vendor id='0x8086'>Intel Corporation</vendor> </capability> </device>
# virsh nodedev-dettach pci_8086_3a6c Device pci_8086_3a6c dettached
$ printf %x 0 0 $ printf %x 26 1a $ printf %x 7 7
bus='0x00' slot='0x1a' function='0x7'
virsh edit
(or virsh attach device) and add a device entry in the <devices>
section to attach the PCI device to the guest. Only run this command on offline guests. Red Hat Enterprise Linux does not support hotplugging PCI devices at this time.
# virsh edit win2k3
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x00' slot='0x1a' function='0x7'/>
</source>
</hostdev>
ehci
driver is loaded by default for the USB PCI controller.
$ readlink /sys/bus/pci/devices/0000\:00\:1d.7/driver ../../../bus/pci/drivers/ehci_hcd
$ virsh nodedev-dettach pci_8086_3a6c
$ readlink /sys/bus/pci/devices/0000\:00\:1d.7/driver ../../../bus/pci/drivers/pci-stub
# setsebool -P virt_use_sysfs 1
# virsh start win2k3
virt-manager
tool. The following procedure adds a 2 port USB controller to a virtualized guest.
Identify the device
virsh nodedev-list
command lists all devices attached to the system. The --tree
option is useful for identifying devices attached to the PCI device (for example, disk controllers and USB controllers).
# virsh nodedev-list --tree
# virsh nodedev-list | grep pci
****
is a four digit hexadecimal code):
pci_8086_****
lspci
output to lspci -n
(which turns off name resolution) output can assist in deriving which device has which device identifier code.
Detach the PCI device
# virsh nodedev-dettach pci_8086_3a6c Device pci_8086_3a6c dettached
Power off the guest
Open the hardware settings
Add the new device
Select a PCI device
Confirm the new device
--host-device
parameter.
Identify the PCI device
virsh nodedev-list
command lists all devices attached to the system. The --tree
option is useful for identifying devices attached to the PCI device (for example, disk controllers and USB controllers).
# virsh nodedev-list --tree
# virsh nodedev-list | grep pci
****
is a four digit hexadecimal code):
pci_8086_****
lspci
output to lspci -n
(which turns off name resolution) output can assist in deriving which device has which device identifier code.
Add the device
virsh nodedev
command as the value for the --host-device
parameter.
# virt-install \
-n hostdev-test -r 1024 --vcpus 2 \
--os-variant fedora11 -v --accelerate \
-l http://download.fedoraproject.org/pub/fedora/linux/development/x86_64/os \
-x 'console=ttyS0 vnc' --nonetworks --nographics \
--disk pool=default,size=8 \
--debug --host-device=pci_8086_10bd
Complete the installation
/etc/modprobe.conf
hides the device from dom0. Either the bnx2
module must be reloaded or the host must be restarted.
install bnx2 /sbin/modprobe pciback; /sbin/modprobe --first-time --ignore-install bnx2 options pciback hide=(0000:09:00.0)
/etc/modprobe.conf
to hide multiple devices.
options pciback hide=(0000:09:00.0)(0000:0a:04.1)
virsh
(Sezione 14.1, «Adding a PCI device with virsh» - Step 5);
virt-manager
(Sezione 14.2, «Adding a PCI device with virt-manager»); or
virt-install
(Sezione 14.3, «PCI passthrough with virt-install»)
/boot/grub/grub.conf
file to enable SR-IOV. To enable SR-IOV with Xen for Intel systems append the pci_pt_e820_access=on
parameter to the kernel.
default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Red Hat Enterprise Linux Server (2.6.18-192.el5xen) root (hd0,0) kernel /xen.gz-2.6.18-192.el5 iommu=1 module /vmlinuz-2.6.18-192.el5xen ro root=/dev/VolGroup00/LogVol00 pci_pt_e820_access=on module /initrd-2.6.18-192.el5xen.img
Enable Intel VT-d in BIOS and in the kernel
Verify support
lspci
command to verify if the device was detected.
# lspci 03:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01) 03:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
Start the SR-IOV kernel modules
modprobe
command. The Intel 82576 network interface card uses the igb
driver kernel module.
# modprobe igb [<option>=<VAL1>,<VAL2>,] # lsmod |grep igb igb 87592 0 dca 6708 1 igb
Activate Virtual Functions
max_vfs
parameter of the igb
module allocates the maximum number of Virtual Functions. The max_vfs
parameter causes the driver to spawn, up to the value of the parameter in, Virtual Functions. For this particular card the valid range is 0
to 7
.
# modprobe -r igb
max_vfs
set to 1
or any number of Virtual Functions up to the maximum supported by your device.
# modprobe igb max_vfs=1
Inspect the new Virtual Functions
lspci
command, list the newly added Virtual Functions attached to the Intel 82576 network device.
# lspci | grep 82576 03:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01) 03:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01) 03:10.0 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 03:10.1 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
-n
parameter of the lspci
command.
# lspci -n | grep 03:00.0 03:00.0 0200: 8086:10c9 (rev 01) # lspci -n | grep 03:10.0 03:10.0 0200: 8086:10ca (rev 01)The Physical Function corresponds to
8086:10c9
and the Virtual Function to 8086:10ca
.
Find the devices with virsh
virsh nodedev-list
command to list available host devices.
# virsh nodedev-list | grep 8086
pci_8086_10c9
pci_8086_10c9_0
pci_8086_10ca
pci_8086_10ca_0
[output truncated]
Get advanced details
pci_8086_10c9
is one of the Physical Functions and pci_8086_10ca_0
is the first corresponding Virtual Function for that Physical Function. Use the virsh nodedev-dumpxml
command to get advanced output for both devices.
# virsh nodedev-dumpxml pci_8086_10ca # virsh nodedev-dumpxml pci_8086_10ca_0 <device> <name>pci_8086_10ca_0</name> <parent>pci_8086_3408</parent> <driver> <name>igbvf</name> </driver> <capability type='pci'> <domain>0</domain> <bus>3</bus> <slot>16</slot> <function>1</function> <product id='0x10ca'>82576 Virtual Function</product> <vendor id='0x8086'>Intel Corporation</vendor> </capability> </device>
pci_8086_10ca_0
to the guest in Passo 8. Note the bus
, slot
and function
parameters of the Virtual Function, these are required for adding the device.
Add the Virtual Function to the guest
virsh nodedev-dumpxml pci_8086_10ca_0
command to calculate the values for the configuration file. Convert slot and function values to hexadecimal values (from decimal) to get the PCI bus addresses. Append "0x" to the beginning of the output to tell the computer that the value is a hexadecimal number.
printf
utility to convert decimal values to hexadecimal values.
$ printf %x 3 3 $ printf %x 16 10 $ printf %x 1 1
bus='0x03' slot='0x10' function='0x01'
virsh edit
command. This example edits a guest named MyGuest
.
# virsh edit MyGuest
devices
section of the XML configuration file.
<hostdev mode='subsystem' type='pci' managed='yes'> <source> <address bus='0x03' slot='0x10' function='0x01'/> </source> </hostdev>
Restart
# virsh start MyGuest
# virsh start test error: Failed to start domain test error: internal error unable to start guest: char device redirected to /dev/pts/2 get_real_device: /sys/bus/pci/devices/0000:03:10.0/config: Permission denied init_assigned_device: Error: Couldn't get real device (03:10.0)! Failed to initialize assigned device host=03:10.0
ntpd
:
# service ntpd start
# chkconfig ntpd on
ntpd
dovrebbe diminuire gli effetti relativi all'alterazione dell'orologio in qualsiasi caso.
constant_tsc
. Per determinare la presenta del flag constant_tsc
eseguire il seguente comando:
$ cat /proc/cpuinfo | grep constant_tsc
constant_tsc
nella vostra CPU. Se al contrario nessun output viene visualizzato allora seguire le istruzioni di seguito indicate.
constant_tsc
, disabilitate tutte le funzioni di gestione dell'alimentazione (BZ#513138). Ogni sistema possiede diversi timer per controllare l'ora. TSC non è stabile sull'host, tale comportamento viene causato talvolta dalle modifiche cpufreq
, da stati deep C oppure da una migrazione su di un host con un TSC più veloce. Per interrompere uno stato deep C, il quale è in grado di arrestare TSC, aggiungere sull'host "processor.max_cstate=1
" alle opzioni d'avvio del kernel nel file grub.conf
:
term Red Hat Enterprise Linux Server (2.6.18-159.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-159.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet processor.max_cstate=1
cpufreq
(necessario solo su host senza constant_tsc
) modificando il file di configurazione /etc/sysconfig/cpuspeed
e successivamente le variabili MIN_SPEED
e MAX_SPEED
sulla frequenza più alta disponibile. I limiti validi sono disponibili nei file /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies
.
Red Hat Enterprise Linux | Parametri aggiuntivi relativi al kernel del guest |
---|---|
5.4 AMD64/Intel 64 con orologio paravirtualizzato | I parametri aggiuntivi non sono necessari |
5.4 AMD64/Intel 64 senza orologio paravirtualizzato | divider=10 notsc lpj=n |
5.4 x86 con orologio paravirtualizzato | I parametri aggiuntivi non sono necessari |
5.4 x86 senza orologio paravirtualizzato | divider=10 clocksource=acpi_pm lpj=n |
5.3 AMD64/Intel 64 | divider=10 notsc |
5.3 x86 | divider=10 clocksource=acpi_pm |
4.8 AMD64/Intel 64 | notsc divider=10 |
4.8 x86 | clock=pmtmr divider=10 |
3.9 AMD64/Intel 64 | I parametri aggiuntivi non sono necessari |
3.9 x86 | I parametri aggiuntivi non sono necessari |
boot.ini
:
/use pmtimer
boot.ini
file is no longer used from Windows Vista and newer. Windows Vista, Windows Server 2008 and Windows 7 use the Boot Configuration Data Editor (bcdedit.exe
) to modify the Windows boot parameters.
{default}
in the example below) should be changed if the system UUID is different than the default boot device.
C:\Windows\system32>bcdedit /set {default} USEPLATFORMCLOCK on The operation completed successfully
# setenforce 1
AutoFS
, NFS
, FTP
, HTTP
, NIS
, telnetd
, sendmail
e così via.
/var/lib/libvirt/images/
. Se state utilizzando una directory diversa per le immagini della vostra macchina virtuale, assicuratevi di aggiungere la directory nella vostra politica SELinux rietichettandola prima di eseguire l'installazione.
vsftpd
.
fstab
file, the initrd
file or used by the kernel command line. If less privileged users, especially virtualized guests, have write access to whole partitions or LVM volumes.
/dev/sdb
). Use partitions (for example, /dev/sdb1
) or LVM volumes.
virt_image_t
label applied to them. The /var/lib/libvirt/images
directory has this label applied to it and its contents by default. This does not mean that images must be stored in this directory; images can be stored anywhere, provided they are labeled with virt_image_t
.
NewVolumeName
sul gruppo di volumi volumegroup
.
# lvcreate -nNewVolumeName
-L5G volumegroup
NewVolumeName
con un file system in grado di supportare gli attributi estesi come ad esempio ext3.
# mke2fs -j /dev/volumegroup/NewVolumeName
/etc
, /var
, /sys
) o nelle home directory /home
o /root
). In questo esempio viene usata una directory chiamata /virtstorage
# mkdir /virtstorage
# mount /dev/volumegroup/NewVolumeName /virtstorage
semanage fcontext -a -t xen_image_t "/virtstorage(/.*)?"
semanage fcontext -a -t virt_image_t "/virtstorage(/.*)?"
/etc/selinux/targeted/contexts/files/file_contexts.local
rendendo la modifica persistente. La riga potrebbe somigliare alla seguente:
/virtstorage(/.*)? system_u:object_r:xen_image_t:s0
/dev/volumegroup/NewVolumeName
with the correct label:
# semanage fcontext -a -t xen_image_t /dev/volumegroup/NewVolumeName # restorecon /dev/volumegroup/NewVolumeName
# semanage fcontext -a -t xen_image_t -f -b /dev/sda2 # restorecon /dev/sda2
xend_disable_t
imposta xend
in modalità unconfined dopo il riavvio del demone. È consigliato disabilitare la protezione per un demone singolo invece di disabilitarla per l'intero sistema. Altresì non rietichettare le directory come xen_image_t
utilizzate in altre parti.
SELinux Boolean | Description |
---|---|
allow_unconfined_qemu_transition | Default: off. This boolean controls whether KVM guests can be transitioned to unconfined users. |
qemu_full_network | Default: on. This boolean controls full network access to KVM guests. |
qemu_use_cifs | Default: on. This boolean controls KVM's access to CIFS or Samba file systems. |
qemu_use_comm | Default: off. This boolean controls whether KVM can access serial or parallel communications ports. |
qemu_use_nfs | Default: on. This boolean controls KVM's access to NFS file systems. |
qemu_use_usb | Default: on. This boolean allows KVM to access USB devices. |
net.ipv4.ip_forward = 1
) is required for virtual bridge devices. Note that installing libvirt enables this variable so it will be enabled when the virtualization packages are installed unless it was manually disabled.
xend
/etc/xen/xend-config.sxp
. Ecco i parametri da abilitare o disabilitare nel file di configurazione xend-config.sxp
:
Item | Descrizione |
---|---|
(console-limit)
|
Determines the console server's memory buffer limit and assigns that limit on a per domain basis.
|
(min-mem)
|
Determina il numero minimo di megabyte riservati per il domain0 (se inserite 0, il valore non varia).
|
(dom0-cpus)
|
Determina il numero delle CPU utilizzate dal domain0 (almeno 1 CPU è assegnata per default).
|
(enable-dump)
|
Se abilitato in presenza di un arresto inaspettato 'crash' crea un dump file (il default è 0).
|
(external-migration-tool)
|
Determina lo script o l'applicazione che gestisce la migrazione del dispositivo esterno. Gli script devono risiedere in
/etc/xen/scripts/external-device-migrate .
|
(logfile)
|
Determina la posizione del file di log (il default è
/var/log/xend.log ).
|
(loglevel)
|
Filtra i valori log mode: DEBUG, INFO, WARNING, ERROR, o CRITICAL (il default è DEBUG).
|
(network-script)
|
Determina lo script che abilita l'ambiente di networking. Gli script devono risiedere nella directory
/etc/xen/scripts/ .
|
(xend-http-server)
|
Abilita il server per l'http stream packet management (il default è no).
|
(xend-unix-server)
|
Abilita il server unix domain socket. Un server socket rappresenta un punto finale delle comunicazioni che gestisce i collegamenti low level network ed accetta o rifiuta i collegamenti in entrata. Il valore predefinito è si.
|
(xend-relocation-server)
|
Abilita il server di riposizionamento per migrazioni 'cross-machine' (il default è no).
|
(xend-unix-path)
|
Determina la posizione dove il comando
xend-unix-server esegue l'output dei dati (il default è /var/lib/xend/xend-socket )
|
(xend-port)
|
Determina la porta utilizzata dal server di gestione http (il default è 8000).
|
(xend-relocation-port)
|
Determina la porta utilizzata dal server di riposizionamento (il default è 8002).
|
(xend-relocation-address)
|
Determina gli indirizzi dell'host abilitati per la migrazione. Il valore predefinito è il valore di
xend-address .
|
(xend-address)
|
Determina l'indirizzo al quale si lega il server del domain socket. Il valore predefinito permette tutti i collegamenti.
|
service xend start
service xend stop
service xend restart
service xend status
xend
al momento dell'avviochkconfig
per aggiungere xend
a initscript
.
chkconfig --level 345 xend
xend
verrà ora avviato nei runlevel 3,4 e 5.
virsh migrate
.
# virsh migrateGuestName
libvirtURI
--live
per il comando virsh migrate
.
# virsh migrate--liveGuestName
libvirtURI
/etc/xen/xend-config.sxp
. Per default il processo di migrazione è disabilitato a causa di alcuni problemi sulla sicurezza dell'host. L'apertura della porta usata per la migrazione potrebbe causare la possibilità da parte di host ed utenti non autorizzati di inizializzare un processo di migrazione o di collegarsi alle porte utilizzate. Non vi è alcun processo di autenticazione e autorizzazione per le richieste di migrazione ed il solo meccanismo di controllo è basato sugli hostname ed indirizzi IP. Per questo motivo è importante prestare particolare attenzione in modo da assicurare che la porta non venga utilizzata da un host non autorizzato.
/etc/xen/xend-config.sxp
per abilitare la migrazione. Modificate i valori, quando necessario, e rimuovere i commenti #
che precedono i seguenti parametri:
(xend-relocation-server yes)
no
. Modificate il valore di xend-relocation-server
ed impostatelo su yes
se desiderate abilitare tale processo.
(xend-relocation-port 8002)
(xend-relocation-port)
, specifica che la porta xend
dovrebbe usare l'interfaccia di riposizionamento, se xend-relocation-server
è stato impostato su yes
xend-relocation-port
deve essere aperta su entrambi i sistemi.
(xend-relocation-address '')
(xend-relocation-address)
è l'indirizzo sul quale xend
dovrebbe essere in ascolto per i collegamenti relocation-socket
, se xend-relocation-server
è stato impostato.
(xend-relocation-address)
parameter restricts the migration server to only listen to a specific interface. The default value in /etc/xen/xend-config.sxp
is an empty string(''
). This value should be replaced with a single, valid IP address. For example:
(xend-relocation-address '10.0.0.1')
(xend-relocation-hosts-allow '')
(xend-relocation-hosts-allow 'hosts')
parameter controls which hostnames can communicate on the relocation port.
xend-relocation-hosts-allow
option to restrict access to the migration server.
xend-relocation-port
e xend-relocation-address
.
(xend-relocation-hosts-allow)
dovrebbe essere una sequenza di espressioni regolari separate da spazi. Qualsiasi host con un fully-qualified domain name o un indirizzo IP che corrisponde ad una delle suddette espressioni regolari verrà accettato.
(xend-relocation-hosts-allow)
:
(xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$')
# service xend restart
et-virt07
e et-virt08
), entrambi utilizzano eth1
come interfaccia di rete predefinita e per questo motivo essi utilizzano xenbr1
come bridge per il networking di Xen. In questo esempio viene usato un disco SCSI collegato localmente (/dev/sdb
) su et-virt07
per uno storage condiviso che utilizza NFS.
# mkdir /var/lib/libvirt/images # mount /dev/sdb /var/lib/libvirt/images
/var/lib/libvirt/images/
, assicuratevi di esportare solo /var/lib/libvirt/images/
e non /var/lib/xen/
, poichè questa directory viene usata dal demone xend
e da altri tool. La condivisione di /var/lib/xen/
potrebbe causare un comportamento imprevedibile.
# cat /etc/exports /var/lib/libvirt/images *(rw,async,no_root_squash)
# showmount -e et-virt07 Export list for et-virt07: /var/lib/libvirt/images *
# virt-install -p -f /var/lib/libvirt/images/testvm1
.dsk -s 5 -n\testvm1
--vnc -r 1024 -l http://example.com/RHEL5-tree\ Server/x86-64/os/ -b xenbr1
[et-virt08 ~]# brctl show bridge name bridge id STP enabled interfaces xenbr1 8000.feffffffffff no peth1 vif0.1
[et-virt07 ~]# brctl show bridge name bridge id STP enabled interfaces xenbr1 8000.feffffffffff no peth1 vif0.1
[et-virt07 ~]# grep xend-relocation /etc/xen/xend-config.sxp |grep -v '#' (xend-relocation-server yes) (xend-relocation-port 8002) (xend-relocation-address '') (xend-relocation-hosts-allow '')
[et-virt08 ~]# grep xend-relocation /etc/xen/xend-config.sxp |grep -v '#' (xend-relocation-server yes) (xend-relocation-port 8002) (xend-relocation-address '') (xend-relocation-hosts-allow '')
[et-virt07 ~]# lsof -i :8002 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME python 3445 root 14u IPv4 10223 TCP *:teradataordbms (LISTEN)
[et-virt08 ~]# lsof -i :8002 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME python 3252 root 14u IPv4 10901 TCP *:teradataordbms (LISTEN)
/var/lib/libvirt/images
directory is available and mounted with networked storage on both hosts. Shared, networked storage is required for migrations.
[et-virt08 ~]# df /var/lib/libvirt/images Filesystem 1K-blocks Used Available Use% Mounted on et-virt07:/var/lib/libvirt/images 70562400 2379712 64598336 4% /var/lib/libvirt/images
[et-virt08 ~]# file /var/lib/libvirt/images/testvm1
.dsk /var/lib/libvirt/images/testvm1
.dsk: x86 boot sector; partition 1: ID=0x83, active, starthead 1, startsector 63, 208782 sectors; partition 2: ID=0x8e, starthead 0, startsector 208845, 10265535 sectors, code offset 0x48
[et-virt08 ~]# touch /var/lib/libvirt/images/foo [et-virt08 ~]# rm -f /var/lib/libvirt/images/foo
[et-virt07 ~]# virsh list Id Name State ---------------------------------- Domain-0 running
[et-virt07 ~]# virsh starttestvm1
Domaintestvm1
started
[et-virt07 ~]# virsh list
Id Name State
----------------------------------
Domain-0 running
testvm1
blocked
[et-virt07 images]# time virsh savetestvm1
testvm1
.sav real 0m15.744s user 0m0.188s sys 0m0.044s
[et-virt07 images]# ls -lrttestvm1
.sav -rwxr-xr-x 1 root root 1075657716 Jan 12 06:46testvm1
.sav
[et-virt07 images]# virsh list Id Name State ---------------------------------- Domain-0 running
[et-virt07 images]# virsh restore testvm1
.sav
[et-virt07 images]# virsh list
Id Name State
----------------------------------
Domain-0 running
testvm1
blocked
domain-id
from et-virt08
to et-virt07
. The hostname you are migrating to and <domain-id> must be replaced with valid values. This example uses the et-virt08
host which must have SSH access to et-virt07
[et-virt08 ~]# xm migrate --live testvm1
et-virt07
et-virt08
[et-virt08 ~]# virsh list Id Name State ---------------------------------- Domain-0 running
et-virt07
:
[et-virt07 ~]# virsh list
Id Name State
----------------------------------
Domain-0 running
testvm1
running
#!/bin/bash while true do touch /var/tmp/$$.log echo `hostname` >> /var/tmp/$$.log echo `date` >> /var/tmp/$$.log cat /var/tmp/$$.log df /var/tmp ls -l /var/tmp/$$.log sleep 3 done
et-virt07
:
[et-virt08 ~]# virsh list
Id Name State
----------------------------------
Domain-0 running
testvm1
blocked
et-virt07
. È possibile aggiungere il comando time
per controllare la durata del processo di migrazione:
[et-virt08 ~]# xm migrate --live testvm1
et-virt07
# ./doit dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:27 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 62 Jan 12 02:26 /var/tmp/2279.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:27 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:30 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 124 Jan 12 02:26 /var/tmp/2279.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:27 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:30 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:33 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 186 Jan 12 02:26 /var/tmp/2279.log Fri Jan 12 02:26:45 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:48 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:51 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:54:57 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:55:00 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:55:03 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 744 Jan 12 06:55 /var/tmp/2279.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:27 EST 2007
et-virt08
:
[et-virt08 ~]# virsh list Id Name State ---------------------------------- Domain-0 running
et-virt07
:
[et-virt07 images]# virsh list
Id Name State
----------------------------------
Domain-0 running
testvm1
blocked
et-virt07
a et-virt08
. Iniziate una migrazione da et-virt07
aet-virt08
:
[et-virt07 images]# xm migrate --live testvm1
et-virt08
[et-virt07 images]# virsh list Id Name State ---------------------------------- Domain-0 running
# ./doit dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:53 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 62 Jan 12 06:57 /var/tmp/2418.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:53 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:56 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 124 Jan 12 06:57 /var/tmp/2418.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:53 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:56 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:58:00 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 186 Jan 12 06:57 /var/tmp/2418.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:53 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:56 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:58:00 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:30:00 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 248 Jan 12 02:30 /var/tmp/2418.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:53 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:56 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:58:00 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:30:00 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:30:03 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 310 Jan 12 02:30 /var/tmp/2418.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:53 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:56 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:58:00 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:30:00 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:30:03 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:30:06 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 372 Jan 12 02:30 /var/tmp/2418.log
et-virt07
, verificate su et-virt08
che la macchina virtuale sia stata avviata:
[et-virt08 ~]# virsh list
Id Name State
----------------------------------
Domain-0 running
testvm1
blocked
[et-virt08 ~]# time virsh migrate --live testvm1
et-virt07
real 0m10.378s
user 0m0.068s
sys 0m0.052s
xm migrate
), è da notare che è possibile eseguire una migrazione live dallo stesso comando. Tuttavia sono presenti altre modifiche aggiuntive riguardanti il file di configurazione xend-config
. Questo esempio identifica le voci da modificare in modo da eseguire una migrazione corretta:
(xend-relocation-server yes)
(xend-relocation-port 8002)
xend
per la migrazione. Usate questo valore a meno che il vostro ambiente di rete ha bisogno di un valore personalizzato. Decommentatelo per abilitarlo.
(xend-relocation-address )
xend-relocation-server
. L'hypervisor Xen è in ascolto solo per il traffico di rete dei processi di migrazione su interfacce specifiche.
(xend-relocation-hosts-allow )
(xend-relocation-hosts-allow- '^localhost\\.localdomain$' )>
virsh
. Il comando migrate
accetta i parametri nel seguente formato:
# virsh migrate --live GuestName DestinationURL
GuestName
rappresenta il nome del guest che si desidera migrare.
DestinationURL
è l'URL o l'hostname del sistema di destinazione. Il suddetto sistema deve avere la stessa versione di Red Hat Enterprise Linux, usare lo stesso hypervisor e libvirt
deve essere in esecuzione.
test1.example.com
a test2.example.com
. Modificare gli hostname per il vostro ambiente. In questo esempio viene riportata una migrazione di una macchina virtuale chiamata RHEL4test
.
Verificate che il guest sia in esecuzione
test1.example.com
, verificare che RHEL4test
sia in esecuzione:
[root@test1 ~]# virsh list Id Name State ---------------------------------- 10 RHEL4 running
Migrazione del guest
test2.example.com
. Aggiungere /system
alla fine dell'URL di destinazione per indicare a libvirt la necessità di avere un accesso completo.
# virsh migrate --live RHEL4test qemu+ssh://test2.example.com/system
Attesa
virsh
riporta solo gli errori. Il guest continua la sua esecuzione sull'host sorgente fino alla migrazione completa.
Verificare che il guest sia arrivato sull'host di destinazione
test2.example.com
, verificare che RHEL4test
sia in esecuzione:
[root@test2 ~]# virsh list Id Name State ---------------------------------- 10 RHEL4 running
virt-manager
ssh
o TLS e SSL.
ssh
fornisce un protocollo di rete cifrato attraverso il quale è possibile inviare in modo sicuro le funzioni di gestione ai server di virtualizzazione remoti. Il metodo descritto usa il libvirt
management connection attraverso un tunnel sicuro su di un collegamento SSH per la gestione delle macchine remote. L'autenticazione viene fatta tramite la cifratura della chiave pubblica SSH e le password, oppure tramite le frasi segrete raccolte dal vostro agent SSH locale. In aggiunta, la console VNC per ogni macchina del guest virtuale verrà collegata a SSH tramite un tunnel.
virt-manager
virt-manager
must run as the user who owns the keys to connect to the remote host. That means, if the remote systems are managed by a non-root user virt-manager
must be run in unprivileged mode. If the remote systems are managed by the local root user then the SSH keys must be own and created by root.
virt-manager
.
Optional: Changing user
$ su -
Generating the SSH key pair
virt-manager
is used. This example uses the default key location, in the ~/.ssh/
directory.
$ ssh-keygen -t rsa
Coping the keys to the remote hosts
root@example.com
).
# ssh-copy-id -i ~/.ssh/id_rsa.pub root@example.com root@example.com's password: Now try logging into the machine, with "ssh 'root@example.com'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting
Optional: Add the passphrase to the ssh-agent
ssh-agent
, if required. On the local host, use the following command to add the passphrase (if there was one) to enable password-less login.
# ssh-add ~/.ssh/id_rsa.pub
libvirt
(libvirtd
)libvirt
daemon provide an interface for managing virtual machines. You must have the libvirtd
daemon installed and running on every remote host that needs managing.
$ ssh root@somehost
# chkconfig libvirtd on
# service libvirtd start
libvirtd
che SSH, dovreste essere in grado di accedere in modo remoto alle vostre macchine virtuali. A questo punto sarà possibile accedere anche ai vostri guest con VNC
.
libvirt
management connection opens a TCP port for incoming connections, which is securely encrypted and authenticated based on x509 certificates. In addition the VNC console for each guest virtual machine will be setup to use TLS with x509 certificate authentication.
libvirt
/etc/xen/xend-config.sxp
. Rimuovere il commento sul parametro di configurazione (vnc-tls 1)
all'interno del file di configurazione.
/etc/xen/vnc
directory needs the following 3 files:
ca-cert.pem
- The CA certificate
server-cert.pem
- The Server certificate signed by the CA
server-key.pem
- The server private key
(vnc-x509-verify 1)
parameter.
virsh
e virt-manager
libvirt
tramite TLS, i certificati client e CA devono essere posizionati in /etc/pki
. Per informazioni consultate http://libvirt.org/remote.html
virt-manager
user interface, use the ' ' transport mechanism option when connecting to a host.
virsh
URI ha il seguente formato:
qemu://hostname.guestname/system
per KVM.
xen://hostname.guestname/
per Xen.
$HOME/.pki
, di seguito sono riportati i file interessati:
ca-cert.pem
- Il certificato CA.
libvirt-vnc
o clientcert.pem
- Il certificato del client firmato dal CA.
libvirt-vnc
o clientkey.pem
- La chiave privata del client.
libvirt
supporta le seguenti modalità di trasporto:
/var/run/libvirt/libvirt-sock
e /var/run/libvirt/libvirt-sock-ro
(per collegamenti di sola-lettura).
libvirtd
) deve essere in esecuzione sulla macchina remota. La porta 22 deve essere aperta per permettere un accesso SSH. Sarà necessario utilizzare una specie di gestione della chiave ssh (per esempio, ssh-agent
) in caso contrario vi sarà richiesta una password.
ext
viene usato per qualsiasi programma esterno in grado di creare una connessione alla macchina remota esternamente a libvirt. Questo parametro non è supportato.
virsh
e libvirt
per il collegamento ad un host remoto. Gli URI possono essere usati con il parametro --connect
per il comando virsh
in modo da eseguire comandi singoli o migrazioni su host remoti.
driver[+transport]://[username@][hostname][:port]/[path][?extraparameters]
towada
, usando un trasporto SSH ed il nome utente SSH ccurran
.
xen+ssh://ccurran@towada/
towada
utilizzando TLS.
xen://towada/
towada
using TLS. The no_verify=1
tells libvirt not to verify the server's certificate.
xen://towada/?no_verify=1
towada
usando SSH.
qemu+ssh://towada/system
qemu+unix:///system?socket=/opt/libvirt/run/libvirt/libvirt-sock
test+tcp://10.1.1.10:5000/default
Nome | Modalità di trasporto | Descrizione | Esempio di utilizzo |
---|---|---|---|
nome | tutte le modalità | Il nome passato alla funzione virConnectOpen remota. Esso è formato generalmente rimuovendo il trasporto, il nome utente, il numero della porta, l'hostname ed i parametri aggiuntivi dall'URI remoto, ma in alcuni casi molto complessi è meglio conferire esplicitamente il nome. | name=qemu:///system |
comando | ssh e ext | Il comando esterno. Per il trasporto ext questo è necessario. Per ssh l'impostazione predefinita è ssh. Per il comando viene eseguita la ricerca del PATH. | command=/opt/openssh/bin/ssh |
socket | unix e ssh | Il percorso per il socket del dominio UNIX il quale sovrascrive l'impostazione predefinita. Per il trasporto ssh, esso viene passato al comando netcat remoto (consultare netcat). | socket=/opt/libvirt/run/libvirt/libvirt-sock |
netcat | ssh |
Il comando
netcat può essere usato per eseguire un collegamento con i sistemi remoti. Il parametro netcat predefinito utilizza il comando nc . Per il trasporto SSH, libvirt crea un comando SSH utilizzando il seguente formato:
I parametri
port , username e hostname possono essere specificati come parte dell'URI remoto. command , netcat e socket sono disponibili da altri parametri aggiuntivi.
| netcat=/opt/netcat/bin/nc |
no_verify | tls | If set to a non-zero value, this disables client checks of the server's certificate. Note that to disable server checks of the client's certificate or IP address you must change the libvirtd configuration. | no_verify=1 |
no_tty | ssh | Se impostato su di un valore diverso da zero ssh non richiederà più alcuna password se non riesce ad eseguire automaticamente un log in su di una macchina remota (per l'utilizzo di ssh-agent o simile). Usatelo quando non siete in possesso di un accesso ad un terminale - per esempio in programmi grafici che utilizzano libvirt. | no_tty=1 |
Indice
vmstat
iostat
lsof
# lsof -i :5900 xen-vncfb 10635 root 5u IPv4 218738 TCP grumble.boston.redhat.com:5900 (LISTEN)
qemu-img
systemTap
crash
xen-gdbserver
sysrq
sysrq t
sysrq w
sysrq c
brtcl
# brctl show bridge name bridge id STP enabled interfaces xenbr0 8000.feffffffffff no vif13.0 pdummy0 vif0.0
# brctl showmacs xenbr0 port no mac addr is local? aging timer 1 fe:ff:ff:ff:ff:ff yes 0.00
# brctl showstp xenbr0 xenbr0 bridge id 8000.feffffffffff designated root 8000.feffffffffff root port 0 path cost 0 max age 20.00 bridge max age 20.00 hello time 2.00 bridge hello time 2.00 forward delay 0.00 bridge forward delay 0.00 aging time 300.01 hello timer 1.43 tcn timer 0.00 topology change timer 0.00 gc timer 0.02 flags vif13.0 (3) port id 8003 state forwarding designated root 8000.feffffffffff path cost 100 designated bridge 8000.feffffffffff message age timer 0.00 designated port 8003 forward delay timer 0.00 designated cost 0 hold timer 0.43 flags pdummy0 (2) port id 8002 state forwarding designated root 8000.feffffffffff path cost 100 designated bridge 8000.feffffffffff message age timer 0.00 designated port 8002 forward delay timer 0.00 designated cost 0 hold timer 0.43 flags vif0.0 (1) port id 8001 state forwarding designated root 8000.feffffffffff path cost 100 designated bridge 8000.feffffffffff message age timer 0.00 designated port 8001 forward delay timer 0.00 designated cost 0 hold timer 0.43 flags
ifconfig
tcpdump
ps
pstree
top
kvmtrace
kvm_stat
xentop
xm dmesg
xm log
virsh
è un tool dell'interfaccia della linea di comando per la gestione dei guest e dell'hypervisor.
virsh
è stato creato considerando l'API di gestione libvirt
e funziona come alternativa al tool xm e al graphical guest Manager (virt-manager
). Gli utenti non privilegiati possono usare virsh
per operazioni di sola lettura. Utilizzate virsh
per eseguire gli script per le macchine del guest.
Comando | Descrizione |
---|---|
help
| Visualizza le informazioni di base d'aiuto. |
list
| Elenca tutti i guest. |
dumpxml
| Esegue l'output del file di configurazione XML per il guest. |
create
| Crea un guest da un file di configurazione XML ed avvia il nuovo guest. |
start
| Avvia un guest inattivo. |
destroy
| Forza l'arresto di un guest. |
define
| Esegue un output di un file di configurazione XML per un guest. |
domid
| Displays the guest's ID. |
domuuid
| Displays the guest's UUID. |
dominfo
| Mostra le informazioni del guest. |
domname
| Displays the guest's name. |
domstate
| Mostra lo stato di un guest. |
quit
| Esce dal terminale interattivo. |
reboot
| Riavvia un guest. |
restore
| Ripristina una sessione del guest precedentemente salvata in un file. |
resume
| Ripristina un guest in pausa. |
save
| Salva lo stato corrente di un guest su di un file. |
shutdown
| Arresta correttamente (gracefully) un guest. |
suspend
| Mette in pausa un guest. |
undefine
| Cancella tutti i file associati con un guest. |
migrate
| Migra un guest su di un altro host. |
virsh
sono utilizzate per gestire le risorse dell'hypervisor e del guest:
Comando | Descrizione |
---|---|
setmem
| Imposta la memoria assegnata per un guest. |
setmaxmem
| Imposta il limite massimo della memoria per l'hypervisor. |
setvcpus
| Modifica il numero di CPU virtuali assegnate per un guest. |
vcpuinfo
| Mostra le informazioni della CPU virtuale di un guest. |
vcpupin
| Controlla l'affinità della CPU virtuale di un guest. |
domblkstat
| Mostra le statistiche relative al dispositivo a blocchi per un guest in esecuzione. |
domifstat
| Mostra le statistiche relative all'interfaccia di rete per un guest in esecuzione. |
attach-device
| Collega un dispositivo ad un guest usando una definizione del dispositivo in un file XML. |
attach-disk
| Collega un nuovo dispositivo a disco ad un guest. |
attach-interface
| Collega una nuova interfaccia di rete ad un guest. |
detach-device
|
Scollega un dispositivo da un guest, accetta lo stesso tipo di descrizione XML come il comando attach-device .
|
detach-disk
| Scollega un dispositivo a disco da un guest. |
detach-interface
| Scollega l'interfaccia di rete da un guest. |
virsh
:
Comando | Descrizione |
---|---|
version
|
Mostra la versione di virsh
|
nodeinfo
| Esegue l'output delle informazioni sull'hypervisor |
virsh
:
# virsh connect {hostname OR URL}
<name>
è il nome della macchina dell'hypervisor. Per inizializzare un collegamento di sola lettura inserite il comando sopra riportato con -readonly
.
virsh
:
# virsh dumpxml {domain-id, domain-name or domain-uuid}
stdout
). You can save the data by piping the output to a file. An example of piping the output to a file called guest.xml
:
# virsh dumpxmlThis fileGuestID
>guest.xml
guest.xml
can recreate the guest (refer to Editing a guest's configuration file. You can edit this XML configuration file to configure additional devices or to deploy additional guests. Refer to Sezione 33.1, «Come utilizzare i file di configurazione XML con virsh» for more information on modifying files created with virsh dumpxml
.
virsh dumpxml
:
# virsh dumpxml r5b2-mySQL01 <domain type='xen' id='13'> <name>r5b2-mySQL01</name> <uuid>4a4c59a7ee3fc78196e4288f2862f011</uuid> <bootloader>/usr/bin/pygrub</bootloader> <os> <type>linux</type> <kernel>/var/lib/libvirt/vmlinuz.2dgnU_</kernel> <initrd>/var/lib/libvirt/initrd.UQafMw</initrd> <cmdline>ro root=/dev/VolGroup00/LogVol00 rhgb quiet</cmdline> </os> <memory>512000</memory> <vcpu>1</vcpu> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <interface type='bridge'> <source bridge='xenbr0'/> <mac address='00:16:3e:49:1d:11'/> <script path='vif-bridge'/> </interface> <graphics type='vnc' port='5900'/> <console tty='/dev/pts/4'/> </devices> </domain>
dumpxml
option (refer to Creazione dump XML di una macchina virtuale (file di configurazione)). To create a guest with virsh
from an XML file:
# virsh create configuration_file.xml
dumpxml
option (refer to Creazione dump XML di una macchina virtuale (file di configurazione)) guests can be edited either while they run or while they are offline. The virsh edit
command provides this functionality. For example, to edit the guest named softwaretesting
:
# virsh edit softwaretesting
$EDITOR
(impostato per default su vi
).
virsh
:
# virsh suspend {domain-id, domain-name or domain-uuid}
resume
(Ripristino di un guest) option.
virsh
con l'opzione resume
:
# virsh resume {domain-id, domain-name or domain-uuid}
suspend
e resume
.
virsh
:
# virsh save {domain-name, domain-id or domain-uuid} filename
restore
(Ripristino di un guest) option. Save is similar to pause, instead of just pausing a guest the present state of the guest is saved.
virsh save
command (Come salvare un guest) using virsh
:
# virsh restore filename
virsh
:
# virsh shutdown {domain-id, domain-name or domain-uuid}
on_shutdown
parameter in the guest's configuration file.
virsh
:
#virsh reboot {domain-id, domain-name or domain-uuid}
on_reboot
element in the guest's configuration file.
virsh
:
# virsh destroy {domain-id, domain-name or domain-uuid}
virsh destroy
can corrupt guest file systems . Use the destroy
option only when the guest is unresponsive. For para-virtualized guests, use the shutdown
option(Come arrestare un guest) instead.
# virsh domid {domain-name or domain-uuid}
# virsh domname {domain-id or domain-uuid}
# virsh domuuid {domain-id or domain-name}
virsh domuuid
:
# virsh domuuid r5b2-mySQL01 4a4c59a7-ee3f-c781-96e4-288f2862f011
virsh
with the guest's domain ID, domain name or UUID you can display information on the specified guest:
# virsh dominfo {domain-id, domain-name or domain-uuid}
virsh dominfo
:
# virsh dominfo r5b2-mySQL01 id: 13 name: r5b2-mysql01 uuid: 4a4c59a7-ee3f-c781-96e4-288f2862f011 os type: linux state: blocked cpu(s): 1 cpu time: 11.0s max memory: 512000 kb used memory: 512000 kb
# virsh nodeinfo
virsh nodeinfo
:
# virsh nodeinfo CPU model x86_64 CPU (s) 8 CPU frequency 2895 Mhz CPU socket(s) 2 Core(s) per socket 2 Threads per core: 2 Numa cell(s) 1 Memory size: 1046528 kb
virsh
:
# virsh list
--inactive
elenca i guest inattivi (i guest definiti ma non ancora attivi) e
--all
elenca tutti i guest. Per esempio:
# virsh list --all Id Name State ---------------------------------- 0 Domain-0 running 1 Domain202 paused 2 Domain010 inactive 3 Domain9600 crashed
virsh list
viene categorizzato come uno di sei stati (di seguito riportati).
running
si riferisce ai guest attualmente attivi su di una CPU.
blocked
sono bloccati e non risultano essere in esecuzione e non possono essere eseguiti. Tale comportamento è dovuto a causa di un guest in attesa sull'I/O (uno stato di attesa tradizionale), o se i guest sono in pausa 'sleep mode'.
paused
elenca i domini che sono in pausa. Tale comportamento si verifica se un amministratore usa il pulsante pause in virt-manager
, xm pause
o virsh suspend
. Quando un guest è in uno stato di pausa esso continuerà a consumare memoria ed altre risorse, pur essendo non eleggibile per una sua programmazione o per le risorse dell'hypervisor.
shutdown
è per i guest in procinto di spegnersi. In questo caso verrà inviato al guest un segnale di spegnimento abilitando un processo di spegnimento corretto delle proprie funzioni. Tale procedura potrebbe non funzionare con tutti i sistemi operativi guest; infatti alcuni di essi non rispondono a tali segnali.
dying
sono domini 'morenti', ciò significa che il dominio non è ancora stato completamente arrestato.
crashed
sono guest che hanno fallito durante la loro esecuzione. Questo stato si verifica solo se il guest è stato configurato in modo da non eseguire il riavvio dopo un crash.
virsh
:
# virsh vcpuinfo {domain-id, domain-name or domain-uuid}
virsh vcpuinfo
:
# virsh vcpuinfo r5b2-mySQL01 VCPU: 0 CPU: 0 State: blocked CPU time: 0.0s CPU Affinity: yy
# virsh vcpupin domain-id vcpu cpulist
domain-id
parameter is the guest's ID number or name.
vcpu
denota il numero di CPU virtualizzate assegnate al guest. Il parametro vcpu
deve essere fornito.
cpulist
è un elenco di numeri dell'identificatore della CPU fisica separati da virgole. Il parametro cpulist
determina su quale CPU fisica le VCPU possono essere eseguite.
virsh
:
# virsh setvcpus {domain-name, domain-id or domain-uuid} count
count
non può eccedere il valore del count specificato durante la creazione del guest.
virsh
:
# virsh setmem {domain-id or domain-name} count
virsh domblkstat
per mostrare le statistiche dei dispositivi a blocchi per un guest in esecuzione.
# virsh domblkstat GuestName block-device
virsh domifstat
per visualizzare le statistiche dell'interfaccia di rete per un guest in esecuzione.
# virsh domifstat GuestName interface-device
virsh
. Migrare il dominio su di un altro host. Aggiungere --live per una migrazione live. Il comando migrate
accetta i parametri nel seguente formato:
# virsh migrate --live GuestName DestinationURL
--live
è facoltativo. Aggiungere il parametro --live
per le migrazioni live.
GuestName
rappresenta il nome del guest che si desidera migrare.
DestinationURL
rappresenta l'URL o l'hostname del sistema di destinazione. Il sistema di desitnazione necessita di:
libvirt
deve essere avviato.
virsh
. Per elencare le reti virtuali:
# virsh net-list
# virsh net-list Name State Autostart ----------------------------------------- default active yes vnet1 active yes vnet2 active yes
# virsh net-dumpxml NetworkName
# virsh net-dumpxml vnet1 <network> <name>vnet1</name> <uuid>98361b46-1581-acb7-1643-85a412626e70</uuid> <forward dev='eth0'/> <bridge name='vnet0' stp='on' forwardDelay='0' /> <ip address='192.168.100.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.100.128' end='192.168.100.254' /> </dhcp> </ip> </network>
virsh net-autostart network-name
— Avvia automaticamente una rete specificata come network-name
.
virsh net-create XMLfile
— genera ed avvia una nuova rete utilizzando un file XML già esistente.
virsh net-define XMLfile
— genera un nuovo dispositivo di rete da un file XML esistente senza avviarlo.
virsh net-destroy network-name
— annulla una rete specificata come network-name
.
virsh net-name networkUUID
— converte un networkUUID
specifico in un nome della rete.
virsh net-uuid network-name
— converte un network-name
specificato in un UUID della rete.
virsh net-start nameOfInactiveNetwork
— avvia una rete inattiva.
virsh net-undefine nameOfInactiveNetwork
— rimuove la definizione di una rete inattiva.
virt-manager
), le caselle di dialogo ed i vari controlli GUI.
virt-manager
fornisce una visuale grafica degli hyparvisor e del guest sul vostro sistema e sulle macchine remote. Per definire i guest paravirtualizzati e completamente virtualizzati è possibile utilizzare virt-manager
. virt-manager
è in grado di eseguire compiti di gestione della virtualizzazione incluso:
virt-manager
. The UUID field displays the globally unique identifier for the virtual machines.
dom0
)'s loopback address (127.0.0.1
). This ensures only those with shell privileges on the host can access virt-manager and the virtual machine through VNC.
virt-manager
sticky key capability to send these sequences. To use this capability, you must press any modifier key (Ctrl or Alt) 3 times and the key you specify gets treated as active until the next non-modifier key is pressed. You can then send Ctrl-Alt-F11 to the guest by entering the key sequence 'Ctrl Ctrl Ctrl Alt+F1'.
virt-manager
, it is not possible to use this sticky key feature to send a Sysrq key combination to a guest.
virt-manager
aprite il menu fate clic su e selezionate (virt-manager
).
virt-manager
.
virt-manager
virt-manager
can be started remotely using ssh as demonstrated in the following command:
ssh -X host's address
[remotehost]# virt-manager
Using ssh
to manage virtual machines and hosts is discussed further in Sezione 22.1, «Gestione remota con SSH».
virt-manager
's preferences window.
DHCP
xm
è in grado di gestire l'hypervisor Xen. È possibile eseguire la maggior parte delle operazioni con i tool di libvirt, virt-manager o il comando virsh
. Il comando xm
non possiede la funzione di controllo per la presenza di errori dei tool di libvirt e non dovrebbe essere usato per compiti supportati dai tool di lbvirt.
xm
non funzionano in Red Hat Enterprise Linux 5. L'elenco di seguito riportato fornisce una panoramica delle opzioni del comando disponibili e non.
virsh
o virt-manager
e non xm
. Il comando xm
non è in grado di gestire bene il controllo degli errori o gli errori relativi alla configurazione, con una conseguente instabilità del sistema o errori nelle macchine virtuali. La modifica manuale dei file di configurazione di Xen è pericolosa ed è sconsigliata.
xm
di base comunemente usati:
xm help [--long]
: visualizza le opzioni disponibili ed il testo d'aiuto.
xm list
per elencare i domini attivi:
$ xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 520 2 r----- 1275.5 r5b2-mySQL01 13 500 1 -b---- 16.1
xm create [-c] DomainName/ID
: start a virtual machine. If the -c option is used, the start up process will attach to the guest's console.
xm console DomainName/ID
: attach to a virtual machine's console.
xm destroy DomainName/ID
: termina una macchina virtuale, simile al power off.
xm reboot DomainName/ID
: riavvia una macchina virtuale, viene eseguito attraverso il processo normale di arresto ed avvio del sistema.
xm shutdown DomainName/ID
: arresta una macchina virtuale, esegue una procedura normale di arresto.
xm pause
xm unpause
xm save
xm restore
xm migrate
xm
per gestire le risorse:
xm mem-set
xm vcpu-list
per elencare le affinità delle CPU virtualizzate:
$ xm vcpu-list Name ID VCPUs CPU State Time(s) CPU Affinity Domain-0 0 0 0 r-- 708.9 any cpu Domain-0 0 1 1 -b- 572.1 any cpu r5b2-mySQL01 13 0 1 -b- 16.1 any cpu
xm vcpu-pin
xm vcpu-set
xm sched-credit
per visualizzare i parametri dello scheduler per un determinato dominio:
$ xm sched-credit -d 0 {'cap': 0, 'weight': 256} $ xm sched-credit -d 13 {'cap': 25, 'weight': 256}
xm
per il monitoring ed il troubleshooting:
xm top
xm dmesg
xm info
xm log
xm uptime
per visualizzare l'uptime dei guest e degli host:
$ xm uptime Name ID Uptime Domain-0 0 3:42:18 r5b2-mySQL01 13 0:06:27
xm sysrq
xm dump-core
xm rename
xm domid
xm domname
xm vnet-list
non è attualmente supportato.
/boot/grub/grub.conf
), viene usato per creare un elenco di sistemi operativi da avviare nell'interfaccia del menu di GRUB. Quando installate l'RPM kernel-xen
, uno script aggiunge la voce kernel-xen
al file di configurazione di GRUB il quale avvia kernel-xen
per impostazione predefinita. Modificate il file grub.conf
per modificare il kernel predefinito o per aggiungere i parametri del kernel supplementari.
title Red Hat Enterprise Linux Server (2.6.18-3.el5xen) root (hd0,0) kernel /xen.gz.-2.6.18-3.el5 module /vmlinuz-2.6..18-3.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet module /initrd-2.6.18-3. el5xenxen.img
initrd
ed il kernel di Linux. Poichè la voce del kernel si trova sopra le altre voci, il kernel viene caricato prima nella memoria. Il boot loader invia, e riceve, gli argomenti della linea di comando da e per l'hypervisor, ed il kernel di Linux. Il seguente esempio mostra come limitare la memoria del kernel di linux di Dom0 a 800 MB:
title Red Hat Enterprise Linux Server (2.6.18-3.el5xen) root (hd0,0) kernel /xen.gz.-2.6.18-3.el5 dom0_mem=800M module /vmlinuz-2.6..18-3.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet module /initrd-2.6.18-3. el5xenxen.img
mem
com1=115200, 8n1
dom0_mem
dom0_max_vcpus
acpi
/* **** Linux config options: propagated to domain0 ****/ /* "acpi=off": Disables both ACPI table parsing and interpreter. */ /* "acpi=force": Overrides the disable blacklist. */ /* "acpi=strict": Disables out-of-spec workarounds. */ /* "acpi=ht": Limits ACPI from boot-time to enable HT. */ /* "acpi=noirq": Disables ACPI interrupt routing. */
noacpi
/etc/elilo.conf
, contiene un elenco di opzioni globali e di stanza dell'immagine. Quando installate l'RPM kernel-xen
uno script di post-installazione sarà in grado di aggiungere la stanza dell'immagine appropriata su elilo.conf
.
image=vmlinuz-2.6.18-92.el5xen vmm=xen.gz-2.6.18-92.el5 label=linux initrd=initrd-2.6.18-92.el5xen.img read-only root=/dev/VolGroup00/rhel5_2 append="-- rhgb quiet"
image
parameter indicates the following lines apply to a single boot selection. This stanza defines a hypervisor (vmm
), initrd
, and command line arguments (read-only
, root
and append
) to the hypervisor and kernel. When ELILO is loaded during the boot sequence, the image is labeled linux
.
read-only
nella opzione della linea di comando del kernel ro
, causando un montaggio del file system root in sola-lettura fino a quando initscripts
monta l'unità root in modalità lettura-scrittura. ELILO copia la riga "root
" sulla linea di comando del kernel. Le suddette righe verranno unite con la riga "append
" per dar luogo ad una linea di comando completa:
"-- root=/dev/VolGroup00/rhel5_2 ro rhgb quiet"
--
vengono usati per delimitare gli argomenti dell'hypervisor e del kernel. Gli argomenti dell'hypervisor vengono prima seguiti del delimitatore --
, e successivamente dagli argomenti del kernel. L'hypervisor generalmente non presenta alcun argomento.
--
. Esempio di parametro di memoria dell'hypervisor (mem
) e del parametro quiet
per il kernel:
append="dom0_mem=2G -- quiet"
Parametro | Descrizione |
---|---|
mem= | Il parametro mem definisce l'utilizzo massimo della RAM dell'hypervisor. Qualsiasi RAM aggiuntiva presente nel sistema verrà ignorata. Il parametro può essere specificato con un suffisso B, K, M o G i quali rappresentano rispettivamente bytes, kilobytes, megabytes e gigabytes. Se non viene specificato alcun suffisso l'unità predefinita è kilobytes. |
dom0_mem= | dom0_mem= imposta la quantità di RAM da assegnare a dom0. Vengono rispettati gli stessi suffissi così come il parametro mem. Il valore predefinito in Red Hat Enterprise Linux 5.2 su Itanium® è 4G. |
dom0_max_vcpus= | dom0_max_vcpus= imposta il numero delle CPU da assegnare all'hypervisor. L'impostazione predefinita in Red Hat Enterprise Linux 5.2 su Itanium® è 4. |
com1= | com1= imposta i parametri per la prima riga seriale. Per esempio, com1=9600,8n1,0x408,5 . Le opzioni io_base e irq possono essere omesse, lasciandole così come valori predefiniti standard. Il parametro baud può essere impostato come auto in modo da preservare i parametri del bootloader. Il parametro com1 può essere omesso se i parametri seriali sono stati impostati come opzioni globali in ELILO o nella configurazione di EFI. |
com2= | Imposta i parametri per la seconda riga seriale. Consultate la descrizione del parametro com1 sopra riportato. |
console= | console è un elenco delle preferenze delimitato da virgole, per le opzioni della console. Le opzioni includono vga, com1 e com2. Questa impostazione dovrebbe essere omessa poichè l'hypervisor cercherà di identificare le impostazioni della console EFI. |
image=vmlinuz-2.6.18-92.el5xen vmm=xen.gz-2.6.18-92.el5 label=linux initrd=initrd-2.6.18-92.el5xen.img read-only root=/dev/VolGroup00/rhel5_2 append="dom0_mem=2G dom0_max_vcpus=2 --"
rhgb quiet
" in modo da generare sulle console gli output del kernel e initscript
. Da notare come il doppio trattino rimane invariato in modo da poter interpretare correttamente come argomento dell'hypervisor la riga da aggiungere.
Item | Description |
---|---|
pae
|
Specifies the physical address extension configuration data.
|
apic
|
Specifies the advanced programmable interrupt controller configuration data.
|
memory
|
Specifies the memory size in megabytes.
|
vcpus
|
Specifies the numbers of virtual CPUs.
|
console
|
Specifies the port numbers to export the domain consoles to.
|
nic
|
Specifies the number of virtual network interfaces.
|
vif
|
Lists the randomly-assigned MAC addresses and bridges assigned to use for the domain's network addresses.
|
disk
|
Lists the block devices to export to the domain and exports physical devices to domain with read only access.
|
dhcp
|
Enables networking using DHCP.
|
netmask
|
Specifies the configured IP netmasks.
|
gateway
|
Specifies the configured IP gateways.
|
acpi
|
Specifies the advanced configuration power interface configuration data.
|
libvirt
configuration files for most tasks. Some users may need Xen configuration files which contain the following standard variables. Configuration items within these files must be enclosed in single quotes('). These configuration files reside in the /etc/xen
directory.
xm create --help_config
.
Parameter
|
Description
|
---|---|
vncpasswd =NAME
| Password per console VNC su di un dominio HVM. |
vncviewer=no | yes
|
Genera un vncviewer in ascolto per un server vnc in un dominio. L'indirizzo del vncviewer viene passato al dominio sulla riga di comando del kernel utilizzando VNC_SERVER=<host>:<port> . La porta usata da vnc è 5500 + DISPLAY. Se possibile scegliere un valore che corrisponde ad una porta disponibile. Solo valido quando vnc=1.
|
vncconsole =no | yes
| Spawn a vncviewer process for the domain's graphical console. Only valid when vnc=1. |
name =NAME
| Nome del dominio. Deve essere unico. |
bootloader =FILE
| Percorso per il bootloader. |
bootargs =NAME
| Argomenti da passare al bootloader. |
bootentry =NAME
|
Sconsigliato. Entry da avviare tramite il bootloader. Usare bootargs .
|
kernel =FILE
| Percorso per l'immagine del kernel. |
ramdisk =FILE
| Percorso per la ramdisk. |
features =FEATURES
| Caratteristiche da abilitare nel kernel del guest |
builder =FUNCTION
| Funzione da usare per creare il dominio. |
memory =MEMORY
| Memoria del dominio in MB. |
maxmem =MEMORY
| Memoria massima del dominio in MB. |
shadow_memory =MEMORY
| Memoria shadow del dominio in MB. |
cpu =CPU
| CPU contenente VCPU0. |
cpus =CPUS
| CPUS sulla quale eseguire il dominio. |
pae =PAE
| Disabilita o abilita PAE del dominio HVM. |
acpi =ACPI
| Disabilita o abilita ACPI del dominio HVM. |
apic =APIC
| Disabilita o abilita APIC del dominio HVM. |
vcpus =VCPUs
| Numero di CPUS virtuali nel dominio. |
cpu_weight =WEIGHT
|
Set the new domain's cpu weight. WEIGHT is a float that controls the domain's share of the cpu.
|
restart =onreboot | always | never
|
Sconsigliato. Utilizzate on_poweroff, on_reboot , e on_crash . Se il dominio deve essere riavviato dopo l'uscita, - onreboot : riavvia all'uscita con shutdown code reboot - always: riavvia sempre dopo l'uscita, ignora codice d'uscita - never: non riavviare mai dopo l'uscita, ignora codice d'uscita.
|
on_poweroff =destroy | restart | preserve | destroy
|
Behavior when a domain exits with reason 'poweroff '. - destroy: the domain is cleaned up as normal; - restart: a new domain is started in place of the old one; - preserve: no clean-up is done until the domain is manually destroyed (using xm destroy, for example); - rename-restart: the old domain is not cleaned up, but is renamed and a new domain started in its place.
|
on_reboot =destroy | restart | preserve | destroy
| Behavior when a domain exits with reason 'reboot'. - destroy: the domain is cleaned up as normal; - restart: a new domain is started in place of the old one; - preserve: no clean-up is done until the domain is manually destroyed (using xm destroy, for example); - rename-restart: the old domain is not cleaned up, but is renamed and a new domain started in its place. |
on_crash =destroy | restart | preserve | destroy
| Behavior when a domain exits with reason 'crash'. - destroy: the domain is cleaned up as normal; - restart: a new domain is started in place of the old one; - preserve: no clean-up is done until the domain is manually destroyed (using xm destroy, for example); - rename-restart: the old domain is not cleaned up, but is renamed and a new domain started in its place. |
blkif =no | yes
| Rende il dominio un backend del dispositivo a blocchi. |
netif =no | yes
| Rende il dominio un backend dell'interfaccia di rete. |
tpmif =no | yes
| Rende il dominio un backend dell'interfaccia TPM. |
disk =phy:DEV,VDEV,MODE[,DOM]
|
Aggiunge un dispositivo a disco ad un dominio. Il dispositivo fisico è DEV , il quale viene esportato sul dominio come VDEV . Il disco è di sola lettura se MODE è r , lettura-scrittura se MODE è w . Se DOM è stato specificato, esso definisce il dominio del driver backend da usare per il disco. L'opzione può essere ripetuta per aggiungere più di un disco.
|
pci =BUS:DEV.FUNC
|
Aggiunge un dispositivo PCI ad un dominio utilizzando i parametri dati (in esadecimale). Per esempio pci=c0:02.1a . L'opzione può essere ripetuta per aggiungere più di un dispositivo pci.
|
ioports =FROM[-TO]
|
Aggiunge un intervallo I/O legacy utilizzando i parametri dati (in hex). Per esempio ioports=02f8-02ff . L'opzione può essere ripetuta per aggiungere più di un intervallo i/o.
|
irq =IRQ
|
Aggiunge un IRQ (interruzione della riga) ad un dominio. Per esempio irq=7 . Questa opzione può essere ripetuta per aggiungere più di un IRQ.
|
usbport =PATH
| Aggiunge una porta USB fisica ad un dominio, come specificato dal percorso di quella porta. Questa opzione può essere ripetuta per aggiungere più di una porta. |
vfb=type=
vnclisten=
xauthority=
keymap =KEYMAP
|
Make the domain a framebuffer backend. The backend type should be either sdl or vnc . For type=vnc , connect an external vncviewer. The server will listen on ADDR (default 127.0.0.1) on port N+5900. N defaults to the domain id. If vncunused=1 , the server will try to find an arbitrary unused port above 5900. For type=sdl , a viewer will be started automatically using the given DISPLAY and XAUTHORITY , which default to the current user's ones.
|
vif=type=
script= =NAME
|
Aggiunge una interfaccia di rete con l'indirizzo MAC dato ed il bridge. vif viene configurato richiamando lo script di configurazione definito. Se il tipo non è stato specificato, il default sarà netfront e non il dispositivo ioemu. Se mac non è stato specificato verrà usato un indirizzo MAC randomico. Se non specificato il backend di rete seleziona il proprio indirizzo MAC . Se bridge non è stato specificato verrà utilizzato il primo bridge disponibile. Se non è stato specificato lo script allora sarà implementato lo script predefinito. Se non è stato specificato il backend, allora verrà utilizzato il dominio del driver backend predefinito. Se vifname non è stato specificato, l'interfaccia virtuale backend avrà come nome vifD.N, dove D è l'id del dominio e N è l'id dell'interfaccia. Questa opzione può essere ripetuta per aggiungere più di un vif. Specificando vifs aumenterete il numero delle interfacce in modo desiderato.
|
vtpm=instance= INSTANCE ,backend=DOM
|
Aggiunge l'interfaccia TPM. Dal lato del backend utilizzare l'istanza data come istanza TPM virtuale. Il numero specificato è il solo numero preferito per l'istanza. Lo script hotplug determinerà il numero dell'istanza che verrà assegnato al dominio. L'associazione tra macchina virtuale ed il numero dell'istanza TPM è disponibile in /etc/xen/vtpm.db . Utilizzate il backend nel dominio specificato.
|
access_control=policy= POLICY ,label=LABEL
| Aggiunge una etichetta di sicurezza ed un riferimento alla politica di sicurezza che la definisce. Il riferimento ssid locale viene calcolato al momento dell'avvio/ripristino del dominio. Al momento, la politica viene anche controllata con la politica attiva. In questo modo la migrazione attraverso il salvataggio/recupero viene soddisfatta e le etichette locali vengono automaticamente create in modo corretto sul sistema dove il dominio viene avviato/ripristinato. |
nics =NUM
| SCONSIGLIATO. Utilizzare invece le voci vif vuote. Imposta il numero di interfacce di rete. Utilizzare l'opzione vif per definire i parametri dell'interfaccia, in caso contrario verrano utilizzati i valori predefiniti. Specificando vifs aumenterete il numero di interfacce in base alle vostre necessità. |
root =DEVICE
|
Imposta il parametro root sulla riga di comando del kernel. Utilizzare un dispositivo, es. /dev/sda1 , o /dev/nfs per NFS root.
|
extra =ARGS
| Imposta argomenti supplementari da aggiungere alla riga di comando del kernel. |
ip =IPADDR
| Imposta l'indirizzo IP dell'interfaccia del kernel. |
gateway =IPADDR
| Imposta il gateway IP del kernel. |
netmask =MASK
| Imposta la maschera di rete IP del kernel. |
hostname =NAME
| Imposta l'hostname IP del kernel. |
interface =INTF
| Imposta il nome dell'interfaccia IP del kernel. |
dhcp =off|dhcp
| Imposta l'opzione dhcp del kernel. |
nfs_server =IPADDR
| Imposta l'indirizzo del server NFS per NFS root. |
nfs_root =PATH
| Imposta il percorso della directory root NFS. |
device_model =FILE
| Percorso del programma per il modello di dispositivo. |
fda =FILE
| Percorso per fda |
fdb =FILE
| Percorso per fdb |
serial =FILE
| Percorso per seriale, pty o vc |
localtime =no | yes
| È stato impostato RTC su orario locale? |
keymap =FILE
| Disposizione tastiera impostata utilizzata |
usb =no | yes
| Emulare dispositivi USB? |
usbdevice =NAME
|
Nome di un dispositivo USB da aggiungere
|
stdvga =no | yes
|
Use std vga or Cirrus Logic
graphics
|
isa =no | yes
|
Simulare solo un sistema ISA
|
boot =a|b|c|d
| Dispositivo d'avvio predefinito |
nographic =no | yes
| I modelli del dispositivo devono usare i grafici? |
soundhw =audiodev
| I modelli del dispositivo devono utilizzare il dispositivo audio? |
vnc
| Il modello del dispositivo deve utilizzare VNC? |
vncdisplay
| Display VNC da usare |
vnclisten
| Indirizzo per il server VNC sul quale eseguire l'ascolto. |
vncunused
| Trova una porta non utilizzata per il server VNC. Valida solo quando vnc=1. |
sdl
| Il modello del dispositivo deve usare SDL? |
display =DISPLAY
| Display X11 da usare |
xauthority =XAUTHORITY
| Authority X11 da usare |
uuid
| xenstore UUID (universally unique identifier) da usare. Se questa opzione non è stata impostata verrà generato un valore randomico, in modo simile agli indirizzi MAC per le interfacce di rete virtuali. Esso deve essere un valore unico su tutto il cluster. |
Funzione del parser | Argomenti validi |
---|---|
set_bool
|
Valori accettati:
|
set_float
|
Accepts a floating point number with Python's float(). For example:
|
set_int
|
Accepts an integer with Python's int().
|
set_value
|
accetta qualsiasi valore di Python.
|
append_value
|
accetta qualsiasi valore di Python e lo aggiunge al valore precedente conservato in un array.
|
Parameter | Funzione del parser | Valore predefinito |
---|---|---|
name
|
setter
|
default value
|
vncpasswd
|
set_value
|
None
|
vncviewer
|
set_bool
|
None
|
vncconsole
|
set_bool
|
None
|
name
|
set_value
|
None
|
bootloader
|
set_value
|
None
|
bootargs
|
set_value
|
None
|
bootentry
|
set_value
|
None
|
kernel
|
set_value
|
None
|
ramdisk
|
set_value
|
''
|
features
|
set_value
|
''
|
builder
|
set_value
|
'linux'
|
memory
|
set_int
|
128
|
maxmem
|
set_int
|
None
|
shadow_memory
|
set_int
|
0
|
cpu
|
set_int
|
None
|
cpus
|
set_value
|
None
|
pae
|
set_int
|
0
|
acpi
|
set_int
|
0
|
apic
|
set_int
|
0
|
vcpus
|
set_int
|
1
|
cpu_weight
|
set_float
|
None
|
restart
|
set_value
|
None
|
on_poweroff
|
set_value
|
None
|
on_reboot
|
set_value
|
None
|
on_crash
|
set_value
|
None
|
blkif
|
set_bool
|
0
|
netif
|
set_bool
|
0
|
tpmif
|
append_value
|
0
|
disk
|
append_value
|
[]
|
pci
|
append_value
|
[]
|
ioports
|
append_value
|
[]
|
irq
|
append_value
|
[]
|
usbport
|
append_value
|
[]
|
vfb
|
append_value
|
[]
|
vif
|
append_value
|
[]
|
vtpm
|
append_value
|
[]
|
access_control
|
append_value
|
[]
|
nics
|
set_int
|
-1
|
root
|
set_value
|
''
|
extra
|
set_value
|
''
|
ip
|
set_value
|
''
|
gateway
|
set_value
|
''
|
netmask
|
set_value
|
''
|
hostname
|
set_value
|
''
|
interface
|
set_value
|
"eth0"
|
dhcp
|
set_value
|
'off'
|
nfs_server
|
set_value
|
None
|
nfs_root
|
set_value
|
None
|
device_model
|
set_value
|
''
|
fda
|
set_value
|
''
|
fdb
|
set_value
|
''
|
serial
|
set_value
|
''
|
localtime
|
set_bool
|
0
|
keymap
|
set_value
|
''
|
usb
|
set_bool
|
0
|
usbdevice
|
set_value
|
''
|
stdvga
|
set_bool
|
0
|
isa
|
set_bool
|
0
|
boot
|
set_value
|
'c'
|
nographic
|
set_bool
|
0
|
soundhw
|
set_value
|
''
|
vnc
|
set_value
|
None
|
vncdisplay
|
set_value
|
None
|
vnclisten
|
set_value
|
None
|
vncunused
|
set_bool
|
1
|
sdl
|
set_value
|
None
|
display
|
set_value
|
None
|
xauthority
|
set_value
|
None
|
uuid
|
set_value
|
None
|
Indice
ftpd
ftpd
virsh
per impostare un guest, TestServer
, per un avvio automatico all'avvio dell'host.
# virsh autostart TestServer
Domain TestServer marked as autostarted
--disable
# virsh autostart --disable TestServer
Domain TestServer unmarked as autostarted
Installate il pacchetto KVM
# yum install kvm
Verificate quale kernel è in esecuzione
uname
per determinare quale kernel è in esecuzione:
$ uname -r 2.6.18-159.el5xen
2.6.18-159.el5xen
", è in esecuzione sul sistema. Se il kernel predefinito, "2.6.18-159.el5
", è in esecuzione sul sistema è possibile saltare la fase secondaria.
Modifica del kernel Xen nel kernel predefinito
grub.conf
determina quale kernel è stato avviato. Per modificare il kernel predefinito modificare il file /boot/grub/grub.conf
come di seguito indicato.
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-159.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-159.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-159.el5.img
title Red Hat Enterprise Linux Server (2.6.18-159.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-159.el5
module /vmlinuz-2.6.18-159.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-159.el5xen.img
0
(o sul numero per il kernel predefinito):
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-159.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-159.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-159.el5.img
title Red Hat Enterprise Linux Server (2.6.18-159.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-159.el5
module /vmlinuz-2.6.18-159.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-159.el5xen.img
Eseguite un riavvio per caricare il nuovo kernel
$ lsmod | grep kvm kvm_intel 85992 1 kvm 222368 2 ksm,kvm_intel
kvm
ed il modulo kvm_intel
o kvm_amd
saranno presenti se la procedura è stata corretta.
Installare i pacchetti Xen
# yum install kernel-xen xen
Verificate quale kernel è in esecuzione
uname
per determinare quale kernel è in esecuzione.
$ uname -r 2.6.18-159.el5
2.6.18-159.el5
", è in esecuzione sul sistema. Questo è il kernel predefinito. Se il kernel presenta xen
alla fine (per esempio 2.6.18-159.el5xen
) allora risulterà in esecuzione il kernel Xen; a tal proposito è possibile saltare la fase secondaria.
Modifica del kernel predefinito in kernel Xen
grub.conf
determina quale kernel è stato avviato. Per modificare il kernel predefinito modificare il file /boot/grub/grub.conf
come di seguito indicato.
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-159.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-159.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-159.el5.img
title Red Hat Enterprise Linux Server (2.6.18-159.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-159.el5
module /vmlinuz-2.6.18-159.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-159.el5xen.img
1
(o il numero corrispondente per il kernel Xen):
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-159.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-159.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-159.el5.img
title Red Hat Enterprise Linux Server (2.6.18-159.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-159.el5
module /vmlinuz-2.6.18-159.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-159.el5xen.img
Eseguite un riavvio per caricare il nuovo kernel
uname
:
$ uname -r 2.6.18-159.el5xen
xen
è presente alla fine dell'output allora il kernel in esecuzione sarà Xen.
qemu-img
viene usato per la formattazione di vari file system usati da Xen e KVM. qemu-img
deve essere usato per la formattazione delle immagini del guest virtualizzato, dei dispositivi di storage aggiuntivi e per lo storage di rete. Le opzioni qemu-img
ed il loro utilizzo sono di seguito riportati.
size
e formato format
.
# qemu-img create [-6] [-e] [-b base_image] [-f format] filename [size]
convert
viene usata per convertire un formato conosciuto in un formato diverso dell'immagine.
# qemu-img convert [-c] [-e] [-f format]filename
[-Ooutput_format
]output_filename
filename
dell'immagine del disco in un disk image output_filename
usando il formato output_format
. Esso può essere facoltativamente cifrato (opzione -e
) o compresso (opzione -c
).
qcow
" supporta la cifratura o la compressione. Il processo di compressione è di sola-lettura. Ciò significa che se si riscrive un settore esso viene scritto nuovamente con dati non compressi.
qcow
o cow
. I settori vuoti sono rilevati ed eliminati dall'immagine di destinazione.
info
mostra le informazioni relative all'immagine del disco. Il formato per l'opzione info
è il seguente:
# qemu-img info [-f format] filename
raw
qemu-img info
per sapere la dimensione reale usata dall'immagine o ls -ls
su Unix/Linux.
qcow2
qcow
cow
cow
viene incluso solo per compatibilità con le versioni precedenti. Non funziona con Windows.
vmdk
cloop
(0.5 * RAM) + (overcommit ratio * RAM) = Recommended swap size
/etc/grub.conf
file to use the virtualization kernel. You must use the xen
kernel to use the Xen hypervisor. Copy your existing xen
kernel entry make sure you copy all of the important lines or your system will panic upon boot (initrd
will have a length of '0
'). If you require xen
hypervisor specific values you must append them to the xen
line of your grub entry.
grub.conf
di un sistema sul quale viene eseguito il pacchetto kernel-xen. grub.conf
sul vostro sistema potrebbe variare. La parte più importante nell'esempio è la sezione corrispondente alla riga title
fino alla nuova riga successiva.
#boot=/dev/sda default=0 timeout=15 #splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 terminal --timeout=10 serial console title Red Hat Enterprise Linux Server (2.6.17-1.2519.4.21.el5xen) root (hd0,0) kernel /xen.gz-2.6.17-1.2519.4.21.el5 com1=115200,8n1 module /vmlinuz-2.6.17-1.2519.4.21.el5xen ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.17-1.2519.4.21.el5xen.img
grub.conf
...grub.conf
could look very different if it has been manually edited before or copied from an example. Read Capitolo 28, Configurazione dei parametri d'avvio del kernel di Xen for more information on using virtualization and grub.
dom0_mem=256M
sulla riga xen
all'interno del vostro grub.conf
. Una versione modificata del file di configurazione di grub nell'esempio precedente:
#boot=/dev/sda default=0 timeout=15 #splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 terminal --timeout=10 serial console title Red Hat Enterprise Linux Server (2.6.17-1.2519.4.21.el5xen) root (hd0,0) kernel /xen.gz-2.6.17-1.2519.4.21.el5 com1=115200,8n1 dom0_mem=256MB module /vmlinuz-2.6.17-1.2519.4.21.el5xen ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.17-1.2519.4.21.el5xen.img
$ grep -E 'svm|vmx' /proc/cpuinfo
vmx
la quale indica un processore Intel con estensioni Intel VT:
flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
svm
la quale indica un processore AMD con estensioni AMD-V:
flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm cr8legacy ts fid vid ttp tm stc
flags:
" potrebbe apparire numerose volte per ogni hyperthread, core o CPU sul sistema.
For users of the KVM hypervisor
kvm
modules are loaded in the kernel:
# lsmod | grep kvm
kvm_intel
or kvm_amd
then the kvm
hardware virtualization modules are loaded and your system meets requirements. sudo
virsh
command can output a full list of virtualization system capabilities. Run virsh capabilities
as root to receive the complete list.
kpartx
tool, covered by this section, to mount the guest file system as a loop device which can then be accessed.
kpartx
command creates device maps from partition tables. Each guest storage image has a partition table embedded in the file.
# yum install kpartx
guest1.img
.
# kpartx -l /var/lib/libvirt/images/guest1.img
loop0p1 : 0 409600 /dev/loop0 63
loop0p2 : 0 10064717 /dev/loop0 409663
guest1
is a Linux guest. The first partition is the boot partition and the second partition is an EXT3 containing the root partition.
/dev/mapper/
.
# kpartx -a /var/lib/libvirt/images/guest1.img
# ls /dev/mapper/ loop0p1 loop0p2
loopXpY
.
/mnt/guest1
for mounting the partition.
# mkdir /mnt/guest1
# mount /dev/mapper/loop0p1
/mnt/guest1 -o loop,ro
/mnt/guest1
directory. Read or copy the files.
# umount /mnt/tmp
# kpartx -d /var/lib/libvirt/images/guest1.img
guest1.img
to the recognized devices in the /dev/mapper/
directory.
# kpartx -a /var/lib/libvirt/images/guest1.img
vgscan
command to find the new volume groups.
# vgscan Reading all physical volumes . This may take a while... Found volume group "VolGroup00" using metadata type lvm2
VolGroup00
by default) with the vgchange -ay
command.
# vgchange -ay VolGroup00 2 logical volumes in volume group VolGroup00 now active.
lvs
command to display information about the new volumes. The volume names (the LV
column) are required to mount the volumes.
# lvs LV VG Attr Lsize Origin Snap% Move Log Copy% LogVol00 VolGroup00 -wi-a- 5.06G LogVol01 VolGroup00 -wi-a- 800.00M
/dev/VolGroup00/LogVol00
in the /mnt/guestboot/
directory.
# mount /dev/VolGroup00/LogVol00 /mnt/guestboot
/mnt/guestboot
directory. Read or copy the files.
# umount /mnt/
VolGroup00
# vgchange -an VolGroup00
# kpartx -d /var/lib/libvirt/images/guest1.img
virsh nodeinfo
command provides information about how many sockets, cores and hyperthreads there are attached a host.
# virsh nodeinfo CPU model: x86_64 CPU(s): 8 CPU frequency: 1000 MHz CPU socket(s): 2 Core(s) per socket: 4 Thread(s) per core: 1 NUMA cell(s): 1 Memory size: 8179176 kB
virsh capabilities
to get additional output data on the CPU configuration.
# virsh capabilities
<capabilities>
<host>
<cpu>
<arch>x86_64</arch>
</cpu>
<migration_features>
<live/>
<uri_transports>
<uri_transport>tcp</uri_transport>
</uri_transports>
</migration_features>
<topology>
<cells num='2'>
<cell id='0'>
<cpus num='4'>
<cpu id='0'/>
<cpu id='1'/>
<cpu id='2'/>
<cpu id='3'/>
</cpus>
</cell>
<cell id='1'>
<cpus num='4'>
<cpu id='4'/>
<cpu id='5'/>
<cpu id='6'/>
<cpu id='7'/>
</cpus>
</cell>
</cells>
</topology>
<secmodel>
<model>selinux</model>
<doi>0</doi>
</secmodel>
</host>
[ Additional XML removed ]
</capabilities>
virsh freecell
command to display the free memory on all NUMA nodes.
# virsh freecell 0: 2203620 kB 1: 3354784 kB
virsh capabilities
command) about NUMA topology.
virsh capabilities
output.
<topology> <cells num='2'> <cell id='0'> <cpus num='4'> <cpu id='0'/> <cpu id='1'/> <cpu id='2'/> <cpu id='3'/> </cpus> </cell> <cell id='1'> <cpus num='4'> <cpu id='4'/> <cpu id='5'/> <cpu id='6'/> <cpu id='7'/> </cpus> </cell> </cells> </topology>
<cell id='1'>
, has physical CPUs 4 to 7.
cpuset
attribute to the configuration file.
virsh edit
.
vcpus
element.
<vcpus>4</vcpus>
cpuset
attribute with the CPU numbers for the relevant NUMA cell.
<vcpus cpuset='4-7'>4</vcpus>
virt-install
provisioning tool provides a simple way to automatically apply a 'best fit' NUMA policy when guests are created.
cpuset
option for virt-install
can use a CPU set of processors or the parameter auto
. The auto
parameter automatically determines the optimal CPU locking using the available NUMA data.
--cpuset=auto
with the virt-install
command when creating new guests.
virsh vcpuinfo
and virsh vcpupin
commands can perform CPU affinity changes on running guests.
virsh vcpuinfo
command gives up to date information about where each virtual CPU is running.
guest1
is a guest with four virtual CPUs is running on a KVM host.
# virsh vcpuinfo guest1
VCPU: 0
CPU: 3
State: running
CPU time: 0.5s
CPU Affinity: yyyyyyyy
VCPU: 1
CPU: 1
State: running
CPU Affinity: yyyyyyyy
VCPU: 2
CPU: 1
State: running
CPU Affinity: yyyyyyyy
VCPU: 3
CPU: 2
State: running
CPU Affinity: yyyyyyyy
virsh vcpuinfo
output (the yyyyyyyy
value of CPU Affinity
) shows that the guest can presently run on any CPU.
# virsh vcpupinguest1
0 4 # virsh vcpupinguest1
1 5 # virsh vcpupinguest1
2 6 # virsh vcpupinguest1
3 7
virsh vcpuinfo
command confirms the change in affinity.
# virsh vcpuinfo guest1
VCPU: 0
CPU: 4
State: running
CPU time: 32.2s
CPU Affinity: ----y---
VCPU: 1
CPU: 5
State: running
CPU time: 16.9s
CPU Affinity: -----y--
VCPU: 2
CPU: 6
State: running
CPU time: 11.9s
CPU Affinity: ------y-
VCPU: 3
CPU: 7
State: running
CPU time: 14.6s
CPU Affinity: -------y
macgen.py
. Now from that directory you can run the script using ./macgen.py
and it will generate a new MAC address. A sample output would look like the following:
$ ./macgen.py 00:16:3e:20:b0:11 #!/usr/bin/python # macgen.py script to generate a MAC address for virtualized guests on Xen # import random # def randomMAC(): mac = [ 0x00, 0x16, 0x3e, random.randint(0x00, 0x7f), random.randint(0x00, 0xff), random.randint(0x00, 0xff) ] return ':'.join(map(lambda x: "%02x" % x, mac)) # print randomMAC()
python-virtinst
per generare un nuovo indirizzo MAC e UUID
, per un utilizzo all'interno del file di configurazione:
# echo 'import virtinst.util ; print\ virtinst.util.uuidToString(virtinst.util.randomUUID())' | python # echo 'import virtinst.util ; print virtinst.util.randomMAC()' | python
#!/usr/bin/env python # -*- mode: python; -*- print "" print "New UUID:" import virtinst.util ; print virtinst.util.uuidToString(virtinst.util.randomUUID()) print "New MAC:" import virtinst.util ; print virtinst.util.randomMAC() print ""
rate
” parameter part of the VIF
entries can throttle virtualized guests.
rate
rate=
option can be added to the VIF=
entry in a virtual machine configuration file to limit a virtual machine's network bandwidth or specify a specific time interval for a time window.
rate=
:
rate
.
rate=10Mb/s
rate=250KB/s
rate=10MB/s@50ms
VIF
somiglierà a quanto di seguito riportato:
vif = [ 'rate=10MB/s , mac=00:16:3e:7a:55:1c, bridge=xenbr1']
rate
entry would limit the virtual machine's interface to 10MB/s for outgoing traffic
virsh
o virt-manager
:
virsh
refer to Configurazione affinità CPU virtuale for more information.
virt-manager
refer to Sezione 26.11, «Visualizzazione delle CPU virtuali» for more information.
/boot/grub/grub.conf
. Managing several or more hosts configuration files quickly becomes difficult. System administrators often prefer to use the 'cut and paste' method for editing multiple grub.conf
files. If you do this, ensure you include all five lines in the Virtualization entry (or this will create system errors). Hypervisor specific values are all found on the 'xen
' line. This example represents a correct grub.conf
virtualization entry:
# boot=/dev/sda/ default=0 timeout=15 #splashimage=(hd0, 0)/grub/splash.xpm.gz hiddenmenu serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 terminal --timeout=10 serial console title Red Hat Enterprise Linux Server (2.6.17-1.2519.4.21. el5xen) root (hd0, 0) kernel /xen.gz-2.6.17-1.2519.4.21.el5 com1=115200,8n1 module /vmlinuz-2.6.17-1.2519.4.21el5xen ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.17-1.2519.4.21.el5xen.img
'dom0_mem=256M'
. This example is the grub.conf
with the hypervisor's memory entry modified.
# boot=/dev/sda
default=0
timeout=15
#splashimage=(hd0,0)/grubs/splash.xpm.gz
hiddenmenu
serial --unit=0 --speed =115200 --word=8 --parity=no --stop=1
terminal --timeout=10 serial console
title Red Hat Enterprise Linux Server (2.6.17-1.2519.4.21. el5xen)
root (hd0,0)
kernel /xen.gz-2.6.17-1.2519.4.21.el5 com1=115200,8n1 dom0_mem=256MB
module /vmlinuz-2.6.17-1.2519.4.21.el5xen ro root=/dev/VolGroup00/LogVol00
module /initrd-2.6.17-1.2519.4.21.el5xen.img
ftpd
vsftpd
fornisce l'accesso necessario agli alberi d'installazione per i guest paravirtualizzati (per esempio ai repositori di Red Hat Enterprise Linux 5), o altri dati. Se non avete ancora installato vsftpd
durante l'installazione del server, è possibile ottenere il pacchetto RPM dalla vostra directory Server
del dispositivo d'installazione, ed installarlo usando rpm -ivh vsftpd*.rpm
(da notare che il pacchetto RPM deve essere presente all'interno della vostra directory corrente).
vsftpd
, edit /etc/passwd
using vipw
and change the ftp user's home directory to the directory where you are going to keep the installation trees for your para-virtualized guests. An example entry for the FTP user would look like the following:
ftp:x:14:50:FTP User:/xen/pub:/sbin/nologin
vsftpd
non sia stato abilitato usando chkconfig --list vsftpd
:
$ chkconfig --list vsftpd vsftpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
chkconfig --levels 345 vsftpd on
per avviare vsftpd automaticamente per i runlevel 3, 4 e 5.
chkconfig --list vsftpd
per verificare che vsftpd
sia stato abilitato all'avvio durante il processo di boot del sistema:
$ chkconfig --list vsftpd vsftpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
service vsftpd start vsftpd
per l'avvio del servizio vsftpd:
$service vsftpd start vsftpd Starting vsftpd for vsftpd: [ OK ]
udev
per l'implementazione della persistenza LUN. Prima di implementare la persistenza LUN nel vostro sistema, assicuratevi di aver acquisito gli UUID corretti. Fatto questo, sarà possibile configurare la persistenza LUN modificando il file scsi_id
il quale risiede nella directory /etc
. Una volta aperto il file con un editor di testo, commentate la seguente riga:
# options=-b
# options=-g
scsi_id
:
# scsi_id -g -s /block/sdc *3600a0b80001327510000015427b625e*
20-names.rules
nella directory /etc/udev/rules.d
Le regole usate per nominare il dispositivo devono seguire il seguente formato:
# KERNEL="sd*", BUS="scsi", PROGRAM="sbin/scsi_id", RESULT="UUID
", NAME="devicename
"
UUID
e devicename
con la voce dell'UUID sopra riportato. Quindi la regola dovrebbe somigliare alla seguente:
KERNEL="sd*
", BUS="scsi", PROGRAM="sbin/scsi_id", RESULT="3600a0b80001327510000015427b625e
", NAME="mydevicename
"
/dev/sd*
in modo da controllare l'UUID dato. Una volta trovato un dispositivo corrispondente, esso creerà un nodo del dispositivo chiamato /dev/devicename
. Per questo esempio il nodo del dispositivo è /dev/mydevice
. Per finire, sarà necessario aggiungere al file /etc/rc.local
la seguente stringa:
/sbin/start_udev
multipath.conf
che risiede nella directory /etc/
:
multipath { wwid 3600a0b80001327510000015427b625e alias oramp1 } multipath { wwid 3600a0b80001327510000015427b6 alias oramp2 } multipath { wwid 3600a0b80001327510000015427b625e alias oramp3 } multipath { wwid 3600a0b80001327510000015427b625e alias oramp4 }
/dev/mpath/oramp1
, /dev/mpath/oramp2
, /dev/mpath/oramp3
, e dev/mpath/oramp4
. I dispositivi risiederanno nella directory /dev/mpath
. I nomi dei LUN resteranno invariati anche dopo aver eseguito diversi processi di riavvio, poichè i suddetti nomi verranno creati sul wwid dei LUN.
/sbin/service smartd stop /sbin/chkconfig --del smartd
/var/lib/xen
, the usually named vmlinuz.******
and initrd.******
. These files are the initrd and vmlinuz files from virtual machines which either failed to boot or failed for some other reason. These files are temporary files extracted from virtual machine's boot disk during the start up sequence. These files should be automatically removed after the virtual machine is shut down cleanly. Then you can safely delete old and stale copies from this directory.
vino-preferences
.
~/.vnc/xstartup
per avviare la sessione di GNOME quando vncserver è stato avviato. Quando eseguite per la prima volta vncserver, vi verrà richiesto di inserire la password che desiderate usare per la vostra sessione VNC.
xstartup
:
#!/bin/sh # Uncomment the following two lines for normal desktop: # unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources #xsetroot -solid grey #vncconfig -iconic & #xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & #twm & if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then eval `dbus-launch --sh-syntax –exit-with-session` echo "D-BUS per-session daemon address is: \ $DBUS_SESSION_BUS_ADDRESS" fi exec gnome-session
uuidgen
command. Then for the vif
entries you must define a unique MAC address for each guest (if you are copying a guest configuration from an existing guest, you can create a script to handle it). For the xen bridge information, if you move an existing guest configuration file to a new host, you must update the xenbr
entry to match your local networking configuration. For the Device entries, you must modify the entries in the 'disk='
section to point to the correct guest image.
/etc/sysconfig/network
file to match the new guest's hostname.
HWADDR
del file /etc/sysconfig/network-scripts/ifcfg-eth0
in modo da corrispondere all'output generato dal file ifconfig eth0
, e se utilizzate gli indirizzi IP statici, modificate la voce IPADDR
.
name
uuid
uuidgen
. Esempio di output UUID:
$ uuidgen a984a14f-4191-4d14-868e-329906b211e5
vif
xenbr
, in modo che essa corrisponda alla vostra configurazione di networking locale (è possibile ottenere le informazioni del bridge usando il comando brctl show
).
disk=
, in modo da indicare l'immagine del guest corretto.
/etc/sysconfig/network
HOSTNAME
entry to the guest's new hostname
.
/etc/sysconfig/network-scripts/ifcfg-eth0
HWADDR
con l'output di ifconfig eth0
IPADDR
se usate un indirizzo IP statico.
libvirt
.
libvirt
.
virsh
can handle XML configuration files. You may want to use this to your advantage for scripting large deployments with special options. You can add devices defined in an XML file to a running para-virtualized guest. For example, to add a ISO file as hdc
to a running guest create an XML file:
# cat satelliteiso.xml <disk type="file" device="disk"> <driver name="file"/> <source file="/var/lib/libvirt/images/rhn-satellite-5.0.1-11-redhat-linux-as-i386-4-embedded-oracle.iso"/> <target dev="hdc"/> <readonly/> </disk>Run
virsh attach-device
to attach the ISO as hdc
to a guest called "satellite" :
# virsh attach-device satellite satelliteiso.xml
Indice
xentop
xentop
visualizza le informazioni real-time di un sistema host e dei domini del guest.
xm
dmesg
e log
vmstat
iostat
lsof
iostat
, mpstat
e sar
sono tutti forniti dal pacchetto sysstat
.
XenOprofile
systemtap
crash
sysrq
sysrq t
sysrq w
ifconfig
tcpdump
tcpdump
command 'sniffs' network packets. tcpdump
is useful for finding network abnormalities and problems with network authentication. There is a graphical version of tcpdump
named wireshark
.
brctl
brctl
è un tool per il networking che controlla e configura la configurazione del bridge di ethernet nel kernel linux di Virtualizzazione. È necessario avere un accesso root prima di eseguire i seguenti comandi:
# brctl show bridge-name bridge-id STP enabled interfaces ----------------------------------------------------------------------------- xenbr0 8000.feffffff no vif13.0 xenbr1 8000.ffffefff yes pddummy0 xenbr2 8000.ffffffef no vif0.0 # brctl showmacs xenbr0 port-no mac-addr local? aging timer 1 fe:ff:ff:ff:ff: yes 0.00 2 fe:ff:ff:fe:ff: yes 0.00 # brctl showstp xenbr0 xenbr0 bridge-id 8000.fefffffffff designated-root 8000.fefffffffff root-port 0 path-cost 0 max-age 20.00 bridge-max-age 20.00 hello-time 2.00 bridge-hello-time 2.00 forward-delay 0.00 bridge-forward-delay 0.00 aging-time 300.01 hello-timer 1.43 tcn-timer 0.00 topology-change-timer 0.00 gc-timer 0.02
Server
di Red Hat Enterprise Linux 5:
yum install vnc
command.
yum install vnc-server
.
/etc/xen/
. Questa directory contiene il demone xend
insieme ad altri file di configurazione della macchina virtuale. Anche i file per lo script di networking risiedono nella directory scripts
.
/var/log/xen
.
/var/lib/libvirt/images
.
/proc/xen/
.
xend
ed il processo qemu-dm
, le due utilità che scrivono i file di log multipli sulla directory /var/log/xen/
:
xend.log
è il file di log che contiene tutti i dati raccolti dal demone xend
, sia se si tratta di un evento normale del sistema, che di un'azione inizializzata da un operatore. Tutte le operazioni della macchina virtuale (come la creazione, l'arresto e la distruzione ecc.) appaiono qui. xend.log
rappresenta generalmente il luogo dove poter controllare inizialmente gli eventi o problemi relativi alle prestazioni. Contiene voci dettagliate e condizioni relative ai messaggi d'errore.
xend-debug.log
è il file di log che contiene i record degli errori relativi ad un evento di xend
, insieme ai sottosistemi di Virtualizzazione (come ad esempio framebuffer, script di Python, ecc).
xen-hotplug-log
è il file di log che contiene i dati degli eventi hotplug. Se un dispositivo o uno script di rete non risultano online, l'evento viene visualizzato qui.
qemu-dm.[PID].log
è il file di log creato dal processo qemu-dm
per ogni guest completamente virtualizzato. Se utilizzate il suddetto file di log è necessario ripristinare il PID del processo qemu-dm
in questione tramite l'utilizzo del comando ps
, così facendo verranno esaminati gli argomenti per poter isolare il processo qemu-dm
sulla macchina virtuale. Da notare che è necessario sostituire il simbolo [PID] con il processo qemu-dm
del PID.
virt-manager.log
che risiedono nella directory /.virt-manager
. Da notare che ogni qualvota si riavvia il Virtual Machine Manager, esso sovrascriverà i contenuti del file di log esistente. Assicuratevi di eseguire il backup del file virt-manager.log
, prima di riavviare il Virtual Machine manager dopo aver incontrato un errore.
/var/lib/libvirt/images
.
xend
, verrà aggiornato xend-database
il quale risiede nella directory /var/lib/xen/xend-db
.
xm dump-core
), risiedono nella directory /var/lib/xen/dumps
.
/etc/xen
contiene i file di configurazione da voi utilizzati per gestire le risorse del sistema. Il file di configurazione del demone xend
è /etc/xen/xend-config.sxp
. È possibile modificare questo file per implementare le modifiche relative a tutto il sistema e per la configurazione del networking. Tuttavia la modifica manuale dei file in /etc/xen/
non è consigliata.
proc
rappresentano un'altra risorsa usata per raccogliere informazioni relative al sistema. Le suddette voci risiedono nella directory /proc/xen
:
/proc/xen/capabilities
/proc/xen/balloon
/proc/xen/xenbus/
xend.log
file contains the same basic information as when you run the xm log
command. This log is found in the /var/log/
directory. Here is an example log entry for when you create a domain running a kernel:
[2006-12-27 02:23:02 xend] ERROR (SrvBase: 163) op=create: Error creating domain: (0, 'Error') Traceback (most recent call list) File "/usr/lib/python2.4/site-packages/xen/xend/server/SrvBase.py" line 107 in_perform val = op_method (op,req) File "/usr/lib/python2.4/site-packages/xen/xend/server/SrvDomainDir.py line 71 in op_create raise XendError ("Error creating domain: " + str(ex)) XendError: Error creating domain: (0, 'Error')
xend-debug.log
, è molto utile per gli amministratori di sistema poichè esso contiene informazioni ancora più dettagliate rispetto a xend.log
. Di seguito viene riportato lo stesso error data relativo allo stesso problema di creazione del dominio del kernel:
ERROR: Will only load images built for Xen v3.0 ERROR: Actually saw: GUEST_OS=netbsd, GUEST_VER=2.0, XEN_VER=2.0; LOADER=generic, BSD_SYMTAB' ERROR: Error constructing guest OS
grub.conf
file to enable a 38400-bps serial console on com1
/dev/ttyS0
:
title Red Hat Enterprise Linux (2.6.18-8.2080_xen0) root (hd0,2) kernel /xen.gz-2.6.18-8.el5 com1=38400,8n1 module /vmlinuz-2.618-8.el5xen ro root=LABEL=/rhgb quiet console=xvc console=tty xencons=xvc module /initrd-2.6.18-8.el5xen.img
sync_console
è in grado di assistervi nella determinazione del problema che causa la sospensione con l'output dell'asynchronous hypervisor console. "pnpacpi=off"
risolve il problema che interrompe l'input sulla console seriale. I parametri "console=ttyS0"
e "console=tty"
indicano che gli errori del kernel vengono registrati sia con la console VGA normale che con la console seriale. Successivamente potrete installare ed impostare ttywatch
, in modo da catturare i dati sull'host remoto collegato tramite un cavo null-modem standard. Per esempio, sarà possibile digitare sull'host remoto:
ttywatch --name myhost --port /dev/ttyS0
/dev/ttyS0
nel file /var/log/ttywatch/myhost.log
.
# virsh console [guest name, ID or UUID]
virt-manager
to display the virtual text console. In the guest console window, select Serial Console from the View menu.
grub.conf
file, and include the 'console =ttyS0 console=tty0'
parameter. This ensures that the kernel messages are sent to the virtual serial console (and the normal graphical console). To use the guest's serial console, you must edit the libvirt configuration file configuration file. On the host, access the serial console with the following command:
# virsh console
virt-manager
to display the virtual text console. In the guest console window, select Serial Console from the View menu.
xend
non accadrà nulla. Digitate virsh list
e ricevete quanto segue:
Error: Error connecting to xend: Connection refused. Is xend running?
xend start
manualmente, ma ricevete più errori:
Error: Could not obtain handle on privileged command interfaces (2 = No such file or directory) Traceback (most recent call last:) File "/usr/sbin/xend/", line 33 in ? from xen.xend.server. import SrvDaemon File "/usr/lib/python2.4/site-packages/xen/xend/server/SrvDaemon.py" , line 26 in ? from xen.xend import XendDomain File "/usr//lib/python2.4/site-packages/xen/xend/XendDomain.py" , line 33, in ? from xen.xend import XendDomainInfo File "/usr/lib/python2.4/site-packages/xen/xend/image.py" , line37, in ? import images File "/usr/lib/python2.4/site-packages/xen/xend/image.py" , line30, in ? xc = xen.lowlevel.xc.xc () RuntimeError: (2, 'No such file or directory' )
kernel-xen
. Per correggere questo problema è necessario selezionare il kernel kernel-xen
al momento dell'avvio (oppure impostare il kernel kernel-xen
come default all'interno del vostro file grub.conf
).
"Invalid argument"
. Tale messaggio generalmente indica che l'immagine del kernel che state cercando di avviare, è incompatibile con l'hypervisor. Un esempio di tale comportamento si verifica se cercate di eseguire un kernel non-PAE FC5 su di un hypervisor FC6 solo PAE.
grub.conf
si smista sul kernel bare-metal invece di un kernel di Virtualizzazione.
/etc/sysconfig/kernel/
directory. You must ensure that kernel-xen
parameter is set as the default option in your grub.conf
file.
/boot/grub/grub.conf
impostando i parametri appropriati del dispositivo seriale.
com1
, modificare /boot/grub/grub.conf
inserendo le righe com1=115200,8n1
, console=tty0
e console=ttyS0,115200
dove indicato.
title Red Hat Enterprise Linux 5 i386 Xen (2.6.18-92.el5xen) root (hd0, 8) kernel /boot/xen.gz-2.6.18-92.el5com1=115200,8n1
module /boot/vmlinuz-2.6.18-92.el5xen ro root=LABEL=VG_i386console=tty0
console=ttyS0,115200
module /boot/initrd-2.6.18-92.el5xen.img
com2
, modificare /boot/grub/grub.conf
inserendo le righe com2=115200,8n1 console=com2L
, console=tty0
e console=ttyS0,115200
dove indicato.
title Red Hat Enterprise Linux 5 i386 Xen (2.6.18-92.el5xen) root (hd0, 8) kernel /boot/xen.gz-2.6.18-92.el5 com2=115200,8n1 console=com2L module /boot/vmlinuz-2.6.18-92.el5xen ro root=LABEL=VG_i386 console=tty0 console=ttyS0,115200 module /boot/initrd-2.6.18-92.el5xen.img
com1
, com2
e così via) selezionato nelle fasi precedenti.
com2
viene usato il parametro console=ttyS0
sulla riga vmlinuz
. L'utilizzo di ogni porta come console=ttyS0
non è un comportamento Linux standard ed è specifico all'ambiente Xen.
virsh console
" o la finestra "Console Seriale" di virt-manager
. Impostate la console seriale virtuale usando questa procedura:
/boot/grub/grub.conf
nel modo seguente:
Red Hat Enterprise Linux 5 i386 Xen (2.6.18-92.el5xen) root (hd0, 0) kernel /boot/vmlinuz-2.6.18-92.el5xen ro root=LABEL=VG_i386 console=xvc0 initrd /boot/initrd-2.6.18-92.el5xen.img
xend
) può essere configurato per registrare l'output dalle console seriali dei guest paravirtualizzati.
xend
modificate /etc/sysconfig/xend
. Cambiate la voce:
# Log all guest console output (cf xm console) #XENCONSOLED_LOG_GUESTS=no
# Log all guest console output (cf xm console) XENCONSOLED_LOG_GUESTS=yes
/var/log/xen/console
.
virsh console
".
ttyS0
su Linux o COM1
su Windows.
/boot/grub/grub.conf
inserendo la riga "console=tty0 console=ttys0,115200
".
title Red Hat Enterprise Linux Server (2.6.18-92.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-92.el5 ro root=/dev/volgroup00/logvol00
console=tty0 console=ttys0,115200
initrd /initrd-2.6.18-92.el5.img
virsh console
".
/var/log/xen/console
poichè essi sono per i guest paravirtualizzati.
virt-manager
or virt-install
tools on Red Hat Enterprise Linux 5, the guests configuration files are created automatically in the /etc/xen
directory.
name = "rhel5vm01" memory = "2048" disk = ['tap:aio:/var/lib/libvirt/images/rhel5vm01.dsk,xvda,w',] vif = ["type=ieomu, mac=00:16:3e:09:f0:12 bridge=xenbr0', "type=ieomu, mac=00:16:3e:09:f0:13 ] vnc = 1 vncunused = 1 uuid = "302bd9ce-4f60-fc67-9e40-7a77d9b4e1ed" bootloader = "/usr/bin/pygrub" vcpus=2 on_reboot = "restart" on_crash = "restart"
serial="pty"
rappresenta il valore di default per il file di configurazione. Questo è l'esempio di file di configurazione per un guest completamente virtualizzato:
name = "rhel5u5-86_64" builder = "hvm" memory = 500 disk = ['/var/lib/libvirt/images/rhel5u5-x86_64.dsk.hda,w'] vif = [ 'type=ioemu, mac=00:16:3e:09:f0:12, bridge=xenbr0', 'type=ieomu, mac=00:16:3e:09:f0:13, bridge=xenbr1'] uuid = "b10372f9-91d7-ao5f-12ff-372100c99af5' device_model = "/usr/lib64/xen/bin/qemu-dm" kernel = "/usr/lib/xen/boot/hvmloader/" vnc = 1 vncunused = 1 apic = 1 acpi = 1 pae = 1 vcpus =1 serial ="pty" # enable serial console on_boot = 'restart'
virsh dumpxml
e virsh create
(o virsh edit
) per modificare i file di configurazione di libvirt
(basati su xml), i quali sono in grado di controllare la presenza di errori e svolgere controlli sulla sicurezza.
failed domain creation due to memory shortage, unable to balloon domain0
xend.log
:
[2006-12-21] 20:33:31 xend 3198] DEBUG (balloon:133) Balloon: 558432 Kib free; 0 to scrub; need 1048576; retries: 20 [2006-12-21] 20:33:31 xend. XendDomainInfo 3198] ERROR (XendDomainInfo: 202 Domain construction failed
xm list domain0
. Se dom0 non viene diminuito, è possibile utilizzare il comando virsh setmem dom0 NewMemSize
per controllare la memoria.
wrong kernel image: non-PAE kernel on a PAE
# xm create -c va-base Using config file "va-base" Error: (22, 'invalid argument') [2006-12-14 14:55:46 xend.XendDomainInfo 3874] ERRORs (XendDomainInfo:202) Domain construction failed Traceback (most recent call last) File "/usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 195 in create vm.initDomain() File " /usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 1363 in initDomain raise VmError(str(exn)) VmError: (22, 'Invalid argument') [2006-12-14 14:55:46 xend.XendDomainInfo 3874] DEBUG (XenDomainInfo: 1449] XendDlomainInfo.destroy: domain=1 [2006-12-14 14:55:46 xend.XendDomainInfo 3874] DEBUG (XenDomainInfo: 1457] XendDlomainInfo.destroy:Domain(1)
Unable to open a connection to the Xen hypervisor or daemon
/etc/hosts
. Controllate il file e verificate se la voce localhost è stata abilitata. Di seguito viene riportato un esempio di voce locahost incorretta:
# Do not remove the following line, or various programs # that require network functionality will fail. localhost.localdomain localhost
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost localhost.localdomain. localhost
xen-xend.logfile
):
Bridge xenbr1 does not exist!
# xm create mySQL01 Using config file " mySQL01" Going to boot Red Hat Enterprise Linux Server (2.6.18.-1.2747 .el5xen) kernel: /vmlinuz-2.6.18-12747.el5xen initrd: /initrd-2.6.18-1.2747.el5xen.img Error: Device 0 (vif) could not be connected. Hotplug scripts not working.
xend.log
visualizza i seguenti errori:
[2006-11-14 15:07:08 xend 3875] DEBUG (DevController:143) Waiting for devices vif [2006-11-14 15:07:08 xend 3875] DEBUG (DevController:149) Waiting for 0 [2006-11-14 15:07:08 xend 3875] DEBUG (DevController:464) hotplugStatusCallback /local/domain/0/backend/vif/2/0/hotplug-status [2006-11-14 15:08:09 xend.XendDomainInfo 3875] DEBUG (XendDomainInfo:1449) XendDomainInfo.destroy: domid=2 [2006-11-14 15:08:09 xend.XendDomainInfo 3875] DEBUG (XendDomainInfo:1457) XendDomainInfo.destroyDomain(2) [2006-11-14 15:07:08 xend 3875] DEBUG (DevController:464) hotplugStatusCallback /local/domain/0/backend/vif/2/0/hotplug-status
/etc/xen
directory. For example, editing the guest mySQL01
# vim /etc/xen/mySQL01
Locate the vif
entry. Assuming you are using xenbr0
as the default bridge, the proper entry should resemble the following:
# vif = ['mac=00:16:3e:49:1d:11, bridge=xenbr0',]
# xm shutdown win2k3xen12 # xm create win2k3xen12 Using config file "win2k3xen12". /usr/lib64/python2.4/site-packages/xenxm/opts.py:520: Deprecation Warning: Non ASCII character '\xc0' in file win2k3xen12 on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details execfile (defconfig, globs, locs,) Error: invalid syntax 9win2k3xen12, line1)
/etc/xen/
contienexend
scripts
la quale contiene gli script per il Virtualization networking.
/var/log/xen/
/var/lib/libvirt/images/
/proc/xen/
cat /proc/partitions
" come di seguito riportato.
# cat /proc/partitions major minor #blocks name 202 16 104857600 xvdb 3 0 8175688 hda
/etc/inittab
:
1:12345:respawn:/sbin/mingetty xvc0
Xen Virtual Ethernet
all'interno del sistema operativo guest. Per effettuare una verifica eseguire quanto di seguito riportato (per Red Hat Enterprise Linux 4 e Red Hat Enterprise Linux 5):
cat /etc/modprobe.conf
cat /etc/modules.conf
alias eth0 xen-vnif
alias eth0 xen-vnif
) per ogni interfaccia paravirtualizzata per il guest.
/etc/modprobe.conf
. Modificate /etc/modprobe.conf
ed aggiungete la seguente riga:
options loop max_loop=64
phy: block device
o tap:aio
. Per implementare i loop device backed guest per un sistema completamente virtualizzato utilizzate i comandi phy: device
o file: file
.
dom0
has not ballooned down enough to provide space for a recently created or started guest. In your /var/log/xen/xend.log
, an example error message indicating this has occurred:
[2006-11-21 20:33:31 xend 3198] DEBUG (balloon:133) Balloon: 558432 KiB free; 0 to scrub; need 1048576; retries: 20. [2006-11-21 20:33:52 xend.XendDomainInfo 3198] ERROR (XendDomainInfo:202) Domain construction failedYou can verify the amount of memory currently used by
dom0
with the command “xm list Domain-0
”. If dom0
is not ballooned down you can use the command “xm mem-set Domain-0 NewMemSize
” where NewMemSize
should be a smaller value.
# xm create testVM Using config file "./testVM". Going to boot Red Hat Enterprise Linux Server (2.6.18-1.2839.el5) kernel: /vmlinuz-2.6.18-1.2839.el5 initrd: /initrd-2.6.18-1.2839.el5.img Error: (22, 'Invalid argument')In the above error you can see that the kernel line shows that the system is trying to boot a non kernel-xen kernel. The correct entry in the example is ”
kernel: /vmlinuz-2.6.18-1.2839.el5xen
”.
/etc/grub.conf
.
kernel-xen
sarà possibile avviare il guest:
xm create -c GuestName
GuestName
is the name of the guest. The previous command will present you with the GRUB boot loader screen and allow you to select the kernel to boot. You will have to choose the kernel-xen kernel to boot. Once the guest has completed the boot process you can log into the guest and edit /etc/grub.conf
to change the default boot kernel to your kernel-xen. Simply change the line “default=X
” (where X is a number starting at '0
') to correspond to the entry with your kernel-xen line. The numbering starts at '0
' so if your kernel-xen entry is the second entry you would enter '1
' as the default,for example “default=1
”.
# xm create -c va-base Using config file "va-base". Error: (22, 'Invalid argument') [2006-12-14 14:55:46 xend.XendDomainInfo 3874] ERROR (XendDomainInfo:202) Domain construction failed Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 195, in create vm.initDomain() File "/usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 1363, in initDomain raise VmError(str(exn)) VmError: (22, 'Invalid argument') [2006-12-14 14:55:46 xend.XendDomainInfo 3874] DEBUG (XendDomainInfo:1449) XendDomainInfo.destroy: domid=1 [2006-12-14 14:55:46 xend.XendDomainInfo 3874] DEBUG (XendDomainInfo:1457) XendDomainInfo.destroyDomain(1)If you need to run a 32 bit or non-PAE kernel you will need to run your guest as a fully-virtualized virtual machine. The rules for hypervisor compatibility are:
Your CPU does not support long mode. Use a 32 bit distribution
. This problem is caused by a missing or incorrect pae
setting. Ensure you have an entry “pae=1
” in your guest's configuration file.
virt-manager
potrebbe non lanciare e visualizzare un errore del tipo “Unable to open a connection to the Xen hypervisor/daemon
”. Tale comportamento è generalmente dovuto a causa di una voce localhost
mancante all'interno del file /etc/hosts
. Verificate la presenza della voce localhost
, e se mancante su /etc/hosts
, inserite una nuova voce per localhost
. Un /etc/hosts
incorretto dovrebbe somigliare al seguente:
# Do not remove the following line, or various programs # that require network functionality will fail. localhost.localdomain localhost
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost localhost.localdomain localhost
Applying Intel CPU microcode update: FATAL: Module microcode not found. ERROR: Module microcode does not exist in /proc/modulesAs the virtual machine is running on virtual CPUs there is no point updating the microcode. Disabling the microcode update for your virtual machines will stop this error:
/sbin/service microcode_ctl stop /sbin/chkconfig --del microcode_ctl
xm create
” andrà alla ricerca di un file di configurazione prima nella directory corrente e successivamente in /etc/xen
# xm shutdown win2k3xen12 # xm create win2k3xen12 Using config file "win2k3xen12". /usr/lib64/python2.4/site-packages/xen/xm/opts.py:520: DeprecationWarning: Non-ASCII character '\xc0' in file win2k3xen12 on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details execfile(defconfig, globs, locs) Error: invalid syntax (win2k3xen12, line 1)
Enabling the virtualization extensions in BIOS
cat /proc/cpuinfo | grep vmx svm
. Se il comando genera un output ciò indicherà che le estensioni di virtualizzazione sono state abilitate. Se tale output risulta assente ciò indicherà che le estensioni di virtualizzazione o l'impostazione corretta del BIOS potrebbero non essere abilitati.
virsh
command (where GUEST
is the guest's name):
# virsh edit GUEST
virsh edit
utilizza la variabile della shell $EDITOR
per determinare l'editor da utilizzare.
<interface type='network'>
[output truncated]
<model type='rtl8139' />
</interface>
'rtl8139'
to 'e1000'
. This will change the driver from the rtl8139 driver to the e1000 driver.
<interface type='network'>
[output truncated]
<model type='e1000'
/>
</interface>
# virsh dumpxml GUEST > /tmp/guest.xml
# cp /tmp/guest.xml /tmp/new-guest.xml # vi /tmp/new-guest.xml
<interface type='network'>
[output truncated]
<model type='e1000' />
</interface>
# virsh define /tmp/new-guest.xml # virsh start new-guest
/var/log/xen/
xend
e dal processo qemu-dm.
xend.log
xend-debug.log
xen-hotplug.log
qemu-dm.PID
.log
qemu-dm
il quale viene avviato per ogni guest completamente virtualizzato.
PID
viene sostituito con il PID
del processo relativo a qemu-dm
PID
per un dato processo qemu-dm
utilizzando il comando ps
. Controllando gli argomenti del processo sarà possibile identificare la macchina virtuale alla quale appartiene il processo qemu-dm
.
.virt-manager
in the user's home
directory whom ran virt-manager. This directory will usually be ~/.virt-manager/virt-manager
.
/var/lib/libvirt/images/
/var/lib/xen/xend-db/
/etc/xen/
/etc/xen/xend-config.sxp
è il file di configurazione principale per il demone xend. xend-config.sxp
viene usato per abilitare/disabilitare la migrazione ed altre funzioni non configurate da libvirt
. Usare i tool di libvirt
per tutte le altre funzioni.
/var/lib/xen/dump/
xm dump-core
.
/proc/xen/
xen-kernel
nei seguenti file:
/proc/xen/capabilities
/proc/xen/privcmd
/proc/xen/balloon
/proc/xen/xenbus
/proc/xen/xsd_port
/proc/xen/xsd_kva
# insmod xen-platform-pci.o Warning: kernel-module version mismatch xen-platform-pci.o was compiled for kernel version 2.4.21-52.EL while this kernel is version 2.4.21-50.EL xen-platform-pci.o: unresolved symbol __ioremap_R9eac042a xen-platform-pci.o: unresolved symbol flush_signals_R50973be2 xen-platform-pci.o: unresolved symbol pci_read_config_byte_R0e425a9e xen-platform-pci.o: unresolved symbol __get_free_pages_R9016dd82 [...]The solution is to use the correct RPM package for your hardware architecture for the para-virtualized drivers.
Warning: kernel-module version mismatch xen-platform-pci.o was compiled for kernel version 2.4.21-52.EL while this kernel is version 2.4.21-50.EL Warning: loading xen-platform-pci.o will taint the kernel: forced load See http://www.tux.org/lkml/#export-tainted for information about tainted modules Module xen-platform-pci loaded, with warnings
# cd /lib/modules/`uname -r`/ # find . -name 'xen_*.ko' -print
# insmod \ /lib/modules/'uname -r'/{LocationofPV-drivers}/xen_platform_pci.ko # insmod /lib/modules/'uname -r'/{LocationofPV-drivers}/xen_balloon.ko # insmod /lib/modules/'uname -r'/{LocationofPV-drivers}/xen_vnif.ko # insmod /lib/modules/'uname -r'/{LocationofPV-drivers}/xen_vbd.ko
/var/log/messages
# grep -E "vif|vbd|xen" /var/log/messages xen_mem: Initialising balloon driver vif vif-0: 2 parsing device/vif/0/mac vbd vbd-768: 19 xlvbd_add at /local/domain/0/backend/vbd/21/76 vbd vbd-768: 19 xlvbd_add at /local/domain/0/backend/vbd/21/76 xen-vbd: registered block device major 202You can also use the
lsmod
command to list the loaded para-virtualized drivers. It should output a list containing the xen_vnif
, xen_vbd
, xen_platform_pci
and xen_balloon
modules.
# lsmod|grep xen xen_vbd 19168 1 xen_vnif 28416 0 xen_balloon 15256 1 xen_vnif xen_platform_pci 98520 3 xen_vbd,xen_vnif,xen_balloon,[permanent]
type=ioemu
' part of 'vif
=' line in your guest's configuration file.
domU
refers to the guest operating systems which run on the host system (the dom0 domain).
/dev/VolGroup00/LogVol02
),
/dev/sda5
), and
/dev/sda
).
tap:aio
tap:aio
parameter sets the Xen hypervisor to use an advanced access mode designed for safety and performance. File-based, are accessed using a kernel thread and a user-space process. The tap:aio
method respects guest flush requests which makes it safer than the file
driver. The virtualization tools use tap:aio
by default for accessing file-based guest disks on the Xen Hypervisor.
ext2
e ext3
, identificatori per dispositivi RAID, identificatori per dispositivi iSCSI e LUN, indirizzi MAC ed identificatori per macchine virtuali.
libvirt
.
/usr/share/doc/xen-<version-number>
/
è la directory che contiene numerose informazioni sull'hypervisor para-virtualization di Xen, sui tool di gestione associati, presenta altresì numerosi esempi di configurazione, informazioni specifiche sull'hardware, e la documentazione per l'utente upstream di Xen corrente.
man virsh
e /usr/share/doc/libvirt-<version-number>
— Contiene i sottocomandi e le opzioni per la utility di gestione della macchina virtuale virsh
, insieme alle informazioni complete sull'API della libreria di virtualizzazione libvirt
.
/usr/share/doc/gnome-applet-vm-<version-number>
— La documentazione per l'applet del pannello grafico di GNOME, che controlla e gestisce macchine virtuali in esecuzione in modo locale.
/usr/share/doc/libvirt-python-<version-number>
— Fornisce le informazioni sui binding di Python per la libreria libvirt
. Il pacchetto libvirt-python
permette agli sviluppatori di python di creare i programmi che interfacciano la libreria di gestione della virtualizzazione libvirt
.
/usr/share/doc/python-virtinst-<version-number>
— Fornisce la documentazione sul comando virt-install
di ausilio durante l'avvio delle installazioni di Fedora, e delle distribuzioni Red Hat Enterprise Linux all'interno delle macchine virtuali.
/usr/share/doc/virt-manager-<version-number>
— Fornisce una documentazione sul Virtual Machine Manager, il quale fornisce un tool grafico per la gestione delle macchine virtuali.