XEN
XEN
XEN
Objectives
1. Understand the Concept of Virtualization
2. Understand how Xen Works
3. Install Xen
4. Manage Xen Domains with YaST
5. Manage Xen Domains at the Command Line
6. Understand Xen Networking
7. Migrate a Guest Domain
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
Figure 8-1
8-2 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
x You can find updated information about Xen, including an instruction how
to run unmodified operating systems on the OpenSUSE Xen page at:
http://en.opensuse.org/Xen
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-3
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
Figure 8-2
8-4 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
Figure 8-3
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-5
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
Figure 8-4
8-6 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-7
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
title Xen
root (hd0,3)
kernel /boot/xen.gz
module /boot/vmlinuz-Xen root=/dev/hda3 selinux=0
module /boot/initrd-Xen
8-8 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
x On some Xen systems you might see the parameter dom0_mem in the kernel
module line. This parameter assigns a certain amount of initial main memory
to domain0 at boot time. However in Xen version 3, this parameter is not
required anymore.
Initially all available memory is used by domain0. When you start additional
domainUs, the required amount of memory is reduced in domain0 and used
for the new domainU.
The entry in menu.lst adds a new option to the boot menu of your
system. When selecting this entry, the Xen virtual machine monitor
is loaded (kernel /boot/xen.gz) which starts SUSE Linux Enterprise
Server 10 in domain0 (see the lines starting with module).
Before rebooting your system with the Xen option, you should
check if the automatically generated entry is correct. Make sure
that ...
■ ... the line root (hd0,3) points to the filesystem which contains
the Xen Virtual Machine Monitor and the Kernel of the Linux
installation for domain0. In our example hd0,3 means the
fourth partition on the first hard drive in the system. Also check
if the parameter root in the first module line points to the root
partition of the domain0 installation.
■ ... the Xen version of the Linux kernel and the initrd are loaded
in the module line. The names of the image files should end in
-xen.
In case the system is not booting properly, you can switch back to a
non-virtualized system by selecting the regular SUSE Linux
Enterprise Server 10 boot option.
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-9
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
x When running Xen, the network setup is done by the xend management
process. This can interfere with the native network configuration scripts of
the domains. Especially SuSEfirewall2 is known to cause problems. It´s
therefore recommended to stop SuSEfirewall2 with rcSuSEfirewall2 and to
remove the firewall scripts from the init process:
insserv -r SuSEfirewall2_setup
insserv -r SuSEfirewall2_init
insserv -r SuSEfirewall2_final (conditional)
8-10 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
Do the following:
■ Part I: Install XenPackages.
■ Part II: Prepare for Reboot
■ Part III: Reboot and Test Xen.
Do the following:
1. Start the YaST Controll Center.
2. Select Software > Software Management.
3. From the Filter menu, select Search.
4. Enter xen in the search field and select search.
5. On the right side, select the packages xen, kernel-xen and
xen-tools.
6. Select Accept and let YaST install all required software
packages.
7. Close the YaST Control Center.
Do the following:
1. Open a terminal window and su - to the root user.
2. Open the file /boot/grub/menu.lst with a text editor (eg. vi).
3. Make sure, that there is a section with the title Xen in the file.
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-11
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
4. In this section, make sure that the parameter root= points to the
root partition of your installation.
5. Close the file.
6. Enter the command:
insserv -r SuSEfirewall2_setup
and
insserv -r SuSEfirewall2_init
7. Close the terminal window.
(End of Exercise)
8-12 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
After you have started the module, the following dialog appears on
the screen:
Figure 8-5
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-13
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
8-14 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
Figure 8-6
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-15
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
Figure 8-7
8-16 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-17
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
For our example we stay with the default and select Next. Now the
domain environment and the installation process is started.
Figure 8-8
Figure 8-9
8-18 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
Select Continue.
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-19
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
In this exercise, you learn how to install a Xen guest domain using
YaST. Before you start with this exercise ,you must have installed
xen on your system.
Do the following:
1. Open the YaST Control Center.
2. Select System > Virtual Machine Management.
3. Select Add.
4. Select Run an OS installation program and then Next.
5. Select Next.
6. After a while, a terminal window opens and a standard SUSE
Linux Enterprise Server installation starts up. Select this
window.
7. Press Alt+N.
8. Use the tab-key to navigate to the item “Yes, I Agree to the
License Agreement”. Then press the space bar.
9. Press Alt+N.
10. Press Alt+N.
11. (Optional) Adjust the settings for Region and Time Zone.
Navigate to the menus with the tab-key and use the arrow keys to
change an option.
12. Press Alt+N.
8-20 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
34. Test if you can login to the new domain as the user root with the
password novell.
35. Please do not close the terminal window, we will use it in the next
exercise.
(End of Exercise)
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-21
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
8-22 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
# This defines the disc of the domain. “phy” means that the
# physical device /dev/hda1 is mapped to the virtual device
# /dev/hda1 in the domain. “w” indicates, that the disc is
# writable.
disk = [ 'phy:hda1,hda1,w' ]
x A good source for detailed documentation and howtos about Xen and the
domain configuration files is the Xen wiki at:
http://wiki.xensource.com/xenwiki/
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-23
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
xm create -c -f /data/xen/SLES10-WebServer.conf
xm list
8-24 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
xm console <domain_id>
xm pause <domain_id>
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-25
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
xm unpause <domain_id>
xm shutdown <domain_id>
In case the domain is not responding anymore, you can force the
shutdown of the domain with the destroy command:
xm destroy <domain_id>
To save the state of a domain for a longer time (eg. over a reboot of
domain0) you can use the save command:
The domain can be restored from the resulting file with the restore
command:
xm restore <filename>
8-26 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
x Instead of the domain ID <domain_id>, you can also use the domain name
in all xm commands.
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-27
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
The following assumes, that you still have an open terminal window
of the guest domain, that you have configured in the previous
exercises.
Do the follwoing:
1. Open a terminal window and su - to the root user.
2. Enter the command xm list.
3. Note the memory allocation of the domain vm1.
4. Switch to the terminal of the Xen domain and halt the system by
typing halt. Wait till the system has been halted.
5. Return to the root terminal and use the command xm list to verify
that the domain vm1 is not running anymore.
6. Open the file /etc/xen/vm/vm1 with a text editor.
7. Look for the memory parameter and change the value to 172.
8. Save and close the file.
9. Enter the following command to start the domain:
xm create -c -f /etc/xen/vm/vm1
10. Wait till the system has been booted and you see the login
prompt.
11. Press the key combination Ctrl-] to detach from the domain
terminal and return to the root terminal.
8-28 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
(End of Exercise)
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-29
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
8-30 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
Do the following:
1. Open a terminal window and su - to the root user.
2. Move the vm1 configuration file into the auto directory:
mv /etc/xen/vm/vm1 /etc/xen/auto/
3. Shutdown vm1 with the command xm shutdown vm1.
4. Wait a moment and control with the command xm list if the
domain has been shut down. Continue with next step when the
domain vm1 is not listed anymore.
5. Reboot you system by entering reboot.
6. At the boot prompt, select the Xen entry.
7. When the system has been started up, log in to the graphical
interface as user geeko with the password novell.
8. Open a terminal window and su - to the root user.
9. Enter the command xm list.
10. The domain vm1 should have been automatically started and
should be listed in the xm output.
(End of Exercise)
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-31
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
8-32 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
Figure 8-10
Understand Bridging
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-33
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
8-34 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
linux-3rsm:~ # ip a
1: lo: <LOOPBACK,UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: peth0: <BROADCAST,MULTICAST,NOARP,UP> mtu 1500 qdisc
pfifo_fast qlen 100
link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
inet6 fe80::fcff:ffff:feff:ffff/64 scope link
valid_lft forever preferred_lft forever
4: vif0.0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue
link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
inet6 fe80::fcff:ffff:feff:ffff/64 scope link
valid_lft forever preferred_lft forever
5: eth0: <BROADCAST,MULTICAST,NOTRAILERS,UP> mtu 1500 qdisc
noqueue
link/ether 00:11:25:81:4c:5b brd ff:ff:ff:ff:ff:ff
inet 149.44.171.67/23 brd 149.44.171.255 scope global
eth0
inet6 2001:780:101:aa00:211:25ff:fe81:4c5b/64 scope
global dynamic
valid_lft 29998sec preferred_lft 9996sec
inet6 fe80::211:25ff:fe81:4c5b/64 scope link
valid_lft forever preferred_lft forever
6: vif0.1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop
link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
7: veth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop
link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
[...]
19: veth7: <BROADCAST,MULTICAST> mtu 1500 qdisc noop
link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
20: xenbr0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue
link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
inet6 2001:780:101:aa00:fcff:ffff:feff:ffff/64 scope
global dynamic
valid_lft 29998sec preferred_lft 9996sec
inet6 fe80::200:ff:fe00:0/64 scope link
valid_lft forever preferred_lft forever
23: vif3.0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue
link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
inet6 fe80::fcff:ffff:feff:ffff/64 scope link
valid_lft forever preferred_lft forever
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-35
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
Figure 8-11
8-36 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
You can use the command brctl show in domain0, to see which
interfaces have been added to the network bridge.
x Due to the complexity of the Xen network setup, the default firewall
(SuSEFirewall2) is not working correctly in domain0. It is therefore
recommended to disable SuSEFirewall2 and to setup a customized firewall
if needed.
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-37
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
This exercise assumes that you have a Xen system with domain 0
and one more Xen domain running.
Do the following:
1. Open a terminal window and su - to the root user.
2. Make sure that the domain vm1 is running by typing the
command xm list.
3. In the output of the xm command, note the ID of the domain vm1.
4. View the network bridge configuration with the command
brctl show.
5. You should see the configuration of the bridge xenbr0. The
interfaces peth0 (physical interface) vif0.0 (virtual interface of
domain 0) and the virtual interface vifx.0 (where x is the domain
ID of domain vm1) should be added to the bridge.
6. Shutdown the domain with the command xm shutdown vm1.
7. Wait a moment and control with the command xm list if the
domain has been shut down. Continue with next step when the
domain vm1 is not listed anymore.
8. Enter the command brctl show again. Note that the inerface of
the domain vm1 has been removed from the bridge.
9. Restart the domain with: xm create -f /etc/xen/vm/vm1
10. Note the ID of vm1 and check with brctl show if the interface of
vm1 has been added again.
(End of Exercise)
8-38 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
This file can then be copied to the new host system. To restore the
domain, use the command xm restore <filename>.
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-39
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
As mentioned above, besides the file created with xm, you might
also have to copy the filesystems to the new host system.
Instead of the save and restore commands of xm, you can also use
the command xm migrate <domain_id> <target_host>. This
command migrates a domain directly to a new host. In this case it´s
not necessary to copy memory state files manually.
In order to get this working, the current and new host must be
running Xen and xend.
(xend-relocation-server yes)
(xend-relocation-hosts-allow ’^localhost$’)
This option controls which hosts are allowed to conntect to xend for
domain migration. By default, only localhost is allowed to connect.
The option takes regular expressions as parameter. Have a look at
the configuration file for examples.
x Please note, that there are two xend involved in a domain migration (current
and new host). You might have to adjust the xend-config.sxp file on both
systems.
8-40 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
Summary
Objective Summary
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-41
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
Objective Summary
■ insserv -r earlykbd
■ insserv -r kbd
■ insserv -r irq_balancer
Under Xen, all domains are
connected with the physical
network through domain0.
8-42 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Manage Virtualization with Xen
Objective Summary
Version 1 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by 8-43
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.
Upgrading to Certified Linux Professional 10
8-44 Copyright © 2007 Novell, Inc. Copying or distributing all or part of this manual is protected by Version 1
a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 license.