render / rpms / libvirt

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