render / rpms / libvirt

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