render / rpms / libvirt

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