[libvirt] [PATCH] OpenVZ driver: fix openvzGetVPSUUID()

Matthias Bolte matthias.bolte at googlemail.com
Fri May 27 11:51:05 UTC 2011


2011/5/27 Jean-Baptiste Rouault <jean-baptiste.rouault at diateam.net>:
> openvzGetUUID did not work since openvz_readline()
> was replaced by getline()
> ---
>  src/openvz/openvz_conf.c |   13 ++-----------
>  1 files changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
> index 2cccd81..7b939b2 100644
> --- a/src/openvz/openvz_conf.c
> +++ b/src/openvz/openvz_conf.c
> @@ -863,7 +863,6 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
>     char *conf_file;
>     char *line = NULL;
>     size_t line_size = 0;
> -    ssize_t ret;
>     char *saveptr = NULL;
>     char *uuidbuf;
>     char *iden;
> @@ -877,16 +876,8 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
>     if (fp == NULL)
>         goto cleanup;
>
> -    while (1) {
> -        ret = getline(&line, &line_size, fp);
> -        if (ret == -1)
> -            goto cleanup;
> -
> -        if (ret == 0) { /* EoF, UUID was not found */
> -            uuidstr[0] = 0;
> -            break;
> -        }
> -
> +    uuidstr[0] = 0;
> +    while (getline(&line, &line_size, fp) >= 0) {
>         iden = strtok_r(line, " ", &saveptr);
>         uuidbuf = strtok_r(NULL, "\n", &saveptr);
>

We need distinguish between getline returning -1 because of EOF and
because of another error. I missed this problem in the other
regression fix and posted a follow up patch [1] for this.

I propose the attached patch as v2 for you patch. I assume you have an
OpenVZ setup at hand, could you test this patch?

[1] https://www.redhat.com/archives/libvir-list/2011-May/msg01788.html

Matthias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-openvz-Fix-regression-in-openvzGetVPSUUID.patch
Type: text/x-patch
Size: 1536 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110527/5d2f9ab6/attachment-0001.bin>


More information about the libvir-list mailing list