-
Understanding KVM VM Migration Types
-
KVM Migrate VM to Another Host with Command Line
-
KVM Migrate VM to Another Host without Command Line
-
Migrate and Protect VM with Vinchin Backup & Recovery Easily
-
KVM migrate VM to another host FAQs
-
Sum Up
For virtual environment maintenance, sometimes you might need to move VM between hosts.
VM migration will bring benefits to IT environment. It will decrease the planned downtime when you would like to maintain or upgrade servers. In addition, it will help fully utilize the hardware resources on all the hosts.
KVM is a not so mature compared with VMware vSphere but it is free and open-source so it's friendly to startup companies but is not so convenient to use as VMware vSphere.
For virtual machine migration, VMware provides vCenter to let users perform vMotion or cold migration with a few clicks, but in native KVM environment, IT administrators often need to manually move VM with command line. If you are using oVirt, there is VM portal to export and import VM.
The procedures to use commands can be tedious and it is likely to have a failed virtual machine so every step needs to be carefully checked.
P.S. If you would like to move VMs on KVM-based platforms like Proxmox VE, oVirt or OpenStack, you can also try Vinchin Backup & Recovery.
Quick answer: To migrate a KVM VM to another host, use virsh migrate. For a running VM, run virsh migrate --live --persistent --undefinesource <vm-name> qemu+ssh://<destination-host>/system. If the VM's disks are not on shared storage, add --copy-storage-all. For a powered-off VM, use --offline --persistent instead, or copy the VM's XML file and disk images to the new host and define the VM there with virsh define.
Understanding KVM VM Migration Types
Before performing migration, it is important to understand the available migration modes.
1. Live Migration
Live migration moves a running VM from one host to another with minimal downtime.
Advantages
Near-zero interruption
Suitable for production workloads
Enables maintenance without service shutdown
Requirements
Shared storage or block migration
Compatible CPU features
Matching QEMU/libvirt versions
Stable network connection
Typical Use Cases
Hypervisor maintenance
Load balancing
High availability environments
2. Cold Migration
Cold migration requires shutting down the VM before transferring it.
Advantages
Simpler setup
Lower compatibility risks
Easier troubleshooting
Disadvantages
Service downtime required
Manual restart necessary
Typical Use Cases
Small environments
Test labs
Cross-platform migration scenarios
KVM Migrate VM to Another Host with Command Line
This section will introduce the way to perform cold KVM migration. Generally speaking, to move KVM VM, you need to copy all the VM data from the source host to the destination host and then define the new VM. Before that, you can backup KVM VM to ensure data security.
You should note that the virtual environment on the destination host must be the same as that on the source host. In addition, the absolute directory of virtual hard disk has been saved in configuration file so the directory on the destination host must be also the same.
1. Since it is cold migration, the first step is to power off the target VM. You can list all the VMs on the source host to find the VM you would like to migrate.
virsh list --all
2. Remember the name of the target guest machine and you need shut down it.
virsh shutdown guest_name
3. You can also recheck its state to make sure it has been powered off:
virsh domstate guest_name
4. The next step is exporting the configuration of guest machine:
virsh dumpxml guest_name > /root/guest_name.xml
5. Find the location of the VM’s virtual disks:
virsh domblklist guest_name
6. Copy the configuration file and the disk images to the destination host.
Keep the same disk path, because the absolute path is saved in the XML file:
scp /root/guest_name.xml root@destination_host_ip:/root/ scp /var/lib/libvirt/images/guest_name.qcow2 root@destination_host_ip:/var/lib/libvirt/images/
Replace the disk path with the one shown by virsh domblklist, and enter the destination host’s password when prompted.
7. On the destination host, define the new VM from the XML file:
virsh define /root/guest_name.xml
8. Then you can start the VM to test whether it works:
virsh start guest_name
If it reports the error that the CPU is not compatible with host CPU, then the CPU of the VM needs to be modified.
virsh edit guest_name
Replace CPU configuration with <cpu mode='host-passthrough' check='none'/>
Migrate a KVM VM with virsh migrate (Live or Offline)
Instead of copying files by hand, you can let libvirt move the VM with a single virsh migrate command. Before you start, make sure that:
The source host can connect to the destination host over SSH, ideally with key-based login.
Both hosts run compatible QEMU and libvirt versions and have compatible CPUs.
The network and storage pool names the VM uses also exist on the destination host.
Live migration with shared storage (the VM keeps running, and its disks stay on NFS, iSCSI or Ceph that both hosts can access):
virsh migrate --live --persistent --undefinesource --verbose guest_name qemu+ssh://destination_host_ip/system
Live migration without shared storage (the disks are copied to the destination host during the move):
virsh migrate --live --persistent --undefinesource --copy-storage-all --verbose guest_name qemu+ssh://destination_host_ip/system
With --copy-storage-all, create an empty disk image of the same size and path on the destination host first, unless your libvirt version creates it automatically.
Offline migration (the VM is shut down, and only its definition moves; copy the disks yourself as in the steps above):
virsh migrate --offline --persistent guest_name qemu+ssh://destination_host_ip/system
The most useful options are:
| Option | What it does |
|---|---|
--live | Migrates a running VM without shutting it down |
--offline | Migrates the definition of a VM that is shut down |
--persistent | Keeps the VM defined on the destination host after it stops |
--undefinesource | Removes the VM definition from the source host after migration |
--copy-storage-all | Copies the full disk images when there is no shared storage |
--verbose | Shows migration progress |
After migration, run virsh list --all on the destination host to confirm the VM is there and running. For a deeper look at live migration, see KVM virtual machine live migration.
KVM Migrate VM to Another Host without Command Line
Two options without command line are listed below.
Option 1. Migrate KVM VM Using Cockpit (Web GUI)
Requirements
Before migration:
Both hosts must have Cockpit installed
libvirt and QEMU versions should be compatible
Shared storage is recommended
SSH trust between hosts should be configured
Step 1. Open the Cockpit Web Console
Access:
https://your-server-ip:9090
Step 2. Go to Virtual Machines
Navigate to Virtual Machines and select the VM you want to migrate

