If you want to completely delete a virtual machine, you need 3 commands
1.virsh Destroy Wyp1 #首先从列表中删除
2.virsh undefine wyp1 #删除虚拟机的配置文件.
3.rm-rf/data/wyp1.img #最后删除虚拟机的文件
If you want to restore the virtual machine wyp1 at this time, you must have an img file , or first copy the wyp2.img file for wyp1.img in a copy of a virtual machine configuration file.
1.cp/data/wyp2.img/data/wyp1.img #复制一份磁盘文件
2.Cp/etc/libvirt/qemu/wyp2.xml/etc/libvirt/qemu/wyp1.xml
or use the command virsh dumpxml wyp2 >/etc/libvirt/qemu/wyp1.xml #备份重定向到wyp1. xml
3.vim/etc/libvirt/qemu/wyp1.xml #主要修改虚拟机name and uuid(Prevent and WYP2 conflicts), modify the type= ' in Disk type Raw' source file= '/data/wyp1.img' disk format and path modified to WYP1 path. There are 4 different places to change, others to keep the default.
4.Virsh define/etc/libvirt/qemu/wyp1.xml #定义虚拟机配置文件
Virtual machine recovery is complete.
2.4-Virtual Disk recovery virtual machine