]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
xen: Move xenFormatSxprChr to xen_common
authorPeter Krempa <pkrempa@redhat.com>
Wed, 3 Jul 2019 07:15:37 +0000 (09:15 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 9 Jul 2019 08:27:19 +0000 (10:27 +0200)
That's the only file using the helper function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/libvirt_xenconfig.syms
src/xenconfig/xen_common.c
src/xenconfig/xen_sxpr.c
src/xenconfig/xen_sxpr.h

index e9fab0a8d0aad5c64527a7c87eb6fcd261e77532..d5b4115c5aa9fbf348b9b926a8269ea912941d55 100644 (file)
@@ -3,7 +3,6 @@
 #
 
 # xenconfig/xen_sxpr.h
-xenFormatSxprChr;
 xenGetDomIdFromSxpr;
 xenGetDomIdFromSxprString;
 xenParseSxpr;
index 059bf785bb5e53199dc9f64791ea9228405faee2..41dffd605d73010f74d2da9041e34d0fca96b0cd 100644 (file)
@@ -1260,6 +1260,85 @@ xenParseConfigCommon(virConfPtr conf,
 }
 
 
+/**
+ * xenFormatSxprChr:
+ * @def: the domain config
+ * @buf: a buffer for the result S-expression
+ *
+ * Convert the character device part of the domain config into a S-expression
+ * in buf.
+ *
+ * Returns 0 in case of success, -1 in case of error
+ */
+static int
+xenFormatSxprChr(virDomainChrDefPtr def,
+                 virBufferPtr buf)
+{
+    const char *type = virDomainChrTypeToString(def->source->type);
+
+    if (!type) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "%s", _("unexpected chr device type"));
+        return -1;
+    }
+
+    switch (def->source->type) {
+    case VIR_DOMAIN_CHR_TYPE_NULL:
+    case VIR_DOMAIN_CHR_TYPE_STDIO:
+    case VIR_DOMAIN_CHR_TYPE_VC:
+    case VIR_DOMAIN_CHR_TYPE_PTY:
+        virBufferAdd(buf, type, -1);
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_FILE:
+    case VIR_DOMAIN_CHR_TYPE_PIPE:
+        virBufferAsprintf(buf, "%s:", type);
+        virBufferEscapeSexpr(buf, "%s", def->source->data.file.path);
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_DEV:
+        virBufferEscapeSexpr(buf, "%s", def->source->data.file.path);
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_TCP:
+        virBufferAsprintf(buf, "%s:%s:%s%s",
+                          (def->source->data.tcp.protocol
+                           == VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW ?
+                           "tcp" : "telnet"),
+                          NULLSTR_EMPTY(def->source->data.tcp.host),
+                          NULLSTR_EMPTY(def->source->data.tcp.service),
+                          (def->source->data.tcp.listen ?
+                           ",server,nowait" : ""));
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_UDP:
+        virBufferAsprintf(buf, "%s:%s:%s@%s:%s", type,
+                          NULLSTR_EMPTY(def->source->data.udp.connectHost),
+                          NULLSTR_EMPTY(def->source->data.udp.connectService),
+                          NULLSTR_EMPTY(def->source->data.udp.bindHost),
+                          NULLSTR_EMPTY(def->source->data.udp.bindService));
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_UNIX:
+        virBufferAsprintf(buf, "%s:", type);
+        virBufferEscapeSexpr(buf, "%s", def->source->data.nix.path);
+        if (def->source->data.nix.listen)
+            virBufferAddLit(buf, ",server,nowait");
+        break;
+
+    default:
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("unsupported chr device type '%s'"), type);
+        return -1;
+    }
+
+    if (virBufferCheckError(buf) < 0)
+        return -1;
+
+    return 0;
+}
+
+
 static int
 xenFormatSerial(virConfValuePtr list, virDomainChrDefPtr serial)
 {
index 3a1c912963d8c74f3854e7c1f01c6f638a02aa31..a9a420ac3ac7445977216f78367af55a82744425 100644 (file)
@@ -1491,81 +1491,3 @@ xenParseSxprString(const char *sexpr,
 
     return def;
 }
-
-/**
- * xenFormatSxprChr:
- * @def: the domain config
- * @buf: a buffer for the result S-expression
- *
- * Convert the character device part of the domain config into a S-expression
- * in buf.
- *
- * Returns 0 in case of success, -1 in case of error
- */
-int
-xenFormatSxprChr(virDomainChrDefPtr def,
-                 virBufferPtr buf)
-{
-    const char *type = virDomainChrTypeToString(def->source->type);
-
-    if (!type) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "%s", _("unexpected chr device type"));
-        return -1;
-    }
-
-    switch (def->source->type) {
-    case VIR_DOMAIN_CHR_TYPE_NULL:
-    case VIR_DOMAIN_CHR_TYPE_STDIO:
-    case VIR_DOMAIN_CHR_TYPE_VC:
-    case VIR_DOMAIN_CHR_TYPE_PTY:
-        virBufferAdd(buf, type, -1);
-        break;
-
-    case VIR_DOMAIN_CHR_TYPE_FILE:
-    case VIR_DOMAIN_CHR_TYPE_PIPE:
-        virBufferAsprintf(buf, "%s:", type);
-        virBufferEscapeSexpr(buf, "%s", def->source->data.file.path);
-        break;
-
-    case VIR_DOMAIN_CHR_TYPE_DEV:
-        virBufferEscapeSexpr(buf, "%s", def->source->data.file.path);
-        break;
-
-    case VIR_DOMAIN_CHR_TYPE_TCP:
-        virBufferAsprintf(buf, "%s:%s:%s%s",
-                          (def->source->data.tcp.protocol
-                           == VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW ?
-                           "tcp" : "telnet"),
-                          NULLSTR_EMPTY(def->source->data.tcp.host),
-                          NULLSTR_EMPTY(def->source->data.tcp.service),
-                          (def->source->data.tcp.listen ?
-                           ",server,nowait" : ""));
-        break;
-
-    case VIR_DOMAIN_CHR_TYPE_UDP:
-        virBufferAsprintf(buf, "%s:%s:%s@%s:%s", type,
-                          NULLSTR_EMPTY(def->source->data.udp.connectHost),
-                          NULLSTR_EMPTY(def->source->data.udp.connectService),
-                          NULLSTR_EMPTY(def->source->data.udp.bindHost),
-                          NULLSTR_EMPTY(def->source->data.udp.bindService));
-        break;
-
-    case VIR_DOMAIN_CHR_TYPE_UNIX:
-        virBufferAsprintf(buf, "%s:", type);
-        virBufferEscapeSexpr(buf, "%s", def->source->data.nix.path);
-        if (def->source->data.nix.listen)
-            virBufferAddLit(buf, ",server,nowait");
-        break;
-
-    default:
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unsupported chr device type '%s'"), type);
-        return -1;
-    }
-
-    if (virBufferCheckError(buf) < 0)
-        return -1;
-
-    return 0;
-}
index 7f66af64059322546e975c8f465f07037121f858..c888d069503fcc28200cd3a75b219595125814b8 100644 (file)
@@ -49,5 +49,3 @@ int xenParseSxprSound(virDomainDefPtr def, const char *str);
 virDomainChrDefPtr xenParseSxprChar(const char *value, const char *tty);
 
 int xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec);
-
-int xenFormatSxprChr(virDomainChrDefPtr def, virBufferPtr buf);