9c6c51
From d6226c73df11563b6ea1ae1454ca57561b3ea665 Mon Sep 17 00:00:00 2001
9c6c51
Message-Id: <d6226c73df11563b6ea1ae1454ca57561b3ea665@dist-git>
9c6c51
From: Erik Skultety <eskultet@redhat.com>
9c6c51
Date: Thu, 19 Jul 2018 15:03:58 +0200
9c6c51
Subject: [PATCH] qemu: Introduce a new graphics display type 'headless'
9c6c51
MIME-Version: 1.0
9c6c51
Content-Type: text/plain; charset=UTF-8
9c6c51
Content-Transfer-Encoding: 8bit
9c6c51
9c6c51
Since 2.10 QEMU supports a new display type egl-headless which uses the
9c6c51
drm nodes for OpenGL rendering copying back the rendered bits back to
9c6c51
QEMU into a dma-buf which can be accessed by standard "display" apps
9c6c51
like VNC or SPICE. Although this display type can be used on its own,
9c6c51
for any practical use case it makes sense to pair it with either VNC or
9c6c51
SPICE display. The clear benefit of this display is that VNC gains
9c6c51
OpenGL support, which it natively doesn't have, and SPICE gains remote
9c6c51
OpenGL support (native OpenGL support only works locally through a UNIX
9c6c51
socket, i.e. listen type=socket/none).
9c6c51
9c6c51
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9c6c51
Signed-off-by: Erik Skultety <eskultet@redhat.com>
9c6c51
(cherry picked from commit d8266ebe1615c4b043db6b8d486465722cdd0ef8)
9c6c51
9c6c51
https://bugzilla.redhat.com/show_bug.cgi?id=1475770
9c6c51
Signed-off-by: Erik Skultety <eskultet@redhat.com>
9c6c51
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9c6c51
---
9c6c51
 docs/formatdomain.html.in                     | 33 +++++++++-
9c6c51
 docs/schemas/domaincommon.rng                 |  3 +
9c6c51
 src/conf/domain_conf.c                        |  6 +-
9c6c51
 src/conf/domain_conf.h                        |  1 +
9c6c51
 src/libxl/libxl_conf.c                        |  1 +
9c6c51
 src/qemu/qemu_command.c                       | 14 ++++-
9c6c51
 src/qemu/qemu_domain.c                        | 60 ++++++++++++++++++-
9c6c51
 src/qemu/qemu_driver.c                        |  2 +
9c6c51
 src/qemu/qemu_hotplug.c                       |  1 +
9c6c51
 src/qemu/qemu_process.c                       |  4 ++
9c6c51
 src/vmx/vmx.c                                 |  1 +
9c6c51
 tests/domaincapsschemadata/full.xml           |  1 +
9c6c51
 .../graphics-egl-headless.args                | 26 ++++++++
9c6c51
 .../graphics-egl-headless.xml                 | 31 ++++++++++
9c6c51
 .../graphics-sdl-egl-headless.xml             | 35 +++++++++++
9c6c51
 .../graphics-spice-egl-headless.args          | 31 ++++++++++
9c6c51
 .../graphics-spice-egl-headless.xml           | 36 +++++++++++
9c6c51
 .../graphics-spice-invalid-egl-headless.xml   | 37 ++++++++++++
9c6c51
 .../graphics-vnc-egl-headless.args            | 28 +++++++++
9c6c51
 .../graphics-vnc-egl-headless.xml             | 37 ++++++++++++
9c6c51
 tests/qemuxml2argvtest.c                      | 17 ++++++
9c6c51
 .../graphics-spice-egl-headless.xml           | 44 ++++++++++++++
9c6c51
 .../graphics-vnc-egl-headless.xml             | 42 +++++++++++++
9c6c51
 tests/qemuxml2xmltest.c                       |  2 +
9c6c51
 24 files changed, 488 insertions(+), 5 deletions(-)
9c6c51
 create mode 100644 tests/qemuxml2argvdata/graphics-egl-headless.args
9c6c51
 create mode 100644 tests/qemuxml2argvdata/graphics-egl-headless.xml
9c6c51
 create mode 100644 tests/qemuxml2argvdata/graphics-sdl-egl-headless.xml
9c6c51
 create mode 100644 tests/qemuxml2argvdata/graphics-spice-egl-headless.args
9c6c51
 create mode 100644 tests/qemuxml2argvdata/graphics-spice-egl-headless.xml
9c6c51
 create mode 100644 tests/qemuxml2argvdata/graphics-spice-invalid-egl-headless.xml
9c6c51
 create mode 100644 tests/qemuxml2argvdata/graphics-vnc-egl-headless.args
9c6c51
 create mode 100644 tests/qemuxml2argvdata/graphics-vnc-egl-headless.xml
9c6c51
 create mode 100644 tests/qemuxml2xmloutdata/graphics-spice-egl-headless.xml
9c6c51
 create mode 100644 tests/qemuxml2xmloutdata/graphics-vnc-egl-headless.xml
9c6c51
9c6c51
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
9c6c51
index a3afe137bf..9dd22554ad 100644
9c6c51
--- a/docs/formatdomain.html.in
9c6c51
+++ b/docs/formatdomain.html.in
9c6c51
@@ -6299,7 +6299,8 @@ qemu-kvm -net nic,model=? /dev/null
9c6c51
         

9c6c51
           The graphics element has a mandatory type
9c6c51
           attribute which takes the value sdl, vnc,
9c6c51
-          spice, rdp or desktop:
9c6c51
+          spice, rdp, desktop or
9c6c51
+          egl-headless:
9c6c51
         

9c6c51
         
9c6c51
           
sdl
9c6c51
@@ -6358,6 +6359,11 @@ qemu-kvm -net nic,model=? /dev/null
9c6c51
               auto-allocation and autoport having no effect due to
9c6c51
               security reasons) Since 1.0.6.
9c6c51
             

9c6c51
+            

9c6c51
+              Although VNC doesn't support OpenGL natively, it can be paired
9c6c51
+              with graphics type egl-headless (see below) which
9c6c51
+              will instruct QEMU to open and use drm nodes for OpenGL rendering.
9c6c51
+            

