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

Re: [Xen-devel] [PATCH 1 of 3 V3] tools/libxc: Remus Checkpoint Compression



On Fri, Oct 14, 2011 at 12:47 AM,  <rshriram@xxxxxxxxx> wrote:

> diff -r 4b0907c6a08c -r 47fdd52af616 tools/libxc/xc_domain_save.c
> --- a/tools/libxc/xc_domain_save.c      Tue Oct 11 12:02:58 2011 +0100
> +++ b/tools/libxc/xc_domain_save.c      Thu Oct 13 15:36:53 2011 -0700
> @@ -218,6 +218,56 @@
>         return noncached_write(xch, ob, fd, buf, len);
>  }
>
> +static int write_compressed(xc_interface *xch, comp_ctx *compress_ctx,
> +                            int dobuf, struct outbuf* ob, int fd)
> +{
> +    int rc = 0;
> +    int header = sizeof(int) + sizeof(unsigned long);
> +    int marker = XC_SAVE_ID_COMPRESSED_DATA;
> +    unsigned long compbuf_len = 0;
> +
> +    do
> +    {
> +        /* check for available space (atleast 8k) */
> +        if ((ob->pos + header + XC_PAGE_SIZE * 2) > ob->size)
> +        {
> +            if (outbuf_flush(xch, ob, fd) < 0)
> +            {
> +                ERROR("Error when flushing outbuf intermediate");
> +                return -1;
> +            }
> +        }
> +
> +        rc = xc_compression_compress_pages(xch, compress_ctx,
> +                                           ob->buf + ob->pos + header,
> +                                           ob->size - ob->pos - header,
> +                                           &compbuf_len);
> +        if (!rc)
> +            return 0;
> +
> +        if (outbuf_hardwrite(xch, ob, fd, &marker, sizeof(marker)) < 0)
> +        {
> +            PERROR("Error when writing marker (errno %d)", errno);
> +            return -1;
> +        }
> +
> +        if (outbuf_hardwrite(xch, ob, fd, &compbuf_len, sizeof(compbuf_len)) 
> < 0)
> +        {
> +            PERROR("Error when writing compbuf_len (errno %d)", errno);
> +            return -1;
> +        }
> +
> +        ob->pos += (size_t) compbuf_len;
> +        if (!dobuf && outbuf_flush(xch, ob, fd) < 0)
> +        {
> +            ERROR("Error when writing compressed chunk");
> +            return -1;
> +        }
> +    } while (rc != 0);
> +
> +    return 0;
> +}
> +
>  struct time_stats {
>     struct timeval wall;
>     long long d0_cpu, d1_cpu;
> @@ -815,11 +865,19 @@
>
>     unsigned long mfn;
>
> -    struct outbuf ob;
> +    struct outbuf ob_pagebuf, ob_tailbuf, *ob = NULL;

I think you need a comment here explaining what each of these are for.

Other than that, looks fine.

 -George

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.