Virtualization With Xen On CentOS 6.2 (x86_64) (Paravirtualization & Hardware Virtualization) - Page 2

4 Paravirtualization

4.1 Creating An Image-Based Virtual Machine

We will create our image-based virtual machines in the directory /var/lib/libvirt/images/ which was created automatically when we installed libvirt.

CentOS has a nice tool called virt-install with which we can create virtual machines for Xen. To start it, we simply run

virt-install --prompt --network bridge=br0 --virt-type=xen

(We must specify our network bridge with --network bridge=br0 so that the virtual machine uses our network bridge which we created in chapter2.)

The tools asks a few questions before it creates a virtual machine. I want to call my first virtual machine vm01, with 1024MB RAM and a disk size of 10GB. I want to store it in the file /var/lib/libvirt/images/vm01.img:

Would you like a fully virtualized guest (yes or no)? This will allow you to run unmodified operating systems.
<-- no
What is the name of your virtual machine?
<-- vm01
How much RAM should be allocated (in megabytes)?
<-- 1024
What would you like to use as the disk (file path)?
<-- /var/lib/libvirt/images/vm01.img
How large would you like the disk (/vm/vm01.img) to be (in gigabytes)?
<-- 10
What is the install URL?
<-- http://ftp.tu-chemnitz.de/pub/linux/centos/6.2/os/x86_64

In this chapter I want to create a paravirtualized guest, not a fully (hardware) virtualized guest, that's why I answer the first question with no.

As install URL, you should specify a mirror close to you where the installer can download all files needed for the installation of CentOS 6.2 in our virtual machine. You can find a list of CentOS mirrors here: http://www.centos.org/modules/tinycontent/index.php?id=13

After we have answered all questions, virt-install starts the normal CentOS 6.2 installer (in text mode) in our vm01 virtual machine. After a few moments the installer gives you the choice to use VNC or to continue with the text mode installer. Using text mode is no problem if you are familiar with the CentOS installer, but if you like a little more comfort, select Start VNC here:

On the next screen you can provide a password for the VNC connection (recommended). IF you don't want to use a password, hit No password:

Afterwards, the installer tells you how you can connect to the installer via VNC (192.168.0.15:1 in this case):

Now open a VNC client (like TightVNC) and type in the connection details (192.168.0.15:1 in this case) and click on Connect:

If you have specified a password for the VNC connection, you must now provide it:

Afterwards you can use the CentOS installer in your VNC client:

After the installation, we stay at the vm01 console. To leave it, type CTRL+] if you are at the console, or CTRL+5 if you're using PuTTY. You will then be back at the dom0 console.

Run

virsh console vm01

to log in on that virtual machine again (type CTRL+] if you are at the console, or CTRL+5 if you're using PuTTY to go back to dom0), or use an SSH client to connect to it.

To get a list of running virtual machines, type

virsh list

The output should look like this:

[root@server1 ~]# virsh list
 Id Name                 State
----------------------------------
  0 Domain-0             running
  2 vm01                 idle

[root@server1 ~]#

To shut down vm01, do this:

virsh shutdown vm01

To start vm01 again, run

virsh start vm01

Here are the most important Xen commands:

virsh start <name> - Start a virtual machine.
virsh shutdown <name> - Stop a virtual machine.
virsh destroy <name> - Stop a virtual machine immediately without shutting it down. It's as if you switch off the power button.
virsh list - List all running systems.
virsh console <name> - Log in on a virtual machine.
virsh help - List of all commands.

 

4.2 Creating An LVM-Based Virtual Machine (Paravirtualization)

This chapter explains how you can set up LVM-based virtual machines instead of virtual machines that use disk images. Virtual machines that use disk images are very slow and heavy on disk IO.

In this example I'm using a CentOS 6.2 host with the LVM volume group /dev/VolGroup00 that has about 465GB of space. /dev/VolGroup00 contains two logical volumes, /dev/VolGroup00/LogVol00 and /dev/VolGroup00/LogVol01 that consume about 104GB of space - the rest is not allocated and can be used to create logical volumes for our virtual machines:

