目录

Libvirt

Tips

IDV显卡回挂

  1. 以下步骤在 ubuntu 18.04 环境。查看系统内核版本(内核版本很重要)
    root@Default:~# uname -a
    Linux troila-Default-string 5.3.0-53-generic #47~18.04.1-Ubuntu SMP Thu May 7 13:10:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  2. 查看显卡设备
    root@troila-Default-string:~# lspci
    00:02.0 VGA compatible controller: Intel Corporation Skylake GT2 [HD Graphics 520] (rev 07)
  3. 查看显卡的vid,pid
    root@Default:~# lspci -n
    00:02.0 0300: 8086:1916 (rev 07)
  4. 挂载显卡
    systemctl restart getty@tty1.service   #停止gdm
    sleep 1
    echo "8086 1916" > /sys/bus/pci/drivers/vfio-pci/new_id    #创建虚拟机所用驱动id
    echo "0000:00:02.0" > /sys/bus/pci/devices/0000\:00\:02.0/driver/unbind  #解绑i915驱动与显卡设备
    echo "0000:00:02.0" > /sys/bus/pci/drivers/vfio-pci/bind     #绑定vfio驱动到显卡
    echo "8086 1916" > /sys/bus/pci/drivers/vfio-pci/remove_id   #移动id

    注:执行后,依赖gnome的进程(包括隐藏窗口的进程)都会变成僵尸进程

  5. 显卡回挂
    echo -n "0000:00:02.0" > /sys/bus/pci/devices/0000\:00\:02.0/driver/unbind   #解绑vfio与显卡设备
    echo -n "0000:00:02.0" > /sys/bus/pci/drivers/i915/bind     #i915驱动绑定到显卡上
    systemctl restart display-manager   #重启gdm