Blob Blame History Raw
From 93ea8130081b8450981320c7c4e7b1b65a75f269 Mon Sep 17 00:00:00 2001
From: Thilo Boehm <tboehm@linux.vnet.ibm.com>
Date: Wed, 11 Sep 2013 16:45:36 +0200
Subject: [PATCH 16/60] schema: New SVPC types for chardev/consoles

C definitions for the console source types, defining the representation
of the consoles in the hypervisor host. Includes mapping from and to
string representations.

Signed-off-by: Thilo Boehm <tboehm@linux.vnet.ibm.com>
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/svpc_types.h | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 96 insertions(+), 1 deletion(-)

diff --git a/src/svpc_types.h b/src/svpc_types.h
index 99dd56f..2e4d73f 100644
--- a/src/svpc_types.h
+++ b/src/svpc_types.h
@@ -1,5 +1,5 @@
 /*
- * Copyright IBM Corp. 2007
+ * Copyright IBM Corp. 2007, 2013
  *
  * Authors:
  *  Dan Smith <danms@us.ibm.com>
@@ -167,5 +167,100 @@ enum CIM_op_status {
         CIM_OP_STATUS_POWER_MODE = 18,
 };
 
+/* emum for the Character device Source resource types */
+enum CIM_chardev_source_type {
+        CIM_CHARDEV_SOURCE_TYPE_NULL = 0,
+        CIM_CHARDEV_SOURCE_TYPE_VC = 1,
+        CIM_CHARDEV_SOURCE_TYPE_PTY = 2,
+        CIM_CHARDEV_SOURCE_TYPE_DEV = 3,
+        CIM_CHARDEV_SOURCE_TYPE_FILE = 4,
+        CIM_CHARDEV_SOURCE_TYPE_PIPE = 5,
+        CIM_CHARDEV_SOURCE_TYPE_STDIO = 6,
+        CIM_CHARDEV_SOURCE_TYPE_UDP = 7,
+        CIM_CHARDEV_SOURCE_TYPE_TCP = 8,
+        CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK = 9,
+        CIM_CHARDEV_SOURCE_TYPE_SPICEVMC = 10,
+        /* please insert new source types above */
+        CIM_CHARDEV_SOURCE_TYPE_INVALIDTYPE,
+        CIM_CHARDEV_SOURCE_TYPE_UNKNOWN = 32768,
+};
+
+static inline int chardev_source_type_StrToID(const char *type_str)
+{
+        int rc = CIM_CHARDEV_SOURCE_TYPE_UNKNOWN;
+
+        if (type_str == NULL)
+                return rc;
+
+        if (STREQC(type_str, "null"))
+                 rc = CIM_CHARDEV_SOURCE_TYPE_NULL;
+        else if (STREQC(type_str, "vc"))
+                 rc = CIM_CHARDEV_SOURCE_TYPE_VC;
+        else if (STREQC(type_str, "pty"))
+                 rc = CIM_CHARDEV_SOURCE_TYPE_PTY;
+        else if (STREQC(type_str, "dev"))
+                 rc = CIM_CHARDEV_SOURCE_TYPE_DEV;
+        else if (STREQC(type_str, "file"))
+                 rc = CIM_CHARDEV_SOURCE_TYPE_FILE;
+        else if (STREQC(type_str, "pipe"))
+                 rc = CIM_CHARDEV_SOURCE_TYPE_PIPE;
+        else if (STREQC(type_str, "stdio"))
+                 rc = CIM_CHARDEV_SOURCE_TYPE_STDIO;
+        else if (STREQC(type_str, "udp"))
+                 rc = CIM_CHARDEV_SOURCE_TYPE_UDP;
+        else if (STREQC(type_str, "tcp"))
+                 rc = CIM_CHARDEV_SOURCE_TYPE_TCP;
+        else if (STREQC(type_str, "unix"))
+                 rc = CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK;
+        else if (STREQC(type_str, "spicevmc"))
+                 rc = CIM_CHARDEV_SOURCE_TYPE_SPICEVMC;
+
+        return rc;
+}
+
+static inline const char* chardev_source_type_IDToStr(int type)
+{
+        char *type_str = NULL;
+
+        switch (type)
+        {
+        case CIM_CHARDEV_SOURCE_TYPE_NULL:
+                type_str = "null";
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_VC:
+                type_str = "vc";
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_PTY:
+                type_str = "pty";
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_DEV:
+                type_str = "dev";
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_FILE:
+                type_str = "file";
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_PIPE:
+                type_str = "pipe";
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_STDIO:
+                type_str = "stdio";
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_UDP:
+                type_str = "udp";
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_TCP:
+                type_str = "tcp";
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK:
+                type_str = "unix";
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_SPICEVMC:
+                type_str = "spicevmc";
+                break;
+        default:
+                break;
+        }
+        return type_str;
+}
 
 #endif
-- 
2.1.0