You have 2 computers, both with Linux (Linux Mint in my case). On one computer you have a QEMU/KVM virtual machine and you want to copy/move it to the other computer. On this second computer you have already QEMU/KVM installed and ready. You want to follow an off-line migration – so the virtual machine is stopped first, then recreated on the second computer. And then you can start it again on the second computer.
- Stop the virtual machine on the first computer.
- Locate the disk image file (like .qcow2 file) used by the virtual machine on the first computer. The Virtual Machine Manager program can help here. The file will be large (usually some GBs) but you need to copy it (somehow) to the second computer.
- Export virtual machine definion to an XML file:
virsh dumpxml VMNAME > my_vm.xml
- Copy the XML file to the second computer. Edit the file to update path to the disk image. Search for a tag
<disk>. It should contain a tag
<source>having “file” attribute – you need to update its value so it points to the disk image file copied in step 2.
- If the VM was attached to a custom defined networks, there are some more steps – see: https://serverfault.com/questions/434064/correct-way-to-move-kvm-vm
- On the second computer run:
virsh define my_vm.xml
- Run the Virtual Machine Manager on the second computer. It should show a new virtual machine that you have just imported. Run it.
In my case the first run failed with error message “the CPU is incompatible with host CPU: Host CPU does not provide required features: xop, fma4, tbm”. I’ve solved the issue by going to the tab with virtual machine details (in Virtual Machine Manager), then going to the “Processor” section and clicking checkbox “Copy host CPU configuration”:
You can find some more information here: https://documentation.suse.com/sles/15-SP1/html/SLES-all/cha-libvirt-config-gui.html#id-18.104.22.168.9.5
Then I’ve started my virtual machine again and it was fine!