Skip to contentSkip to conversation

vfio issue in qemu 2.5

DISCUSSION Goutham GS 2 participants 6 messages Feb 4, 2016 – Feb 5, 2016 KVM

lore
Share & tools
lore

Goutham GS

author
#0 lore raw

Hi All,

We are facing a vfio issue on qemu 2.5. Really appreciate any help or pointers. Details are as below:

We are using qemu 2.5 compiled out of git commit 0b0571dd246871f18b7d64b5279511e91e2a7bf6 and are using Linux Kernel 3.18.19 for both host and the VM. We are also using KVM VM with pci-assign'ed SRIOV VF interfaces.

The issue happens once in a while when a running VM is rebooted. On boot, the VM hits the following error and stops.

qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: vfio: failed to set iommu for container: Bad address
qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: vfio: failed to setup container for group 40
qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: vfio: failed to get group 40
qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: Device initialization failed

Strange thing is, once this error is hit, no further VMs can be spawned on the host and all of them run into the same problem. However a reboot of the host appears to solve the issue.

I have attached the relevant logs.

Regards,
Goutham.

#1 lore raw
Quoted 26 lines · On Thu, 4 Feb 2016 20:31:17 +0530 "Goutham GS" <[email protected]>…

Hi All,

We are facing a vfio issue on qemu 2.5. Really appreciate any help or pointers. Details are as below:

We are using qemu 2.5 compiled out of git commit 0b0571dd246871f18b7d64b5279511e91e2a7bf6 and are using Linux Kernel 3.18.19 for both host and the VM. We are also using KVM VM with pci-assign'ed SRIOV VF interfaces.

The issue happens once in a while when a running VM is rebooted. On boot, the VM hits the following error and stops.

qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: vfio: failed to set iommu for container: Bad address
qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: vfio: failed to setup container for group 40
qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: vfio: failed to get group 40
qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: Device initialization failed

Quoted 5 lines

Strange thing is, once this error is hit, no further VMs can be spawned on the host and all of them run into the same problem. However a reboot of the host appears to solve the issue.

I have attached the relevant logs.

Is it possible to try a newer kernel on the host? "Bad address" is -EFAULT, but I'm not actually able to spot a return path for the VFIO_SET_IOMMU ioctl that returns -EFAULT. Is there anything in dmesg when this triggers? Thanks,

Alex

author
#2 lore raw

Hello Alex,

Thanks for your quick response.

Unfortunately we are tied to this kernel. Probably we can move to 3.19, if we are sure of the benefits . Not sure.

Regarding dmesg, there is nothing on the host and the VM never came up to the point where we could collect dmesg.

Regards,
Goutham.

-----Original Message-----
From: Alex Williamson [mailto:[email protected]]
Sent: Thursday, February 4, 2016 10:32 PM
To: Goutham GS <[email protected]>
Cc: [email protected]
Subject: Re: vfio issue in qemu 2.5

Quoted 26 lines · On Thu, 4 Feb 2016 20:31:17 +0530 "Goutham GS" <[email protected]>…

Hi All,

We are facing a vfio issue on qemu 2.5. Really appreciate any help or pointers. Details are as below:

We are using qemu 2.5 compiled out of git commit 0b0571dd246871f18b7d64b5279511e91e2a7bf6 and are using Linux Kernel 3.18.19 for both host and the VM. We are also using KVM VM with pci-assign'ed SRIOV VF interfaces.

The issue happens once in a while when a running VM is rebooted. On boot, the VM hits the following error and stops.

qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: vfio: failed to set iommu for container: Bad address
qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: vfio: failed to setup container for group 40
qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: vfio: failed to get group 40
qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: Device initialization failed

Quoted 5 lines

Strange thing is, once this error is hit, no further VMs can be spawned on the host and all of them run into the same problem. However a reboot of the host appears to solve the issue.

I have attached the relevant logs.

Is it possible to try a newer kernel on the host? "Bad address" is -EFAULT, but I'm not actually able to spot a return path for the VFIO_SET_IOMMU ioctl that returns -EFAULT. Is there anything in dmesg when this triggers? Thanks,

Alex

author
#3 lore raw

Hello Alex,

Sorry, I got the timestamps wrong yesterday.

I see the following messages in kern.log at the time of the issue:

Jan 31 03:46:39 qa2-sn2 kernel: [228419.858857] vfio-pci 0000:04:01.4:
enabling device (0000 -> 0002)
Jan 31 03:46:39 qa2-sn2 kernel: [228419.970492] vfio-pci 0000:04:02.7:
enabling device (0000 -> 0002)
Jan 31 03:46:39 qa2-sn2 kernel: [228420.082435] IOMMU: no free domain ids
Jan 31 03:46:39 qa2-sn2 kernel: [228420.124440] IOMMU: no free domain ids

Does this say anything?

Regards,
Goutham.

