[RFC QEMU PATCH] ui: Make the DisplayType enum entries conditional

Markus Armbruster armbru at redhat.com
Wed Jun 9 13:16:01 UTC 2021


Thomas Huth <thuth at redhat.com> writes:

> Libvirt's "domcapabilities" command has a way to state whether
> certain graphic frontends are available in QEMU or not. Originally,
> libvirt looked at the "--help" output of the QEMU binary to determine
> whether SDL was available or not (by looking for the "-sdl" parameter
> in the help text), but since libvirt stopped doing this analysis of
> the help text, the detection of SDL is currently broken, see:
>
>  https://bugzilla.redhat.com/show_bug.cgi?id=1790902
>
> QEMU should provide a way via the QMP interface instead. The simplest
> way, without introducing additional commands, is to make the DisplayType
> enum entries conditional, so that the enum only contains the entries if
> the corresponding CONFIG_xxx switches have been set. Unfortunately, this
> only works for sdl, cocoa and spice, since gtk, egl-headless and curses
> are hard-wired in the "data" section of the DisplayOptions, and thus
> unfortunately always have to be defined.

Here:

    { 'union'   : 'DisplayOptions',
      'base'    : { 'type'           : 'DisplayType',
                    '*full-screen'   : 'bool',
                    '*window-close'  : 'bool',
                    '*show-cursor'   : 'bool',
                    '*gl'            : 'DisplayGLMode' },
      'discriminator' : 'type',
      'data'    : { 'gtk'            : 'DisplayGTK',
                    'curses'         : 'DisplayCurses',
                    'egl-headless'   : 'DisplayEGLHeadless'} }

Flat union branches can be made conditional like so:

      'data'    : { 'gtk'            : { 'type': 'DisplayGTK',
                                         'if': 'defined(CONFIG_GTK)' },

Then you should be able to make the corresponding enum value
conditional, too.




More information about the libvir-list mailing list