Blank screen when viewing GL-accelerated virtio screen on 22.04

Bug #1972075 reported by Max Goodhart
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libvirt (Ubuntu)
Fix Released
High
Christian Ehrhardt 
Jammy
Fix Released
Medium
Christian Ehrhardt 
Kinetic
Fix Released
High
Christian Ehrhardt 

Bug Description

[Impact]

 * New GL handling code in qemu/libs triggers apparmor denials in
   Jammy and later

  * Libvirt already has code that does context aware "if gl is
    enabled then allow things". The patch extends those by the
    new paths it needs to access.

[Test Plan]

 * In your preferred way get a guest of your choice that has UI support,
   for example Ubuntu Desktop

 * Set virtio graphics and Enable GL acceleration.
   Essentially this comes down to those elements:
   <video>
     <model type='virtio'/>
     <driver name='qemu'/>
   </video>
   <graphics type='spice'>
     <listen type='socket'/>
     <gl enable='yes'/>
   </graphics)
   There are various similar equally valid variants that you
   can configure this.
   You can do the same via the virt-manager Ui if you prefer that.

Without the fix that will trigger apparmor denials and not show the Display correctly.

[Where problems could occur]

 * This is just "allowing more" to be read out of the apparmor isolation,
   therefore I'd hope that regressions are not happening. The scenarios I
   could think of are:
   1. a user of Jammy set this up, wasn't really using GL and after the
      fix suddenly gets unexpected UI output (unlikely, and not really a
      problem)
   2. The paths would be considered unsafe to be read by the guest and
      thereby be a problem (that is not the case as far as we know so far)
   3. There might be a missed issue in the changed code, breaking
      virt-aa-helper (the nature of the change makes this unlikely, it
      isn't too complex) and that would stop starting new guests.
      They'd fail with an apparmor related message then.

None of the above seems realistic or critical to me, I think we are safe with this change.

[Other Info]

 * n/a

--- original bug ---

Also filed upstream:
https://gitlab.com/libvirt/libvirt/-/merge_requests/151

I recently upgraded from Ubuntu 21.10 to 22.04. I have an existing VM with virtio video and gl-accelerated Spice display which previously worked.

After the upgrade, virt-manager and virt-viewer display a blank screen. In the qemu libvirt logs, I observe many repetitions of:

qemu_spice_gl_scanout_texture: failed to get fd for texture

dmesg contains these AppArmor errors:

[250001.100362] audit: type=1400 audit(1651958128.696:706): apparmor="DENIED" operation="open" profile="libvirt-98a090a8-2fdf-463c-959b-810e5bc88b0d" name="/sys/devices/pci0000:00/0000:00:02.0/revision" pid=132725 comm="qemu-system-x86" requested_mask="r" denied_mask="r" fsuid=64055 ouid=0
[250001.100367] audit: type=1400 audit(1651958128.696:707): apparmor="DENIED" operation="open" profile="libvirt-98a090a8-2fdf-463c-959b-810e5bc88b0d" name="/sys/devices/pci0000:00/0000:00:02.0/config" pid=132725 comm="qemu-system-x86" requested_mask="r" denied_mask="r" fsuid=64055 ouid=0

Modifying the AppArmor config for this VM to permit access to the `revision` and `config` sysfs paths fixed this issue for me. The VM display is visible and virgl is working. I was able to do so by adding the following line:

  "/sys/devices/**/{uevent,vendor,device,subsystem_vendor,subsystem_device,config,revision}" r,

Related branches

description: updated
description: updated
description: updated
tags: added: desktop-lts-wishlist rls-jj-incoming
Revision history for this message
Sebastien Bacher (seb128) wrote :

The Desktop team would like to see that one considered as high and see a SRU to 22.04 if possible once we have a fix available

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Interesting. I did a quick search here and found many reports of other people having this problem (or at least something very similar) in other distros. Eventually they all led to https://gitlab.gnome.org/GNOME/gnome-boxes/-/issues/586.

Either way, I agree that seeing these apparmor denials is not good and we should do something about them.

I'm subscribing the Server team so that we can take a better look into this problem.

Thanks.

tags: added: server-todo
Changed in libvirt (Ubuntu):
importance: Undecided → High
Changed in libvirt (Ubuntu Kinetic):
status: New → Triaged
Revision history for this message
Max Goodhart (chromakode) wrote :

I have submitted the patch upstream to the libvirt mailing list. I don't feel qualified to assert that giving the VM read access to those sysfs files is the right fix, but it did resolve the issue for me.

I noticed that GNOME-Boxes bug too while troubleshooting this. I did not try the egl-headless suggestion at the end of the thread, but did attempt to set the env var "MESA_LOADER_DRIVER_OVERRIDE=i965", which still resulted in a blank display for me.

It is unclear to me whether the "qemu_spice_gl_scanout_texture: failed to get fd for texture" message is specific to this issue, or if it would occur in a broad class of errors where the graphics fails to initialize.

In my case, this is running on an i7-1165G7 Framework laptop with Mesa Intel(R) Xe Graphics (TGL GT2) (0x9a49).

Revision history for this message
Paride Legovini (paride) wrote :

Hello Max, this is your upstream submission, correct?

https://listman.redhat.com/archives/libvir-list/2022-May/231286.html

Revision history for this message
Max Goodhart (chromakode) wrote :

Yes, that is my upstream submission.

Changed in libvirt (Ubuntu Jammy):
status: New → Triaged
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Thanks Max, reviewed and approved upstream.
If there are no objections e.g. to the change of Author then I can merge it there and start fix uploads for affected Ubuntu releases.

Changed in libvirt (Ubuntu Jammy):
assignee: nobody → Christian Ehrhardt  (paelzer)
Changed in libvirt (Ubuntu Kinetic):
assignee: nobody → Christian Ehrhardt  (paelzer)
Changed in libvirt (Ubuntu Jammy):
importance: Undecided → Medium
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Based on the to-be-committed patch upstream I have prepared these Ubuntu uploads and test PPA.

I'd be happy about review and feedback on those.

Kinetic: https://code.launchpad.net/~paelzer/ubuntu/+source/libvirt/+git/libvirt/+merge/422941
Jammy: https://code.launchpad.net/~paelzer/ubuntu/+source/libvirt/+git/libvirt/+merge/422942
PPA: https://launchpad.net/~paelzer/+archive/ubuntu/lp-1972075-libvirt-gl

description: updated
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I merged the change upstream.
Waiting for a review, but that is happening soon.

Max: Before we upload, could you give the PPA a try if it resolves things in your setup as well (it should as it is your change, but why not trying to be sure).

Revision history for this message
Max Goodhart (chromakode) wrote :

Pleased to report that the PPA packages (version 8.0.0-1ubuntu7.1~jammyppa1) resolve the issue for me.

I verified by downgrading to 8.0.0-1ubuntu7, reproducing the blank screen. Then I upgraded to 8.0.0-1ubuntu7.1~jammyppa1, and the VM display works again. Thanks Christian!

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Thanks for the test Max.
Thanks for the review Sergio.

Uploaded for Kinetic, will start the Jammy SRU once it is fully completed there.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libvirt - 8.0.0-1ubuntu8

---------------
libvirt (8.0.0-1ubuntu8) kinetic; urgency=medium

  * d/p/u/lp-1972075-Allow-VM-to-read-sysfs-PCI-config-revision-files.patch:
    apparmor allow new paths used for GL accelerated video (LP: #1972075)

 -- Christian Ehrhardt <email address hidden> Thu, 19 May 2022 08:14:48 +0200

Changed in libvirt (Ubuntu Kinetic):
status: Triaged → Fix Released
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Completed in Kinetic, uploaded for Jammy now - waiting on the SRU teams review to accept it.

Revision history for this message
Robie Basak (racb) wrote : Please test proposed package

Hello Max, or anyone else affected,

Accepted libvirt into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/libvirt/8.0.0-1ubuntu7.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in libvirt (Ubuntu Jammy):
status: Triaged → Fix Committed
tags: added: verification-needed verification-needed-jammy
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

@Max - it is always best to do this in the original reported environment - do you think you could do that verification (just like you did with the PPA)?

Revision history for this message
Max Goodhart (chromakode) wrote :

Hi Christian and Robie, apologies for the delay. I have confirmed that the jammy-proposed version 8.0.0-1ubuntu7.1 of libvirt packages fixes this issue for me.

Similar to the PPA packages, I tested using the original VM with which I ran into this bug. I confirmed that video was not working with the jammy 8.0.0-1ubuntu7 packages installed. Then I upgraded to 8.0.0-1ubuntu7.1 and re-launched the VM, and video output worked as expected. Finally, I downgraded back to 8.0.0-1ubuntu7 and reproduced the original bug.

tags: added: verification-done-jammy
removed: verification-needed verification-needed-jammy
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Perfect, thank you Max!

tags: added: verification-done
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for libvirt has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libvirt - 8.0.0-1ubuntu7.1

---------------
libvirt (8.0.0-1ubuntu7.1) jammy; urgency=medium

  * d/p/u/lp-1972075-Allow-VM-to-read-sysfs-PCI-config-revision-files.patch:
    apparmor allow new paths used for GL accelerated video (LP: #1972075)

 -- Christian Ehrhardt <email address hidden> Thu, 19 May 2022 08:14:48 +0200

Changed in libvirt (Ubuntu Jammy):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.