PDA

View Full Version : How to rename a VM


Alsaleem
04-05-2017, 05:37 PM
Is there any change to rename a virtual machine in VM manager? :confused:

I need to import virtual machines with the same names. The operation just hangs and cannot be completed

fly
04-12-2017, 05:24 AM
Hello,

There are steps to renew virtual machine

1. Shut down vm.

2. Rename virtual machine's xml file:
mv /etc/libvirt/qemu/old.1118.vm.xml /etc/libvirt/qemu/new.1118.vm.xml

Change vm's name in the file new.1118.vm.xml
Delete filterref section from the file.

3. Rename vm's volume:
mv /kvm/old.1118.vm /kvm/new.1118.vm

4. Redefine vm:

virsh undefine old.1118.vm

virsh define /etc/libvirt/qemu/new.1118.vm.xml

5. Change name in the VMmanager's data base:

update vm set name='new.1118.vm', name_idn='new.1118.vm' where id=<vm id in VMmanager>;
update volume set name='new.1118.vm' where id=<volume id in VMmanager>;

6. Restart VMmanager
killall core

7. Go to VMmanager -> virtual machine, click to edit button and select checkbox "Disable anti-spoofing", click to OK. Then open form again and unselect checkbox "Disable anti-spoofing". It is necessary to make anti-spoofing rules be recreated with new vm name.

8. Power up vm