### #虚拟机管理 #
Virt-manager # #开启图形管理工具
Virt-viewer Vmname # #显示虚拟机, Vmname represents the virtual machine name
Virsh List # #列出正在运行的vm
Virsh List--all # #列出所有vm
Virsh Start Vmname # #运行指定vm
Virsh Shutdown Vmname # #正常关闭指定vm
Virsh Destroy Vmname # #强行结束指定vm
Virsh Create Vmname.xml # #临时恢复指定vm, Vmname represents front-end management files
Virsh Define Vmname.xml # #永久恢复vm
Virsh undefine vmname # #删除vm的前端管理, storage is not deleted
# # # # #虚拟机快照 ########
The command for the snapshot is: qemu-img create-f qcow2-b vm2.qcow2 node1.qcow2
Write simple scripts to implement snapshots
This script not only has the snapshot function, but is directly made to reset the virtual machine, which is equivalent to deleting the snapshot before and building a snapshot again
!/bin/bash
Virsh Destroy $ &>/dev/null # #关闭旧的虚拟机
Virsh undefine $ &>/dev/null # #删除旧的快照
Qemu-img create-f qcow2-b/var/lib/libvirt/images/$1.qcow2/var/lib/libvirt/images/$2.qcow2 &>/dev/null
Virt-install \ # #创建新的快照
--name $ \ # #设置名字
--ram 1000 \ # #设置内存大小
--DISK/VAR/LIB/LIBVIRT/IMAGES/$2.QCOW2 \ # #保存文件路径
--import &>/dev/null & # #不显示所有信息
Write this file name kz.sh and give execution permission, execute the effect as shown