9c6c51
           
9c6c51
           
spice Since 0.8.6
9c6c51
           
9c6c51
@@ -6463,6 +6469,12 @@ qemu-kvm -net nic,model=? /dev/null
9c6c51
               You can enable or disable OpenGL support explicitly with
9c6c51
               the gl element, by setting the enable
9c6c51
               property. (QEMU only, since 1.3.3).
9c6c51
+              Note that this only works locally, since this requires usage of
9c6c51
+              UNIX sockets, i.e. using listen types 'socket' or
9c6c51
+              'none'. For accelerated OpenGL with remote support, consider
9c6c51
+              pairing this element with type egl-headless
9c6c51
+              (see below). However, this will deliver weaker performance
9c6c51
+              compared to native Spice OpenGL support.
9c6c51
             

9c6c51
             

9c6c51
               By default, QEMU will pick the first available GPU DRM render node.
9c6c51
@@ -6498,6 +6510,25 @@ qemu-kvm -net nic,model=? /dev/null
9c6c51
               fullscreen.
9c6c51
             

9c6c51
           
9c6c51
+          
egl-headlessSince 4.6.0
9c6c51
+          
9c6c51
+            

9c6c51
+              This display type provides support for an OpenGL accelerated
9c6c51
+              display accessible both locally and remotely (for comparison,
9c6c51
+              Spice's native OpenGL support only works locally using UNIX
9c6c51
+              sockets at the moment, but has better performance). Since this
9c6c51
+              display type doesn't provide any window or graphical console like
9c6c51
+              the other types, for practical reasons it should be paired with
9c6c51
+              either vnc or spice graphics types.
9c6c51
+              This display type is only supported by QEMU domains
9c6c51
+              (needs QEMU 2.10 or newer) and doesn't
9c6c51
+              accept any attributes.
9c6c51
+            

9c6c51
+            
9c6c51
+<graphics type='spice' autoport='yes'/>
9c6c51
+<graphics type='egl-headless'/>
9c6c51
+            
9c6c51
+          
9c6c51
         
9c6c51
       
9c6c51
     
9c6c51
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
9c6c51
index f24a56392a..157726752c 100644
9c6c51
--- a/docs/schemas/domaincommon.rng
9c6c51
+++ b/docs/schemas/domaincommon.rng
9c6c51
@@ -3366,6 +3366,9 @@
9c6c51
             </attribute>
9c6c51
           </optional>
9c6c51
         </group>
9c6c51
+        <attribute name="type">
9c6c51
+          <value>egl-headless</value>
9c6c51
+        </attribute>
9c6c51
       </choice>
9c6c51
     </element>
9c6c51
   </define>
9c6c51
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
9c6c51
index db8e17dac4..fa4dfafcff 100644
9c6c51
--- a/src/conf/domain_conf.c
9c6c51
+++ b/src/conf/domain_conf.c
9c6c51
@@ -615,7 +615,8 @@ VIR_ENUM_IMPL(virDomainGraphics, VIR_DOMAIN_GRAPHICS_TYPE_LAST,
9c6c51
               "vnc",
9c6c51
               "rdp",
9c6c51
               "desktop",
9c6c51
-              "spice")
9c6c51
+              "spice",
9c6c51
+              "egl-headless")
9c6c51
 
9c6c51
 VIR_ENUM_IMPL(virDomainGraphicsListen, VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST,
9c6c51
               "none",
9c6c51
@@ -1426,6 +1427,7 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
9c6c51
         virDomainGraphicsAuthDefClear(&def->data.spice.auth);
9c6c51
         break;
9c6c51
 
9c6c51
+    case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
9c6c51
         break;
9c6c51
     }
9c6c51
@@ -14172,6 +14174,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
9c6c51
         if (virDomainGraphicsDefParseXMLSpice(def, node, ctxt, flags) < 0)
9c6c51
             goto error;
9c6c51
         break;
9c6c51
+    case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
9c6c51
         break;
9c6c51
     }
9c6c51
@@ -26404,6 +26407,7 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
9c6c51
         virDomainGraphicsAuthDefFormatAttr(buf, &def->data.spice.auth, flags);
9c6c51
         break;
9c6c51
 
9c6c51
+    case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
9c6c51
         break;
9c6c51
     }
9c6c51
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
9c6c51
index 0f10e242fd..26f75b15d0 100644
9c6c51
--- a/src/conf/domain_conf.h
9c6c51
+++ b/src/conf/domain_conf.h
9c6c51
@@ -1473,6 +1473,7 @@ typedef enum {
9c6c51
     VIR_DOMAIN_GRAPHICS_TYPE_RDP,
9c6c51
     VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
9c6c51
     VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
9c6c51
+    VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS,
9c6c51
 
9c6c51
     VIR_DOMAIN_GRAPHICS_TYPE_LAST
9c6c51
 } virDomainGraphicsType;
9c6c51
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
9c6c51
index 452a77f3b8..cda4eb9d31 100644
9c6c51
--- a/src/libxl/libxl_conf.c
9c6c51
+++ b/src/libxl/libxl_conf.c
9c6c51
@@ -1441,6 +1441,7 @@ libxlMakeVfb(virPortAllocatorRangePtr graphicsports,
9c6c51
         case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
9c6c51
         case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
9c6c51
         case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
9c6c51
+        case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
9c6c51
         case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
9c6c51
             break;
9c6c51
     }
9c6c51
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
9c6c51
index fed4f8faf9..8915040c6a 100644
9c6c51
--- a/src/qemu/qemu_command.c
9c6c51
+++ b/src/qemu/qemu_command.c
9c6c51
@@ -8212,6 +8212,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
9c6c51
     return -1;
9c6c51
 }
9c6c51
 
9c6c51
+
9c6c51
 static int
9c6c51
 qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
9c6c51
                              virCommandPtr cmd,
9c6c51
@@ -8241,6 +8242,11 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
9c6c51
                                                   qemuCaps, graphics) < 0)
