User Tools

Site Tools


unix:virtualization:virtlib:importxen

This is an old revision of the document!


Import Xen virtuals to KVM/Xen

Warning: Preliminary. These are my notes I'm getting ready to try.

This is a work in progress, as I've not been able to find anything on the 'net about it. Everything I've seen assumes your Xen virtuals are being managed by libvirt already, so it is a matter of using some built in utilities.

The way I propose to do it is to manually generate a libvirt configuration file, modified to use values from the original Xen machine. We'll use the virt-install command with the –import and –print-xml options.

Lets try to convert the following Xen configuration file

builder='hvm'
memory=4096
vcpus=4     # change this to the number of virtual cpu's it should have
name='server.example.com'# change this to the name displayed on xm list
 
# change the MAC address to be unique. There is a list of MAC's we use in shared/Tech/DailyData/ips.ods
# change the vifname so it shows up well on ifconfig output
vif= [
       'mac=00:16:3f:97:db:f3,bridge=br_dmz,vifname=server0',
     ]
disk=[
       # this points to the "drive" we created
       'phy:/dev/disk/by-path/ip-10.22.209.32:3260-iscsi-iqn.2019-09.com.nas:server.disk0-lun-0,hda,w',
       # this points to the installation media
       # note, you may (should) remove the disk image after the install is done
       'file:/mnt/devuan_beowulf_3.1.1_amd64_netinstall.iso,ioemu:hdc:cdrom,r',
     ]
 
# NOTE: you must change this to C after the initial installation or it will boot right back into the installer
boot='cd' # this makes it boot from the installation media. Change it to 'c' after install
vnc=1    # allow us to use vnc to connect during install (and after)
vncdisplay=4
usbdevice='tablet'
localtime=0
serial='pty' # allow us to connect from xm console
xen_platform_pci=1 # allows us to use the pv drivers for Linux hvm
uuid='44f33f93-f606-4513-8dc0-7e1eac977025'

To do this, will run virt-install

virt-install \
   --hvm \
   --connect    qemu:///system \
   --import \
   --noautoconsole \
   --boot     hd,cdrom,menu=on \
   --name       server.example.com \
   --os-variant debian10 \
   --metadata uuid=44f33f93-f606-4513-8dc0-7e1eac977025 \
   --memory     4096 \
   --vcpus      4 \
   --disk       path=/dev/disk/by-path/ip-10.22.209.32:3260-iscsi-iqn.2019-09.com.nas:server.disk0-lun-0,bus=virtio,target=sda \
   --cdrom     /mnt/devuan_beowulf_3.1.1_amd64_netinstall.iso \
   --graphics vnc,port=5904 \
   --network  bridge=br_dmz,mac=00:16:3f:97:db:f3,model=virtio

The items after name in the above command are all populated from a Xen configuration file. NOTE: it is very important to place the boot drive first in the list, before any other drives or cdrom's

unix/virtualization/virtlib/importxen.1652067020.txt.gz · Last modified: 2022/05/08 22:30 by rodolico