0a7476
From 7b4b21814c4a1af212b061e265ee0ca8220abd1e Mon Sep 17 00:00:00 2001
0a7476
Message-Id: <7b4b21814c4a1af212b061e265ee0ca8220abd1e@dist-git>
0a7476
From: Erik Skultety <eskultet@redhat.com>
0a7476
Date: Tue, 9 Apr 2019 08:34:26 +0200
0a7476
Subject: [PATCH] conf: Introduce virDomainGraphics-related helpers
0a7476
MIME-Version: 1.0
0a7476
Content-Type: text/plain; charset=UTF-8
0a7476
Content-Transfer-Encoding: 8bit
0a7476
0a7476
A few simple helpers that allow us to determine whether a graphics can
0a7476
and will need to make use of a DRM render node.
0a7476
0a7476
Signed-off-by: Erik Skultety <eskultet@redhat.com>
0a7476
Reviewed-by: Ján Tomko <jtomko@redhat.com>
0a7476
(cherry picked from commit 255e073263b55b524f68b64c282e73509f93985e)
0a7476
0a7476
https: //bugzilla.redhat.com/show_bug.cgi?id=1628892
0a7476
Signed-off-by: Erik Skultety <eskultet@redhat.com>
0a7476
Message-Id: <24845c3d51a90b5de6989e70e9de51b07b44ade9.1554791287.git.eskultet@redhat.com>
0a7476
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
0a7476
---
0a7476
 src/conf/domain_conf.c   | 43 ++++++++++++++++++++++++++++++++++++++++
0a7476
 src/conf/domain_conf.h   |  9 +++++++++
0a7476
 src/libvirt_private.syms |  3 +++
0a7476
 3 files changed, 55 insertions(+)
0a7476
0a7476
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
0a7476
index 6af14cc06f..d079be2bb5 100644
0a7476
--- a/src/conf/domain_conf.c
0a7476
+++ b/src/conf/domain_conf.c
0a7476
@@ -30713,3 +30713,46 @@ virDomainGraphicsDefHasOpenGL(const virDomainDef *def)
0a7476
 
0a7476
     return false;
0a7476
 }
0a7476
+
0a7476
+
0a7476
+bool
0a7476
+virDomainGraphicsSupportsRenderNode(const virDomainGraphicsDef *graphics)
0a7476
+{
0a7476
+    return graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE;
0a7476
+}
0a7476
+
0a7476
+
0a7476
+const char *
0a7476
+virDomainGraphicsGetRenderNode(const virDomainGraphicsDef *graphics)
0a7476
+{
0a7476
+    const char *ret = NULL;
0a7476
+
0a7476
+    switch (graphics->type) {
0a7476
+    case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
0a7476
+        if (graphics->data.spice.gl == VIR_TRISTATE_BOOL_YES)
0a7476
+            ret = graphics->data.spice.rendernode;
0a7476
+        break;
0a7476
+    case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
0a7476
+    case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
0a7476
+    case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
0a7476
+    case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
0a7476
+    case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
0a7476
+    case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
0a7476
+        break;
0a7476
+    }
0a7476
+
0a7476
+    return ret;
0a7476
+}
0a7476
+
0a7476
+
0a7476
+bool
0a7476
+virDomainGraphicsNeedsAutoRenderNode(const virDomainGraphicsDef *graphics)
0a7476
+{
0a7476
+    if (!virDomainGraphicsSupportsRenderNode(graphics))
0a7476
+        return false;
0a7476
+
0a7476
+    if (virDomainGraphicsGetRenderNode(graphics))
0a7476
+        return false;
0a7476
+
0a7476
+    return true;
0a7476
+}
0a7476
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
0a7476
index 65abe9cde6..b1139812d5 100644
0a7476
--- a/src/conf/domain_conf.h
0a7476
+++ b/src/conf/domain_conf.h
0a7476
@@ -3651,4 +3651,13 @@ virDomainDefHasManagedPR(const virDomainDef *def);
0a7476
 bool
0a7476
 virDomainGraphicsDefHasOpenGL(const virDomainDef *def);
0a7476
 
0a7476
+bool
0a7476
+virDomainGraphicsSupportsRenderNode(const virDomainGraphicsDef *graphics);
0a7476
+
0a7476
+const char *
0a7476
+virDomainGraphicsGetRenderNode(const virDomainGraphicsDef *graphics);
0a7476
+
0a7476
+bool
0a7476
+virDomainGraphicsNeedsAutoRenderNode(const virDomainGraphicsDef *graphics);
0a7476
+
0a7476
 #endif /* __DOMAIN_CONF_H */
0a7476
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
0a7476
index 6655dfdecc..984a9be18f 100644
0a7476
--- a/src/libvirt_private.syms
0a7476
+++ b/src/libvirt_private.syms
0a7476
@@ -370,8 +370,10 @@ virDomainGraphicsAuthConnectedTypeToString;
0a7476
 virDomainGraphicsDefFree;
0a7476
 virDomainGraphicsDefHasOpenGL;
0a7476
 virDomainGraphicsGetListen;
0a7476
+virDomainGraphicsGetRenderNode;
0a7476
 virDomainGraphicsListenAppendAddress;
0a7476
 virDomainGraphicsListenAppendSocket;
0a7476
+virDomainGraphicsNeedsAutoRenderNode;
0a7476
 virDomainGraphicsSpiceChannelModeTypeFromString;
0a7476
 virDomainGraphicsSpiceChannelModeTypeToString;
0a7476
 virDomainGraphicsSpiceChannelNameTypeFromString;
0a7476
@@ -386,6 +388,7 @@ virDomainGraphicsSpiceStreamingModeTypeFromString;
0a7476
 virDomainGraphicsSpiceStreamingModeTypeToString;
0a7476
 virDomainGraphicsSpiceZlibCompressionTypeFromString;
0a7476
 virDomainGraphicsSpiceZlibCompressionTypeToString;
0a7476
+virDomainGraphicsSupportsRenderNode;
0a7476
 virDomainGraphicsTypeFromString;
0a7476
 virDomainGraphicsTypeToString;
0a7476
 virDomainGraphicsVNCSharePolicyTypeFromString;
0a7476
-- 
0a7476
2.21.0
0a7476