982648
From 360ffd013a763e200207c4237064071750e58f93 Mon Sep 17 00:00:00 2001
982648
Message-Id: <360ffd013a763e200207c4237064071750e58f93@dist-git>
982648
From: Erik Skultety <eskultet@redhat.com>
982648
Date: Thu, 19 Jul 2018 15:04:00 +0200
982648
Subject: [PATCH] conf: Introduce virDomainGraphicsDefHasOpenGL helper
982648
MIME-Version: 1.0
982648
Content-Type: text/plain; charset=UTF-8
982648
Content-Transfer-Encoding: 8bit
982648
982648
A simple helper which will loop through all the graphics elements and
982648
checks whether at least one of them enables OpenGL support, either by
982648
containing <gl enable='yes'/> or being of type 'egl-headless'.
982648
982648
Signed-off-by: Erik Skultety <eskultet@redhat.com>
982648
Acked-by: Michal Privoznik <mprivozn@redhat.com>
982648
Reviewed-by: Ján Tomko <jtomko@redhat.com>
982648
(cherry picked from commit 425329181f1db19f34a8ffffc1da9afa7f323f13)
982648
982648
https://bugzilla.redhat.com/show_bug.cgi?id=1475770
982648
Signed-off-by: Erik Skultety <eskultet@redhat.com>
982648
Reviewed-by: Ján Tomko <jtomko@redhat.com>
982648
---
982648
 src/conf/domain_conf.c   | 43 ++++++++++++++++++++++++++++++++++++++++
982648
 src/conf/domain_conf.h   |  3 +++
982648
 src/libvirt_private.syms |  1 +
982648
 3 files changed, 47 insertions(+)
982648
982648
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
982648
index fa4dfafcff..08654ab41d 100644
982648
--- a/src/conf/domain_conf.c
982648
+++ b/src/conf/domain_conf.c
982648
@@ -30284,3 +30284,46 @@ virDomainDefHasManagedPR(const virDomainDef *def)
982648
 
982648
     return false;
982648
 }
982648
+
982648
+
982648
+/**
982648
+ * virDomainGraphicsDefHasOpenGL:
982648
+ * @def: domain definition
982648
+ *
982648
+ * Returns true if a domain config contains at least one <graphics> element
982648
+ * with OpenGL support enabled, false otherwise.
982648
+ */
982648
+bool
982648
+virDomainGraphicsDefHasOpenGL(const virDomainDef *def)
982648
+{
982648
+    size_t i;
982648
+
982648
+    for (i = 0; i < def->ngraphics; i++) {
982648
+        virDomainGraphicsDefPtr graphics = def->graphics[i];
982648
+
982648
+        /* we only care about OpenGL support for a given type here */
982648
+        switch (graphics->type) {
982648
+        case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
982648
+        case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
982648
+        case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
982648
+            continue;
982648
+        case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
982648
+            if (graphics->data.sdl.gl == VIR_TRISTATE_BOOL_YES)
982648
+                return true;
982648
+
982648
+            continue;
982648
+        case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
982648
+            if (graphics->data.spice.gl == VIR_TRISTATE_BOOL_YES)
982648
+                return true;
982648
+
982648
+            continue;
982648
+        case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
982648
+            return true;
982648
+
982648
+        case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
982648
+            break;
982648
+        }
982648
+    }
982648
+
982648
+    return false;
982648
+}
982648
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
982648
index 26f75b15d0..3deda1d978 100644
982648
--- a/src/conf/domain_conf.h
982648
+++ b/src/conf/domain_conf.h
982648
@@ -3642,4 +3642,7 @@ virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,
982648
 bool
982648
 virDomainDefHasManagedPR(const virDomainDef *def);
982648
 
982648
+bool
982648
+virDomainGraphicsDefHasOpenGL(const virDomainDef *def);
982648
+
982648
 #endif /* __DOMAIN_CONF_H */
982648
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
982648
index 5bd08d3f67..86846f3b08 100644
982648
--- a/src/libvirt_private.syms
982648
+++ b/src/libvirt_private.syms
982648
@@ -368,6 +368,7 @@ virDomainGetFilesystemForTarget;
982648
 virDomainGraphicsAuthConnectedTypeFromString;
982648
 virDomainGraphicsAuthConnectedTypeToString;
982648
 virDomainGraphicsDefFree;
982648
+virDomainGraphicsDefHasOpenGL;
982648
 virDomainGraphicsGetListen;
982648
 virDomainGraphicsListenAppendAddress;
982648
 virDomainGraphicsListenAppendSocket;
982648
-- 
982648
2.18.0
982648