1. Home
  2. Linux
  3. How to Install Xen Virtualization Software on Linux and Launch a VM using virt-manager?

How to Install Xen Virtualization Software on Linux and Launch a VM using virt-manager?

Question: I have a Red Hat Enterprise Linux version 5.5 operating system running on an Intel Xeon machine that supports VTx. I would like to know how to install Xen virtualization software and launch a guest virtual machine on top of it?

Answer:

Xen is an Open Source software that allows you to provision virtualized resources to guests. Setting up of Xen Virtualization software involves – installation of Xen kernel, xen server (xend), virt-manager (GUI tool to create, destroy and manage virtual machines). The Xen kernel runs on top of Linux kernel and is responsible for launching Dom0 (default and first virtual machine), the only VM that interacts directly with the system hardware.

Installing Xen hypervisor on Linux

Pre-requisites: You need ‘root‘ privileges.

Install Xen packages using Yum command.

# yum install xen virt-manager kernel-xen

Note: If ‘yum’ returns an error as “Error: Nothing to do“, then scroll down to the bottom of this page to see the fix.

The above command will install Xen server, Xen-kernel and virt-manager. The Xen-server (xend) would have started by default. If not, you should start the server:

#/etc/init.d/xend start

Allow xend to start automatically upon system reboot.

# chkconfig xend on
# reboot

Note: Make sure to boot the system using Xen kernel.

To boot the system automatically using Xen-kernel, edit  /etc/grub.conf to have xen-kernel as the first entry and default=0

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-398.el5xen)
 root (hd0,0)
 kernel /xen.gz-2.6.18-398.el5
 module /vmlinuz-2.6.18-398.el5xen ro root=LABEL=/ rhgb quiet
 module /initrd-2.6.18-398.el5xen.img
title Red Hat Enterprise Linux Server (3.2.59-1.el5.elrepo)
 root (hd0,0)
 kernel /vmlinuz-3.2.59-1.el5.elrepo ro root=LABEL=/ rhgb quiet
 initrd /initrd-3.2.59-1.el5.elrepo.img

How to launch a Virtual Machine (VM) using virt-manager

#virt-manager &

The above command will launch the virt-manager – a GUI application that allows you to create, manage and destroy virtual machines.

linux xen vm manager

Select the host and click “New” button at the bottom to setup a new virtual machine. Follow the on-screen instruction to select a disk image, allocate RAM, hard disk and installation of the operating system etc…

xen server start new vm

Create virtual machine from command-line

You can also create new virtual machines using xen command line tools. To do that, you need to run the below command.

# virt-install \
--name test-host \
--ram 1024 \
--file /dev/sdc \
--network bridge:eth0 \
--cdrom /tmp/centos.iso

XM monitoring commands

View the list of VMs that are currently created and its status

#xm list
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 6415 4 r----- 2905.5
centos 3 520 1 -b---- 46.8
centos-2 8 1032 1 ------ 4.6

Display the uptime of all virtual machines, including the Dom0

#xm uptime
Name ID Uptime
Domain-0 0 21:45:02
centos 3 6:15:18
centos-2 8 0:03:07

Real-time monitoring of virtual machines (CPU, MEM usages)

#xm top

xm commands xen server

Display host information

#xm info

Display domain virtual processor information

#xm vcpu-list
Name ID VCPUs CPU State Time(s) CPU Affinity
Domain-0 0 0 0 -b- 1018.2 0
Domain-0 0 1 1 -b- 613.2 1
Domain-0 0 2 2 -b- 590.2 2
Domain-0 0 3 3 r-- 785.6 3
centos 3 0 1 -b- 47.0 any cpu
centos-2 8 0 3 -b- 17.8 any cpu

Display virtual network information of a domain

Get the domain names using the below command:

#xm list

Get the virtual network interface information using the below command:

#xm network-list centos
 Idx BE MAC Addr. handle state evt-ch tx-/rx-ring-ref BE-path
 0 0 00:16:3e:6b:67:9b 0 4 5 797 /798 /local/domain/0/backend/vif/3/0

Display domain node information

#virsh nodeinfo
 CPU model: x86_64
 CPU(s): 4
 CPU frequency: 2400 MHz
 CPU socket(s): 1
 Core(s) per socket: 4
 Thread(s) per core: 1
 NUMA cell(s): 1
 Memory size: 8379392 kB

Display domain virtual CPU information

#virsh vcpuinfo centos
 VCPU: 0
 CPU: 1
 State: idle
 CPU time: 47.1s
 CPU Affinity: yyyy

Display xend log

#xm log
#xm dmesg

Errors and Solution while Installing Xen

Yum returns ‘Error: Nothing to do’ while ‘yum install xen’ on CentOS 6.4

Solution:

# yum install http://fedora.cu.be/epel/6/i386/epel-release-6-8.noarch.rpm

The above command will install epel repository. Now run the below command,

# yum install centos-release-xen
# yum install xen

Solution : Fix for “Cannot retrieve metalink error while executing yum install xen


Related Content
Updated on September 3, 2017

Was this article helpful?

Related Articles

Add A Comment