Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm wondering what is the correct way of moving a VM between two KVM hosts without using any kind of shared storage

Would copying the disk files and the XML dump from the source KVM machine to the destination one suffice? If so, what commands need to be run to import the vm on the destination?

OS is Ubuntu on both the Dom0's and DomU.

Thanks in advance

share|improve this question

2 Answers 2

up vote 1 down vote accepted
  1. copy the VM's disks from /var/lib/libvirt/images on src host to the same dir on destination host
  2. on the source host run virsh dumpxml VMNAME > domxml.xml and copy this xml to the dest. host
  3. on the destination host run virsh define domxml.xml

start thew VM.

  • If the disk location differs, you need to edit the xml's devices/disk node to point to the image on the destination host
  • If the VM is attached to custom defined networks, you'll need to either edit them out of the xml on the destination host or redefine them as well (virsh net-dumpxml > netxml.xml and the virsh net-define netxml.xml && virsh net-start NETNAME & virsh net-autostart NETNAME)
share|improve this answer

Yes, just copying the XML file and the virtual disk images is sufficient, but this obviously precludes a "live" migration. The VM must be shut off during this procedure.

Once copied to the destination, libvirtd must be reloaded or restarted to recognize the new XML file.

share|improve this answer
    
According to help.ubuntu.com/community/KVM/Virsh and to complete an answer I believe the sequence of commands would be: On the source Dom0: - virsh shutdown foo - virsh dumpxml foo > /tmp/foo.xml Then on the destination Dom0: - Copy over the disk files and putting them on the same directory as the source Dom0 - Copy over the XML dump - virsh create /tmp/foo.xml - virsh start foo –  Onitlikesonic Oct 2 '12 at 14:33
    
Reasonable enough if you use virsh. I'd just copy the files directly and reload libvirtd. –  Michael Hampton Oct 2 '12 at 14:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.