static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,

                                    bool last_stage)

{

    int pages = -1;

    uint64_t bytes_xmit = 0;

    uint8_t *p;

    int ret, blen;

    RAMBlock *block = pss->block;

    ram_addr_t offset = pss->page << TARGET_PAGE_BITS;



    p = block->host + offset;



    ret = ram_control_save_page(rs->f, block->offset,

                                offset, TARGET_PAGE_SIZE, &bytes_xmit);

    if (bytes_xmit) {

        rs->bytes_transferred += bytes_xmit;

        pages = 1;

    }

    if (ret != RAM_SAVE_CONTROL_NOT_SUPP) {

        if (ret != RAM_SAVE_CONTROL_DELAYED) {

            if (bytes_xmit > 0) {

                rs->norm_pages++;

            } else if (bytes_xmit == 0) {

                rs->zero_pages++;

            }

        }

    } else {

        /* When starting the process of a new block, the first page of

         * the block should be sent out before other pages in the same

         * block, and all the pages in last block should have been sent

         * out, keeping this order is important, because the 'cont' flag

         * is used to avoid resending the block name.

         */

        if (block != rs->last_sent_block) {

            flush_compressed_data(rs);

            pages = save_zero_page(rs, block, offset, p);

            if (pages == -1) {

                /* Make sure the first page is sent out before other pages */

                bytes_xmit = save_page_header(rs, block, offset |

                                              RAM_SAVE_FLAG_COMPRESS_PAGE);

                blen = qemu_put_compression_data(rs->f, p, TARGET_PAGE_SIZE,

                                                 migrate_compress_level());

                if (blen > 0) {

                    rs->bytes_transferred += bytes_xmit + blen;

                    rs->norm_pages++;

                    pages = 1;

                } else {

                    qemu_file_set_error(rs->f, blen);

                    error_report("compressed data failed!");

                }

            }

            if (pages > 0) {

                ram_release_pages(block->idstr, offset, pages);

            }

        } else {

            pages = save_zero_page(rs, block, offset, p);

            if (pages == -1) {

                pages = compress_page_with_multi_thread(rs, block, offset);

            } else {

                ram_release_pages(block->idstr, offset, pages);

            }

        }

    }



    return pages;

}

static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,

                                    bool last_stage)

