I’m trying to passthrough GTX 1080 to instance (virtual machine) under KVM (qemu).
My command line (for qemu) is:
/usr/bin/qemu-system-x86_64 -name test -S -machine pc-i440fx-trusty,accel=kvm,usb=off -cpu host -m 1024 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid a86d92f8-53e4-4014-b9e2-b6170a52d608 -smbios type=1,serial=4c4c4544-0058-3410-8057-c6c04f573032,uuid=a86d92f8-53e4-4014-b9e2-b6170a52d608 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/a86d92f8-53e4-4014-b9e2-b6170a52d608.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-hpet -no-shutdown -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/nova/instances/a86d92f8-53e4-4014-b9e2-b6170a52d608/disk,if=none,id=drive-virtio-disk0,format=raw,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=24,id=hostnet0,vhost=on,vhostfd=25 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=fa:16:3e:85:43:44,bus=pci.0,addr=0x3 -chardev file,id=charserial0,path=/var/lib/nova/instances/a86d92f8-53e4-4014-b9e2-b6170a52d608/console.log -device isa-serial,chardev=charserial0,id=serial0 -chardev pty,id=charserial1 -device isa-serial,chardev=charserial1,id=serial1 -device usb-tablet,id=input0 -k en-us -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device pci-assign,configfd=26,host=42:00.0,id=hostdev0,bus=pci.0,addr=0x5 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
Device visible on host:
42:00.0 VGA compatible controller: NVIDIA Corporation Device 1b80 (rev a1) (prog-if 00 [VGA controller])
Subsystem: NVIDIA Corporation Device 119e
Flags: bus master, fast devsel, latency 0, IRQ 72
Memory at d4000000 (32-bit, non-prefetchable)
Memory at 3bff0000000 (64-bit, prefetchable)
Memory at 3bfee000000 (64-bit, prefetchable)
I/O ports at d000
Expansion ROM at d5000000 [disabled]
Capabilities: [60] Power Management version 3
Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
Capabilities: [78] Express Legacy Endpoint, MSI 00
Capabilities: [100] Virtual Channel
Capabilities: [250] Latency Tolerance Reporting
Capabilities: [128] Power Budgeting <?>
Capabilities: [420] Advanced Error Reporting
Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
Capabilities: [900] #19
Kernel driver in use: pci-stub
I can see device inside virtual machine:
00:05.0 VGA compatible controller: NVIDIA Corporation Device 1b80 (rev a1)
and I can install/compile driver (tried both 367.35 & 370.23, .run blobs from nvidia.com). They install, but not recognized by nvidia-smi:
nvidia-smi
Unable to determine the device handle for GPU 0000:00:05.0: Unknown Error
dmesg shows:
[ 1093.280138] nvidia 0000:00:05.0: irq 45 for MSI/MSI-X
[ 1093.303496] NVRM: RmInitAdapter failed! (0x23:0x56:451)
[ 1093.303503] NVRM: rm_init_adapter failed for device bearing minor number 0
[ 1093.304132] nvidia 0000:00:05.0: irq 45 for MSI/MSI-X
[ 1093.335032] NVRM: RmInitAdapter failed! (0x23:0x56:451)
[ 1093.335037] NVRM: rm_init_adapter failed for device bearing minor number 0
nouveau blacklisted, nvidia & nvidia-uvm loaded:
lsmod |egrep ‘nvidia|nou’
nvidia_uvm 710792 0
nvidia_drm 14707 0
nvidia_modeset 773069 1 nvidia_drm
nvidia 11908960 2 nvidia_modeset,nvidia_uvm
drm 303102 3 ttm,drm_kms_helper,nvidia_drm
guest cmdline: BOOT_IMAGE=/boot/vmlinuz-3.13.0-93-generic root=LABEL=cloudimg-rootfs ro nofb nomodeset vga=normal console=tty0 console=ttyS0,115200 no_timer_check nofb nomodeset vga=normal
host cmdline:
initrd=initrd.gz intel_iommu=on boot=live config nosplash nopersistent noprompt noautologin quickreboot BOOT_IMAGE=vmlinuz (some pxe options omitted).
I’ve tried it on Ubuntu 16.04 (linux 4.6) and ubuntu 14.04 (linux 3.13) - same behavior.
Any idea how to configure qemu/libvirt?