Virt-v2v testing

From PRAGMA wiki
Jump to: navigation, search

Manually migrate a VM from Rocks/Xen to Rocks/KVM

The original VM is frontend-0-0-19, created on Rocks/Xen hosting system - fiji-xen. We want to migrate it to the Rocks/KVM system - cal-kvm and the destination VM name is calit2-119-255 with a new ip# 137.110.119.225.

On fiji-xen

  • Boot up frontend-0-0-19
  • Get xml dump
# virsh dumpxml frontend-0-0-19 > frontend-0-0-19.xml
  • Shutdown frontend-0-0-19
  • copy the follow files to the Rocks/KVM system cal-kvm (Warning: Do NOT copy these files to the standard VM disk file directory. It's safe to copy them to an user home directory.)
    • frontend-0-0-19.xml
    • /state/partition1/xen/disks/frontend-0-0-19.hda

On cal-kvm

  • Modify /opt/rocks/lib/python2.6/site-packages/rocks/commands/report/host/vm/config/__init__.py file, so that
# diff __init__.py __init__.py.orig
351c351
<       a = "<target dev='%s' bus='ide'/>" % device
---
>       a = "<target dev='%s' bus='virtio'/>" % device
  • If this is the first time to use virt-v2v, create a local storage domain for transferred storage
    • Run virt-manager
    • Right-click on "localhost (QEMU)" and select "Details"
    • Select "Storage" tab then click the plus sign down the buttom-left corner
    • Enter the Name "transferedimages" and click the "Forward" button
    • Fill the path "/state/partition2/kvm/disks", then confirm/finish

Modify frontend-0-0-19.xml

  • Rename frontend-0-0-19.xml to calit2-119-255.xml (This is not necessary technically, but nice to be consistent, to reduce confusion to humans)
  • Edit calti2-119-255.xml, replace "frontend-0-0-19" with "calit2-119-225"
  • Fix the directory path in the line "<source file='/state/partition1/xen/disks/calit2-119-225.hda'/>", so that the path is point to the imported VM image file. In this example, "<source file='/export/home/cindy/vm-images/SDSC/calit2-119-225.hda'/>".

Modify the disk image frontent-0-0-19.hda

  • Rename the image file
# mv frontend-0-0-19.hda calit2-119-225.hda
  • Mount the disk image
# kpartx -av calit2-119-225.hda
add map loop0p1 (253:0): 0 32772537 linear /dev/loop0 63
add map loop0p2 (253:1): 0 8193150 linear /dev/loop0 32772600
add map loop0p3 (253:2): 0 2040255 linear /dev/loop0 40965750
add map loop0p4 (253:3): 0 2 linear /dev/loop0 43006005
add map loop0p5 (253:4): 0 27294372 linear /dev/loop0 43006068
# mkdir /tmp/mnt
# mount /dev/mapper/loop0p1 /tmp/mnt
  • Modify yum.conf

Because fiji-xen is running Rocks 5.4 and cal-kvm is running Rocks 6.0, we need to fix the /etc/yum.conf in the VM image for the migration. Remember to remove the last 18 lines in yum.conf after the migration is done.

# cat /etc/yum.repos.d/yum.conf/CentOS-Base.repo >> /tmp/mnt/etc/yum.conf

Then edit /tmp/mnt/etc/yum.conf, so the result shows differences between /tmp/mnt/etc/yum.conf and the /etc/yum.repos.d/yum.conf/CentOS-Base.repo looks something like this:

1,14d0
< [main]
< cachedir=/var/cache/yum
< debuglevel=2
< logfile=/var/log/yum.log
< pkgpolicy=newest
< distroverpkg=redhat-release
< tolerant=1
< exactarch=1
< assumeyes=1
<
< [Rocks-5.4]
< enabled = 0
< name=Rocks 5.4
< baseurl=http://198.202.88.202/install/rocks-dist/x86_64
28c14
< enabled = 1
---
> enabled = 0
30,32c16,17
< mirrorlist=http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=os
< #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=x86_64&repo=os
< #baseurl=http://mirror.centos.org/centos/$releasever/os/x86_64/
---
> mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
> #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
34c19
< gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
---
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
38,41c23,26
< enabled = 1
< name=CentOS-5 - Updates
< mirrorlist=http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=updates
< #baseurl=http://mirror.centos.org/centos/5/updates/x86_64/
---
> enabled = 0
> name=CentOS-$releasever - Updates
> mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
> #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
43c28
< gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
---
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
48,50c33,35
< name=CentOS-5 - Extras
< mirrorlist=http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=extras
< #baseurl=http://mirror.centos.org/centos/5/extras/x86_64/
---
> name=CentOS-$releasever - Extras
> mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
> #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
52c37
< gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
---
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
57,59c42,44
< name=CentOS-5 - Plus
< mirrorlist=http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=centosplus
< #baseurl=http://mirror.centos.org/centos/5/centosplus/x86_64/
---
> name=CentOS-$releasever - Plus
> mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
> #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
62c47
< gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
---
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
67,69c52,54
< name=CentOS-5 - Contrib
< mirrorlist=http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=contrib
< #baseurl=http://mirror.centos.org/centos/5/contrib/x86_64/
---
> name=CentOS-$releasever - Contrib
> mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
> #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
72c57
< gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
---
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
  • Modify VM network settings
    • Change IP# to 137.110.119.225 in /tmp/mnt/etc/sysconfig/network-scripts/ifcfg-eth1
    • Change gateway address in /tmp/mnt/etc/sysconfig/network
    • Replace /tmp/mnt/etc/resolv.conf with /etc/resolv.conf
    • Add your ssh public key to /tmp/mnt/root/.ssh/authorized_keys file
  • Unmount and unmap the VM image file
# umount /tmp/mnt
# kpartx -dv calit2-119-225.hda

Convert VM image

Mapping only public network
# virt-v2v -i libvirtxml -os transferimages --bridge eth1 calit2-119-225.xml

Note: If some necessary perl modules are missing on your system, you may get errors like this:

Can't locate Pod/Simple.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/share/perl5/Pod/Text.pm line 33.
BEGIN failed--compilation aborted at /usr/share/perl5/Pod/Text.pm line 33.
Compilation failed in require at /usr/share/perl5/Pod/Usage.pm line 452.
BEGIN failed--compilation aborted at /usr/share/perl5/Pod/Usage.pm line 459.
Compilation failed in require at /usr/bin/virt-v2v line 25.
BEGIN failed--compilation aborted at /usr/bin/virt-v2v line 25.

Just install the missing perl modules until all such errors clearred. For the above error, run "yum install perl-Pod-Simple".

Mapping 2 interfaces
  • Find the bridge names for both interfaces in calit2-119-225.xml file
  • Map the 2 interfaces by adding 2 entries in /etc/virt-v2v.conf
<network type='bridge' name='xenbr.eth1'>
    <network type='bridge' name='eth1'/>
  </network>

  <network type='bridge' name='xenbr.eth0.11'>
    <network type='bridge' name='eth0'/>
  </network>
  • Convert VM image
[root@calit2-119-121 SDSC]# virt-v2v -i libvirtxml -os transferimages calit2-119-225.xml
calit2-119-225.hda: 100% [===========================================]D 0h07m43s
virt-v2v: WARNING: Failed to install packages using yum. Output was: sh_lines: sh_lines: http://137.110.119.225/install/rocks-dist/x86_64/repodata/repomd.xml: [Errno 4] IOError: <urlopen error (111, 'Connection refused')>
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: Rocks-5.4. Please verify its path and try again at /usr/share/perl5/vendor_perl/Sys/VirtConvert/GuestfsHandle.pm line 187.
 at /usr/share/perl5/vendor_perl/Sys/VirtConvert/Converter/RedHat.pm line 1266
virt-v2v: calit2-119-225 configured with virtio drivers.

Note: If some necessary perl modules are missing on your system, you may get errors like this:

Can't locate Pod/Simple.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/share/perl5/Pod/Text.pm line 33.
BEGIN failed--compilation aborted at /usr/share/perl5/Pod/Text.pm line 33.
Compilation failed in require at /usr/share/perl5/Pod/Usage.pm line 452.
BEGIN failed--compilation aborted at /usr/share/perl5/Pod/Usage.pm line 459.
Compilation failed in require at /usr/bin/virt-v2v line 25.
BEGIN failed--compilation aborted at /usr/bin/virt-v2v line 25.

Just install the missing perl modules until all such errors clearred. For the above error, run "yum install perl-Pod-Simple".

Re-create VM via Rocks

  • Remove VM definition from libvirt
# virsh undefine calit-119-225
  • Create the VM in Rocks
# rocks add cluster 137.110.119.225 0 fe-name=calit2-119-225
# rocks set host boot action=os calit2-119-225
# rocks start host vm calit2-119-225
  • Find out the new VM network settings
# rocks list host interface calit2-119-225

Synch network settings

  • Start virt-manager
  • Select calit2-119-225 then click "Run"
  • logon to calit2-119-225 as root
  • Change IP#s and MAC addresses in /etc/hosts, /etc/sysconfig/network-scripts/ifcfg-eth0 and /etc/sysconfig/network-scripts/ifcfg-eth1 to match the output of "rocks list host interface calit2-119-225" above.
  • Restart network on VM
# service network restart
  • Test network connectivity