[PATCH 11/14] xen: Move xenParseSxprChar to xen_common

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It's the only place where it's used.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/libvirt_xenconfig.syms |   1 -
 src/xenconfig/xen_common.c | 146 +++++++++++++++++++++++++++++++++++++
 src/xenconfig/xen_sxpr.c   | 146 -------------------------------------
 src/xenconfig/xen_sxpr.h   |   2 -
 4 files changed, 146 insertions(+), 149 deletions(-)

diff --git a/src/libvirt_xenconfig.syms b/src/libvirt_xenconfig.syms
index 603f1ce420..ddaecd6850 100644
--- a/src/libvirt_xenconfig.syms
+++ b/src/libvirt_xenconfig.syms
@@ -5,7 +5,6 @@
 # xenconfig/xen_sxpr.h
 xenGetDomIdFromSxpr;
 xenGetDomIdFromSxprString;
-xenParseSxprChar;

 # xenconfig/xen_xm.h
 xenFormatXM;
diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 8eaa64a4e9..aa069fb74e 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -763,6 +763,152 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
 }


+/**
+  * xenParseSxprChar:
+  * @value: A string describing a character device.
+  * @tty: the console pty path
+  *
+  * Parse the xend S-expression for description of a character device.
+  *
+  * Returns a character device object or NULL in case of failure.
+  */
+static virDomainChrDefPtr
+xenParseSxprChar(const char *value,
+                 const char *tty)
+{
+    const char *prefix;
+    char *tmp;
+    virDomainChrDefPtr def;
+
+    if (!(def = virDomainChrDefNew(NULL)))
+        return NULL;
+
+    prefix = value;
+
+    if (value[0] == '/') {
+        def->source->type = VIR_DOMAIN_CHR_TYPE_DEV;
+        if (VIR_STRDUP(def->source->data.file.path, value) < 0)
+            goto error;
+    } else {
+        if ((tmp = strchr(value, ':')) != NULL) {
+            *tmp = '\0';
+            value = tmp + 1;
+        }
+
+        if (STRPREFIX(prefix, "telnet")) {
+            def->source->type = VIR_DOMAIN_CHR_TYPE_TCP;
+            def->source->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET;
+        } else {
+            if ((def->source->type = virDomainChrTypeFromString(prefix)) < 0) {
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                               _("unknown chr device type '%s'"), prefix);
+                goto error;
+            }
+        }
+    }
+
+    switch (def->source->type) {
+    case VIR_DOMAIN_CHR_TYPE_PTY:
+        if (VIR_STRDUP(def->source->data.file.path, tty) < 0)
+            goto error;
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_FILE:
+    case VIR_DOMAIN_CHR_TYPE_PIPE:
+        if (VIR_STRDUP(def->source->data.file.path, value) < 0)
+            goto error;
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_TCP:
+    {
+        const char *offset = strchr(value, ':');
+        const char *offset2;
+
+        if (offset == NULL) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           "%s", _("malformed char device string"));
+            goto error;
+        }
+
+        if (offset != value &&
+            VIR_STRNDUP(def->source->data.tcp.host, value, offset - value) < 0)
+            goto error;
+
+        offset2 = strchr(offset, ',');
+        offset++;
+        if (VIR_STRNDUP(def->source->data.tcp.service, offset,
+                        offset2 ? offset2 - offset : -1) < 0)
+            goto error;
+
+        if (offset2 && strstr(offset2, ",server"))
+            def->source->data.tcp.listen = true;
+    }
+    break;
+
+    case VIR_DOMAIN_CHR_TYPE_UDP:
+    {
+        const char *offset = strchr(value, ':');
+        const char *offset2, *offset3;
+
+        if (offset == NULL) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           "%s", _("malformed char device string"));
+            goto error;
+        }
+
+        if (offset != value &&
+            VIR_STRNDUP(def->source->data.udp.connectHost, value, offset - value) < 0)
+            goto error;
+
+        offset2 = strchr(offset, '@');
+        if (offset2 != NULL) {
+            if (VIR_STRNDUP(def->source->data.udp.connectService,
+                            offset + 1, offset2 - offset - 1) < 0)
+                goto error;
+
+            offset3 = strchr(offset2, ':');
+            if (offset3 == NULL) {
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                               "%s", _("malformed char device string"));
+                goto error;
+            }
+
+            if (offset3 > (offset2 + 1) &&
+                VIR_STRNDUP(def->source->data.udp.bindHost,
+                            offset2 + 1, offset3 - offset2 - 1) < 0)
+                goto error;
+
+            if (VIR_STRDUP(def->source->data.udp.bindService, offset3 + 1) < 0)
+                goto error;
+        } else {
+            if (VIR_STRDUP(def->source->data.udp.connectService, offset + 1) < 0)
+                goto error;
+        }
+    }
+    break;
+
+    case VIR_DOMAIN_CHR_TYPE_UNIX:
+    {
+        const char *offset = strchr(value, ',');
+        if (VIR_STRNDUP(def->source->data.nix.path, value,
+                        offset ? offset - value : -1) < 0)
+            goto error;
+
+        if (offset != NULL &&
+            strstr(offset, ",server") != NULL)
+            def->source->data.nix.listen = true;
+    }
+    break;
+    }
+
+    return def;
+
+ error:
+    virDomainChrDefFree(def);
+    return NULL;
+}
+
+
 static int
 xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat)
 {
diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c
index 953909e7b4..f087464c4d 100644
--- a/src/xenconfig/xen_sxpr.c
+++ b/src/xenconfig/xen_sxpr.c
@@ -62,149 +62,3 @@ int xenGetDomIdFromSxpr(const struct sexpr *root, int *id)
     *id = tmp ? sexpr_int(root, "domain/domid") : -1;
     return 0;
 }
