核心显卡下分辨率设置
vim /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
#modify console to gfxterm
GRUB_TERMINAL_OUTPUT="gfxterm"
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet intel_iommu=on"
GRUB_DISABLE_RECOVERY="true"
#add resolution radio
GRUB_GFXMODE=1600x900
#重新生成内核
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
#reboot
reboot
RPM 依赖
yum install net-tools vim wget kernel-devel htop virt-manager \
qemu-img qemu-kvm qemu-kvm-tools libvirtvirt-install bridge-utils -y
禁用默认驱动
vim /usr/lib/modprobe.d/dist-blacklist.conf
#在文件最后追加
blacklist nouveau
options nouveau modeset=0
#备份镜像
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
#重建镜像
dracut -v /boot/initramfs-$(uname -r).img $(uname -r)
#重启
reboot
#验证,输出结果为空
lsmod | grep nouveau
开启IOMMU 支持
#添加 intel_iommu 到 GRUB_CMDLINE_LINUX 中
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet intel_iommu=on"
#更新内核
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
#重启
reboot
#验证
dmesg | grep -E "DMAR|IOMMU"
VFIO-PCI 设备
#查看pci设备
lspci -nnk | grep -i nvidia
#绑定设备
echo "options vfio-pci ids=10de:1c81,10de:0fb9" > /etc/modprobe.d/vfio.conf
#开机加载
echo 'vfio-pci' > /etc/modules-load.d/vfio-pci.conf
#验证
dmesg | grep -i vfio
升级QEMU-KVM
#REPO
wget http://rpmfind.net/linux/centos/7.6.1810/extras/x86_64/Packages/centos-release-qemu-ev-1.0-4.el7.centos.noarch.rpm
wget http://rpmfind.net/linux/centos/7.6.1810/extras/x86_64/Packages/centos-release-virt-common-1-1.el7.centos.noarch.rpm
yum install -y centos-release-qemu-ev-1.0-4.el7.centos.noarch.rpm centos-release-virt-common-1-1.el7.centos.noarch.rpm
sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-QEMU-EV.repo
#安装qemu-kvm-ev
yum --enablerepo=centos-qemu-ev -y install qemu-kvm-ev
#重启
systemctl restart libvirtd
OVMF
#REPO
vi /etc/yum.repos.d/kraxel.repo
# create new
[qemu-firmware-jenkins]
name=firmware for qemu, built by jenkins, fresh from git repos
baseurl=https://www.kraxel.org/repos/jenkins/
enabled=0
gpgcheck=0
#RPM Install
yum --enablerepo=qemu-firmware-jenkins -y install OVMF
#check ovmf directory
ls /usr/share/OVMF/
#QEMU配置
vim /etc/libvirt/qemu.conf
nvram = [
"/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVMF/OVMF_VARS.fd",
]
#重启libvirtd服务
service libvirtd restart
VM
#Create VM
virt-install --name win --ram 4096 \
--disk path=/home/win.img,size=80 \
--vcpus=2 \
--cpu host \
--os-type windows \
--os-variant=win10 \
--network bridge=br0 \
--graphics spice,listen=0.0.0.0,password=password,keymap=en-us \
--video qxl \
--cdrom /home/win10.iso \
--boot uefi \
--features kvm_hidden=on \
--host-device 03:00.0 \
--host-device 03:00.1
#VM安装系统后,安装对应NVIDIA显卡驱动
ERROR CODE 43
#编辑VM XML
virsh edit win
#修改第一行
<domain type='kvm'>
#为
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
#找到<features>节点,添加内容
<features>
...
<kvm>
<hidden state='on'/>
</kvm>
...
</features>
#找到</device>节点,在device后添加内容
<qemu:commandline>
<qemu:arg value='-cpu'/>
<qemu:arg value='host,hv_time,kvm=off,hv_vendor_id=null'/>
</qemu:commandline>
#重启VM
virsh destroy win
virsh start win