[libvirt] [PATCH v2 2/7] conf: Introduce a new graphics display type 'headless'

Michal Privoznik mprivozn at redhat.com
Tue Jul 10 11:39:05 UTC 2018


On 07/09/2018 06:24 PM, Erik Skultety wrote:
> Since 2.10 QEMU supports a new display type egl-headless which uses the
> drm nodes for OpenGL rendering copying back the rendered bits back to
> QEMU into a dma-buf which can be accessed by standard "display" apps
> like VNC or SPICE. Although this display type can be used on its own,
> for any practical use case it makes sense to pair it with either VNC or
> SPICE display. The clear benefit of this display is that VNC gains
> OpenGL support, which it natively doesn't have, and SPICE gains remote
> OpenGL support (native OpenGL support only works locally through a UNIX
> socket, i.e. listen type=socket/none)
> 
> Signed-off-by: Erik Skultety <eskultet at redhat.com>
> ---
>  docs/formatdomain.html.in                          | 33 ++++++++++++-
>  docs/schemas/domaincommon.rng                      |  3 ++
>  src/conf/domain_conf.c                             |  6 ++-
>  src/conf/domain_conf.h                             |  1 +
>  src/libxl/libxl_conf.c                             |  1 +
>  src/qemu/qemu_command.c                            | 35 +++++++++++++-
>  src/qemu/qemu_domain.c                             | 54 ++++++++++++++++++++++
>  src/qemu/qemu_driver.c                             |  2 +
>  src/qemu/qemu_hotplug.c                            |  1 +
>  src/qemu/qemu_process.c                            |  4 ++
>  src/vmx/vmx.c                                      |  1 +
>  tests/domaincapsschemadata/full.xml                |  1 +
>  tests/qemuxml2argvdata/graphics-egl-headless.args  | 26 +++++++++++
>  tests/qemuxml2argvdata/graphics-egl-headless.xml   | 31 +++++++++++++
>  .../qemuxml2argvdata/graphics-sdl-egl-headless.xml | 35 ++++++++++++++
>  .../graphics-spice-egl-headless.args               | 31 +++++++++++++
>  .../graphics-spice-egl-headless.xml                | 36 +++++++++++++++
>  .../graphics-spice-invalid-egl-headless.xml        | 37 +++++++++++++++
>  .../graphics-vnc-egl-headless.args                 | 28 +++++++++++
>  .../qemuxml2argvdata/graphics-vnc-egl-headless.xml | 37 +++++++++++++++
>  tests/qemuxml2argvtest.c                           | 17 +++++++
>  .../graphics-spice-egl-headless.xml                | 44 ++++++++++++++++++
>  .../graphics-vnc-egl-headless.xml                  | 42 +++++++++++++++++
>  tests/qemuxml2xmltest.c                            |  2 +
>  24 files changed, 504 insertions(+), 4 deletions(-)
>  create mode 100644 tests/qemuxml2argvdata/graphics-egl-headless.args
>  create mode 100644 tests/qemuxml2argvdata/graphics-egl-headless.xml
>  create mode 100644 tests/qemuxml2argvdata/graphics-sdl-egl-headless.xml
>  create mode 100644 tests/qemuxml2argvdata/graphics-spice-egl-headless.args
>  create mode 100644 tests/qemuxml2argvdata/graphics-spice-egl-headless.xml
>  create mode 100644 tests/qemuxml2argvdata/graphics-spice-invalid-egl-headless.xml
>  create mode 100644 tests/qemuxml2argvdata/graphics-vnc-egl-headless.args
>  create mode 100644 tests/qemuxml2argvdata/graphics-vnc-egl-headless.xml
>  create mode 100644 tests/qemuxml2xmloutdata/graphics-spice-egl-headless.xml
>  create mode 100644 tests/qemuxml2xmloutdata/graphics-vnc-egl-headless.xml
> 


> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index b10bbc40a4..f488050bf8 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -3695,6 +3695,57 @@ qemuDomainDefPostParseBasic(virDomainDefPtr def,
>  }
>  
>  
> +static int
> +qemuDomainDefGraphicsPostParse(virDomainDefPtr def)
> +{
> +    virDomainGraphicsDefPtr graphics = NULL;
> +    bool have_egl_headless = false;
> +    size_t i;
> +
> +    /* are we running with egl-headless? */
> +    for (i = 0; i < def->ngraphics; i++) {
> +        graphics = def->graphics[i];
> +
> +        if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS) {
> +            have_egl_headless = true;
> +            break;
> +        }
> +    }
> +
> +    /* Only VNC and SPICE can be paired with egl-headless, the other types
> +     * either don't make sense to pair with egl-headless or aren't even
> +     * supported by QEMU.
> +     */
> +    if (have_egl_headless) {
> +        for (i = 0; i < def->ngraphics; i++) {
> +            graphics = def->graphics[i];
> +
> +            if (graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS &&
> +                graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
> +                graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
> +                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                               _("graphics type 'egl-headless' is only supported "
> +                                 "with one of: 'vnc', 'spice' graphics types"));
> +                return -1;
> +            }
> +
> +            /* '-spice gl=on' and '-display egl-headless' are mutually
> +             * exclusive
> +             */
> +            if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
> +                graphics->data.spice.gl == VIR_TRISTATE_BOOL_YES) {
> +                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                               _("multiple OpenGL displays are not supported "
> +                                 "by QEMU"));
> +                return -1;
> +            }
> +        }
> +    }
> +
> +    return 0;
> +}
> +

So this ^^ is actually a validate callback. I think it should be named
as such and thus called from elsewhere.

The rest looks okay.

Michal




More information about the libvir-list mailing list