vgdisplay

[root@server1 ~]# vgdisplay
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               465.26 GiB
  PE Size               4.00 MiB
  Total PE              119106
  Alloc PE / Size       26250 / 102.54 GiB
  Free  PE / Size       92856 / 362.72 GiB
  VG UUID               LCdZgy-jVrp-S92Q-RQeI-H87G-jiko-4fmaHF

[root@server1 ~]#

lvdisplay

[root@server1 ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                n5remv-KYEE-O0Ry-g2r6-OrUe-rjyV-x65rHu
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                4.88 GiB
  Current LE             1250
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                CnvnGP-sDL8-OtBU-OzTT-VjZQ-ZIUo-yzISkX
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                97.66 GiB
  Current LE             25000
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:1

[root@server1 ~]#

I want to create the virtual machine vm02 now which uses the logical volume /dev/VolGroup00/vm02. I want the virtual machine to have a disk space of 10GB, so I create the logical volume /dev/VolGroup00/vm02 as follows:

lvcreate -L10G -n vm02 VolGroup00

Afterwards we can run

virt-install --prompt --network bridge=br0 --virt-type=xen

again:

Would you like a fully virtualized guest (yes or no)? This will allow you to run unmodified operating systems.
<-- no
What is the name of your virtual machine?
<-- vm02
How much RAM should be allocated (in megabytes)?
<-- 1024
What would you like to use as the disk (file path)?
<-- /dev/VolGroup00/vm02
What is the install URL?
<-- http://ftp.tu-chemnitz.de/pub/linux/centos/6.2/os/x86_64

As the disk file path, we specify our new volume group /dev/VolGroup00/vm02. Please note that virt-install doesn't ask for the disk space anymore because the disk space is determined by the size of the logical volume (10GB).

Share this page:

10 Comment(s)

Add comment

Comments

From: Anonymous at: 2012-04-11 04:44:49

Fantastic write up! Thanks.

From: Anonymous at: 2013-01-14 15:30:20

Hey I am trying to get libvirt to install on CentOS 6.3 ... but when I am building I get the following errors ....

 checking for LIBXML... no
checking libxml2 xml2-config >= 2.6.0 ... configure: error: Could not find libxml2 anywhere (see config.log for details).
error: Bad exit status from /var/tmp/rpm-tmp.BotBuI (%build)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.BotBuI (%build)

 

From: Anonymous at: 2014-06-29 18:45:05

Transaction Check Error:
  file /lib/firmware/amd-ucode/microcode_amd.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package microcode_ctl-1:1.17-17.el6.x86_64
  file /lib/firmware/amd-ucode/microcode_amd_fam15h.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package microcode_ctl-1:1.17-17.el6.x86_64
  file /lib/firmware/radeon/ARUBA_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/BTC_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/CAYMAN_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/CEDAR_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/CYPRESS_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/JUNIPER_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/PITCAIRN_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/R700_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/REDWOOD_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/SUMO_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/TAHITI_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/VERDE_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch

Error Summary
Lot of errors ... :(
 

From: Cutup at: 2014-07-14 09:17:32

hi

i have problem to this..

my machine installed CENTOS 6.5(Final)

I want to install xen on kernel 2.6.32-431.el6

but insert in to terminal that command

yum -y install xen kernel-xen

it is not installed with this error.  

Transaction Check Error:
  file /lib/firmware/amd-ucode/microcode_amd.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package microcode_ctl-1:1.17-17.el6.x86_64
  file /lib/firmware/amd-ucode/microcode_amd_fam15h.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package microcode_ctl-1:1.17-17.el6.x86_64
  file /lib/firmware/radeon/ARUBA_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/BTC_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/CAYMAN_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/CEDAR_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/CYPRESS_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/JUNIPER_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/PITCAIRN_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/R700_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/REDWOOD_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/SUMO_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/TAHITI_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch
  file /lib/firmware/radeon/VERDE_rlc.bin from install of kernel-xen-firmware-3.14.9-1.el6xen.x86_64 conflicts with file from package xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch

Error Summary
 
=
 
please anyone tell me how to solve this problem
 

From: Niall Gowanlock at: 2014-07-29 09:46:15

I found removing the conflicting packages got me passed this e.g.  

yum remove xorg-x11-drv-ati-firmware.noarch

to find the conflicting packages do 

yum list installed | more

Reboot to ensure nothings broken, then re-run the installer.  

This got me installed on Cent os 6.5 but I had problem's on boot after installation but that appears to be a separate issue.

From: Anonymous at: 2012-04-19 04:51:38

This actually worked wonderfully! Now running CentOS 6.2 64-bit with Xend!!! Sweet!

From: at: 2012-05-03 19:59:54

First, at yum install kernel-xen xen I've found the error:

GPG key retrieval failed: [Errno 14] Could not open/read file:///etc/pki/rpm-gpg/RPM-GPG-KEY


As pointed by Jordan, the solution is, before installing the xen-kernel, run:

cd /etc/pki/rpm-gpg/ wget http://www.crc.id.au/repo/RPM-GPG-KEY-kernel-xen


that done, you may resume with yum install kernel-xen xen.


Second, at my install, rpmbuild -bb libvirt.spec exploded with something like:

======================================= 1 of 59 tests failed (2 tests were not run) Please report to libvir-list@redhat.com ======================================= make[1]: *** [check-TESTS] Error 1 make[1]: Leaving directory `/root/rpmbuild/BUILD/libvirt-0.9.4/tests' make: *** [check-am] Error 2 error: Bad exit status from /var/tmp/rpm-tmp.3Yorik (%check) RPM build errors: Bad exit status from /var/tmp/rpm-tmp.3Yorik (%check)


scrolling back, I've found the problem at:

TEST: xencapstest ..!.!.!.!. 10 FAIL FAIL: xencapstest


after some googling and discarting possible causes like this, I decide to adopt a daredevilish path... ;-)
(if someone could point another way to deal with it, I'll like to hear)

cd /root/rpmbuild/SOURCES tar xzvf libvirt-0.9.4.tar.gz vim libvirt-0.9.4/tests/xencapstest.c


and change, starting from line 182, the return values of the four tests for 'Capabilities for ia64'. So, the lines change from something like:

    if (virtTestRun("Capabilities for ia64 ... NULL) != 0)        ret = -1;

to

    if (virtTestRun("Capabilities for ia64 ... NULL) != 0)        ret = 0;


that done, write, quit, repackage the modified source code...

tar czvf libvirt-0.9.4.tar.gz libvirt-0.9.4 rm -rf libvirt-0.9.4


... and run the libvirt rebuild again.

cd /root/rpmbuild/SPECS rpmbuild -bb libvirt.spec

From: Yavor Marinov at: 2012-05-06 23:05:25

Thanks for the great article! 

I think we must download the latest src.rpm from 'updates' directory: 

 wget http://vault.centos.org/6.2/updates/Source/SPackages/libvirt-0.9.4-23.el6_2.8.src.rpm

later, this action fails: 

rpm -Uvh --force libvirt-0.9.4-23.el6.x86_64.rpm libvirt-client-0.9.4-23.el6.x86_64.rpm libvirt-python-0.9.4-23.el6.x86_64.rpm

'cuz we have dependency witch can't be resolved. must add '--nodeps' 

From: libaoyin at: 2012-05-15 08:28:17

There is some errors while I complete all steps and reboot. 1. start xend and xendstored service while reboot. 2.There is some message like below wile run "xm list": Error: Unable to connect to xend: No such file or directory. Is xend running? What's wrong with that?

From: Sunny at: 2012-07-01 03:19:44

You should install qemu-kvm package.