Revision f8a2e5e3

b/block/qcow.c
368 368
    return cluster_offset;
369 369
}
370 370

  
371
static int qcow_is_allocated(BlockDriverState *bs, int64_t sector_num,
372
                             int nb_sectors, int *pnum)
371
static int coroutine_fn qcow_co_is_allocated(BlockDriverState *bs,
372
        int64_t sector_num, int nb_sectors, int *pnum)
373 373
{
374 374
    BDRVQcowState *s = bs->opaque;
375 375
    int index_in_cluster, n;
376 376
    uint64_t cluster_offset;
377 377

  
378
    qemu_co_mutex_lock(&s->lock);
378 379
    cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0);
380
    qemu_co_mutex_unlock(&s->lock);
379 381
    index_in_cluster = sector_num & (s->cluster_sectors - 1);
380 382
    n = s->cluster_sectors - index_in_cluster;
381 383
    if (n > nb_sectors)
......
844 846
    .bdrv_co_readv          = qcow_co_readv,
845 847
    .bdrv_co_writev         = qcow_co_writev,
846 848
    .bdrv_co_flush_to_disk  = qcow_co_flush,
847
    .bdrv_is_allocated      = qcow_is_allocated,
849
    .bdrv_co_is_allocated   = qcow_co_is_allocated,
848 850

  
849 851
    .bdrv_set_key           = qcow_set_key,
850 852
    .bdrv_make_empty        = qcow_make_empty,
b/block/qcow2.c
344 344
    return 0;
345 345
}
346 346

  
347
static int qcow2_is_allocated(BlockDriverState *bs, int64_t sector_num,
348
                              int nb_sectors, int *pnum)
347
static int coroutine_fn qcow2_co_is_allocated(BlockDriverState *bs,
348
        int64_t sector_num, int nb_sectors, int *pnum)
349 349
{
350
    BDRVQcowState *s = bs->opaque;
350 351
    uint64_t cluster_offset;
351 352
    int ret;
352 353

  
353 354
    *pnum = nb_sectors;
354
    /* FIXME We can get errors here, but the bdrv_is_allocated interface can't
355
     * pass them on today */
355
    /* FIXME We can get errors here, but the bdrv_co_is_allocated interface
356
     * can't pass them on today */
357
    qemu_co_mutex_lock(&s->lock);
356 358
    ret = qcow2_get_cluster_offset(bs, sector_num << 9, pnum, &cluster_offset);
359
    qemu_co_mutex_unlock(&s->lock);
357 360
    if (ret < 0) {
358 361
        *pnum = 0;
359 362
    }
......
1277 1280
    .bdrv_open          = qcow2_open,
1278 1281
    .bdrv_close         = qcow2_close,
1279 1282
    .bdrv_create        = qcow2_create,
1280
    .bdrv_is_allocated  = qcow2_is_allocated,
1283
    .bdrv_co_is_allocated = qcow2_co_is_allocated,
1281 1284
    .bdrv_set_key       = qcow2_set_key,
1282 1285
    .bdrv_make_empty    = qcow2_make_empty,
1283 1286

  
b/block/vmdk.c
861 861
    return NULL;
862 862
}
863 863

  
864
static int vmdk_is_allocated(BlockDriverState *bs, int64_t sector_num,
865
                             int nb_sectors, int *pnum)
864
static int coroutine_fn vmdk_co_is_allocated(BlockDriverState *bs,
865
        int64_t sector_num, int nb_sectors, int *pnum)
866 866
{
867 867
    BDRVVmdkState *s = bs->opaque;
868 868
    int64_t index_in_cluster, n, ret;
......
873 873
    if (!extent) {
874 874
        return 0;
875 875
    }
876
    qemu_co_mutex_lock(&s->lock);
876 877
    ret = get_cluster_offset(bs, extent, NULL,
877 878
                            sector_num * 512, 0, &offset);
879
    qemu_co_mutex_unlock(&s->lock);
878 880
    /* get_cluster_offset returning 0 means success */
879 881
    ret = !ret;
880 882

  
......
1596 1598
    .bdrv_close     = vmdk_close,
1597 1599
    .bdrv_create    = vmdk_create,
1598 1600
    .bdrv_co_flush_to_disk  = vmdk_co_flush,
1599
    .bdrv_is_allocated      = vmdk_is_allocated,
1601
    .bdrv_co_is_allocated   = vmdk_co_is_allocated,
1600 1602
    .bdrv_get_allocated_file_size  = vmdk_get_allocated_file_size,
1601 1603

  
1602 1604
    .create_options = vmdk_create_options,

Also available in: Unified diff