Diff for /qemu/block-migration.c between versions 1.1.1.3 and 1.1.1.4

version 1.1.1.3, 2018/04/24 18:34:38 version 1.1.1.4, 2018/04/24 18:56:53
Line 62  typedef struct BlkMigBlock { Line 62  typedef struct BlkMigBlock {
     QEMUIOVector qiov;      QEMUIOVector qiov;
     BlockDriverAIOCB *aiocb;      BlockDriverAIOCB *aiocb;
     int ret;      int ret;
     int64_t time;  
     QSIMPLEQ_ENTRY(BlkMigBlock) entry;      QSIMPLEQ_ENTRY(BlkMigBlock) entry;
 } BlkMigBlock;  } BlkMigBlock;
   
Line 78  typedef struct BlkMigState { Line 77  typedef struct BlkMigState {
     int prev_progress;      int prev_progress;
     int bulk_completed;      int bulk_completed;
     long double total_time;      long double total_time;
       long double prev_time_offset;
     int reads;      int reads;
 } BlkMigState;  } BlkMigState;
   
Line 131  uint64_t blk_mig_bytes_total(void) Line 131  uint64_t blk_mig_bytes_total(void)
     return sum << BDRV_SECTOR_BITS;      return sum << BDRV_SECTOR_BITS;
 }  }
   
 static inline void add_avg_read_time(int64_t time)  
 {  
     block_mig_state.reads++;  
     block_mig_state.total_time += time;  
 }  
   
 static inline long double compute_read_bwidth(void)  static inline long double compute_read_bwidth(void)
 {  {
     assert(block_mig_state.total_time != 0);      assert(block_mig_state.total_time != 0);
     return  (block_mig_state.reads * BLOCK_SIZE)/ block_mig_state.total_time;      return (block_mig_state.reads / block_mig_state.total_time) * BLOCK_SIZE;
 }  }
   
 static int bmds_aio_inflight(BlkMigDevState *bmds, int64_t sector)  static int bmds_aio_inflight(BlkMigDevState *bmds, int64_t sector)
Line 191  static void alloc_aio_bitmap(BlkMigDevSt Line 185  static void alloc_aio_bitmap(BlkMigDevSt
   
 static void blk_mig_read_cb(void *opaque, int ret)  static void blk_mig_read_cb(void *opaque, int ret)
 {  {
       long double curr_time = qemu_get_clock_ns(rt_clock);
     BlkMigBlock *blk = opaque;      BlkMigBlock *blk = opaque;
   
     blk->ret = ret;      blk->ret = ret;
   
     blk->time = qemu_get_clock_ns(rt_clock) - blk->time;      block_mig_state.reads++;
       block_mig_state.total_time += (curr_time - block_mig_state.prev_time_offset);
     add_avg_read_time(blk->time);      block_mig_state.prev_time_offset = curr_time;
   
     QSIMPLEQ_INSERT_TAIL(&block_mig_state.blk_list, blk, entry);      QSIMPLEQ_INSERT_TAIL(&block_mig_state.blk_list, blk, entry);
     bmds_set_aio_inflight(blk->bmds, blk->sector, blk->nr_sectors, 0);      bmds_set_aio_inflight(blk->bmds, blk->sector, blk->nr_sectors, 0);
Line 250  static int mig_save_device_bulk(Monitor  Line 245  static int mig_save_device_bulk(Monitor 
     blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;      blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;
     qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);      qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);
   
     blk->time = qemu_get_clock_ns(rt_clock);      if (block_mig_state.submitted == 0) {
           block_mig_state.prev_time_offset = qemu_get_clock_ns(rt_clock);
       }
   
     blk->aiocb = bdrv_aio_readv(bs, cur_sector, &blk->qiov,      blk->aiocb = bdrv_aio_readv(bs, cur_sector, &blk->qiov,
                                 nr_sectors, blk_mig_read_cb, blk);                                  nr_sectors, blk_mig_read_cb, blk);
Line 409  static int mig_save_device_dirty(Monitor Line 406  static int mig_save_device_dirty(Monitor
                 blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;                  blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;
                 qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);                  qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);
   
                 blk->time = qemu_get_clock_ns(rt_clock);                  if (block_mig_state.submitted == 0) {
                       block_mig_state.prev_time_offset = qemu_get_clock_ns(rt_clock);
                   }
   
                 blk->aiocb = bdrv_aio_readv(bmds->bs, sector, &blk->qiov,                  blk->aiocb = bdrv_aio_readv(bmds->bs, sector, &blk->qiov,
                                             nr_sectors, blk_mig_read_cb, blk);                                              nr_sectors, blk_mig_read_cb, blk);
Line 672  static int block_load(QEMUFile *f, void  Line 671  static int block_load(QEMUFile *f, void 
                 bs_prev = bs;                  bs_prev = bs;
                 total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;                  total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
                 if (total_sectors <= 0) {                  if (total_sectors <= 0) {
                     error_report("Error getting length of block device %s\n",                      error_report("Error getting length of block device %s",
                                  device_name);                                   device_name);
                     return -EINVAL;                      return -EINVAL;
                 }                  }

Removed from v.1.1.1.3  
changed lines
  Added in v.1.1.1.4


unix.superglobalmegacorp.com