##12.虚拟机管理###
1.调用虚拟机命令
virt-manager ##开启虚拟机管理器
virsh list ##列出正在运行的虚拟机
virsh list --all ##列出所有虚拟机
virsh shutdown xxx ##正常关闭虚拟机
virsh start xxx ##开启虚拟机
virsh destroy xxx ##强行关闭,相当于
virt-viewer xxx ##相当于rht-vmctl view
在家中怎么模拟virsh
1.准备一个已经安装好的虚拟机
mv /etc/libvirt/qemu/test.xml /mnt/ ##移动硬件到新的主机中
mv /var/lib/libvirt/images/test.qcow2 /mnt/ ##移动硬盘到新的主机
在虚拟机管理器中删除这个装好的虚拟机
模拟恢复过程
cd /mnt
virsh create test.xml ##用硬件信息启动虚拟机(一次性启动)
在操作过程中会出现报错
error:cannot access storage file '/var/lib/libcirt/images/test.qcow2(a07,gid:107): No such file or directory
解决方案:
mv /mnt/test.qcow2 /var/lib/libvirt/images/
virsh define test.xml ##永久恢复虚拟机
sync ##确保镜像完整