[Libguestfs] [PATCH] daemon: lvm: Change the separator character to ':'.

Richard W.M. Jones rjones at redhat.com
Tue Nov 10 12:28:31 UTC 2015


The separator character (currently comma) was picked arbitrarily to
allow us to parse the output of commands like 'lvs' for APIs such as
'lvs-full'.  Unfortunately the choice of comma conflicts with the 'lvs
-o modules' column, since the list of modules is separated by commas,
breaking our parser.

Change the separator to another arbitrary character (colon) which
hopefully is not used by any column.
---
 generator/daemon.ml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/generator/daemon.ml b/generator/daemon.ml
index a950c17..13ef350 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -561,7 +561,7 @@ cleanup_free_mountable (mountable_t *mountable)
             pr "    fprintf (stderr, \"%%s: failed: string finished early, around token %%s\\n\", __func__, \"%s\");\n" name;
             pr "    return -1;\n";
             pr "  }\n";
-            pr "  p = strchrnul (tok, ',');\n";
+            pr "  p = strchrnul (tok, ':');\n";
             pr "  if (*p) next = p+1; else next = NULL;\n";
             pr "  *p = '\\0';\n";
             (match coltype with
@@ -631,7 +631,7 @@ cleanup_free_mountable (mountable_t *mountable)
         pr "  r = command (&out, &err,\n";
         pr "	       \"lvm\", \"%ss\",\n" typ;
         pr "	       \"-o\", lvm_%s_cols, \"--unbuffered\", \"--noheadings\",\n" typ;
-        pr "	       \"--nosuffix\", \"--separator\", \",\", \"--units\", \"b\", NULL);\n";
+        pr "	       \"--nosuffix\", \"--separator\", \":\", \"--units\", \"b\", NULL);\n";
         pr "  if (r == -1) {\n";
         pr "    reply_with_error (\"%%s\", err);\n";
         pr "    free (out);\n";
-- 
2.5.0




More information about the Libguestfs mailing list