2012년 4월 26일 목요일

Creating Windows HVM on various Xens


This post is describing how I had worked to create Windows VMs (HVM type) on xen hypervisor. I needed to make test environment for VMware 5. vCenter server needs to be installed on Windows machine and needs to join to Windows Active Directory. In this environment, at least two windows machines was needed so I decided to install these in the VM. 


I've already had three physical machines. (a Redhat 5.6 host which xen enabled, a XCP + Ubuntu 12.04 host and a WMware ESXi host)
At first, I tried to create those VMs on XCP. 


1. XCP 1.5 beta on Ubuntu 12.04
I created the first VM via xe command, it was installed without an error. 
However, It was not able to connect to the network.
Click this link to know how it didn't work. https://plus.google.com/103057145276112976207/posts/UrGA7KqVG7m
When I tried it again by XenCenter 5.6. It didn't work, too.


Linux VMs were okay (PV and HVM) on this host, they had no problem for connection.
Next, I tried to do on Redhat 5.6.


2. Redhat 5.6
This machine was kernel-xen-2.6.18-308.4.1.el5 and xen-3.0.3-135.el5


1) Got an error when I created a vm via xm command, /var/log/xen/xend-debug was:  
Traceback (most recent call last):
  File "/usr/lib64/python2.4/logging/handlers.py", line 71, in emit
    if self.shouldRollover(record):
  File "/usr/lib64/python2.4/logging/handlers.py", line 149, in shouldRollover
    msg = "%s\n" % self.format(record)
  File "/usr/lib64/python2.4/logging/__init__.py", line 617, in format
    return fmt.format(record)
  File "/usr/lib64/python2.4/logging/__init__.py", line 405, in format
    record.message = record.getMessage()
  File "/usr/lib64/python2.4/logging/__init__.py", line 276, in getMessage
    msg = msg % self.args
TypeError: int argument required


It's a known bug.
https://bugzilla.redhat.com/show_bug.cgi?id=279581


2) Couldn't finish installation process via virt-manager
It stopped at this screen and it didn't go to the next stage. 



It seemed that xen 3.0 too out-dated and made my mind to upgrade xen version. 


3. Upgrade to xen 3.3.x or 4.x on Redhat 5.6
I downloaded from http://www.gitco.de/linux/x86_64/centos/5/ and install newer xen 3.3.x or 4.x.
After install newer version, xen kernel was the same with before update.
xen only was changed to new one.
But, it didn't nominally booted and caused continuous reboot.


4. Install CentOS 6.2 and xen 4.0.1
I installed CentOS 6.2 and xen 4.0.1 on the machine that used be redhat 5.6. 
As you know, KVM has been the only default hypervisor since CentOS 6.x. so xen users has to install xen manually. 
gitco.de site provies xen RPM and related others.


# Install xen
$ cd /etc/yum.repos.d
$ wget http://www.gitco.de/linux/x86_64/centos/6/gitco-centos6-x86_64.repo
$ yum install xen

# check kernel version before install xen-kernel
$ uname -a
Linux mcloud.******* 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6
19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux

# Install xen aware kernel
$ yum install kernel kernel-devel kernel-headers kernel-firmware

# check if xen was normally installed.
$ ls -al /boot/xen*
-rw-r--r--. 1 root root   677326 Nov 27  2010 /boot/xen-4.0.1.gz
lrwxrwxrwx. 1 root root       12 Apr 26 17:23 /boot/xen.gz -> xen-4.0.1.gz
-rw-r--r--. 1 root root 12091421 Nov 27  2010 /boot/xen-syms-4.0.1

# Modify boot file
$ vi /boot/grub/grub.conf
...
default=0
...
title CentOS (2.6.32.26-174.1.xendom0.el6.x86_64)
       root (hd0,0)
       kernel /xen.gz
       module /vmlinuz-2.6.32.26-174.1.xendom0.el6.x86_64 ro
root=/dev/mapper/....
       module /initramfs-2.6.32.26-174.1.xendom0.el6.x86_64.img
title CentOS (2.6.32-220.el6.x86_64)
       root (hd0,0)
       kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/mapper/...
       initrd /initramfs-2.6.32-220.el6.x86_64.img

