kvm 透传显卡至win10虚拟机
- 环境
已安装nvidia 显卡 驱动
操作系统:CentOS Linux release 7.9.2009 (Core)
内核版本:Linux 5.4.135-1.el7.elrepo.x86_64
显卡 型号:rtx 6000
kvm版本:
virsh version
Compiled against library: libvirt 4.5.0
Using library: libvirt 4.5.0
Using API : QEMU 4.5.0
Running hypervisor: QEMU 1.5.3
- 解绑GPU 设备
- 配置GRUB_CMDLINE_LINUX(实测,有效),查询要解绑的设备,记录设备id号
lspci -nn|grep NVIDIA |grep VGA
或者 lspci -nn|grep NVIDIA
2.修改 /etc/default/grub文件的GRUB_CMDLINE_LINUX
vi /etc/default/grub
以下是内容,新增加 GRUB_CMDLINE_LINUX行: intel_iommu=on pci-stub.ids=10de:1e30"
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="intel_iommu=on crashkernel=auto spectre_v2=retpoline rhgb quiet rdblacklist=nouveau pci-stub.ids=10de:1e30"
GRUB_DISABLE_RECOVERY="true"
3.更新grub2 conf,执行如下命令
grub2-mkconfig -o /boot/grub2/grub.cfg
4.重启系统
reboot
- 验证并查看nvidia 显卡
1.执行nvidia-smi ,看不到显卡,证明显卡已经被解绑
# nvidia-smi
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
2.验证内核支持iommu
cat /proc/cmdline | grep iommu
结果输出: intel_iommu=on
3.验证VT-D是否启用
dmesg |grep -e DMAR -e IOMMU
- 安装win10虚拟机
qemu-img create -f qcow2 /home/kvm-machines/shaoyan.qcow2 200G
virt-install --name shaoyan --ram 4096 --vcpus=8 --os-type=windows --accelerate --cdrom=/home/kvm_images/win10.iso --disk path=/home/kvm-machines/shaoyan.qcow2,format=qcow2,bus=ide --bridge=br0 --autostart --vnc --vncport=5910 --vnclisten=0.0.0.0
- 宿主机安装软件包
yum -y groups install 'GNOME Desktop' virt-manager virt-viewer dejavu-lgc-sans-fonts
- 显卡加载vfio驱动
1.显卡加载vfio驱动
modprobe vfio
modprobe vfio-pci
2.从服务器卸载1张显卡的4个设备
virsh nodedev-detach pci_0000_b1_00_0
virsh nodedev-detach pci_0000_b1_00_1
virsh nodedev-detach pci_0000_b1_00_2
virsh nodedev-detach pci_0000_b1_00_3
3.验证显卡设备是否加载vfio-pci驱动,加载成功
# lspci -vv -s b1:00.0 | grep driver
Kernel driver in use: vfio-pci
[root@rtx_6000 10.147.100.107 ~ ]
# lspci -vv -s b1:00.1 | grep driver
Kernel driver in use: vfio-pci
[root@rtx_6000 10.147.100.107 ~ ]
# lspci -vv -s b1:00.2 | grep driver
Kernel driver in use: vfio-pci
[root@rtx_6000 10.147.100.107 ~ ]
# lspci -vv -s b1:00.3 | grep driver
Kernel driver in use: vfio-pci
- win10虚拟机添加NVDIA显卡
1.通过远控卡登录服务器透传显卡,执行startx 调出可视化页面
startx
2.添加显卡硬件
3.查看显卡
- 显卡驱动安装
1.要安装显卡驱动,需要修改虚拟机win10的配置文件 否则显卡驱动安装过程中自检会报错ERROR CODE 43,驱动不允许安装在虚拟机上。
#编辑VM XML
virsh edit shaoyan
#修改第一行
<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 shaoyan
virsh start shaoyan
2.附录完整xml 文件如下,如果是拷贝至其他宿主机配置文件的话,只需要保留xml 文件中的第一组hostdev即可,否则会报错
# cat /etc/libvirt/qemu/shaoyan.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh edit shaoyan
or other application using the libvirt API.
-->
<domain type='kvm'>
<name>shaoyan</name>
<uuid>e06c6c3b-0a57-43e8-9d6f-02fd1e2aad83</uuid>
<title>gpu</title>
<description>gpu</description>
<memory unit='KiB'>16777216</memory>
<currentMemory unit='KiB'>16777216</currentMemory>
<vcpu placement='static'>16</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<hyperv>
<relaxed state='on'/>
<vapic state='on'/>
<spinlocks state='on' retries='8191'/>
</hyperv>
</features>
<cpu mode='host-passthrough' check='none'/>
<clock offset='localtime'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
<timer name='hpet' present='no'/>
<timer name='hypervclock' present='yes'/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<pm>
<suspend-to-mem enabled='no'/>
<suspend-to-disk enabled='no'/>
</pm>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/data/kvm/shaoyan.qcow2'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0' model='ich9-ehci1'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x7'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci1'>
<master startport='0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0' multifunction='on'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci2'>
<master startport='2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x1'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci3'>
<master startport='4'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:48:b2:5a'/>
<source bridge='br0'/>
<model type='e1000'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target type='isa-serial' port='0'>
<model name='isa-serial'/>
</target>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='tablet' bus='usb'>
<address type='usb' bus='0' port='1'/>
</input>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='vnc' port='5910' autoport='no' listen='0.0.0.0'>
<listen type='address' address='0.0.0.0'/>
</graphics>
<video>
<model type='vga' vram='16384' heads='1' primary='yes'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0xb1' slot='0x00' function='0x0'/>
</source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</hostdev>
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0xb1' slot='0x00' function='0x1'/>
</source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</hostdev>
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0xb1' slot='0x00' function='0x2'/>
</source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</hostdev>
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0xb1' slot='0x00' function='0x3'/>
</source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
</hostdev>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
</devices>
</domain>
3.登录win10 虚拟机配置网络
4.安装驱动,选择具体型号进行下载并安装驱动
https://www.nvidia.cn/Download/index.aspx?lang=cn
5.查看显卡设备
6.xmanage 软件下载
链接:https://pan.baidu.com/s/1WVN2fqThOpozecoeJtktiQ
提取码:0035
7.安装xmanage 并启动 xmanager.exe
8.服务器修改 /etc/ssh/sshd_config,修改两项
X11Forwarding yes
X11UseLocalhost no
9.启动桌面,10.33.0.214 地址为本地 openvpn 分配的私网地址
export DISPLAY=10.33.0.214:0.0
virt-manager
- 至此,win10通过kvm虚拟化透传GPU 显卡完成!
kvm 透传显卡至win10虚拟机的更多相关文章
- Ubuntu+KVM显卡透传
好久没有更新微博了,最近有点忙,大家见谅啊!今天带来的是我前段时间做的东西,也就是在 Ubuntu下做KVM虚拟机显科透传.(最近人有点懒,其实有几次是有时间更新的,但是就是懒得动,唉!得保持清醒不能 ...
- KVM嵌套虚拟化nested之CPU透传
嵌套式虚拟nested是一个可通过内核参数来启用的功能.它能够使一台虚拟机具有物理机CPU特性,支持vmx或者svm(AMD)硬件虚拟化.该特性需要内核升级到Linux 3.X版本 ,所以在cento ...
- 自动化kolla-ansible部署openstack+GPU透传方法
自动化kolla-ansible部署openstack+GPU透传方法 欢迎加QQ群:1026880196 进行交流学习 1. CentOS7.x-8.x系列为虚拟机配置GPU直通 1. 编辑文件vi ...
- openstack PCI透传(GPU)
描述 kolla-ansible部署openstack的GPU透传方法 一.gpu物理服务器配置 在gpu服务器上主启用IOMMU 确认内核⽀支持iommu $ cat /proc/cmdline | ...
- centos7 && centos6.5部KVM使用NAT联网并为虚拟机配置firewalld && iptables防火墙端口转发
centos7 && centos6.5 部KVM使用NAT联网并为虚拟机配置firewalld && iptables防火墙端口转发 一.准备工作: 1: 检查kvm ...
- kvm介绍、安装及创建虚拟机
kvm虚拟化介绍 一.虚拟化分类 1.虚拟化,是指通过虚拟化技术将一台计算机虚拟为多台逻辑计算机.在一台计算机上同时运行多个逻辑计算机,每个逻辑计算机可运行不同的操作系统,并且应用程序都可以在相互独立 ...
- 1、利用蓝牙定位及姿态识别实现一个智能篮球场套件(一)——用重写CC2541透传模块做成智能手环
一.预言 要实现一个智能篮球场套件,需要设计一个佩戴在篮球运动员手臂上的可以检测投篮.记步的手环,以及一套可以根据RSSI定位运动员的蓝牙定位装置.下面是大致需要的步骤: 首先,需要用CC2541透传 ...
- KVM虚拟化技术(七)虚拟机配置文件
KVM虚拟机的配置文件在/etc/libvirt/qemu/下,为xml文件 整体结构如下: <domain type='kvm'> 虚拟机整体信息 系统信息 硬件资源特性 突发事件处理 ...
- 个推+DCLOUD,推送消息和透传消息
DCLOUD方案中集成了个推方案,最好是用个推来做推送相关的东西 消息分2类: 1.推送消息,这种一般会出现在手机的最上面的通知栏,用户是肯定会知道的 2.透传消息,这种一般就是一个Alert提示框, ...
- APP消息推送:通知和透传
目前市场上的消息推送方式有两种:通知和透传.什么是透传?透传即是透明传送,即传送网络无论传输业务如何,只负责将需要传送的业务传送到目的节点,同时保证传输的质量即可,而不对传输的业务进行处理.透传消息, ...
随机推荐
- [python] CairoSVG使用教程
1 CairoSVG介绍 代码下载地址 CairoSVG是一个将SVG1.1转为PNG,PDF, PS格式的转化.SVG算目前火热的图像文件格式了,它的英文全称为Scalable Vector Gra ...
- [常用工具] dlib编译调用指南
dlib是一个C++工具包(dLIB中也有Python接口,但是主要编程语言为C++),包含绝大多数常用的机器学习算法,许多图像处理算法和深度学习算法,被工业界和学术界广泛应用于机器人.嵌入式设备.移 ...
- Nodejs后端自动化测试
偶然看到收藏一下 const puppeteer = require('puppeteer'); const fs = require('fs'); (async () => { const b ...
- angular Ionic CLI环境搭建安装以及栅格响应式布局
- java 进阶P-6.2+P-6.3
细胞自动机 CellularAutomation(细胞自动机)细胞自动机(英语:Cellular automaton),又称格状自动机.元胞自动机,是一种离散模型,在可算性理论.数学及理论生物学都有相 ...
- .NET 中的并发编程
今天我们购买的每台电脑都有一个多核心的 CPU,允许它并行执行多个指令.操作系统通过将进程调度到不同的内核来发挥这个结构的优点.然而,还可以通过异步 I/O 操作和并行处理来帮助我们提高单个应用程序的 ...
- ubuntu20.04安装systemback
sudo add-apt-repository --remove ppa:nemh/systemback sudo apt-key adv --keyserver keyserver.ubuntu.c ...
- cv::Mat::step详解
1.简介 step的几个类别区分: step:矩阵第一行元素的字节数 step[0]:矩阵第一行元素的字节数 step[1]:矩阵中一个元素的字节数 step1(0):矩阵中一行有几个通道数 step ...
- G - 逆序对的数量
G - 逆序对的数量 原题链接 什么是逆序对? 简单来说,两个数比较,下标小的数反而大,两个数称之为逆序对如\({3,1}\)就是这么一个逆序对 归并排序 由于逆序对逆序的性质,我们可以联想到排序: ...
- 《爆肝整理》保姆级系列教程-玩转Charles抓包神器教程(7)-Charles苹果手机手机抓包知否知否?
1.简介 Charles和Fiddler一样不但能截获各种浏览器发出的 HTTP 请求,也可以截获各种智能手机发出的HTTP/ HTTPS 请求. Charles也能截获iOS设备发出的请求,比如 i ...