How can I rename a VM on KVM+libvirt?

I would like it to change the name in the 'inventory' as well as change the name of the storage etc.

link|improve this question

65% accept rate
after I asked this question the fine folks on the libvirt project have added the 'virsh edit my-vm-name' command. – Arthur Ulfeldt Nov 29 '11 at 7:37
feedback

2 Answers

up vote 4 down vote accepted

run

virsh dumpxml name_of_vm > name_of_vm.xml

Edit the xml file then import it.

virsh define name_of_vm.xml

Of course you will have to stop and start the vm for the changes to take effect

virsh destroy name_of_vm
virsh start name_of_vm
link|improve this answer
1  
need to add one step: (before defining the vm with the new name) "virsh undefine name-of-vm" otherwise it complains about duplicate UUID. – Arthur Ulfeldt Nov 18 '10 at 17:12
i also had to rename the hd.img file and edit the line in the xml file – Arthur Ulfeldt Nov 18 '10 at 18:45
feedback
virsh dumpxml myvm > foo.xml
<edit foo.xml, change the name, move storage>
virsh undefine myvm
virsh define foo.xml

Source: https://www.redhat.com/archives/libvirt-users/2010-October/msg00072.html

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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