9c6c51
                 return -1;
9c6c51
 
9c6c51
+            break;
9c6c51
+        case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
9c6c51
+            virCommandAddArg(cmd, "-display");
9c6c51
+            virCommandAddArg(cmd, "egl-headless");
9c6c51
+
9c6c51
             break;
9c6c51
         case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
9c6c51
         case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
9c6c51
@@ -10068,6 +10074,7 @@ qemuBuildCommandLineValidate(virQEMUDriverPtr driver,
9c6c51
     int sdl = 0;
9c6c51
     int vnc = 0;
9c6c51
     int spice = 0;
9c6c51
+    int egl_headless = 0;
9c6c51
 
9c6c51
     if (!virQEMUDriverIsPrivileged(driver)) {
9c6c51
         /* If we have no cgroups then we can have no tunings that
9c6c51
@@ -10109,6 +10116,9 @@ qemuBuildCommandLineValidate(virQEMUDriverPtr driver,
9c6c51
         case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
9c6c51
             ++spice;
9c6c51
             break;
9c6c51
+        case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
9c6c51
+            ++egl_headless;
9c6c51
+            break;
9c6c51
         case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
9c6c51
         case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
9c6c51
         case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
9c6c51
@@ -10116,10 +10126,10 @@ qemuBuildCommandLineValidate(virQEMUDriverPtr driver,
9c6c51
         }
9c6c51
     }
9c6c51
 
9c6c51
-    if (sdl > 1 || vnc > 1 || spice > 1) {
9c6c51
+    if (sdl > 1 || vnc > 1 || spice > 1 || egl_headless > 1) {
9c6c51
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
9c6c51
                        _("only 1 graphics device of each type "
9c6c51
-                         "(sdl, vnc, spice) is supported"));
9c6c51
+                         "(sdl, vnc, spice, headless) is supported"));
9c6c51
         return -1;
9c6c51
     }
9c6c51
 
9c6c51
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
9c6c51
index a42a6df91b..9498594857 100644
9c6c51
--- a/src/qemu/qemu_domain.c
9c6c51
+++ b/src/qemu/qemu_domain.c
9c6c51
@@ -5502,6 +5502,60 @@ qemuDomainDeviceDefValidateTPM(virDomainTPMDef *tpm,
9c6c51
 }
9c6c51
 
9c6c51
 
9c6c51
+static int
9c6c51
+qemuDomainDeviceDefValidateGraphics(const virDomainGraphicsDef *graphics,
9c6c51
+                                    const virDomainDef *def,
9c6c51
+                                    virQEMUCapsPtr qemuCaps)
9c6c51
+{
9c6c51
+    bool have_egl_headless = false;
9c6c51
+    size_t i;
9c6c51
+
9c6c51
+    for (i = 0; i < def->ngraphics; i++) {
9c6c51
+        graphics = def->graphics[i];
9c6c51
+
9c6c51
+        if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS) {
9c6c51
+            have_egl_headless = true;
9c6c51
+            break;
9c6c51
+        }
9c6c51
+    }
9c6c51
+
9c6c51
+    /* Only VNC and SPICE can be paired with egl-headless, the other types
9c6c51
+     * either don't make sense to pair with egl-headless or aren't even
9c6c51
+     * supported by QEMU.
9c6c51
+     */
9c6c51
+    if (have_egl_headless) {
9c6c51
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_EGL_HEADLESS)) {
9c6c51
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
9c6c51
+                           _("egl-headless display is not supported with this "
9c6c51
+                             "QEMU binary"));
9c6c51
+            return -1;
9c6c51
+        }
9c6c51
+
9c6c51
+        if (graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS &&
9c6c51
+            graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
9c6c51
+            graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
9c6c51
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
9c6c51
+                           _("graphics type 'egl-headless' is only supported "
9c6c51
+                             "with one of: 'vnc', 'spice' graphics types"));
9c6c51
+            return -1;
9c6c51
+        }
9c6c51
+
9c6c51
+        /* '-spice gl=on' and '-display egl-headless' are mutually
9c6c51
+         * exclusive
9c6c51
+         */
9c6c51
+        if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
9c6c51
+            graphics->data.spice.gl == VIR_TRISTATE_BOOL_YES) {
9c6c51
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
9c6c51
+                           _("multiple OpenGL displays are not supported "
9c6c51
+                             "by QEMU"));
9c6c51
+            return -1;
9c6c51
+        }
9c6c51
+    }
9c6c51
+
9c6c51
+    return 0;
9c6c51
+}
9c6c51
+
9c6c51
+
9c6c51
 static int
9c6c51
 qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
9c6c51
                             const virDomainDef *def,
9c6c51
@@ -5569,11 +5623,15 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
9c6c51
         ret = qemuDomainDeviceDefValidateTPM(dev->data.tpm, def);
9c6c51
         break;
9c6c51
 
9c6c51
+    case VIR_DOMAIN_DEVICE_GRAPHICS:
9c6c51
+        ret = qemuDomainDeviceDefValidateGraphics(dev->data.graphics, def,
9c6c51
+                                                  qemuCaps);
9c6c51
+        break;
9c6c51
+
9c6c51
     case VIR_DOMAIN_DEVICE_LEASE:
9c6c51
     case VIR_DOMAIN_DEVICE_FS:
9c6c51
     case VIR_DOMAIN_DEVICE_INPUT:
9c6c51
     case VIR_DOMAIN_DEVICE_SOUND:
9c6c51
-    case VIR_DOMAIN_DEVICE_GRAPHICS:
9c6c51
     case VIR_DOMAIN_DEVICE_HUB:
9c6c51
     case VIR_DOMAIN_DEVICE_MEMBALLOON:
9c6c51
     case VIR_DOMAIN_DEVICE_NVRAM:
