XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    How do you clone a VM to another host?

    Scheduled Pinned Locked Moved Xen Orchestra
    12 Posts 7 Posters 6.5k Views 5 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R Offline
      rk9268vc @Andrew
      last edited by

      @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,

      1 Reply Last reply Reply Quote 0
      • splastunovS Offline
        splastunov
        last edited by

        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

        aa215cc3-784e-4211-95a2-e8a24e006644-image.png

        R 1 Reply Last reply Reply Quote 1
        • R Offline
          rk9268vc @splastunov
          last edited by

          @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

          1 Reply Last reply Reply Quote 0
          • olivierlambertO Offline
            olivierlambert Vates 🪐 Co-Founder CEO
            last edited by

            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 🙂

            R 1 Reply Last reply Reply Quote 0
            • R Offline
              rk9268vc @olivierlambert
              last edited by

              @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

              1 Reply Last reply Reply Quote 0
              • olivierlambertO Offline
                olivierlambert Vates 🪐 Co-Founder CEO
                last edited by

                XO should list all existing SR (as long as the pool is connected in XO obviously), regardless the pool.

                1 Reply Last reply Reply Quote 0
                • P Offline
                  pctechsolution
                  last edited by

                  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?

                  1 Reply Last reply Reply Quote 0
                  • splastunovS Offline
                    splastunov
                    last edited by splastunov

                    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 VBDs xe vbd-list vm-name-lable={VM-name}.
                    You will see all VBDs and VDIs of VM.
                    Go to certain SR cd /var/run/sr-mount/{SR-UUID} and copy VDI to new host's SR (you can use scp).
                    On destination host:

                    1. Get new VDI UUID vhd-util read -p -n {VDI-UUID}.vhd
                    2. Rename file using this UUID
                      91acf2f8-fbdd-4a6e-b85a-3520c00ddec9-image.png
                    3. Rescan SR on destination host.
                    4. 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.

                    1. Make snapshot with uniq name.
                    2. List VBDs xe vbd-list vm-name-lable={VM-name}.
                    3. Export all VDIs xe vdi-export uuid={VDI-UUID} filename={VM-Name_xvda}.vhd format=vhd --progress (repeat for all VDIs).
                    4. Copy to destination host
                    5. Use vhd-util to get new UUID and rename VDI vhd-util read -p -n {VDI-UUID}.vhd
                    6. Shutdown VM. Do not delete VM before it will not start successfully on "new" host!
                    7. Get snapshot list xe snapshot-list
                    8. Get disks in snapshot xe snapshot-disk-list uuid={snapshot_UUID}
                    9. 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
                    10. Copy diff to destination host
                    11. Import diff xe vdi-import uuid=VDI_UUID_from_step_5 filename=2920_delta_xvda.vhd format=vhd --progress
                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      DustinB
                      last edited by

                      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.

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        Thomas Miller @rk9268vc
                        last edited by

                        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.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post