-----Original Message-----
From: Goutham GS [mailto:[email protected]]
Sent: Thursday, February 4, 2016 11:53 PM
To: 'Alex Williamson' <[email protected]>
Cc: [email protected]
Subject: RE: vfio issue in qemu 2.5

Hello Alex,

Thanks for your quick response.

Unfortunately we are tied to this kernel. Probably we can move to 3.19, if we are sure of the benefits . Not sure.

Regarding dmesg, there is nothing on the host and the VM never came up to the point where we could collect dmesg.

Regards,
Goutham.

-----Original Message-----
From: Alex Williamson [mailto:[email protected]]
Sent: Thursday, February 4, 2016 10:32 PM
To: Goutham GS <[email protected]>
Cc: [email protected]
Subject: Re: vfio issue in qemu 2.5

Quoted 26 lines · On Thu, 4 Feb 2016 20:31:17 +0530 "Goutham GS" <[email protected]>…

Hi All,

We are facing a vfio issue on qemu 2.5. Really appreciate any help or pointers. Details are as below:

We are using qemu 2.5 compiled out of git commit 0b0571dd246871f18b7d64b5279511e91e2a7bf6 and are using Linux Kernel 3.18.19 for both host and the VM. We are also using KVM VM with pci-assign'ed SRIOV VF interfaces.

The issue happens once in a while when a running VM is rebooted. On boot, the VM hits the following error and stops.

qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: vfio: failed to set iommu for container: Bad address
qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: vfio: failed to setup container for group 40
qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: vfio: failed to get group 40
qemu-system-x86_64: -device vfio-pci,host=04:00.7,id=hostdev2,bus=pci.0,addr=0x9: Device initialization failed

Quoted 5 lines

Strange thing is, once this error is hit, no further VMs can be spawned on the host and all of them run into the same problem. However a reboot of the host appears to solve the issue.

I have attached the relevant logs.

Is it possible to try a newer kernel on the host? "Bad address" is -EFAULT, but I'm not actually able to spot a return path for the VFIO_SET_IOMMU ioctl that returns -EFAULT. Is there anything in dmesg when this triggers? Thanks,

Alex

#4 lore raw
Quoted 11 lines · On Fri, 5 Feb 2016 10:49:23 +0530 "Goutham GS" <[email protected]>…

Hello Alex,

Sorry, I got the timestamps wrong yesterday.

I see the following messages in kern.log at the time of the issue:

Jan 31 03:46:39 qa2-sn2 kernel: [228419.858857] vfio-pci 0000:04:01.4:
enabling device (0000 -> 0002)
Jan 31 03:46:39 qa2-sn2 kernel: [228419.970492] vfio-pci 0000:04:02.7:
enabling device (0000 -> 0002)
Jan 31 03:46:39 qa2-sn2 kernel: [228420.082435] IOMMU: no free domain
Quoted 4 lines

ids Jan 31 03:46:39 qa2-sn2 kernel: [228420.124440] IOMMU: no free domain ids

Does this say anything?

That's kind of a big deal. Kernel v3.17 introduced a domain ID leak that didn't get fully fixed until kernel v4.2. To make matters worse, even though the fixes were tagged for stable, the last one doesn't seem to have been backported to any pre-4.2 stable series. Long story short, you'll need to move to v4.2 or backport this to your kernel:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=46ebb7af7b93792de65e124e1ab8b89a108a41f2

Thanks,
Alex

author
#5 lore raw

Hello Alex,

Thanks a tonne. We will backport the fix.

Regards,
Goutham.

-----Original Message-----
From: Alex Williamson [mailto:[email protected]]
Sent: Friday, February 5, 2016 11:32 AM
To: Goutham GS <[email protected]>
Cc: [email protected]
Subject: Re: vfio issue in qemu 2.5

Quoted 11 lines · On Fri, 5 Feb 2016 10:49:23 +0530 "Goutham GS" <[email protected]>…

Hello Alex,

Sorry, I got the timestamps wrong yesterday.

I see the following messages in kern.log at the time of the issue:

Jan 31 03:46:39 qa2-sn2 kernel: [228419.858857] vfio-pci 0000:04:01.4:
enabling device (0000 -> 0002)
Jan 31 03:46:39 qa2-sn2 kernel: [228419.970492] vfio-pci 0000:04:02.7:
enabling device (0000 -> 0002)
Jan 31 03:46:39 qa2-sn2 kernel: [228420.082435] IOMMU: no free domain 
Quoted 4 lines

ids Jan 31 03:46:39 qa2-sn2 kernel: [228420.124440] IOMMU: no free domain ids

Does this say anything?

That's kind of a big deal. Kernel v3.17 introduced a domain ID leak that didn't get fully fixed until kernel v4.2. To make matters worse, even though the fixes were tagged for stable, the last one doesn't seem to have been backported to any pre-4.2 stable series. Long story short, you'll need to move to v4.2 or backport this to your kernel:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=4
6ebb7af7b93792de65e124e1ab8b89a108a41f2

Thanks,
Alex