joeknock90 / Single-GPU-Passthrough

1.48k stars 75 forks source link

I'm trying to setup GPU passthrough and I'm running into this error: "error: Failed to create file '/var/lib/libvirt/qemu/nvram/win10_VARS.fd': Input/output error" #8

Closed Sol33t303 closed 5 years ago

Sol33t303 commented 5 years ago

When I try to start the VM remotely from my laptop via SSH I get the error in the title. I am using a GTX 1080ti + a Ryzen 2700x (the CPU doesn't have a GPU, thus the guide I'm using). The only part where I have deviated from the guide is I have modified the scripts lightly, so instead of using systemctl to stop my DM, it uses rc-service because I'm on a distro using OpenRC (Gentoo). I didn't touch the rest of the script.

Interestingly, when I try only stopping my DM and unloading the nvidia driver manually (not doing the rest of the script), I can get to the point where the tianocore logo shows up, but it then freezes.

Here is the VMs xml file https://pastebin.com/p7i3VL57

start.sh:

#!/bin/bash

# Stop display manager
rc-service xdm stop

# Unbind VTconsoles
echo 0 > /sys/class/vtconsole/vtcon0/bind
echo 0 > /sys/class/vtconsole/vtcon1/bind

# Unbind EFI-Framebuffer
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind

# Unbind the GPU from display driver
virsh nodedev-detach pci_0000_01_00_0
virsh nodedev-detach pci_0000_01_00_1

# Load VFIO Kernel Module
modprobe vfio-pci

sleep 1

revert.sh:

#!/bin/bash

# Unload VFIO-PCI Kernel Driver
modprobe -r vfio-pci
modprobe -r vfio_iommu_type1
modprobe -r vfio

# Re-Bind GPU to Nvidia Driver
virsh nodedev-reattach pci_0000_01_00_1
virsh nodedev-reattach pci_0000_01_00_0

echo 1 > /sys/class/vtconsole/vtcon0/bind
nvidia-xconfig --query-gpu-info > /dev/null 2>&1
echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind

# Restart Display Manager
rc-service xdm start
joeknock90 commented 5 years ago

Awesome. If I weren't passing out on my couch as I type this I would start working on it now. I'll try to replicate this tomorrow. I am not terribly familiar with Gentoo but I've been meaning to be.

joeknock90 commented 5 years ago

Does the error happen if you just boot the VM without passing a card through?

Sol33t303 commented 5 years ago

Does the error happen if you just boot the VM without passing a card through?

Yeah, works fine if I move the scripts into my home directory and use virt-manager to stop the GPU from being passed through. EDIT: Sorry, I mean no, the error doesn't show up, and the VM works fine. Sorry I'm a bit tired right now :)

joeknock90 commented 5 years ago

I gotcha. Ok, so on reddit you said that you got the error to go away but you're getting a black screen now?

Sol33t303 commented 5 years ago

Well it's not really a black screen, more like I'm just not getting any output from my GPU at all after starting the VM. After starting the VM I tried connecting to it over VNC, but all it says is this "Guest has not initialised thedisplay (yet)"

And here is the contents of the log for the VM:

