vdi: switch to *_co_* functions

Signed-off-by: Alberto Faria <afaria@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20221013123711.620631-22-pbonzini@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Alberto Faria 2022-10-13 14:37:08 +02:00 committed by Kevin Wolf
parent 3aba34adb1
commit 3f65302822

View File

@ -663,7 +663,8 @@ vdi_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
* so this full-cluster write does not overlap a partial write * so this full-cluster write does not overlap a partial write
* of the same cluster, issued from the "else" branch. * of the same cluster, issued from the "else" branch.
*/ */
ret = bdrv_pwrite(bs->file, data_offset, s->block_size, block, 0); ret = bdrv_co_pwrite(bs->file, data_offset, s->block_size, block,
0);
qemu_co_rwlock_unlock(&s->bmap_lock); qemu_co_rwlock_unlock(&s->bmap_lock);
} else { } else {
nonallocating_write: nonallocating_write:
@ -708,7 +709,7 @@ nonallocating_write:
assert(VDI_IS_ALLOCATED(bmap_first)); assert(VDI_IS_ALLOCATED(bmap_first));
*header = s->header; *header = s->header;
vdi_header_to_le(header); vdi_header_to_le(header);
ret = bdrv_pwrite(bs->file, 0, sizeof(*header), header, 0); ret = bdrv_co_pwrite(bs->file, 0, sizeof(*header), header, 0);
g_free(header); g_free(header);
if (ret < 0) { if (ret < 0) {
@ -725,7 +726,7 @@ nonallocating_write:
base = ((uint8_t *)&s->bmap[0]) + bmap_first * SECTOR_SIZE; base = ((uint8_t *)&s->bmap[0]) + bmap_first * SECTOR_SIZE;
logout("will write %u block map sectors starting from entry %u\n", logout("will write %u block map sectors starting from entry %u\n",
n_sectors, bmap_first); n_sectors, bmap_first);
ret = bdrv_pwrite(bs->file, offset * SECTOR_SIZE, ret = bdrv_co_pwrite(bs->file, offset * SECTOR_SIZE,
n_sectors * SECTOR_SIZE, base, 0); n_sectors * SECTOR_SIZE, base, 0);
} }
@ -844,7 +845,7 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,
vdi_header_print(&header); vdi_header_print(&header);
} }
vdi_header_to_le(&header); vdi_header_to_le(&header);
ret = blk_pwrite(blk, offset, sizeof(header), &header, 0); ret = blk_co_pwrite(blk, offset, sizeof(header), &header, 0);
if (ret < 0) { if (ret < 0) {
error_setg(errp, "Error writing header"); error_setg(errp, "Error writing header");
goto exit; goto exit;
@ -865,7 +866,7 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,
bmap[i] = VDI_UNALLOCATED; bmap[i] = VDI_UNALLOCATED;
} }
} }
ret = blk_pwrite(blk, offset, bmap_size, bmap, 0); ret = blk_co_pwrite(blk, offset, bmap_size, bmap, 0);
if (ret < 0) { if (ret < 0) {
error_setg(errp, "Error writing bmap"); error_setg(errp, "Error writing bmap");
goto exit; goto exit;
@ -874,7 +875,7 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,
} }
if (image_type == VDI_TYPE_STATIC) { if (image_type == VDI_TYPE_STATIC) {
ret = blk_truncate(blk, offset + blocks * block_size, false, ret = blk_co_truncate(blk, offset + blocks * block_size, false,
PREALLOC_MODE_OFF, 0, errp); PREALLOC_MODE_OFF, 0, errp);
if (ret < 0) { if (ret < 0) {
error_prepend(errp, "Failed to statically allocate file"); error_prepend(errp, "Failed to statically allocate file");