
KVM Dirver
- 虚拟机创建
- 虚拟机内存分配
- 虚拟CPU寄存器读写
- 虚拟CPU运行
QEMU(经过讲话与修改)
- 模拟PC硬件的用户控件组件
- 提供I/O设备模型及访问外设的途径
KVM工作原理

下载KVM需要的组件
yum -y install qemu-kvm
yum -y install qemu-kvm-tools
yum -y install virt-install
yum -y install qemu-img
yum -y install bridge-utils
yum -y install libvirt
yum -y install virt-manager
//KVM 模块
/KVM 调试工具,可不安装
//构建虚拟机的命令行工具
//gemu 组件,创建磁盘、启动虚拟机等
//网络支持工具
//虚拟机管理工具
//图形界面管理虚拟机
关机修改虚拟机配置

检查有否支持虚拟化
grep -e 'vmx' -e 'svm' /proc/cpuinfo
#VMX是英特尔版本,SVM是AMD版本
#检查KVM模块是否安装
lsmod |grep KVM
#开启libvirtd服务
systemctl start libvirtd
systemctl enable libvirtd
有两种模式 net和桥接 net模式不需要配置
配置桥接模式
cd /etc/sysconfig/network-scripts/
cp ifcfg-ens33 ifcfg-br0
#修改ens33网卡配置文件
echo 'BRIDGE=br0' >> ifcfg-ens33
#修改br0配置文件
vim ifcfg-br0
#删除UUID
TYPE=Bridge
NAME=br0
DEVICE=br0
systemctl restart network

创建镜像存储目录
mkdir -p /data/{iso,store}
#上传Centos7镜像
[root@localhost ~]# ls /data/iso/
CentOS-7-x86_64-DVD-2207-02.iso
打开虚拟系统管理器
virt-manager


创建存储





创建虚拟机








virt命令
#查看正在运行的虚拟机
[root@localhost ~]# virsh list
Id 名称 状态
----------------------------------------------------
3 test running
#查询所有虚拟机
virsh list
#关闭虚拟机
virsh shutdown test
#打开虚拟机
virsh start test
#强制关机
virsh destroy test
#挂起虚拟机
virsh suspend test
#恢复虚拟机
virsh resume test
#删除虚拟机(关机后)
virsh undefine test