-
-
-/**
-  * xenParseSxprChar:
-  * @value: A string describing a character device.
-  * @tty: the console pty path
-  *
-  * Parse the xend S-expression for description of a character device.
-  *
-  * Returns a character device object or NULL in case of failure.
-  */
-virDomainChrDefPtr
-xenParseSxprChar(const char *value,
-                 const char *tty)
-{
-    const char *prefix;
-    char *tmp;
-    virDomainChrDefPtr def;
-
-    if (!(def = virDomainChrDefNew(NULL)))
-        return NULL;
-
-    prefix = value;
-
-    if (value[0] == '/') {
-        def->source->type = VIR_DOMAIN_CHR_TYPE_DEV;
-        if (VIR_STRDUP(def->source->data.file.path, value) < 0)
-            goto error;
-    } else {
-        if ((tmp = strchr(value, ':')) != NULL) {
-            *tmp = '\0';
-            value = tmp + 1;
-        }
-
-        if (STRPREFIX(prefix, "telnet")) {
-            def->source->type = VIR_DOMAIN_CHR_TYPE_TCP;
-            def->source->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET;
-        } else {
-            if ((def->source->type = virDomainChrTypeFromString(prefix)) < 0) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unknown chr device type '%s'"), prefix);
-                goto error;
-            }
-        }
-    }
-
-    switch (def->source->type) {
-    case VIR_DOMAIN_CHR_TYPE_PTY:
-        if (VIR_STRDUP(def->source->data.file.path, tty) < 0)
-            goto error;
-        break;
-
-    case VIR_DOMAIN_CHR_TYPE_FILE:
-    case VIR_DOMAIN_CHR_TYPE_PIPE:
-        if (VIR_STRDUP(def->source->data.file.path, value) < 0)
-            goto error;
-        break;
-
-    case VIR_DOMAIN_CHR_TYPE_TCP:
-    {
-        const char *offset = strchr(value, ':');
-        const char *offset2;
-
-        if (offset == NULL) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           "%s", _("malformed char device string"));
-            goto error;
-        }
-
-        if (offset != value &&
-            VIR_STRNDUP(def->source->data.tcp.host, value, offset - value) < 0)
-            goto error;
-
-        offset2 = strchr(offset, ',');
-        offset++;
-        if (VIR_STRNDUP(def->source->data.tcp.service, offset,
-                        offset2 ? offset2 - offset : -1) < 0)
-            goto error;
-
-        if (offset2 && strstr(offset2, ",server"))
-            def->source->data.tcp.listen = true;
-    }
-    break;
-
-    case VIR_DOMAIN_CHR_TYPE_UDP:
-    {
-        const char *offset = strchr(value, ':');
-        const char *offset2, *offset3;
-
-        if (offset == NULL) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           "%s", _("malformed char device string"));
-            goto error;
-        }
-
-        if (offset != value &&
-            VIR_STRNDUP(def->source->data.udp.connectHost, value, offset - value) < 0)
-            goto error;
-
-        offset2 = strchr(offset, '@');
-        if (offset2 != NULL) {
-            if (VIR_STRNDUP(def->source->data.udp.connectService,
-                            offset + 1, offset2 - offset - 1) < 0)
-                goto error;
-
-            offset3 = strchr(offset2, ':');
-            if (offset3 == NULL) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               "%s", _("malformed char device string"));
-                goto error;
-            }
-
-            if (offset3 > (offset2 + 1) &&
-                VIR_STRNDUP(def->source->data.udp.bindHost,
-                            offset2 + 1, offset3 - offset2 - 1) < 0)
-                goto error;
-
-            if (VIR_STRDUP(def->source->data.udp.bindService, offset3 + 1) < 0)
-                goto error;
-        } else {
-            if (VIR_STRDUP(def->source->data.udp.connectService, offset + 1) < 0)
-                goto error;
-        }
-    }
-    break;
-
-    case VIR_DOMAIN_CHR_TYPE_UNIX:
-    {
-        const char *offset = strchr(value, ',');
-        if (VIR_STRNDUP(def->source->data.nix.path, value,
-                        offset ? offset - value : -1) < 0)
-            goto error;
-
-        if (offset != NULL &&
-            strstr(offset, ",server") != NULL)
-            def->source->data.nix.listen = true;
-    }
-    break;
-    }
-
-    return def;
-
- error:
-    virDomainChrDefFree(def);
-    return NULL;
-}
diff --git a/src/xenconfig/xen_sxpr.h b/src/xenconfig/xen_sxpr.h
index f7112bc6ee..ad6e293e57 100644
--- a/src/xenconfig/xen_sxpr.h
+++ b/src/xenconfig/xen_sxpr.h
@@ -30,5 +30,3 @@
 /* helper functions to get the dom id from a sexpr */
 int xenGetDomIdFromSxprString(const char *sexpr, int *id);
 int xenGetDomIdFromSxpr(const struct sexpr *root, int *id);
-
-virDomainChrDefPtr xenParseSxprChar(const char *value, const char *tty);
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux