7.1 前提:

[root@room8pc205 ~]# virsh undefine centos7.0   //取消定义模板虚拟机node,让模板固定

域 centos7.0 已经被取消定义

[root@room8pc205 ~]# cd /var/lib/libvirt/images/

[root@room8pc205 images]# ls  #在这里面是可以找到node.qcow2这个文件的

7.2 创建虚拟机

7.2.1 利用后端模板创建前端盘

[root@room8pc205 images]# qemu-img create -f qcow2 -b node.qcow2 node1.img 30g

Formatting 'node1.img', fmt=qcow2 size=32212254720 backing_file='node.qcow2' encryption=off cluster_size=65536 lazy_refcounts=off

[root@room8pc205 images]# ls -lh  node1.img

-rw-r--r-- 1 root root 193K 7月  19 14:38 node1.img

7.3 编写xml配置文件

[root@room8pc205 ~]# sed 's,demo,node1,' demo.xml >/etc/libvirt/qemu/node1.xml

生成完成后虚拟机创建完毕

7.4 定义虚拟机

[root@room8pc205 ~]# virsh define /etc/libvirt/qemu/node1.xml

定义域 mode1(从 /etc/libvirt/qemu/node1)

7.5 利用vish查看虚拟机

[root@room8pc205 ~]# virsh list --all

 Id    名称                         状态

----------------------------------------------------

 -     node1                          关闭

 -     win2008                        关闭

[root@room8pc205 ~]# virsh start node1

域 node1 已开始