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

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

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

99cbc7
+            

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

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

99cbc7
             

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

99cbc7
           
99cbc7
+          
egl-headlessSince 4.6.0
99cbc7
+          
99cbc7
+            

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

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