|
@@ -1440,16 +1440,16 @@ static int coroutine_fn get_whole_cluster(BlockDriverState *bs,
|
|
if (copy_from_backing) {
|
|
if (copy_from_backing) {
|
|
/* qcow2 emits this on bs->file instead of bs->backing */
|
|
/* qcow2 emits this on bs->file instead of bs->backing */
|
|
BLKDBG_EVENT(extent->file, BLKDBG_COW_READ);
|
|
BLKDBG_EVENT(extent->file, BLKDBG_COW_READ);
|
|
- ret = bdrv_pread(bs->backing, offset, skip_start_bytes,
|
|
|
|
- whole_grain, 0);
|
|
|
|
|
|
+ ret = bdrv_co_pread(bs->backing, offset, skip_start_bytes,
|
|
|
|
+ whole_grain, 0);
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
ret = VMDK_ERROR;
|
|
ret = VMDK_ERROR;
|
|
goto exit;
|
|
goto exit;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
BLKDBG_EVENT(extent->file, BLKDBG_COW_WRITE);
|
|
BLKDBG_EVENT(extent->file, BLKDBG_COW_WRITE);
|
|
- ret = bdrv_pwrite(extent->file, cluster_offset, skip_start_bytes,
|
|
|
|
- whole_grain, 0);
|
|
|
|
|
|
+ ret = bdrv_co_pwrite(extent->file, cluster_offset, skip_start_bytes,
|
|
|
|
+ whole_grain, 0);
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
ret = VMDK_ERROR;
|
|
ret = VMDK_ERROR;
|
|
goto exit;
|
|
goto exit;
|
|
@@ -1460,18 +1460,18 @@ static int coroutine_fn get_whole_cluster(BlockDriverState *bs,
|
|
if (copy_from_backing) {
|
|
if (copy_from_backing) {
|
|
/* qcow2 emits this on bs->file instead of bs->backing */
|
|
/* qcow2 emits this on bs->file instead of bs->backing */
|
|
BLKDBG_EVENT(extent->file, BLKDBG_COW_READ);
|
|
BLKDBG_EVENT(extent->file, BLKDBG_COW_READ);
|
|
- ret = bdrv_pread(bs->backing, offset + skip_end_bytes,
|
|
|
|
- cluster_bytes - skip_end_bytes,
|
|
|
|
- whole_grain + skip_end_bytes, 0);
|
|
|
|
|
|
+ ret = bdrv_co_pread(bs->backing, offset + skip_end_bytes,
|
|
|
|
+ cluster_bytes - skip_end_bytes,
|
|
|
|
+ whole_grain + skip_end_bytes, 0);
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
ret = VMDK_ERROR;
|
|
ret = VMDK_ERROR;
|
|
goto exit;
|
|
goto exit;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
BLKDBG_EVENT(extent->file, BLKDBG_COW_WRITE);
|
|
BLKDBG_EVENT(extent->file, BLKDBG_COW_WRITE);
|
|
- ret = bdrv_pwrite(extent->file, cluster_offset + skip_end_bytes,
|
|
|
|
- cluster_bytes - skip_end_bytes,
|
|
|
|
- whole_grain + skip_end_bytes, 0);
|
|
|
|
|
|
+ ret = bdrv_co_pwrite(extent->file, cluster_offset + skip_end_bytes,
|
|
|
|
+ cluster_bytes - skip_end_bytes,
|
|
|
|
+ whole_grain + skip_end_bytes, 0);
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
ret = VMDK_ERROR;
|
|
ret = VMDK_ERROR;
|
|
goto exit;
|
|
goto exit;
|
|
@@ -1490,23 +1490,23 @@ static int coroutine_fn vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data,
|
|
offset = cpu_to_le32(offset);
|
|
offset = cpu_to_le32(offset);
|
|
/* update L2 table */
|
|
/* update L2 table */
|
|
BLKDBG_EVENT(extent->file, BLKDBG_L2_UPDATE);
|
|
BLKDBG_EVENT(extent->file, BLKDBG_L2_UPDATE);
|
|
- if (bdrv_pwrite(extent->file,
|
|
|
|
- ((int64_t)m_data->l2_offset * 512)
|
|
|
|
- + (m_data->l2_index * sizeof(offset)),
|
|
|
|
- sizeof(offset), &offset, 0) < 0) {
|
|
|
|
|
|
+ if (bdrv_co_pwrite(extent->file,
|
|
|
|
+ ((int64_t)m_data->l2_offset * 512)
|
|
|
|
+ + (m_data->l2_index * sizeof(offset)),
|
|
|
|
+ sizeof(offset), &offset, 0) < 0) {
|
|
return VMDK_ERROR;
|
|
return VMDK_ERROR;
|
|
}
|
|
}
|
|
/* update backup L2 table */
|
|
/* update backup L2 table */
|
|
if (extent->l1_backup_table_offset != 0) {
|
|
if (extent->l1_backup_table_offset != 0) {
|
|
m_data->l2_offset = extent->l1_backup_table[m_data->l1_index];
|
|
m_data->l2_offset = extent->l1_backup_table[m_data->l1_index];
|
|
- if (bdrv_pwrite(extent->file,
|
|
|
|
- ((int64_t)m_data->l2_offset * 512)
|
|
|
|
- + (m_data->l2_index * sizeof(offset)),
|
|
|
|
- sizeof(offset), &offset, 0) < 0) {
|
|
|
|
|
|
+ if (bdrv_co_pwrite(extent->file,
|
|
|
|
+ ((int64_t)m_data->l2_offset * 512)
|
|
|
|
+ + (m_data->l2_index * sizeof(offset)),
|
|
|
|
+ sizeof(offset), &offset, 0) < 0) {
|
|
return VMDK_ERROR;
|
|
return VMDK_ERROR;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (bdrv_flush(extent->file->bs) < 0) {
|
|
|
|
|
|
+ if (bdrv_co_flush(extent->file->bs) < 0) {
|
|
return VMDK_ERROR;
|
|
return VMDK_ERROR;
|
|
}
|
|
}
|
|
if (m_data->l2_cache_entry) {
|
|
if (m_data->l2_cache_entry) {
|
|
@@ -1623,11 +1623,10 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs,
|
|
}
|
|
}
|
|
l2_table = (char *)extent->l2_cache + (min_index * l2_size_bytes);
|
|
l2_table = (char *)extent->l2_cache + (min_index * l2_size_bytes);
|
|
BLKDBG_EVENT(extent->file, BLKDBG_L2_LOAD);
|
|
BLKDBG_EVENT(extent->file, BLKDBG_L2_LOAD);
|
|
- if (bdrv_pread(extent->file,
|
|
|
|
|
|
+ if (bdrv_co_pread(extent->file,
|
|
(int64_t)l2_offset * 512,
|
|
(int64_t)l2_offset * 512,
|
|
l2_size_bytes,
|
|
l2_size_bytes,
|
|
- l2_table,
|
|
|
|
- 0
|
|
|
|
|
|
+ l2_table, 0
|
|
) < 0) {
|
|
) < 0) {
|
|
return VMDK_ERROR;
|
|
return VMDK_ERROR;
|
|
}
|
|
}
|
|
@@ -1898,7 +1897,8 @@ vmdk_read_extent(VmdkExtent *extent, int64_t cluster_offset,
|
|
cluster_buf = g_malloc(buf_bytes);
|
|
cluster_buf = g_malloc(buf_bytes);
|
|
uncomp_buf = g_malloc(cluster_bytes);
|
|
uncomp_buf = g_malloc(cluster_bytes);
|
|
BLKDBG_EVENT(extent->file, BLKDBG_READ_COMPRESSED);
|
|
BLKDBG_EVENT(extent->file, BLKDBG_READ_COMPRESSED);
|
|
- ret = bdrv_pread(extent->file, cluster_offset, buf_bytes, cluster_buf, 0);
|
|
|
|
|
|
+ ret = bdrv_co_pread(extent->file, cluster_offset, buf_bytes, cluster_buf,
|
|
|
|
+ 0);
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
@@ -2143,8 +2143,8 @@ vmdk_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
|
return length;
|
|
return length;
|
|
}
|
|
}
|
|
length = QEMU_ALIGN_UP(length, BDRV_SECTOR_SIZE);
|
|
length = QEMU_ALIGN_UP(length, BDRV_SECTOR_SIZE);
|
|
- ret = bdrv_truncate(s->extents[i].file, length, false,
|
|
|
|
- PREALLOC_MODE_OFF, 0, NULL);
|
|
|
|
|
|
+ ret = bdrv_co_truncate(s->extents[i].file, length, false,
|
|
|
|
+ PREALLOC_MODE_OFF, 0, NULL);
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
@@ -2585,7 +2585,7 @@ static int coroutine_fn vmdk_co_do_create(int64_t size,
|
|
desc_offset = 0x200;
|
|
desc_offset = 0x200;
|
|
}
|
|
}
|
|
|
|
|
|
- ret = blk_pwrite(blk, desc_offset, desc_len, desc, 0);
|
|
|
|
|
|
+ ret = blk_co_pwrite(blk, desc_offset, desc_len, desc, 0);
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
error_setg_errno(errp, -ret, "Could not write description");
|
|
error_setg_errno(errp, -ret, "Could not write description");
|
|
goto exit;
|
|
goto exit;
|
|
@@ -2593,7 +2593,7 @@ static int coroutine_fn vmdk_co_do_create(int64_t size,
|
|
/* bdrv_pwrite write padding zeros to align to sector, we don't need that
|
|
/* bdrv_pwrite write padding zeros to align to sector, we don't need that
|
|
* for description file */
|
|
* for description file */
|
|
if (desc_offset == 0) {
|
|
if (desc_offset == 0) {
|
|
- ret = blk_truncate(blk, desc_len, false, PREALLOC_MODE_OFF, 0, errp);
|
|
|
|
|
|
+ ret = blk_co_truncate(blk, desc_len, false, PREALLOC_MODE_OFF, 0, errp);
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
goto exit;
|
|
goto exit;
|
|
}
|
|
}
|