KVM基本功能管理之virsh常用命令

1:查看命令帮助

[root@localhost ~]# virsh -h

2:查看kvm的配置文件的存放目录

[root@localhost ~]# ll /etc/libvirt/qemu
总用量 8
drwx------. 3 root root 42 4月 26 23:22 networks
-rw-------. 1 root root 4175 4月 27 10:38 test1.xml

3:查看虚拟机状态

[root@localhost ~]# virsh list --all
Id 名称 状态
----------------------------------------------------
- test1 关闭

 4:虚拟机的开机和关机

开启虚拟机

[root@localhost ~]# virsh start test1

域 test1 已开始

关闭虚拟机
[root@localhost ~]# virsh shutdown test1
域 test1 被关闭

强制虚拟机系统关闭电源

[root@localhost ~]# virsh destroy test1   (无论什么状态直接关闭)

5:通过配置文件启动虚拟机

[root@localhost ~]# virsh create /etc/libvirt/qemu/test1.xml

[root@localhost ~]# virsh list --all
Id 名称 状态
----------------------------------------------------
1 test1 running

6:挂起虚拟机

 7:恢复虚拟机

 8:配置虚拟机随宿主机启动而启动

 9:配置虚拟机取消随宿主机启动而启动

 10:导出虚拟机配置

 11:删除虚拟机

 可以看到里面已经没有原来的test1虚拟机

通过备份恢复test1虚拟机

 由上可以看出虚拟机test1已经恢复

12:查看虚拟机详细信息

 13:克隆虚拟机

 启动克隆好的虚拟机

 14:虚拟机快照

 以上为虚拟机快照创建的方法,以及给快照设定名字

 删除快照

 从以上可以看出快照曹毅已经被删除

原文地址:https://www.cnblogs.com/cy888888/p/12799321.html