$ reboot

Note: After reboot, it was causing continuous reboot !!!. If you have the same problem with this, you should build kernel for xen. For me, I picked the way that downloaded its rpm source and built it.

Here's my way of building the rpm source.

# Remove packages that I previously installed 
$ yum remove kernel-firmware kernel-headers kernel-devel kernel

# Get the kernel-xen rpm source
$ mkdir /root/src
$ cd /root/src

# Install rpm-build tool
$ yum install rpm-build
$ rpm -i ./*.src.rpm
.....
warning: user rpmbuild does not exist - using root
.....
=> Ignore these warnings

$ cd /root/rpmbuild/SPECS/
$ rpmbuild -bb kernel.spec
error: Failed build dependencies:
       gcc >= 3.4.2 is needed by kernel-2.6.32.26-174.1.xendom0.el6.x86_64
       redhat-rpm-config is needed by kernel-2.6.32.26-174.1.xendom0.el6.x86_64
       xmlto is needed by kernel-2.6.32.26-174.1.xendom0.el6.x86_64
       asciidoc is needed by kernel-2.6.32.26-174.1.xendom0.el6.x86_64
       elfutils-libelf-devel is needed by kernel-2.6.32.26-174.1.xendom0.el6.x86_64
       zlib-devel is needed by kernel-2.6.32.26-174.1.xendom0.el6.x86_64
       binutils-devel is needed by kernel-2.6.32.26-174.1.xendom0.el6.x86_64

# Meet required dependencies
$ yum install gcc redhat-rpm-config xmlto asciidoc elfutils-libelf-devel zlib-devel binutils-devel

# It took about 15 minutes for rpmbuild
$ rpmbuild -bb kernel.spec

$ cd ../RPMS/x86_64/
$ ls -al
total 265816
-rw-r--r--. 1 root root  19851580 Apr 26 19:56
kernel-2.6.32.26-174.1.xendom0.el6.x86_64.rpm
-rw-r--r--. 1 root root 212588868 Apr 26 19:57
kernel-debuginfo-2.6.32.26-174.1.xendom0.el6.x86_64.rpm
-rw-r--r--. 1 root root  32409920 Apr 26 19:56
kernel-debuginfo-common-x86_64-2.6.32.26-174.1.xendom0.el6.x86_64.rpm
-rw-r--r--. 1 root root   6543740 Apr 26 19:56
kernel-devel-2.6.32.26-174.1.xendom0.el6.x86_64.rpm
-rw-r--r--. 1 root root    791828 Apr 26 19:56
kernel-headers-2.6.32.26-174.1.xendom0.el6.x86_64.rpm
$ chmod u+x *

# needs to one more dependancy 
$ yum install kernel-firmware

$ rpm -i --force *
ldconfig: /etc/ld.so.conf.d/kernel-2.6.32.26-174.1.xendom0.el6.x86_64.conf:6:
hwcap index 1 already defined as nosegneg

$ rpm -qa kernel
kernel-2.6.32-220.el6.x86_64
kernel-2.6.32.26-174.1.xendom0.el6.x86_64

# Modify boot file
$ vi /boot/grub/grub.conf
...
default=0
...
title CentOS (2.6.32.26-174.1.xendom0.el6.x86_64)
       root (hd0,0)
       kernel /xen.gz
       module /vmlinuz-2.6.32.26-174.1.xendom0.el6.x86_64 ro
root=/dev/mapper/....
       module /initramfs-2.6.32.26-174.1.xendom0.el6.x86_64.img
title CentOS (2.6.32-220.el6.x86_64)
       root (hd0,0)
       kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/mapper/...
       initrd /initramfs-2.6.32-220.el6.x86_64.img

$ reboot

$ xm list ( It also worked by excute "xl list"
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0 14534     8        r--     35.7


This time, I was finally done to create the windows VM. 
After create, I found some less important problems.
- VNC of virt-manager sometimes didn't work. ( I used another RD client.)
- For windows vm, different values between current memory and max memory may cause continuous reboot. ( Once I set the same value with them, It worked.)

References:
- Install xen 4.0 on CentOS 6.0 (Korean language): http://guni.tistory.com/328


댓글 없음:

댓글 쓰기