Decided to play around with virsh today to see if I could rename some VMs that changed their hostname and purpose. It's actually quite simple!
I am using Fedora 14 for this but I assume it will work for Ubuntu and CentOS as well.
You must have elevated privileges for this to work so either become root or use sudo.
Power off the virtual machine and export the machine's XML configuration file:
[root@tclarrltp ~]# virsh dumpxml name_of_vm > name_of_vm.xml
Next, edit the XML file and change the name between the <name></name> tags (should be right near the top). As an added step you could also rename the disk file to reflect the change of the name and change the name of it in the <devices> section under <source file='/path/to/name_of_vm.img'>.
Save the XML file and undefine the old VM name with:
[root@tclarrltp ~]# virsh undefine name_of_vm
Now just import the edited XML file to define the VM:
[root@tclarrltp ~]# virsh define name_of_vm.xml
And that should be it! You can now start up your vm either in the Virtual Machine Manager or with virsh using:
[root@tclarrltp ~]# virsh start name_of_vm
Hope this was helpful!