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

Re: [Libguestfs] [PATCH] daemon: lvm: change the separator character to '\r'



On Tue, Jul 26, 2016 at 03:24:08PM +0200, Pino Toscano wrote:
> Commit b91b39e06ab7eb9b9b06c8b4dfef2ef9f381ab19 changed the separator to
> ':', although this creates parsing issues when there are fields with
> colons (for example lv_tags=imgbased:pool).
> 
> Change once more the separator, but this time using a non-printable
> character such as '\r': while it will produce uglier debug logs, this
> should greatly reduce the possibilities of conflicts with texts of
> metadata.
> ---
>  generator/daemon.ml | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/generator/daemon.ml b/generator/daemon.ml
> index d8dc9cf..1d79126 100644
> --- a/generator/daemon.ml
> +++ b/generator/daemon.ml
> @@ -563,7 +563,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, '\\r');\n";
>              pr "  if (*p) next = p+1; else next = NULL;\n";
>              pr "  *p = '\\0';\n";
>              (match coltype with
> @@ -633,7 +633,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\", \"\\r\", \"--units\", \"b\", NULL);\n";
>          pr "  if (r == -1) {\n";
>          pr "    reply_with_error (\"%%s\", err);\n";
>          pr "    free (out);\n";

Slightly surprised this works, but yes, ACK :-)

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v


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