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.
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.
run
Undefine the old vm to prevent an error because of an duplicate UUID.
Edit the xml file then import it.
Of course you will have to stop and start the vm for the changes to take effect
Source: https://www.redhat.com/archives/libvirt-users/2010-October/msg00072.html
virsh
implementeddomrename
in release 1.2.19: Sep 02 2015. So the current best practice is just:As you might expect, thedomain must be stopped, but also it cannot have any snapshots.
To change many machines you can use this:
Wait for above to finish and run:
Wait for above to finish and run:
Run this one-by-one for each machine. You can use this RegExp if you have a list containing
old-name new-name
:I do it little differently and may be un-recommended method (not sure).
virsh destroy old-vm virsh edit old-vm
In the XML change
virsh list --all
1 old-vm shut-off
2 new-vm shut-off
Now undefine the old-vm
virsh undefine old-vm