Hide Forgot
Description of problem: If we assign a device with VFIO and the IOMMU mappings fail, the initfn still succeeds making it look like the device was fully attached. When this happens the device is only able to DMA to whatever fraction of memory managed to get mapped, so it's still fully isolated, but it likely doesn't work. A better experience would be to fail the initfn. This can be seen if the locked memory limit for the process is set too low, allowing only a portion of memory to be pinned. Version-Release number of selected component (if applicable): How reproducible: Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info:
Fix included in qemu-kvm-1.5.3-45.el7
Reproduced on qemu-kvm-1.5.3-36.el7.x86_64. Steps: 1. start a guest with unprivileged user: $ /usr/libexec/qemu-kvm -M pc -enable-kvm -drive file=/home/win7-32-virtio.qcow2,if=none,id=drive-virtio-disk0,format=qcow2 -device virtio-blk-pci,scsi=off,bus=pci.0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -net none -monitor stdio -spice port=9000,disable-ticketing -vga qxl -global qxl-vga.ram_size=67108864 -global qxl-vga.vram_size=67108864 -boot menu=on -m 256M -smp 2 -device vfio-pci,host=0000:28:01.0,id=vf Actual Result: Guest started successfully even through there were logs as bellow: QEMU 1.5.3 monitor - type 'help' for more information (qemu) qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio_dma_map(0x7f6e35f7cb50, 0x0, 0xa0000, 0x7f6e08000000) = -12 (Cannot allocate memory) qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio_dma_map(0x7f6e35f7cb50, 0xc0000, 0x20000, 0x7f6e07c00000) = -12 (Cannot allocate memory) qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio_dma_map(0x7f6e35f7cb50, 0x100000, 0xff00000, 0x7f6e08100000) = -12 (Cannot allocate memory) qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xc8000, 0x18000, 0x7f6e07c08000) = -12 (Cannot allocate memory) qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xd0000, 0x10000, 0x7f6e07c10000) = -12 (Cannot allocate memory) qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xc0000, 0x18000, 0x7f6e080c0000) = -12 (Cannot allocate memory) qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xc0000, 0x20000, 0x7f6e080c0000) = -12 (Cannot allocate memory) qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xc0000, 0x28000, 0x7f6e080c0000) = -12 (Cannot allocate memory) qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xe8000, 0x18000, 0x7f6e07e08000) = -12 (Cannot allocate memory) qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xc0000, 0x30000, 0x7f6e080c0000) = -12 (Cannot allocate memory) qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xf0000, 0x10000, 0x7f6e07e10000) = -12 (Cannot allocate memory) qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xc0000, 0xff40000, 0x7f6e080c0000) = -12 (Cannot allocate memory) qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xf4000000, 0x4000000, 0x7f6e03a00000) = -12 (Cannot allocate memory) qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xf8000000, 0x4000000, 0x7f6dfe800000) = -12 (Cannot allocate memory) qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xfc000000, 0x10000, 0x7f6dfde00000) = -12 (Cannot allocate memory) Verified on qemu-img-1.5.3-45.el7.x86_64. Guest rejected to start on error: QEMU 1.5.3 monitor - type 'help' for more information (qemu) qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio_dma_map(0x7f6eec1f4700, 0x0, 0xa0000, 0x7f6eb8000000) = -12 (Cannot allocate memory) qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio_dma_map(0x7f6eec1f4700, 0xc0000, 0x20000, 0x7f6ed6c00000) = -12 (Cannot allocate memory) qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio_dma_map(0x7f6eec1f4700, 0x100000, 0xff00000, 0x7f6eb8100000) = -12 (Cannot allocate memory) qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio: memory listener initialization failed for container qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio: failed to setup container for group 22 qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio: failed to get group 22 qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: Device initialization failed. qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: Device 'vfio-pci' could not be initialized As per above, this issue has been fixed.
This request was resolved in Red Hat Enterprise Linux 7.0. Contact your manager or support representative in case you have further questions about the request.