{

    int pages = -1;

    uint64_t bytes_xmit = 0;

    uint8_t *p;

    int ret, blen;

    RAMBlock *block = pss->block;

    ram_addr_t offset = pss->page << TARGET_PAGE_BITS;



    p = block->host + offset;



    ret = ram_control_save_page(rs->f, block->offset,

                                offset, TARGET_PAGE_SIZE, &bytes_xmit);

    if (bytes_xmit) {

        rs->bytes_transferred += bytes_xmit;

        pages = 1;

    }

    if (ret != RAM_SAVE_CONTROL_NOT_SUPP) {

        if (ret != RAM_SAVE_CONTROL_DELAYED) {

            if (bytes_xmit > 0) {

                rs->norm_pages++;

            } else if (bytes_xmit == 0) {

                rs->zero_pages++;

            }

        }

    } else {

        











        if (block != rs->last_sent_block) {

            flush_compressed_data(rs);

            pages = save_zero_page(rs, block, offset, p);

            if (pages == -1) {

                

                bytes_xmit = save_page_header(rs, block, offset |

                                              RAM_SAVE_FLAG_COMPRESS_PAGE);

                blen = qemu_put_compression_data(rs->f, p, TARGET_PAGE_SIZE,

                                                 migrate_compress_level());

                if (blen > 0) {

                    rs->bytes_transferred += bytes_xmit + blen;

                    rs->norm_pages++;

                    pages = 1;

                } else {

                    qemu_file_set_error(rs->f, blen);

                    error_report("compressed data failed!");

                }

            }

            if (pages > 0) {

                ram_release_pages(block->idstr, offset, pages);

            }

        } else {

            pages = save_zero_page(rs, block, offset, p);

            if (pages == -1) {

                pages = compress_page_with_multi_thread(rs, block, offset);

            } else {

                ram_release_pages(block->idstr, offset, pages);

            }

        }

    }



    return pages;

}

                bytes_xmit = save_page_header(rs, block, offset |
static int FUNC_0(RAMState *VAR_0, PageSearchStatus *VAR_1,

                                    bool VAR_2)

{

    int VAR_3 = -1;

    uint64_t bytes_xmit = 0;

    uint8_t *p;

    int VAR_4, VAR_5;

    RAMBlock *block = VAR_1->block;

    ram_addr_t offset = VAR_1->page << TARGET_PAGE_BITS;



    p = block->host + offset;



    VAR_4 = ram_control_save_page(VAR_0->f, block->offset,

                                offset, TARGET_PAGE_SIZE, &bytes_xmit);

    if (bytes_xmit) {

        VAR_0->bytes_transferred += bytes_xmit;

        VAR_3 = 1;

    }

    if (VAR_4 != RAM_SAVE_CONTROL_NOT_SUPP) {

        if (VAR_4 != RAM_SAVE_CONTROL_DELAYED) {

            if (bytes_xmit > 0) {

                VAR_0->norm_pages++;

            } else if (bytes_xmit == 0) {

                VAR_0->zero_pages++;

            }

        }

    } else {

        











        if (block != VAR_0->last_sent_block) {

            flush_compressed_data(VAR_0);

            VAR_3 = save_zero_page(VAR_0, block, offset, p);

            if (VAR_3 == -1) {

                

                bytes_xmit = save_page_header(VAR_0, block, offset |

                                              RAM_SAVE_FLAG_COMPRESS_PAGE);

                VAR_5 = qemu_put_compression_data(VAR_0->f, p, TARGET_PAGE_SIZE,

                                                 migrate_compress_level());

                if (VAR_5 > 0) {

                    VAR_0->bytes_transferred += bytes_xmit + VAR_5;

                    VAR_0->norm_pages++;

                    VAR_3 = 1;

                } else {

                    qemu_file_set_error(VAR_0->f, VAR_5);

                    error_report("compressed data failed!");

                }

            }

            if (VAR_3 > 0) {

                ram_release_pages(block->idstr, offset, VAR_3);

            }

        } else {

            VAR_3 = save_zero_page(VAR_0, block, offset, p);

            if (VAR_3 == -1) {

                VAR_3 = compress_page_with_multi_thread(VAR_0, block, offset);

            } else {

                ram_release_pages(block->idstr, offset, VAR_3);

            }

        }

    }



    return VAR_3;

}

static int FUNC_0(RAMState *VAR_0, PageSearchStatus *VAR_1,
bool VAR_2)
{ int VAR_3 = -1; uint64_t bytes_xmit = 0; uint8_t *p; int VAR_4, VAR_5; RAMBlock *block = VAR_1->block; ram_addr_t offset = VAR_1->page << TARGET_PAGE_BITS; p = block->host + offset; VAR_4 = ram_control_save_page(VAR_0->f, block->offset,
offset, TARGET_PAGE_SIZE, &bytes_xmit); if (bytes_xmit) { VAR_0->bytes_transferred += bytes_xmit; VAR_3 = 1; } if (VAR_4 != RAM_SAVE_CONTROL_NOT_SUPP) { if (VAR_4 != RAM_SAVE_CONTROL_DELAYED) { if (bytes_xmit > 0) { VAR_0->norm_pages++; } else if (bytes_xmit == 0) { VAR_0->zero_pages++; } } } else { if (block != VAR_0->last_sent_block) { flush_compressed_data(VAR_0); VAR_3 = save_zero_page(VAR_0, block, offset, p); if (VAR_3 == -1) { bytes_xmit = save_page_header(VAR_0, block, offset |
RAM_SAVE_FLAG_COMPRESS_PAGE); VAR_5 = qemu_put_compression_data(VAR_0->f, p, TARGET_PAGE_SIZE,
migrate_compress_level()); if (VAR_5 > 0) { VAR_0->bytes_transferred += bytes_xmit + VAR_5; VAR_0->norm_pages++; VAR_3 = 1; } else { qemu_file_set_error(VAR_0->f, VAR_5); error_report("compressed data failed!"); } } if (VAR_3 > 0) { ram_release_pages(block->idstr, offset, VAR_3); } } else { VAR_3 = save_zero_page(VAR_0, block, offset, p); if (VAR_3 == -1) { VAR_3 = compress_page_with_multi_thread(VAR_0, block, offset); } else { ram_release_pages(block->idstr, offset, VAR_3); } } } return VAR_3; }