9c6c51
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
9c6c51
index 670651a75d..3158f217fa 100644
9c6c51
--- a/src/qemu/qemu_driver.c
9c6c51
+++ b/src/qemu/qemu_driver.c
9c6c51
@@ -18118,6 +18118,7 @@ qemuDomainOpenGraphics(virDomainPtr dom,
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
9c6c51
+    case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
9c6c51
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
9c6c51
                        _("Can only open VNC or SPICE graphics backends, not %s"),
9c6c51
                        virDomainGraphicsTypeToString(vm->def->graphics[idx]->type));
9c6c51
@@ -18186,6 +18187,7 @@ qemuDomainOpenGraphicsFD(virDomainPtr dom,
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
9c6c51
+    case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
9c6c51
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
9c6c51
                        _("Can only open VNC or SPICE graphics backends, not %s"),
9c6c51
                        virDomainGraphicsTypeToString(vm->def->graphics[idx]->type));
9c6c51
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
9c6c51
index 91a751a2fe..053ddb14ec 100644
9c6c51
--- a/src/qemu/qemu_hotplug.c
9c6c51
+++ b/src/qemu/qemu_hotplug.c
9c6c51
@@ -3699,6 +3699,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
9c6c51
+    case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
9c6c51
         virReportError(VIR_ERR_INTERNAL_ERROR,
9c6c51
                        _("unable to change config on '%s' graphics type"), type);
9c6c51
         break;
9c6c51
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
9c6c51
index c903a8e5c8..a4b1f97df5 100644
9c6c51
--- a/src/qemu/qemu_process.c
9c6c51
+++ b/src/qemu/qemu_process.c
9c6c51
@@ -4467,6 +4467,7 @@ qemuProcessGraphicsReservePorts(virDomainGraphicsDefPtr graphics,
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
9c6c51
+    case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
9c6c51
         break;
9c6c51
     }
9c6c51
@@ -4505,6 +4506,7 @@ qemuProcessGraphicsAllocatePorts(virQEMUDriverPtr driver,
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
9c6c51
+    case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
9c6c51
         break;
9c6c51
     }
9c6c51
@@ -4657,6 +4659,7 @@ qemuProcessGraphicsSetupListen(virQEMUDriverPtr driver,
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
9c6c51
+    case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
9c6c51
     case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
9c6c51
         break;
9c6c51
     }
9c6c51
@@ -4944,6 +4947,7 @@ qemuProcessStartValidateGraphics(virDomainObjPtr vm)
9c6c51
         case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
9c6c51
         case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
9c6c51
         case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
9c6c51
+        case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
9c6c51
         case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
9c6c51
             break;
9c6c51
         }
9c6c51
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
9c6c51
index fe24b060d7..937bf0c96b 100644
9c6c51
--- a/src/vmx/vmx.c
9c6c51
+++ b/src/vmx/vmx.c
9c6c51
@@ -3282,6 +3282,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
9c6c51
           case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
9c6c51
           case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
9c6c51
           case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
9c6c51
+          case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
9c6c51
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
9c6c51
                            _("Unsupported graphics type '%s'"),
9c6c51
                            virDomainGraphicsTypeToString(def->graphics[i]->type));
9c6c51
diff --git a/tests/domaincapsschemadata/full.xml b/tests/domaincapsschemadata/full.xml
9c6c51
index d3faf38da0..154c4a6fe9 100644
9c6c51
--- a/tests/domaincapsschemadata/full.xml
9c6c51
+++ b/tests/domaincapsschemadata/full.xml
9c6c51
@@ -59,6 +59,7 @@
9c6c51
         <value>rdp</value>
9c6c51
         <value>desktop</value>
9c6c51
         <value>spice</value>
9c6c51
+        <value>egl-headless</value>
9c6c51
       </enum>
9c6c51
     </graphics>
9c6c51
     <video supported='yes'>
9c6c51
diff --git a/tests/qemuxml2argvdata/graphics-egl-headless.args b/tests/qemuxml2argvdata/graphics-egl-headless.args
9c6c51
new file mode 100644
9c6c51
index 0000000000..fdf540ddfc
9c6c51
--- /dev/null
9c6c51
+++ b/tests/qemuxml2argvdata/graphics-egl-headless.args
9c6c51
@@ -0,0 +1,26 @@
9c6c51
+LC_ALL=C \
9c6c51
+PATH=/bin \
9c6c51
+HOME=/home/test \
9c6c51
+USER=test \
9c6c51
+LOGNAME=test \
9c6c51
+/usr/bin/qemu-system-i686 \
9c6c51
+-name QEMUGuest1 \
9c6c51
+-S \
9c6c51
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
9c6c51
+-m 214 \
9c6c51
+-smp 1,sockets=1,cores=1,threads=1 \
9c6c51
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
9c6c51
+-no-user-config \
9c6c51
+-nodefaults \
9c6c51
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
9c6c51
+server,nowait \
9c6c51
+-mon chardev=charmonitor,id=monitor,mode=control \
9c6c51
+-rtc base=utc \
9c6c51
+-no-shutdown \
9c6c51
+-no-acpi \
9c6c51
+-boot c \
9c6c51
+-usb \
9c6c51
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
9c6c51
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
9c6c51
+-display egl-headless \
9c6c51
+-vga cirrus
9c6c51
diff --git a/tests/qemuxml2argvdata/graphics-egl-headless.xml b/tests/qemuxml2argvdata/graphics-egl-headless.xml
9c6c51
new file mode 100644
9c6c51
index 0000000000..7b001cd2eb
9c6c51
--- /dev/null
9c6c51
+++ b/tests/qemuxml2argvdata/graphics-egl-headless.xml
9c6c51
@@ -0,0 +1,31 @@
9c6c51
+<domain type='qemu'>
9c6c51
+  <name>QEMUGuest1</name>
9c6c51
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9c6c51
+  <memory unit='KiB'>219100</memory>
9c6c51
+  <currentMemory unit='KiB'>219100</currentMemory>
9c6c51
+  <vcpu placement='static'>1</vcpu>
9c6c51
+  <os>
9c6c51
+    <type arch='i686' machine='pc'>hvm</type>
9c6c51
+    <boot dev='hd'/>
9c6c51
+  </os>
9c6c51
+  <clock offset='utc'/>
9c6c51
+  <on_poweroff>destroy</on_poweroff>
9c6c51
+  <on_reboot>restart</on_reboot>
9c6c51
+  <on_crash>destroy</on_crash>
9c6c51
+  <devices>
9c6c51
+    <emulator>/usr/bin/qemu-system-i686</emulator>
9c6c51
+    <disk type='block' device='disk'>
9c6c51
+      <driver name='qemu' type='raw'/>
9c6c51
+      <source dev='/dev/HostVG/QEMUGuest1'/>
9c6c51
+      <target dev='hda' bus='ide'/>
9c6c51
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9c6c51
+    </disk>
9c6c51
+    <controller type='usb' index='0'/>
9c6c51
+    <controller type='ide' index='0'/>
9c6c51
+    <controller type='pci' index='0' model='pci-root'/>
9c6c51
+    <input type='mouse' bus='ps2'/>
9c6c51
+    <input type='keyboard' bus='ps2'/>
9c6c51
+    <graphics type='egl-headless'/>
9c6c51
+    <memballoon model='none'/>
9c6c51
+  </devices>
9c6c51
+</domain>
9c6c51
diff --git a/tests/qemuxml2argvdata/graphics-sdl-egl-headless.xml b/tests/qemuxml2argvdata/graphics-sdl-egl-headless.xml
9c6c51
new file mode 100644
9c6c51
index 0000000000..955dfeb3c2
9c6c51
--- /dev/null
9c6c51
+++ b/tests/qemuxml2argvdata/graphics-sdl-egl-headless.xml
9c6c51
@@ -0,0 +1,35 @@
9c6c51
+<domain type='qemu'>
9c6c51
+  <name>QEMUGuest1</name>
9c6c51
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9c6c51
+  <memory unit='KiB'>219136</memory>
9c6c51
+  <currentMemory unit='KiB'>219136</currentMemory>
9c6c51
+  <vcpu placement='static'>1</vcpu>
9c6c51
+  <os>
9c6c51
+    <type arch='i686' machine='pc'>hvm</type>
9c6c51
+    <boot dev='hd'/>
9c6c51
+  </os>
9c6c51
+  <clock offset='utc'/>
9c6c51
+  <on_poweroff>destroy</on_poweroff>
9c6c51
+  <on_reboot>restart</on_reboot>
9c6c51
+  <on_crash>destroy</on_crash>
9c6c51
+  <devices>
9c6c51
+    <emulator>/usr/bin/qemu-system-i686</emulator>
9c6c51
+    <disk type='block' device='disk'>
9c6c51
+      <driver name='qemu' type='raw'/>
9c6c51
+      <source dev='/dev/HostVG/QEMUGuest1'/>
9c6c51
+      <target dev='hda' bus='ide'/>
9c6c51
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9c6c51
+    </disk>
9c6c51
+    <controller type='usb' index='0'/>
9c6c51
+    <controller type='ide' index='0'/>
9c6c51
+    <controller type='pci' index='0' model='pci-root'/>
9c6c51
+    <input type='mouse' bus='ps2'/>
9c6c51
+    <input type='keyboard' bus='ps2'/>
9c6c51
+    <graphics type='sdl' display=':0.1' xauth='/root/.Xauthority'/>
9c6c51
+    <graphics type='egl-headless'/>
9c6c51
+    <video>
9c6c51
+      <model type='vga' vram='16384' heads='1'/>
9c6c51
+    </video>
9c6c51
+    <memballoon model='none'/>
9c6c51
+  </devices>
9c6c51
+</domain>
9c6c51
diff --git a/tests/qemuxml2argvdata/graphics-spice-egl-headless.args b/tests/qemuxml2argvdata/graphics-spice-egl-headless.args
9c6c51
new file mode 100644
9c6c51
index 0000000000..4886ee05f6
9c6c51
--- /dev/null
9c6c51
+++ b/tests/qemuxml2argvdata/graphics-spice-egl-headless.args
9c6c51
@@ -0,0 +1,31 @@
9c6c51
+LC_ALL=C \
9c6c51
+PATH=/bin \
9c6c51
+HOME=/home/test \
9c6c51
+USER=test \
9c6c51
+LOGNAME=test \
9c6c51
+QEMU_AUDIO_DRV=spice \
9c6c51
+/usr/bin/qemu-system-i686 \
9c6c51
+-name QEMUGuest1 \
9c6c51
+-S \
9c6c51
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
9c6c51
+-m 214 \
9c6c51
+-smp 1,sockets=1,cores=1,threads=1 \
9c6c51
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
9c6c51
+-no-user-config \
9c6c51
+-nodefaults \
9c6c51
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
9c6c51
+server,nowait \
9c6c51
+-mon chardev=charmonitor,id=monitor,mode=control \
9c6c51
+-rtc base=utc \
9c6c51
+-no-shutdown \
9c6c51
+-no-acpi \
9c6c51
+-boot c \
9c6c51
+-usb \
9c6c51
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
9c6c51
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
9c6c51
+-spice port=5903,addr=127.0.0.1 \
9c6c51
+-display egl-headless \
9c6c51
+-vga qxl \
9c6c51
+-global qxl-vga.ram_size=67108864 \
9c6c51
+-global qxl-vga.vram_size=33554432 \
9c6c51
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
9c6c51
diff --git a/tests/qemuxml2argvdata/graphics-spice-egl-headless.xml b/tests/qemuxml2argvdata/graphics-spice-egl-headless.xml
9c6c51
new file mode 100644
9c6c51
index 0000000000..fafae13a0f
9c6c51
--- /dev/null
9c6c51
+++ b/tests/qemuxml2argvdata/graphics-spice-egl-headless.xml
9c6c51
@@ -0,0 +1,36 @@
9c6c51
+<domain type='qemu'>
9c6c51
+  <name>QEMUGuest1</name>
9c6c51
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9c6c51
+  <memory unit='KiB'>219136</memory>
9c6c51
+  <currentMemory unit='KiB'>219136</currentMemory>
9c6c51
+  <vcpu placement='static'>1</vcpu>
9c6c51
+  <os>
9c6c51
+    <type arch='i686' machine='pc'>hvm</type>
9c6c51
+    <boot dev='hd'/>
9c6c51
+  </os>
9c6c51
+  <clock offset='utc'/>
9c6c51
+  <on_poweroff>destroy</on_poweroff>
9c6c51
+  <on_reboot>restart</on_reboot>
9c6c51
+  <on_crash>destroy</on_crash>
9c6c51
+  <devices>
9c6c51
+    <emulator>/usr/bin/qemu-system-i686</emulator>
9c6c51
+    <disk type='block' device='disk'>
9c6c51
+      <source dev='/dev/HostVG/QEMUGuest1'/>
9c6c51
+      <target dev='hda' bus='ide'/>
9c6c51
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9c6c51
+    </disk>
9c6c51
+    <controller type='usb' index='0'/>
9c6c51
+    <controller type='ide' index='0'/>
9c6c51
+    <controller type='pci' index='0' model='pci-root'/>
9c6c51
+    <input type='mouse' bus='ps2'/>
9c6c51
+    <input type='keyboard' bus='ps2'/>
9c6c51
+    <graphics type='spice' port='5903' autoport='no' listen='127.0.0.1'>
9c6c51
+      <listen type='address' address='127.0.0.1'/>
9c6c51
+    </graphics>
9c6c51
+    <graphics type='egl-headless'/>
9c6c51
+    <video>
9c6c51
+      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
9c6c51
+    </video>
9c6c51
+    <memballoon model='virtio'/>
9c6c51
+  </devices>
9c6c51
+</domain>
9c6c51
diff --git a/tests/qemuxml2argvdata/graphics-spice-invalid-egl-headless.xml b/tests/qemuxml2argvdata/graphics-spice-invalid-egl-headless.xml
9c6c51
new file mode 100644
9c6c51
index 0000000000..25ae61cef6
9c6c51
--- /dev/null
9c6c51
+++ b/tests/qemuxml2argvdata/graphics-spice-invalid-egl-headless.xml
9c6c51
@@ -0,0 +1,37 @@
9c6c51
+<domain type='qemu'>
9c6c51
+  <name>QEMUGuest1</name>
9c6c51
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9c6c51
+  <memory unit='KiB'>219136</memory>
9c6c51
+  <currentMemory unit='KiB'>219136</currentMemory>
9c6c51
+  <vcpu placement='static'>1</vcpu>
9c6c51
+  <os>
9c6c51
+    <type arch='i686' machine='pc'>hvm</type>
9c6c51
+    <boot dev='hd'/>
9c6c51
+  </os>
9c6c51
+  <clock offset='utc'/>
9c6c51
+  <on_poweroff>destroy</on_poweroff>
9c6c51
+  <on_reboot>restart</on_reboot>
9c6c51
+  <on_crash>destroy</on_crash>
9c6c51
+  <devices>
9c6c51
+    <emulator>/usr/bin/qemu-system-i686</emulator>
9c6c51
+    <disk type='block' device='disk'>
9c6c51
+      <source dev='/dev/HostVG/QEMUGuest1'/>
9c6c51
+      <target dev='hda' bus='ide'/>
9c6c51
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9c6c51
+    </disk>
9c6c51
+    <controller type='usb' index='0'/>
9c6c51
+    <controller type='ide' index='0'/>
9c6c51
+    <controller type='pci' index='0' model='pci-root'/>
9c6c51
+    <input type='mouse' bus='ps2'/>
9c6c51
+    <input type='keyboard' bus='ps2'/>
9c6c51
+    <graphics type='spice'>
9c6c51
+      <listen type='none'/>
9c6c51
+      <gl enable='yes'/>
9c6c51
+    </graphics>
9c6c51
+    <graphics type='egl-headless'/>
9c6c51
+    <video>
9c6c51
+      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
9c6c51
+    </video>
9c6c51
+    <memballoon model='virtio'/>
9c6c51
+  </devices>
9c6c51
+</domain>
9c6c51
diff --git a/tests/qemuxml2argvdata/graphics-vnc-egl-headless.args b/tests/qemuxml2argvdata/graphics-vnc-egl-headless.args
9c6c51
new file mode 100644
9c6c51
index 0000000000..2d2b3cf0fb
9c6c51
--- /dev/null
9c6c51
+++ b/tests/qemuxml2argvdata/graphics-vnc-egl-headless.args
9c6c51
@@ -0,0 +1,28 @@
9c6c51
+LC_ALL=C \
9c6c51
+PATH=/bin \
9c6c51
+HOME=/home/test \
9c6c51
+USER=test \
9c6c51
+LOGNAME=test \
9c6c51
+QEMU_AUDIO_DRV=none \
9c6c51
+/usr/bin/qemu-system-i686 \
9c6c51
+-name QEMUGuest1 \
9c6c51
+-S \
9c6c51
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
9c6c51
+-m 214 \
9c6c51
+-smp 1,sockets=1,cores=1,threads=1 \
9c6c51
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
9c6c51
+-no-user-config \
9c6c51
+-nodefaults \
9c6c51
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
9c6c51
+server,nowait \
9c6c51
+-mon chardev=charmonitor,id=monitor,mode=control \
9c6c51
+-rtc base=utc \
9c6c51
+-no-shutdown \
9c6c51
+-no-acpi \
9c6c51
+-boot c \
9c6c51
+-usb \
9c6c51
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
9c6c51
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
9c6c51
+-vnc '[2001:1:2:3:4:5:1234:1234]:3' \
9c6c51
+-display egl-headless \
9c6c51
+-vga cirrus
9c6c51
diff --git a/tests/qemuxml2argvdata/graphics-vnc-egl-headless.xml b/tests/qemuxml2argvdata/graphics-vnc-egl-headless.xml
9c6c51
new file mode 100644
9c6c51
index 0000000000..570cf2e50f
9c6c51
--- /dev/null
9c6c51
+++ b/tests/qemuxml2argvdata/graphics-vnc-egl-headless.xml
9c6c51
@@ -0,0 +1,37 @@
9c6c51
+<domain type='qemu'>
9c6c51
+  <name>QEMUGuest1</name>
9c6c51
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9c6c51
+  <memory unit='KiB'>219100</memory>
9c6c51
+  <currentMemory unit='KiB'>219100</currentMemory>
9c6c51
+  <vcpu placement='static'>1</vcpu>
9c6c51
+  <os>
9c6c51
+    <type arch='i686' machine='pc'>hvm</type>
9c6c51
+    <boot dev='hd'/>
9c6c51
+  </os>
9c6c51
+  <clock offset='utc'/>
9c6c51
+  <on_poweroff>destroy</on_poweroff>
9c6c51
+  <on_reboot>restart</on_reboot>
9c6c51
+  <on_crash>destroy</on_crash>
9c6c51
+  <devices>
9c6c51
+    <emulator>/usr/bin/qemu-system-i686</emulator>
9c6c51
+    <disk type='block' device='disk'>
9c6c51
+      <driver name='qemu' type='raw'/>
9c6c51
+      <source dev='/dev/HostVG/QEMUGuest1'/>
9c6c51
+      <target dev='hda' bus='ide'/>
9c6c51
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9c6c51
+    </disk>
9c6c51
+    <controller type='usb' index='0'/>
9c6c51
+    <controller type='ide' index='0'/>
9c6c51
+    <controller type='pci' index='0' model='pci-root'/>
9c6c51
+    <input type='mouse' bus='ps2'/>
9c6c51
+    <input type='keyboard' bus='ps2'/>
9c6c51
+    <graphics type='vnc' port='5903' autoport='no' listen='2001:1:2:3:4:5:1234:1234'>
9c6c51
+      <listen type='address' address='2001:1:2:3:4:5:1234:1234'/>
9c6c51
+    </graphics>
9c6c51
+    <graphics type='egl-headless'/>
9c6c51
+    <video>
9c6c51
+      <model type='cirrus' vram='16384' heads='1'/>
9c6c51
+    </video>
9c6c51
+    <memballoon model='none'/>
9c6c51
+  </devices>
9c6c51
+</domain>
9c6c51
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
9c6c51
index 3be5af03aa..848e40440a 100644
9c6c51
--- a/tests/qemuxml2argvtest.c
9c6c51
+++ b/tests/qemuxml2argvtest.c
9c6c51
@@ -1167,6 +1167,10 @@ mymain(void)
9c6c51
     DO_TEST_PARSE_ERROR("disk-scsi-incompatible-address",
9c6c51
                         QEMU_CAPS_VIRTIO_SCSI);
