static int blk_mig_save_bulked_block(QEMUFile *f)

{

    int64_t completed_sector_sum = 0;

    BlkMigDevState *bmds;

    int progress;

    int ret = 0;



    QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {

        if (bmds->bulk_completed == 0) {

            if (mig_save_device_bulk(f, bmds) == 1) {

                /* completed bulk section for this device */

                bmds->bulk_completed = 1;

            }

            completed_sector_sum += bmds->completed_sectors;

            ret = 1;

            break;

        } else {

            completed_sector_sum += bmds->completed_sectors;

        }

    }



    if (block_mig_state.total_sector_sum != 0) {

        progress = completed_sector_sum * 100 /

                   block_mig_state.total_sector_sum;

    } else {

        progress = 100;

    }

    if (progress != block_mig_state.prev_progress) {

        block_mig_state.prev_progress = progress;

        qemu_put_be64(f, (progress << BDRV_SECTOR_BITS)

                         | BLK_MIG_FLAG_PROGRESS);

        DPRINTF("Completed %d %%\r", progress);

    }



    return ret;

}

static int blk_mig_save_bulked_block(QEMUFile *f)

{

    int64_t completed_sector_sum = 0;

    BlkMigDevState *bmds;

    int progress;

    int ret = 0;



    QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {

        if (bmds->bulk_completed == 0) {

            if (mig_save_device_bulk(f, bmds) == 1) {

                

                bmds->bulk_completed = 1;

            }

            completed_sector_sum += bmds->completed_sectors;

            ret = 1;

            break;

        } else {

            completed_sector_sum += bmds->completed_sectors;

        }

    }



    if (block_mig_state.total_sector_sum != 0) {

        progress = completed_sector_sum * 100 /

                   block_mig_state.total_sector_sum;

    } else {

        progress = 100;

    }

    if (progress != block_mig_state.prev_progress) {

        block_mig_state.prev_progress = progress;

        qemu_put_be64(f, (progress << BDRV_SECTOR_BITS)

                         | BLK_MIG_FLAG_PROGRESS);

        DPRINTF("Completed %d %%\r", progress);

    }



    return ret;

}

static int FUNC_0(QEMUFile *VAR_0)

{

    int64_t completed_sector_sum = 0;

    BlkMigDevState *bmds;

    int VAR_1;

    int VAR_2 = 0;



    QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {

        if (bmds->bulk_completed == 0) {

            if (mig_save_device_bulk(VAR_0, bmds) == 1) {

                

                bmds->bulk_completed = 1;

            }

            completed_sector_sum += bmds->completed_sectors;

            VAR_2 = 1;

            break;

        } else {

            completed_sector_sum += bmds->completed_sectors;

        }

    }



    if (block_mig_state.total_sector_sum != 0) {

        VAR_1 = completed_sector_sum * 100 /

                   block_mig_state.total_sector_sum;

    } else {

        VAR_1 = 100;

    }

    if (VAR_1 != block_mig_state.prev_progress) {

        block_mig_state.prev_progress = VAR_1;

        qemu_put_be64(VAR_0, (VAR_1 << BDRV_SECTOR_BITS)

                         | BLK_MIG_FLAG_PROGRESS);

        DPRINTF("Completed %d %%\r", VAR_1);

    }



    return VAR_2;

}

static int FUNC_0(QEMUFile *VAR_0)
{ int64_t completed_sector_sum = 0; BlkMigDevState *bmds; int VAR_1; int VAR_2 = 0; QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { if (bmds->bulk_completed == 0) { if (mig_save_device_bulk(VAR_0, bmds) == 1) { bmds->bulk_completed = 1; } completed_sector_sum += bmds->completed_sectors; VAR_2 = 1; break; } else { completed_sector_sum += bmds->completed_sectors; } } if (block_mig_state.total_sector_sum != 0) { VAR_1 = completed_sector_sum * 100 /
block_mig_state.total_sector_sum; } else { VAR_1 = 100; } if (VAR_1 != block_mig_state.prev_progress) { block_mig_state.prev_progress = VAR_1; qemu_put_be64(VAR_0, (VAR_1 << BDRV_SECTOR_BITS)
| BLK_MIG_FLAG_PROGRESS); DPRINTF("Completed %d %%\r", VAR_1); } return VAR_2; }