2019-04-18 21:22:34.421+0000: starting up libvirt version: 4.9.0, qemu version: 3.1.0, kernel: 4.19.27-gentoo-r1, hostname: Altair
LC_ALL=C PATH=/bin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/lib/llvm/7/bin:/usr/lib/llvm/6/bin:/opt/bin:/usr/lib64/opencascade-7.3.0/ros/bin:/opt/cuda/bin:/opt/cuda/libnvvp HOME=/root USER=root QEMU_AUDIO_DRV=none /usr/bin/qemu-system-x86_64 -name guest=win10,debug-threads=on -S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-1-win10/master-key.aes -machine pc-q35-3.1,accel=kvm,usb=off,vmport=off,dump-guest-core=off -cpu EPYC-IBPB,x2apic=on,tsc-deadline=on,hypervisor=on,tsc_adjust=on,cmp_legacy=on,perfctr_core=on,virt-ssbd=on,monitor=off,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff,kvm=off -drive file=/usr/share/OVMF/OVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on -drive file=/var/lib/libvirt/qemu/nvram/win10_VARS.fd,if=pflash,format=raw,unit=1 -m 16384 -realtime mlock=off -smp 8,sockets=8,cores=1,threads=1 -uuid 034680e7-7cd2-4449-bd25-ddfa2de187db -no-user-config -nodefaults -chardev socket,id=charmonitor,fd=21,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime,driftfix=slew -global kvm-pit.lost_tick_policy=delay -no-hpet -no-shutdown -global ICH9-LPC.disable_s3=1 -global ICH9-LPC.disable_s4=1 -boot menu=on,strict=on -device pcie-root-port,port=0x10,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 -device pcie-root-port,port=0x11,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 -device pcie-root-port,port=0x12,chassis=3,id=pci.3,bus=pcie.0,addr=0x2.0x2 -device pcie-root-port,port=0x13,chassis=4,id=pci.4,bus=pcie.0,addr=0x2.0x3 -device pcie-root-port,port=0x14,chassis=5,id=pci.5,bus=pcie.0,addr=0x2.0x4 -device pcie-root-port,port=0x15,chassis=6,id=pci.6,bus=pcie.0,addr=0x2.0x5 -device qemu-xhci,p2=15,p3=15,id=usb,bus=pci.2,addr=0x0 -drive file=/var/lib/libvirt/images/win10.qcow2,format=qcow2,if=none,id=drive-virtio-disk0 -device virtio-blk-pci,scsi=off,bus=pci.3,addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=2 -drive file=/home/sol33t303/Downloads/Win10_1809Oct_v2_English_x64.iso,format=raw,if=none,id=drive-sata0-0-1,media=cdrom,readonly=on -device ide-cd,bus=ide.1,drive=drive-sata0-0-1,id=sata0-0-1,bootindex=1 -drive file=/usr/share/drivers/windows/virtio-win-0.1.160.iso,format=raw,if=none,id=drive-sata0-0-2,media=cdrom,readonly=on -device ide-cd,bus=ide.2,drive=drive-sata0-0-2,id=sata0-0-2 -netdev tap,fd=23,id=hostnet0,vhost=on,vhostfd=24 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:e3:09:28,bus=pci.1,addr=0x0 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0,bus=usb.0,port=1 -spice port=5901,addr=127.0.0.1,disable-ticketing,image-compression=off,seamless-migration=on -vnc 0.0.0.0:0 -k en-us -device VGA,id=video0,vgamem_mb=16,bus=pcie.0,addr=0x1 -device ich9-intel-hda,id=sound0,bus=pcie.0,addr=0x1b -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -chardev spicevmc,id=charredir0,name=usbredir -device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=2 -chardev spicevmc,id=charredir1,name=usbredir -device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=3 -device vfio-pci,host=08:00.0,id=hostdev0,bus=pci.5,addr=0x0,romfile=/var/lib/libvirt/vbios/1080ti-patched.rom -device vfio-pci,host=08:00.1,id=hostdev1,bus=pci.6,addr=0x0 -device virtio-balloon-pci,id=balloon0,bus=pci.4,addr=0x0 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny -msg timestamp=on
char device redirected to /dev/pts/0 (label charserial0)

I can't see any issues in the log, so I have no idea what the issue is.

Sol33t303 commented 5 years ago

I fixed it! I pretty much just created a whole new VM and did the process again, I still didn't get output from the GPU, but no I was at least able to connect to the VM from my laptop and I was able to interact with it. The GPU was being passthroughed fine, but I had to install drivers, then after that, it was able to show the tianocore logo but would stop there. I connected to it remotely again and found out that I was getting error code 43, then after adding the stuff from here to my VMs XML file, it seems like everything is working :)