Step 3. Choose Migrate
In supported environments, Cockpit provides a migration option directly inside the VM management page.
Just enter Destination host, connection credentials, and migration mode
Step 4. Start Migration
Click Migrate button to start the process
Option 2. KVM Migration in Proxmox VE
Step 1. In the Proxmox Web interface, select the VM and located the menu to click Migrate

Step 2. Select the target node, like Destination host, Online or offline migration, and Storage migration options

Step 3. Start Migration, and Proxmox automatically performs: memory transfer, diak handling, and VM switchover
Migrate and Protect VM with Vinchin Backup & Recovery Easily
Migrating VM part by part with command line might cause issue if certain step is incorrect. In addition, unknown errors might appear on the destination host. To smoothly migrate virtual machine, you can trust Vinchin Backup & Recovery.
Vinchin Backup & Recovery is not only a professional backup and disaster recovery solution for multiple KVM-based platforms, but also an advanced VM migration solution, supporting VMware vSphere, Hyper-V, XenServer, Proxmox, Red Hat Virtualization, oVirt, Oracle Linux KVM (OLVM), OpenStack, etc. (Native KVM is not supported for now).
VM migration will be easy in Vinchin Backup & Recovery. You just need to backup VM agentlessly in a user-friendly web console and then you can use that backup to restore VM on another added host. You don't have to type commands anymore, just complete the process with backup and restore wizards.
Vinchin Backup & Recovery lets you migrate VM between platforms. With Vinchin Virtual Machine Convert Engine, source VM will be smartly converted to be compatible on the destination host.
For instance, if you would like to migrate VM from Proxmox to VMware:
1. Just select the backup of the target Proxmox VM

2. Select a VMware host as target host

3. Simply set up restore strategies or directly skip this step

4. Just submit the job and then the Proxmox VM will be quickly restored on the VMware host

Vinchin Backup & Recovery has been selected by thousands of companies and you can also start a 60-day full-featured free trial here. Also, contact us, leave your requirements, and then you will receive your tailored solution. We have established partnerships with reputable companies all over the world so if you would like to do a local business, you can select a local partner here.
KVM migrate VM to another host FAQs
Q1. Can you migrate a KVM virtual machine to another host without shutting it down?
Yes, you can. KVM live migration is supported in some environment like Red Hat and Oracle. There is also another way to migrate VM without shutting down VM. Using Vinchin allows you to migrate the VM via its backup so the impact to production environment is mitigated.
Q2. What is the difference between hot migration and cold migration in KVM?
Hot migrate allows you to migrate the KVM to another host while it is running but cold migration requires you to shut down the VM during the migration.
Q3. Can you migrate a KVM VM via snapshot?
Usually, it is not supported because snapshot is not a full VM and it can only work with the original VM.
Sum Up
Virtualization technology allows IT administrators to easily move virtual machines and this post has introduced the way to migrate KVM VM to another host with commands, moving VM part by part and then defining it on the destination host.
Of course, you have an easy way to move KVM VM with Vinchin Backup & Recovery without command line. It is easy to operate and you will have more options to choose. Don't miss out on the free trial.
Share on: