Bug 1791236 - virgl 3d acceleration enabled automatically after enabling egl-headless
Summary: virgl 3d acceleration enabled automatically after enabling egl-headless
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.2
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: 8.0
Assignee: Jonathon Jongsma
QA Contact: yafu
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-01-15 09:52 UTC by Guo, Zhiyi
Modified: 2020-11-17 17:47 UTC (History)
12 users (show)

Fixed In Version: libvirt-6.2.0-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-17 17:46:36 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Guo, Zhiyi 2020-01-15 09:52:17 UTC
Description of problem:
virgl 3d acceleration enabled automatically after enabling egl-headless

Version-Release number of selected component (if applicable):
qemu-kvm-4.2.0-5.module+el8.2.0+5389+367d9739.x86_64
kernel-4.18.0-169.el8.x86_64(host & vm)


How reproducible:
100%

Steps to Reproduce:
1.Try to boot a rhel 8.2 vm with libvirt cli:
...
    <graphics type='spice' port='5900' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
      <image compression='off'/>
    </graphics>
    <graphics type='egl-headless'>
      <gl rendernode='/dev/dri/renderD128'/>
    </graphics>
...
    <video>
      <model type='virtio' heads='1' primary='yes'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
...
2.Check the virgl enablement inside vm
3.

Actual results:
virgl is enabled automatically:
[    8.775521] [drm] virgl 3d acceleration enabled
Check the qemu cli, there is no virgl=on option used:
... -display egl-headless,rendernode=/dev/dri/renderD128 -device virtio-vga,id=video0,max_outputs=1,bus=pcie.0,addr=0x1 -device ...

Expected results:
virgl shouldn't be enabled without virgl=on option

Additional info:
This will result when testing virtio vga + intel vgpu, virtio-vga will always consume some resource from host gpu

Comment 1 Gerd Hoffmann 2020-01-15 10:48:04 UTC
> Expected results:
> virgl shouldn't be enabled without virgl=on option

Why not?  I'd expect people typically expect that virgl gets enabled if possible.
If you don't want it in specific use cases there is the option to explicitly say so using "virgl=off".

Comment 2 Guo, Zhiyi 2020-01-16 02:54:58 UTC
(In reply to Gerd Hoffmann from comment #1)
> > Expected results:
> > virgl shouldn't be enabled without virgl=on option
> 
> Why not?  I'd expect people typically expect that virgl gets enabled if
> possible.
> If you don't want it in specific use cases there is the option to explicitly
> say so using "virgl=off".

Looks like libvirt cannot specify virgl=off, but use egl-headless to controll the ON/OFF of virgl is also weird to me.

Let's look at some user scenarios:

1)users want to enable virgl, in this scenario, they need both egl-headless and "acceleration accel3d='yes'" for virtio-vga:
...
    <graphics type='egl-headless'>
      <gl rendernode='/dev/dri/renderD128'/>
    </graphics>
...
    <video>
      <model type='virtio' heads='1' primary='yes'>
        <acceleration accel3d='yes'/>
      </model>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
...

These two libvirt elements will translate into -display egl-headless,rendernode=/dev/dri/renderD128 -device virtio-vga,id=video0,virgl=on,max_outputs=1,bus=pcie.0,addr=0x1 in qemu cli and virgl is enabled inside VM as expected.

2)user want to use virtio-vga but with virgl disabled, the legacy way is no egl-headless and acceleration accel3d='yes' specified and I have no doubt about this one.

3)user want to use virtio-vga but with virgl disabled, they add egl-headless in their xml but they don't need the 3d capability for now(maybe multiple VMs are enabled on a server and only some people require to work with 3d content and they don't want other people to share host graphic resource). In this case, they can use:

a)
...
    <graphics type='egl-headless'>
      <gl rendernode='/dev/dri/renderD128'/>
    </graphics>
...
    <video>
      <model type='virtio' heads='1' primary='yes'>
        <acceleration accel3d='no'/>
      </model>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
...

b)
...
    <graphics type='egl-headless'>
      <gl rendernode='/dev/dri/renderD128'/>
    </graphics>
...
    <video>
      <model type='virtio' heads='1' primary='yes'>
      </model>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
...

Whatever a) or b), they will all translate into -display egl-headless,rendernode=/dev/dri/renderD128 -device virtio-vga,id=video0,max_outputs=1,bus=pcie.0,addr=0x1 in qemu cli
From the meaning of the libvirt xml and qemu cli, these seems point to virgl is OFF. However, virgl is ON inside VM!!

4) in scenario virtio-vga(primary) + intel vgpu(secondary), users only want to use virtio-vga for boot messages and use intel vgpu for their desktop.

...
    <video>
      <model type='virtio' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
...
    <graphics type='egl-headless'>
      <gl rendernode='/dev/dri/renderD128'/>
    </graphics>
...
    <hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci' display='on'>
      <source>
        <address uuid='24e33b95-444c-45f4-98a5-758de39aa651'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </hostdev>
...

Use egl-headless here I think is just for enabling vfio display of vgpu, however, virgl is also enabled as well. If people want to enable virgl indeed in this configuration, they can add <acceleration accel3d='yes'/> to virtio-vga for this purpose. But if they want the virgl to remain OFF or are not aware of the existence of virgl, just don't specify "acceleration accel3d" is more natural.

Comment 3 Gerd Hoffmann 2020-01-16 08:20:45 UTC
> a)
> ...
>     <graphics type='egl-headless'>
>       <gl rendernode='/dev/dri/renderD128'/>
>     </graphics>
> ...
>     <video>
>       <model type='virtio' heads='1' primary='yes'>
>         <acceleration accel3d='no'/>
>       </model>
>       <alias name='video0'/>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x01'
> function='0x0'/>
>     </video>
> ...

> Whatever a) or b), they will all translate into -display
> egl-headless,rendernode=/dev/dri/renderD128 -device
> virtio-vga,id=video0,max_outputs=1,bus=pcie.0,addr=0x1 in qemu cli

Oh.  That is wrong.  With explicit "accel3d='no'" libvirt should pass "virgl=off" to qemu (if the virgl property is present).

Comment 4 Michal Privoznik 2020-01-25 06:57:15 UTC
I've merged the patch upstream:

dee2218bc8 qemu: explicitly disable virgl when requested

v6.0.0-97-gdee2218bc8

Comment 8 yafu 2020-06-08 08:31:58 UTC
Reproduced with libvirt-6.0.0-17.x86_64.

Verified with libvirt-6.4.0-1.x86_64.
Test steps:
Scenario 1: guest with spice gl and acce3d='no':
1.Start a guest with spice gl and accel3d='no':
#virsh dumpxml vm1
...
    <graphics type='egl-headless'>
      <gl rendernode='/dev/dri/renderD128'/>
    </graphics>
...
    <video>
      <model type='virtio' heads='1' primary='yes'>
        <acceleration accel3d='no'/>
      </model>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
...

2.Check the qemu cmd line:
#ps aux | grep -i qemu | grep -i virgl
...-device virtio-vga,id=ua-1035e984-8238-46e1-bf56-b546246e1a35,virgl=off,max_outputs=1,bus=pcie.0,addr=0x1...

3.Check virgl in guest os:
# dmesg | grep -i virgl
[   14.169104] [drm] virgl 3d acceleration not supported by host


scenario 2: guest with spice gl and no acce3d setting:
1.Start guest with spice gl and no acce3d setting:
#virsh dumpxml vm1
...
    <graphics type='egl-headless'>
      <gl rendernode='/dev/dri/renderD128'/>
    </graphics>
...
    <video>
      <model type='virtio' heads='1' primary='yes'>
      </model>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
...

2.Check the qemu cmd line:
#ps aux | grep -i qemu | grep -i virgl:
no output

3.Check virgl in guest os:
# dmesg | grep -i virgl
[   14.136783] [drm] virgl 3d acceleration enabled

scenario 3: guest with spice gl and acce3d='yes':
#virsh dumpxml vm1
...
    <graphics type='egl-headless'>
      <gl rendernode='/dev/dri/renderD128'/>
    </graphics>
...
    <video>
      <model type='virtio' heads='1' primary='yes'>
        <acceleration accel3d='yes'/>
      </model>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
...

2.Check qemu cmd line:
#ps aux | grep -i qemu | grep -i virgl:
...-device virtio-vga,id=ua-1035e984-8238-46e1-bf56-b546246e1a35,virgl=on,max_outputs=1,bus=pcie.0,addr=0x1...

3.Check virgl in guest os:
# dmesg | grep -i virgl
[   14.136783] [drm] virgl 3d acceleration enabled

Comment 11 errata-xmlrpc 2020-11-17 17:46:36 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (virt:8.3 bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:5137


Note You need to log in before you can comment on or make changes to this bug.