1.查看并关闭要修改的虚拟机
2.进入/etc/libvirt/qemu文件夹 cd /etc/libvirt/qemu查看:
3.导出要修改虚拟机的xml文件 比如:我导出centos6.5_nginx_192.168.0.101.xml
command: virsh dumpxml centos6.5_nginx_192.168.0.101 > centos6.5_nginx_1.xml
4.编辑centos6.5_nginx_1.xml文件 把里面所有的centos6.5_nginx_192.168.0.101替换成centos6.5_nginx_1 :
command: :1,$ s/centos6.5_nginx_192.168.0.101/centos6.5_nginx_1/g (自行查找vi有关命令) 或者 sed -i 's/centos6.5_nginx_192.168.0.101/centos6.5_nginx_1/g' centos6.5_nginx_1.xml
5.重新定义
virsh undefine centos6.5_nginx_192.168.0.101
virsh define centos6.5_nginx_1.xml
6.进入qcow2文件夹对相关磁盘重命名(尝试启动,若是启动不了一般是缺少这一步,提示找不到磁盘)
mv centos6.5_nginx_192.168.0.101.qcow2 centos6.5_nginx_1.qcow2