Sunday, September 14, 2008

Xen on SLES10

Xen consists of two major components.
  • Virtual Machine Monitor (VMM) - A layer between physical hardware and VM. In general term, this is called hypervisor.
  • Xen Tools - a set of command line application used to administer VM.

VMM must be loaded before any of VMs are started. VM in xen are called as domains. Privileged domain, called domain0 is an interface to communicate directly with an adminstrator to access the physical hardware of the host machine.

An unprivileged domain is called domainU. To install Xen, the following package is needed.

  • xen
  • xen-tools
  • kernel-xen
  • xen-doc* (optional)

After the installation, the reboot is required to boot into Xen bootloader. In case the system is not booting properly, you can switch back to the non-virtualized system and disable the firewall.

  • rcSuSEfirewall2 stop
  • insserv -r SuSEfirewall2_setup
  • insserv -r SuSEfirewall2_init
  • insserv -r SuSEfirewall_final (conditional)

To manage Xen domains at the commands line.

  • Xen configuration file is located at: /etc/xen/vm
  • There are examples of template configuration file for a single domain: /etc/xen/examples
  • xm is the administration tools, it communicates with the xend management processes running on domain0 linux installation.
  • To start a vm, the create command is used: xm create -c -f /data/xen/SLES10-WebServer.conf
  • To list the currently running Xen domains: xm list
  • The list command contains the following fields: name, domid, memory, vcpus, state (r - running, b - blocked, domain has been created, but it is blocked when a domain is waiting for IO or nothing to do, p - pause, s - shutdown, c - crashed)
  • To connects you with the terminal of running domain: xm console domain_id
  • To disconnect from a terminal: use the keystrokes: Ctrl-]
  • To interrupt the execution a domain temporarily: xm pause domain_id
  • To unpause: xm unpause domain_id
  • To shutdown: xm shutdown domain_id
  • To force shutdown a not responding domain: xm destroy domain_id
  • To save the state of a domain for a longer time: xm save domain_id
  • To restore a domain from a resulting file: xm restore filename
  • To change the memory allocation for a domain: xm mem-set domain_id amount_of_memory_in_megabytes

Automate Domain Startup and shutdown

  • SLES10 comes with a start script called, xendomains, which included in the xen-tools package.
  • If domain0 is booted, all the domains with the configuration files located under /etc/xen/auto will be started.
  • If domain0 is shutdown, or rebooted, all the running Xen domains will be shutdown.
  • The script can be adjusted /etc/sysconfig/xendomains for some configuration options like: XENDOMAINS_MIGRATE. It will migrate domain automatically to a different host when a domain0 is shutdown. The flags has to be set to the IP address of the target machine.

Understand Xen Networking














  • domain0 is controlling the physical network interfaces of the host system. Unprivileged domains are connected to domain0 through Virtual Ethernet adapters.
  • domainU (VE) <---->(VE)domain0(Physical Ethernet)<------>Network(LAN)
  • The default mechanism to connect VE and PE in domain0 is bridging.
  • When a new domain is created, the following steps happened.
  • 1. Xen provides a VE to the new domain
  • 2. xend creates a new VE in domain0
  • 3. both VE are connected through a virtual point to point connection.
  • 4. The VE in domain0 is added to the bridge with the physical interface.
  • xend performs the networking changes with the help of scripts: /etc/xen/scripts.
  • The script to initiate the bridge xenbr0: /etc/xen/scripts/nework-bridge
  • The script to start and add the VE: /etc/xen/scripts/vif-bridge
  • To configure the network scripts are used by xend: /etc/xen/xend-config.sxp
  • Command: ip a is prompted on domain0 will list down all the different interface naming schema.
  • 1. peth - physical interfaces in domain0. peth devices are connected to the network bridge
  • 2. vif - virtual interfaces which are part of the bridge. E.g: vif6.0 is connected to the first vif in domain 6.
  • 3. veth - virtual interfaces are connected to the vif interfaces of domain0 (vif0.x)
  • 4. eth0 - the default veth interface is named eth0 and connected with vif0.0. This is the default network interface of domain0.
  • 5. xenbr0 - the default bridge that connects virtual and physical interfaces.

Migrate a Guest Domain

  • 2 methods: Use domain save and restore or Use migration and live migration.
  • Domain Save and Restore
  • 1. suspend the domain: xm save domain_id filename
  • 2. copy the file to the new host system, then restore the domain: xm restore filename
  • Migration and Live Migration
  • 1. xm migrate domain_id target_host
  • 2. By adding --live migration flag, the downtime during the migration can be reduced.
  • 3. /etc/xen/xend-config.sxp with 2 importants flags: xend-relocation-server yes, xend-relocation-hosts-allow '^localhost$'


No comments: