qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Orit Wasserman <owasserm@redhat.com>
Cc: blauwirbel@gmail.com, stefanha@gmail.com, qemu-devel@nongnu.org,
	quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH v7 05/11] Add XBZRLE to ram_save_block and ram_save_live
Date: Sun, 29 Jan 2012 12:52:27 +0200	[thread overview]
Message-ID: <4F2524EB.8080305@redhat.com> (raw)
In-Reply-To: <1327587897-31192-6-git-send-email-owasserm@redhat.com>

On 01/26/2012 04:24 PM, Orit Wasserman wrote:
> Add migration state to store XBRLE params (enablement and cache size).
> In the outgoing migration check to see if the page is cached and
> changed than send compressed page by using save_xbrle_page function.
> In the incoming migration check to see if RAM_SAVE_FLAG_XBRLE is set
> and decompress the page (by using load_xbrle function).
>
> +/* XBZRLE (Xor Based Zero Length Encoding */
> +typedef struct XBZRLEHeader {
> +    uint8_t xh_flags;
> +    uint16_t xh_len;
> +    uint32_t xh_cksum;
> +} XBZRLEHeader;

__attribute__((packed))

> +
> +/* RAM Migration State */
> +typedef struct ArchMigrationState {
> +    int use_xbzrle;
> +    int64_t xbzrle_cache_size;
> +} ArchMigrationState;
> +
> +static ArchMigrationState arch_mig_state;

Strange name.

>  
> +#define ENCODING_FLAG_XBZRLE 0x1
> +
> +static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data,
> +                            ram_addr_t current_addr, RAMBlock *block,
> +                            ram_addr_t offset, int cont)
> +{

...

> +    /* Send XBZRLE based compressed page */
> +    save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_XBZRLE);
> +    qemu_put_buffer(f, (uint8_t *) &hdr, sizeof(hdr));

Or better, encode the members separately so they get proper endian encoding.

> +    qemu_put_buffer(f, encoded_buf, encoded_len);
> +    bytes_sent = encoded_len + sizeof(hdr);
> +
> +done:
> +    g_free(encoded_buf);
> +    return bytes_sent;
> +}
> +
>  static RAMBlock *last_block;
>  static ram_addr_t last_offset;
>  
>
>  
> +/*
> +  page = zrun
> +       | zrun nzrun
> +       | zrun nzrun page

This is no longer accurate.

> +
> +  zrun = length
> +
> +  nzrun = length byte...
> +
> +  length = uleb128 encoded integer
> + */
> +int encode_page(uint8_t *old_buf, uint8_t *new_buf, int slen, uint8_t *dst,
> +                int dlen)
> +{
...
> +}
> +
> +int decode_page(uint8_t *src, int slen, uint8_t *dst, int dlen)
> +{
> +    int i = 0, d = 0;
> +    uint32_t count = 0;
> +
> +    while (i < slen - 1) {
> +        /* zrun */
> +        i += uleb128_decode_small(src + i, &count);
> +        d += count;
> +
> +        /* overflow */
> +        if (d > dlen) {
> +            return -1;

assert instead?

> +        }
> +
> +        /* completed decoding */
> +        if (i == slen) {
> +            return d + 1;
> +        }
> +
> +        /* nzrun */
> +        i += uleb128_decode_small(src + i, &count);
> +        /* overflow */
> +        if (d + count > dlen) {
> +            return -1;
> +        }
> +        memcpy(dst + d, src + i, count);
> +        d += count;
> +        i += count;
> +    }
> +

memset() for the tail?

> +    return d + 1;
> +}


-- 
error compiling committee.c: too many arguments to function

  reply	other threads:[~2012-01-29 10:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-26 14:24 [Qemu-devel] [PATCH v7 00/11] XBRLE delta for live migration of large memory app Orit Wasserman
2012-01-26 14:24 ` [Qemu-devel] [PATCH v7 01/11] Add cache handling functions Orit Wasserman
2012-01-26 14:24 ` [Qemu-devel] [PATCH v7 02/11] Add uleb encoding/decoding functions Orit Wasserman
2012-01-26 14:24 ` [Qemu-devel] [PATCH v7 03/11] Add save_block_hdr function Orit Wasserman
2012-01-26 14:24 ` [Qemu-devel] [PATCH v7 04/11] Add host_from_stream_offset_versioned function Orit Wasserman
2012-01-26 14:24 ` [Qemu-devel] [PATCH v7 05/11] Add XBZRLE to ram_save_block and ram_save_live Orit Wasserman
2012-01-29 10:52   ` Avi Kivity [this message]
2012-01-26 14:24 ` [Qemu-devel] [PATCH v7 06/11] Add MigrationParams structure Orit Wasserman
2012-01-26 14:24 ` [Qemu-devel] [PATCH v7 07/11] Add XBZRLE parameters to MigrationState Orit Wasserman
2012-01-26 14:24 ` [Qemu-devel] [PATCH v7 08/11] Add migration capabilties Orit Wasserman
2012-01-26 14:24 ` [Qemu-devel] [PATCH v7 09/11] Add set_cachesize command Orit Wasserman
2012-01-26 14:24 ` [Qemu-devel] [PATCH v7 10/11] Add XBZRLE option to migrate command Orit Wasserman
2012-01-26 14:24 ` [Qemu-devel] [PATCH v7 11/11] Add XBZRLE statstics information Orit Wasserman
2012-02-24  8:33 ` [Qemu-devel] [PATCH v7 00/11] XBRLE delta for live migration of large memory app Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F2524EB.8080305@redhat.com \
    --to=avi@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=owasserm@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).