static int colo_do_checkpoint_transaction(MigrationState *s,

                                          QIOChannelBuffer *bioc,

                                          QEMUFile *fb)

{

    Error *local_err = NULL;

    int ret = -1;



    colo_send_message(s->to_dst_file, COLO_MESSAGE_CHECKPOINT_REQUEST,

                      &local_err);

    if (local_err) {





    colo_receive_check_message(s->rp_state.from_dst_file,

                    COLO_MESSAGE_CHECKPOINT_REPLY, &local_err);

    if (local_err) {



    /* Reset channel-buffer directly */

    qio_channel_io_seek(QIO_CHANNEL(bioc), 0, 0, NULL);

    bioc->usage = 0;



    qemu_mutex_lock_iothread();





    vm_stop_force_state(RUN_STATE_COLO);


    trace_colo_vm_state_change("run", "stop");










    /* Disable block migration */

    s->params.blk = 0;

    s->params.shared = 0;

    qemu_savevm_state_header(fb);

    qemu_savevm_state_begin(fb, &s->params);

    qemu_mutex_lock_iothread();

    qemu_savevm_state_complete_precopy(fb, false);




    qemu_fflush(fb);



    colo_send_message(s->to_dst_file, COLO_MESSAGE_VMSTATE_SEND, &local_err);

    if (local_err) {




     * We need the size of the VMstate data in Secondary side,

     * With which we can decide how much data should be read.


    colo_send_message_value(s->to_dst_file, COLO_MESSAGE_VMSTATE_SIZE,

                            bioc->usage, &local_err);

    if (local_err) {





    qemu_put_buffer(s->to_dst_file, bioc->data, bioc->usage);

    qemu_fflush(s->to_dst_file);

    ret = qemu_file_get_error(s->to_dst_file);

    if (ret < 0) {





    colo_receive_check_message(s->rp_state.from_dst_file,

                       COLO_MESSAGE_VMSTATE_RECEIVED, &local_err);

    if (local_err) {





    colo_receive_check_message(s->rp_state.from_dst_file,

                       COLO_MESSAGE_VMSTATE_LOADED, &local_err);

    if (local_err) {





    ret = 0;



    qemu_mutex_lock_iothread();

    vm_start();


    trace_colo_vm_state_change("stop", "run");



out:

    if (local_err) {

        error_report_err(local_err);


    return ret;

static int colo_do_checkpoint_transaction(MigrationState *s,

                                          QIOChannelBuffer *bioc,

                                          QEMUFile *fb)

{

    Error *local_err = NULL;

    int ret = -1;



    colo_send_message(s->to_dst_file, COLO_MESSAGE_CHECKPOINT_REQUEST,

                      &local_err);

    if (local_err) {





    colo_receive_check_message(s->rp_state.from_dst_file,

                    COLO_MESSAGE_CHECKPOINT_REPLY, &local_err);

    if (local_err) {



    

    qio_channel_io_seek(QIO_CHANNEL(bioc), 0, 0, NULL);

    bioc->usage = 0;



    qemu_mutex_lock_iothread();





    vm_stop_force_state(RUN_STATE_COLO);


    trace_colo_vm_state_change("run", "stop");










    

    s->params.blk = 0;

    s->params.shared = 0;

    qemu_savevm_state_header(fb);

    qemu_savevm_state_begin(fb, &s->params);

    qemu_mutex_lock_iothread();

    qemu_savevm_state_complete_precopy(fb, false);




    qemu_fflush(fb);



    colo_send_message(s->to_dst_file, COLO_MESSAGE_VMSTATE_SEND, &local_err);

    if (local_err) {




     * We need the size of the VMstate data in Secondary side,

     * With which we can decide how much data should be read.


    colo_send_message_value(s->to_dst_file, COLO_MESSAGE_VMSTATE_SIZE,

                            bioc->usage, &local_err);

    if (local_err) {





    qemu_put_buffer(s->to_dst_file, bioc->data, bioc->usage);

    qemu_fflush(s->to_dst_file);

    ret = qemu_file_get_error(s->to_dst_file);

    if (ret < 0) {





    colo_receive_check_message(s->rp_state.from_dst_file,

                       COLO_MESSAGE_VMSTATE_RECEIVED, &local_err);

    if (local_err) {





    colo_receive_check_message(s->rp_state.from_dst_file,

                       COLO_MESSAGE_VMSTATE_LOADED, &local_err);

    if (local_err) {





    ret = 0;



    qemu_mutex_lock_iothread();

    vm_start();


    trace_colo_vm_state_change("stop", "run");



out:

    if (local_err) {

        error_report_err(local_err);


    return ret;

static int FUNC_0(MigrationState *VAR_0,

                                          QIOChannelBuffer *VAR_1,

                                          QEMUFile *VAR_2)

{

    Error *local_err = NULL;

    int VAR_3 = -1;



    colo_send_message(VAR_0->to_dst_file, COLO_MESSAGE_CHECKPOINT_REQUEST,

                      &local_err);

    if (local_err) {





    colo_receive_check_message(VAR_0->rp_state.from_dst_file,

                    COLO_MESSAGE_CHECKPOINT_REPLY, &local_err);

    if (local_err) {



    

    qio_channel_io_seek(QIO_CHANNEL(VAR_1), 0, 0, NULL);

    VAR_1->usage = 0;



    qemu_mutex_lock_iothread();





    vm_stop_force_state(RUN_STATE_COLO);


    trace_colo_vm_state_change("run", "stop");










    

    VAR_0->params.blk = 0;

    VAR_0->params.shared = 0;

    qemu_savevm_state_header(VAR_2);

    qemu_savevm_state_begin(VAR_2, &VAR_0->params);

    qemu_mutex_lock_iothread();

    qemu_savevm_state_complete_precopy(VAR_2, false);




    qemu_fflush(VAR_2);



    colo_send_message(VAR_0->to_dst_file, COLO_MESSAGE_VMSTATE_SEND, &local_err);

    if (local_err) {




     * We need the size of the VMstate data in Secondary side,

     * With which we can decide how much data should be read.


    colo_send_message_value(VAR_0->to_dst_file, COLO_MESSAGE_VMSTATE_SIZE,

                            VAR_1->usage, &local_err);

    if (local_err) {





    qemu_put_buffer(VAR_0->to_dst_file, VAR_1->data, VAR_1->usage);

    qemu_fflush(VAR_0->to_dst_file);

    VAR_3 = qemu_file_get_error(VAR_0->to_dst_file);

    if (VAR_3 < 0) {





    colo_receive_check_message(VAR_0->rp_state.from_dst_file,

                       COLO_MESSAGE_VMSTATE_RECEIVED, &local_err);

    if (local_err) {





    colo_receive_check_message(VAR_0->rp_state.from_dst_file,

                       COLO_MESSAGE_VMSTATE_LOADED, &local_err);

    if (local_err) {





    VAR_3 = 0;



    qemu_mutex_lock_iothread();

    vm_start();


    trace_colo_vm_state_change("stop", "run");



out:

    if (local_err) {

        error_report_err(local_err);


    return VAR_3;

static int FUNC_0(MigrationState *VAR_0,
QIOChannelBuffer *VAR_1,
QEMUFile *VAR_2)
{ Error *local_err = NULL; int VAR_3 = -1; colo_send_message(VAR_0->to_dst_file, COLO_MESSAGE_CHECKPOINT_REQUEST,
&local_err); if (local_err) { colo_receive_check_message(VAR_0->rp_state.from_dst_file,
COLO_MESSAGE_CHECKPOINT_REPLY, &local_err); if (local_err) { qio_channel_io_seek(QIO_CHANNEL(VAR_1), 0, 0, NULL); VAR_1->usage = 0; qemu_mutex_lock_iothread(); vm_stop_force_state(RUN_STATE_COLO); trace_colo_vm_state_change("run", "stop"); VAR_0->params.blk = 0; VAR_0->params.shared = 0; qemu_savevm_state_header(VAR_2); qemu_savevm_state_begin(VAR_2, &VAR_0->params); qemu_mutex_lock_iothread(); qemu_savevm_state_complete_precopy(VAR_2, false); qemu_fflush(VAR_2); colo_send_message(VAR_0->to_dst_file, COLO_MESSAGE_VMSTATE_SEND, &local_err); if (local_err) { * We need the size of the VMstate data in Secondary side,
* With which we can decide how much data should be read.
colo_send_message_value(VAR_0->to_dst_file, COLO_MESSAGE_VMSTATE_SIZE,
VAR_1->usage, &local_err); if (local_err) { qemu_put_buffer(VAR_0->to_dst_file, VAR_1->data, VAR_1->usage); qemu_fflush(VAR_0->to_dst_file); VAR_3 = qemu_file_get_error(VAR_0->to_dst_file); if (VAR_3 < 0) { colo_receive_check_message(VAR_0->rp_state.from_dst_file,
COLO_MESSAGE_VMSTATE_RECEIVED, &local_err); if (local_err) { colo_receive_check_message(VAR_0->rp_state.from_dst_file,
COLO_MESSAGE_VMSTATE_LOADED, &local_err); if (local_err) { VAR_3 = 0; qemu_mutex_lock_iothread(); vm_start(); trace_colo_vm_state_change("stop", "run"); out:
if (local_err) { error_report_err(local_err); return VAR_3;