Bug 1540181

Summary: Libvirt: disallow virtio-gpu to boot with vIOMMU
Product: Red Hat Enterprise Linux 7 Reporter: Peter Xu <peterx>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED WONTFIX QA Contact: Fangge Jin <fjin>
Severity: medium Docs Contact:
Priority: low    
Version: 7.5CC: chayang, dyuan, fjin, jdenemar, jishao, juzhang, knoel, kraxel, michen, peterx, pezhang, pkrempa, qzhang, rbalakri, virt-maint, xuzhang, yafu, zpeng
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: 1531543
: 1540182 (view as bug list) Environment:
Last Closed: 2018-01-31 07:55:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Comment 2 Peter Krempa 2018-01-30 13:24:28 UTC
The qemu BZ describes it as a bug in qemu which may eventually be properly fixed, so this is only a workaround.

If it's so I don't think we want to fix this in libvirt. This creates problems once qemu manages to fix it since it's usually hard to detect when such configuration is valid now.

In such case, qemu should reject it until fixed. Or we need a strong guarantee that qemu will add a witness which will be enabled once the bug is fixed so we can lift this restriction.

Given that this is a corner case, I think we should be fine with qemu refusing to start.

Comment 3 Peter Xu 2018-01-31 03:08:55 UTC
(In reply to Peter Krempa from comment #2)
> The qemu BZ describes it as a bug in qemu which may eventually be properly
> fixed, so this is only a workaround.
> 
> If it's so I don't think we want to fix this in libvirt. This creates
> problems once qemu manages to fix it since it's usually hard to detect when
> such configuration is valid now.
> 
> In such case, qemu should reject it until fixed. Or we need a strong
> guarantee that qemu will add a witness which will be enabled once the bug is
> fixed so we can lift this restriction.
> 
> Given that this is a corner case, I think we should be fine with qemu
> refusing to start.

It's okay to me, but for both video and libvirt I'm not familiar enough to say a solid word.  Gerd, would you help confirm?

Thanks,
PeterX

Comment 4 Gerd Hoffmann 2018-01-31 07:29:36 UTC
> It's okay to me, but for both video and libvirt I'm not familiar enough to
> say a solid word.  Gerd, would you help confirm?

Throw an error in realize should be easy, and given that there is no easy for libvirt to detect whenever a device supports iommu or not failing with a clear message in the logs (which I think will also be shown by "virt start") is a reasonable approach to the issue.

I guess only pci devices (not virtio-mmio) can have a iommu attached, correct?  Then we need a check for both virtio-gpu-pci and virtio-vga devices.  Do you want come up with a patch?  If not I can give it a try, but I need some hints how a pci device can figure whenever it has a iommu attached to it or not.

Comment 5 Peter Xu 2018-01-31 07:50:58 UTC
(In reply to Gerd Hoffmann from comment #4)
> > It's okay to me, but for both video and libvirt I'm not familiar enough to
> > say a solid word.  Gerd, would you help confirm?
> 
> Throw an error in realize should be easy, and given that there is no easy
> for libvirt to detect whenever a device supports iommu or not failing with a
> clear message in the logs (which I think will also be shown by "virt start")
> is a reasonable approach to the issue.
> 
> I guess only pci devices (not virtio-mmio) can have a iommu attached,
> correct?  Then we need a check for both virtio-gpu-pci and virtio-vga
> devices.  Do you want come up with a patch?  If not I can give it a try, but
> I need some hints how a pci device can figure whenever it has a iommu
> attached to it or not.

Yeah, I posted one already for upstream QEMU (with you CCed).  Please have a look:

  [PATCH] virtio-gpu: disallow vIOMMU

Regarding to the virtio-mmio question - I am not sure about it.  IIUC that's used mostly in ARM, and I'm not sure whether ARM can declare a MMIO device under vIOMMU/vSMMU protection.  My above patch only fixes virtio-gpu-pci and virtio-vga. 

Then I'm fine to close current bug, and we can continue the discussion upstream, or in the other QEMU bug tracker.

Thanks,
Peter