How do you clone a VM to another host?
-
@Andrew when i select "copy" it does not give me the option to select the other host, only different disks of the same host.
The other host does show up as a separate pool so i wonder if that is the issue?The VM is around 480 GB and i am moving from a 500GB raid to a 512GB raid so i dont have a lot of wiggle room,
-
Live migration is not possible in this case, because of lack of free space.
You have to shutdown VM, then click this button and chose another host

-
@splastunov Hi. The VM doesnt have to be live migrated, shutdown is fine.
The problem is migrate moves the VM. I want to simply copy the VM to the new machine and keep the instance on the current one.
If I migrate, it will be gone from the current machine.
I do not have the storage space to clone the VM first, then migrate on either host.what i want to do is clone, but to another host, not to the same host - if that makes sense
-
There's a copy button in Xen Orchestra (cf the previous screenshot, in the same bar, the last icon on the right). Copy is a XO feature that will stream the VM to the destination, and in the end make a copy. I suggest you spend some time exploring all XO capabilities, there's many chances it's already covered by existing features

-
@olivierlambert Hi, thanks for the comment.
As mentioned, it does not give me the option to copy to the other host. When I select copy, it only shows the disks of the current host as targets.
The only way that I see to see the other host as a target is with migrate.
Is there a setting or something to be able to see others hosts when copying?
thanks -
XO should list all existing SR (as long as the pool is connected in XO obviously), regardless the pool.
-
I'm having same issue, is there any update to this? I can migrate between hosts but when I hit copy it doesn't allow me to copy between hosts and only shows the host on which it's on.
I have an XENServer host (primary) and XCP-ng (new server). I Can migrate from xenserver to xcp-ng but can't copy for some reason?
-
There is no implementation in XAPI to "copy" VM to remote host (maybe XO has it own implementaion I'm not sure).
Copy works only localy.
You can only migrate it to remote host.Disclaimer.
Everything you do on your own risk.But you can do it manually by export/copy VDI from one host to another.
If you do not need "live" copy while VM is running, just stop VM, get all VBDsxe vbd-list vm-name-lable={VM-name}.
You will see all VBDs and VDIs of VM.
Go to certain SRcd /var/run/sr-mount/{SR-UUID}and copy VDI to new host's SR (you can usescp).
On destination host:- Get new VDI UUID
vhd-util read -p -n {VDI-UUID}.vhd - Rename file using this UUID

- Rescan SR on destination host.
- Create VM, attach VDI.
If VDI stored on "shared" SR (iSCSI, NFS, ceph rbd and etc...), firts you have to export VDI by command
xe vdi-export uuid={VDI-UUID} filename={VM-Name_xvda}.vhd format=vhd --progress
After success export, copy to destination host, read, rename and etc....If you need "live" migration you can do it with minimal down time via snapshot.
- Make snapshot with uniq name.
- List VBDs
xe vbd-list vm-name-lable={VM-name}. - Export all VDIs
xe vdi-export uuid={VDI-UUID} filename={VM-Name_xvda}.vhd format=vhd --progress(repeat for all VDIs). - Copy to destination host
- Use vhd-util to get new UUID and rename VDI
vhd-util read -p -n {VDI-UUID}.vhd - Shutdown VM. Do not delete VM before it will not start successfully on "new" host!
- Get snapshot list
xe snapshot-list - Get disks in snapshot
xe snapshot-disk-list uuid={snapshot_UUID} - Export diff
xe vdi-export uuid={main_VDI_UUID_from_step_3} filename=2920_delta_xvda.vhd format=vhd base={snapshot_VDI_UUID_from_step_8)} --progress - Copy diff to destination host
- Import diff
xe vdi-import uuid=VDI_UUID_from_step_5 filename=2920_delta_xvda.vhd format=vhd --progress
- Get new VDI UUID
-
The simple answer here is to use the Continuous Replication backup type. It'll copy the VM to another host on whatever schedule you set.
It couldn't be simpler.
-
To anyone still having this issue or finding this thread when searching online: "How to clone a VM between hosts in Xen Orchestra" or similar...
The key piece of information missing from all these answers is that you must first connect both hosts (XCP-ng) servers to the same Xen Orchestra instance before you can clone (copy (export/import)) a VM from one host to another while using the Xen Orchestra GUI. Note that as mentioned in the first reply that this is only one solution, given both hosts can see each other over the network. You can also manually export and import the VM as an image file to your local PC's storage if needed.
To do this, first navigate to "Settings->Servers" and configure/connect the destination host alongside the existing host so you end up with two hosts connected to the same Xen Orchestra. Note that Xen Orchestra can display information and manage multiple hosts if required (does not have to be tied to a single XCP-ng instance).
Then navigate back to "Home->VMs" and you should now see all VMs listed for both hosts in the same list. From here you can select the VM to clone and from the copy dialog menu when you select a "SR" you should now be able to select between both host's disks (Local Storage or Pools) to copy the VM onto. Note that this command will spin up two separate tasks: an export and import task simultaneously on each host to complete the copy (sort of streaming it at the same time). Also don't forget to first shutdown the VM first before you copy it so you do not risk losing/corrupting any live data while it is cloning.
Hope this helps everyone.