Diff for /qemu/block.c between versions 1.1.1.10 and 1.1.1.12

version 1.1.1.10, 2018/04/24 17:06:50 version 1.1.1.12, 2018/04/24 17:16:37
Line 533  static int bdrv_check_byte_request(Block Line 533  static int bdrv_check_byte_request(Block
   
     len = bdrv_getlength(bs);      len = bdrv_getlength(bs);
   
     if ((offset + size) > len)      if (offset < 0)
           return -EIO;
   
       if ((offset > len) || (len - offset < size))
         return -EIO;          return -EIO;
   
     return 0;      return 0;
Line 1170  int bdrv_write_compressed(BlockDriverSta Line 1173  int bdrv_write_compressed(BlockDriverSta
         return -ENOMEDIUM;          return -ENOMEDIUM;
     if (!drv->bdrv_write_compressed)      if (!drv->bdrv_write_compressed)
         return -ENOTSUP;          return -ENOTSUP;
       if (bdrv_check_request(bs, sector_num, nb_sectors))
           return -EIO;
     return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors);      return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors);
 }  }
   
Line 1327  char *bdrv_snapshot_dump(char *buf, int  Line 1332  char *bdrv_snapshot_dump(char *buf, int 
 /**************************************************************/  /**************************************************************/
 /* async I/Os */  /* async I/Os */
   
 typedef struct VectorTranslationState {  typedef struct VectorTranslationAIOCB {
       BlockDriverAIOCB common;
     QEMUIOVector *iov;      QEMUIOVector *iov;
     uint8_t *bounce;      uint8_t *bounce;
     int is_write;      int is_write;
     BlockDriverAIOCB *aiocb;      BlockDriverAIOCB *aiocb;
     BlockDriverAIOCB *this_aiocb;  } VectorTranslationAIOCB;
 } VectorTranslationState;  
   
 static void bdrv_aio_cancel_vector(BlockDriverAIOCB *acb)  static void bdrv_aio_cancel_vector(BlockDriverAIOCB *_acb)
 {  {
     VectorTranslationState *s = acb->opaque;      VectorTranslationAIOCB *acb
           = container_of(_acb, VectorTranslationAIOCB, common);
   
     bdrv_aio_cancel(s->aiocb);      bdrv_aio_cancel(acb->aiocb);
 }  }
   
 static void bdrv_aio_rw_vector_cb(void *opaque, int ret)  static void bdrv_aio_rw_vector_cb(void *opaque, int ret)
 {  {
     VectorTranslationState *s = opaque;      VectorTranslationAIOCB *s = (VectorTranslationAIOCB *)opaque;
   
     if (!s->is_write) {      if (!s->is_write) {
         qemu_iovec_from_buffer(s->iov, s->bounce, s->iov->size);          qemu_iovec_from_buffer(s->iov, s->bounce, s->iov->size);
     }      }
     qemu_vfree(s->bounce);      qemu_vfree(s->bounce);
     s->this_aiocb->cb(s->this_aiocb->opaque, ret);      s->common.cb(s->common.opaque, ret);
     qemu_aio_release(s->this_aiocb);      qemu_aio_release(s);
 }  }
   
 static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs,  static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs,
Line 1363  static BlockDriverAIOCB *bdrv_aio_rw_vec Line 1369  static BlockDriverAIOCB *bdrv_aio_rw_vec
                                             int is_write)                                              int is_write)
   
 {  {
     VectorTranslationState *s = qemu_mallocz(sizeof(*s));      VectorTranslationAIOCB *s = qemu_aio_get_pool(&vectored_aio_pool, bs,
     BlockDriverAIOCB *aiocb = qemu_aio_get_pool(&vectored_aio_pool, bs,                                                    cb, opaque);
                                                 cb, opaque);  
   
     s->this_aiocb = aiocb;  
     s->iov = iov;      s->iov = iov;
     s->bounce = qemu_memalign(512, nb_sectors * 512);      s->bounce = qemu_memalign(512, nb_sectors * 512);
     s->is_write = is_write;      s->is_write = is_write;
Line 1379  static BlockDriverAIOCB *bdrv_aio_rw_vec Line 1383  static BlockDriverAIOCB *bdrv_aio_rw_vec
         s->aiocb = bdrv_aio_read(bs, sector_num, s->bounce, nb_sectors,          s->aiocb = bdrv_aio_read(bs, sector_num, s->bounce, nb_sectors,
                                  bdrv_aio_rw_vector_cb, s);                                   bdrv_aio_rw_vector_cb, s);
     }      }
     return aiocb;      if (!s->aiocb) {
           qemu_vfree(s->bounce);
           qemu_aio_release(s);
           return NULL;
       }
       return &s->common;
 }  }
   
 BlockDriverAIOCB *bdrv_aio_readv(BlockDriverState *bs, int64_t sector_num,  BlockDriverAIOCB *bdrv_aio_readv(BlockDriverState *bs, int64_t sector_num,
Line 1555  static int bdrv_write_em(BlockDriverStat Line 1564  static int bdrv_write_em(BlockDriverStat
   
 void bdrv_init(void)  void bdrv_init(void)
 {  {
     aio_pool_init(&vectored_aio_pool, sizeof(BlockDriverAIOCB),      aio_pool_init(&vectored_aio_pool, sizeof(VectorTranslationAIOCB),
                   bdrv_aio_cancel_vector);                    bdrv_aio_cancel_vector);
   
     bdrv_register(&bdrv_raw);      bdrv_register(&bdrv_raw);

Removed from v.1.1.1.10  
changed lines
  Added in v.1.1.1.12


unix.superglobalmegacorp.com