9c6c51
 
9c6c51
+    DO_TEST("graphics-egl-headless",
9c6c51
+            QEMU_CAPS_EGL_HEADLESS,
9c6c51
+            QEMU_CAPS_DEVICE_CIRRUS_VGA);
9c6c51
+
9c6c51
     DO_TEST("graphics-vnc", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
9c6c51
     DO_TEST("graphics-vnc-socket", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
9c6c51
     DO_TEST("graphics-vnc-websocket", QEMU_CAPS_VNC, QEMU_CAPS_VNC_WEBSOCKET,
9c6c51
@@ -1198,9 +1202,14 @@ mymain(void)
9c6c51
     driver.config->vncSASL = driver.config->vncTLSx509verify = driver.config->vncTLS = 0;
9c6c51
     VIR_FREE(driver.config->vncSASLdir);
9c6c51
     VIR_FREE(driver.config->vncTLSx509certdir);
9c6c51
+    DO_TEST("graphics-vnc-egl-headless",
9c6c51
+            QEMU_CAPS_VNC,
9c6c51
+            QEMU_CAPS_EGL_HEADLESS,
9c6c51
+            QEMU_CAPS_DEVICE_CIRRUS_VGA);
9c6c51
 
9c6c51
     DO_TEST("graphics-sdl",
9c6c51
             QEMU_CAPS_DEVICE_VGA);
9c6c51
+    DO_TEST_FAILURE("graphics-sdl-egl-headless", NONE);
9c6c51
     DO_TEST("graphics-sdl-fullscreen",
9c6c51
             QEMU_CAPS_DEVICE_CIRRUS_VGA);
9c6c51
     DO_TEST("graphics-spice",
9c6c51
@@ -1255,6 +1264,14 @@ mymain(void)
9c6c51
             QEMU_CAPS_SPICE_UNIX,
9c6c51
             QEMU_CAPS_DEVICE_CIRRUS_VGA);
9c6c51
     driver.config->spiceAutoUnixSocket = false;
9c6c51
+    DO_TEST("graphics-spice-egl-headless",
9c6c51
+            QEMU_CAPS_SPICE,
9c6c51
+            QEMU_CAPS_EGL_HEADLESS,
9c6c51
+            QEMU_CAPS_DEVICE_QXL);
9c6c51
+    DO_TEST_FAILURE("graphics-spice-invalid-egl-headless",
9c6c51
+                    QEMU_CAPS_SPICE,
9c6c51
+                    QEMU_CAPS_EGL_HEADLESS,
9c6c51
+                    QEMU_CAPS_DEVICE_QXL);
9c6c51
 
9c6c51
     DO_TEST("input-usbmouse", NONE);
9c6c51
     DO_TEST("input-usbtablet", NONE);
9c6c51
diff --git a/tests/qemuxml2xmloutdata/graphics-spice-egl-headless.xml b/tests/qemuxml2xmloutdata/graphics-spice-egl-headless.xml
9c6c51
new file mode 100644
9c6c51
index 0000000000..6d96264914
9c6c51
--- /dev/null
9c6c51
+++ b/tests/qemuxml2xmloutdata/graphics-spice-egl-headless.xml
9c6c51
@@ -0,0 +1,44 @@
9c6c51
+<domain type='qemu'>
9c6c51
+  <name>QEMUGuest1</name>
9c6c51
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9c6c51
+  <memory unit='KiB'>219136</memory>
9c6c51
+  <currentMemory unit='KiB'>219136</currentMemory>
9c6c51
+  <vcpu placement='static'>1</vcpu>
9c6c51
+  <os>
9c6c51
+    <type arch='i686' machine='pc'>hvm</type>
9c6c51
+    <boot dev='hd'/>
9c6c51
+  </os>
9c6c51
+  <clock offset='utc'/>
9c6c51
+  <on_poweroff>destroy</on_poweroff>
9c6c51
+  <on_reboot>restart</on_reboot>
9c6c51
+  <on_crash>destroy</on_crash>
9c6c51
+  <devices>
9c6c51
+    <emulator>/usr/bin/qemu-system-i686</emulator>
9c6c51
+    <disk type='block' device='disk'>
9c6c51
+      <driver name='qemu' type='raw'/>
9c6c51
+      <source dev='/dev/HostVG/QEMUGuest1'/>
9c6c51
+      <target dev='hda' bus='ide'/>
9c6c51
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9c6c51
+    </disk>
9c6c51
+    <controller type='usb' index='0'>
9c6c51
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
9c6c51
+    </controller>
9c6c51
+    <controller type='ide' index='0'>
9c6c51
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
9c6c51
+    </controller>
9c6c51
+    <controller type='pci' index='0' model='pci-root'/>
9c6c51
+    <input type='mouse' bus='ps2'/>
9c6c51
+    <input type='keyboard' bus='ps2'/>
9c6c51
+    <graphics type='spice' port='5903' autoport='no' listen='127.0.0.1'>
9c6c51
+      <listen type='address' address='127.0.0.1'/>
9c6c51
+    </graphics>
9c6c51
+    <graphics type='egl-headless'/>
9c6c51
+    <video>
9c6c51
+      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1' primary='yes'/>
9c6c51
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
9c6c51
+    </video>
9c6c51
+    <memballoon model='virtio'>
9c6c51
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
9c6c51
+    </memballoon>
9c6c51
+  </devices>
9c6c51
+</domain>
9c6c51
diff --git a/tests/qemuxml2xmloutdata/graphics-vnc-egl-headless.xml b/tests/qemuxml2xmloutdata/graphics-vnc-egl-headless.xml
9c6c51
new file mode 100644
9c6c51
index 0000000000..4155c10397
9c6c51
--- /dev/null
9c6c51
+++ b/tests/qemuxml2xmloutdata/graphics-vnc-egl-headless.xml
9c6c51
@@ -0,0 +1,42 @@
9c6c51
+<domain type='qemu'>
9c6c51
+  <name>QEMUGuest1</name>
9c6c51
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9c6c51
+  <memory unit='KiB'>219100</memory>
9c6c51
+  <currentMemory unit='KiB'>219100</currentMemory>
9c6c51
+  <vcpu placement='static'>1</vcpu>
9c6c51
+  <os>
9c6c51
+    <type arch='i686' machine='pc'>hvm</type>
9c6c51
+    <boot dev='hd'/>
9c6c51
+  </os>
9c6c51
+  <clock offset='utc'/>
9c6c51
+  <on_poweroff>destroy</on_poweroff>
9c6c51
+  <on_reboot>restart</on_reboot>
9c6c51
+  <on_crash>destroy</on_crash>
9c6c51
+  <devices>
9c6c51
+    <emulator>/usr/bin/qemu-system-i686</emulator>
9c6c51
+    <disk type='block' device='disk'>
9c6c51
+      <driver name='qemu' type='raw'/>
9c6c51
+      <source dev='/dev/HostVG/QEMUGuest1'/>
9c6c51
+      <target dev='hda' bus='ide'/>
9c6c51
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9c6c51
+    </disk>
9c6c51
+    <controller type='usb' index='0'>
9c6c51
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
9c6c51
+    </controller>
9c6c51
+    <controller type='ide' index='0'>
9c6c51
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
9c6c51
+    </controller>
9c6c51
+    <controller type='pci' index='0' model='pci-root'/>
9c6c51
+    <input type='mouse' bus='ps2'/>
9c6c51
+    <input type='keyboard' bus='ps2'/>
9c6c51
+    <graphics type='vnc' port='5903' autoport='no' listen='2001:1:2:3:4:5:1234:1234'>
9c6c51
+      <listen type='address' address='2001:1:2:3:4:5:1234:1234'/>
9c6c51
+    </graphics>
9c6c51
+    <graphics type='egl-headless'/>
9c6c51
+    <video>
9c6c51
+      <model type='cirrus' vram='16384' heads='1' primary='yes'/>
9c6c51
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
9c6c51
+    </video>
9c6c51
+    <memballoon model='none'/>
9c6c51
+  </devices>
9c6c51
+</domain>
9c6c51
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
9c6c51
index bbb995656e..fa57221d62 100644
9c6c51
--- a/tests/qemuxml2xmltest.c
9c6c51
+++ b/tests/qemuxml2xmltest.c
9c6c51
@@ -417,6 +417,7 @@ mymain(void)
9c6c51
     cfg->vncAutoUnixSocket = false;
9c6c51
     DO_TEST("graphics-vnc-socket", NONE);
9c6c51
     DO_TEST("graphics-vnc-auto-socket", NONE);
9c6c51
+    DO_TEST("graphics-vnc-egl-headless", NONE);
9c6c51
 
9c6c51
     DO_TEST("graphics-sdl", NONE);
9c6c51
     DO_TEST("graphics-sdl-fullscreen", NONE);
9c6c51
@@ -428,6 +429,7 @@ mymain(void)
9c6c51
     cfg->spiceAutoUnixSocket = true;
9c6c51
     DO_TEST("graphics-spice-auto-socket-cfg", NONE);
9c6c51
     cfg->spiceAutoUnixSocket = false;
9c6c51
+    DO_TEST("graphics-spice-egl-headless", NONE);
9c6c51
 
9c6c51
     DO_TEST("input-usbmouse", NONE);
9c6c51
     DO_TEST("input-usbtablet", NONE);
9c6c51
-- 
9c6c51
2.18.0
9c6c51