Migrate VM from Xen to Proxmox

wget --no-check-certificate --http-user=root --http-password=PASWORD xttps://192.168.1.4/export?uuid=$1 -O - | tar --to-command=./xva-conv.sh -xf -
Hi,

When I run this command to write virtual disk, return a lot of erros and never finish... the disk is full before command is completed. Size of disk in XCP is 100GB but when disk of proxmox is full the Ref file generated has 1TB of size, do you already see this errors on script?


xpr: non-integer argument
/tmp/xen-to-pve/xva-conv.sh: line 33: [: -eq: unary operator expected
expr: non-integer argument
- [ <=> ] 1.29G 23.0KB/s cat:
/tmp/xen-to-pve/xva-conv.sh: line 33: [: 00004815.xxhash: integer expression expected
expr: non-integer argument
expr: non-integer argument
/tmp/xen-to-pve/xva-conv.sh: line 33: [: -eq: unary operator expected
expr: non-integer argument
/tmp/xen-to-pve/xva-conv.sh: line 33: [: 00004816.xxhash: integer expression expected
expr: non-integer argument
 
I did a (much) better version if you would like to try. It doesn't have to extract nothing, it dumps the full VM to the ZFS pool on PVE.
 
Try the v2 branch: https://github.com/guestisp/xen-to-pve

Tested for about 4 VM transfers on my local server, all perfect. But I did some changes when publishing on github (just to remove hardcoded user/pass and so on) so please try it on a sandbox.

Keep in mind that this will WRITE directly to the storage, if something is wrong you could loose data.
 
  • Like
Reactions: dj423
Next step (atm I don't have time): add named arguments like `--uuid` `--host` and so on and not rely on arguments position
 
Alessandro, your script is awesome!

I have one stranger error, and not found the reason...

about the arguments --uuid --host your script dont need it, but need receive data in correct order...

When I used your script I do one change:


qm set ${VM_ID} -virtio${CNT} local-zfs:${SIZE_GB},cache=writeback
changing local-zfs to my zfs partition name in pve

The process is very fast (3-5 seconds), probably the data to new disk is not copied, and I received this return:

Starting migration of XenServer "03db476f-3577-68d0-9d52-2efb81ce7612" to ProxMox #150
xvda:527f4b5f-c0e7-4905-b574-bb695ed8e2bb:42949672960
Exporting device xvda with UUID 527f4b5f-c0e7-4905-b574-bb695ed8e2bb. Size=40. Disk #0
update VM 150: -virtio0 zfs-sas:40,cache=writeback
Disk not found: /dev/zvol/rpool/data/vm-150-disk-0

I my server I dont found this "block device" folder /dev/zvol/rpool/data/, I need to change it to another folder?


BLOCK_DEVICE="/dev/zvol/rpool/data/${DISK_NAME}"
 
Alessandro, your script is awesome!

I have one stranger error, and not found the reason...

about the arguments --uuid --host your script dont need it, but need receive data in correct order...

When I used your script I do one change:


qm set ${VM_ID} -virtio${CNT} local-zfs:${SIZE_GB},cache=writeback
changing local-zfs to my zfs partition name in pve

The process is very fast (3-5 seconds), probably the data to new disk is not copied, and I received this return:

Starting migration of XenServer "03db476f-3577-68d0-9d52-2efb81ce7612" to ProxMox #150
xvda:527f4b5f-c0e7-4905-b574-bb695ed8e2bb:42949672960
Exporting device xvda with UUID 527f4b5f-c0e7-4905-b574-bb695ed8e2bb. Size=40. Disk #0
update VM 150: -virtio0 zfs-sas:40,cache=writeback
Disk not found: /dev/zvol/rpool/data/vm-150-disk-0

I my server I dont found this "block device" folder /dev/zvol/rpool/data/, I need to change it to another folder?


BLOCK_DEVICE="/dev/zvol/rpool/data/${DISK_NAME}"
update:
I found 2 paths of the disk file, I will try to change the BLOCK_DEVICE path for these:


root@pve-bh:/# find -name vm-150-disk-0
./dev/zvol/zfs-sas/vm-150-disk-0
./dev/zfs-sas/vm-150-disk-0

I will send news soon...
 
Works fine here! Thanks Alessandro.

I only need to change 2 lines in your script:

local-zfs on line 49 to my zfs storage name
path of my zfs folder in line 57, in my case now is: BLOCK_DEVICE="/dev/zvol/zfs-sas/${DISK_NAME}"

Thanks for help!
 
Works fine here! Thanks Alessandro.

I only need to change 2 lines in your script:

local-zfs on line 49 to my zfs storage name
path of my zfs folder in line 57, in my case now is: BLOCK_DEVICE="/dev/zvol/zfs-sas/${DISK_NAME}"

Thanks for help!

yes, that's expected, as I wrote the script for my environment.
Would be nice to automate the change, how can I know the storage path in use ? Should I read the value somewhere ?
 
can you please share the content of "/etc/pve/storage.cfg" ?
dir: local
path /var/lib/vz
content backup,vztmpl,iso

lvmthin: local-lvm
thinpool data
vgname pve
content images,rootdir

dir: nvme
path /nvme
content images
prune-backups keep-all=1
shared 0

zfspool: zfs-sas
pool zfs-sas
content images,rootdir
mountpoint /zfs-sas
sparse 0
 
I suggest 2 changes,

1- name of storage in parameters of your script

2- In block storage, probably /dev/ + namestorage + diskname is fine.. I'm novice in proxmox, in my case work: /dev/zfs-sas/vm-101-disk-0
zfs-sas is name of my storage and vm-101-disk-0 is name of disk (your script already get this)

I can help to edit script if you need.
 
Pull requests are welcome :)

Atm, i think the most useful change would be to remove the XS tool requirement but i wasnt able to call the xenserver api...
 
Here's my way of migrating xen vm's to pve hosts, I've done a few hundred so far and have had very few issues.

Download and prepare xen-to-pve script
Code:
apt-get install git
cd /tmp
git clone https://github.com/guestisp/xen-to-pve.git
chmod +x /xen-to-pve/xva-conv.sh

Make sure you have http access to the xen host
Code:
curl http://192.168.178.125

Shut down VM on Xen host.

Create VM, copy, convert and import disk from Xen host to PVE host.
Code:
qm create 345 --name *vm-name* --acpi 1 --agent 0 --bios seabios --boot cdn --bootdisk virtio0 --onboot yes --cores 2 --memory 2048 --net0 virtio=*MAC-address*,tag=*vlantag*,bridge=*network bridge* && cd /tmp/xen-to-pve && wget --http-user=*Xen-User*--http-password=*Xen-Pass* http://*Xen.hostname.nl*/export?uuid=*Xen-VM-UUID*  --limit-rate=*speedinmb*m -O - | tar --to-command=./xva-conv.sh -xf - && mv Ref* *PVE-VM-ID*.raw && qm importdisk *PVE-VM-ID* *PVE-VM-ID*.raw local-lvm && rm *PVE-VM-ID*.raw -f && qm set *PVE-VM-ID* --virtio0 local-lvm:vm-*PVE-VM-ID*-disk-0

You might want to dig a bit deeper into my oneliner since it's kind of a lot to process.
This oneliner creates a vm on pve with the desired specs without a disk, then downloads the xva file and converts it to .raw and imports it to the vm.

Just make sure you have enough space on the drive you're downloading the vm to.

The only issue I've had so far is vm's not booting due to grub settings.
Some had their boot disk set to xvda, wich becomes vda or sda depending if you choose virtio or scsi.
Other issues happen because there is an option "console=hvc0".

Either way the vm's always booted into grub. I changed settings by editing the settings at boot and made the changes persistent afterwards.
Hi Every time I try to run the command you mentioned I get an error that says "Cannot get /export" even when I try to go to the url of: http://Xen.hostname.nl*/export?uuid= I get this error. Any help would be greatly appreciated.
 
Do you have any log in XenServer ? I did not less than 150 exports with no issue with both version (there is a new one that does the export directly to the ZFS volume)
 
Anyone have any luck with Rocky/Centos VMs? Mine boot after migrating but the disks time out (/dev/mapper/rl-root and /dev/mapper/rl-swap). Would this be an issue with the PVs being named /dev/xvda2 etc?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!