mirror of https://github.com/xemu-project/xemu.git
qcow2: Add errp to preallocate_co()
We'll add a bdrv_co_truncate() call in the next patch which can return an Error that we don't want to discard. So add an errp parameter to preallocate_co(). Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
f29fbf7c6b
commit
360bd07471
|
@ -2721,7 +2721,7 @@ static int qcow2_set_up_encryption(BlockDriverState *bs,
|
||||||
* Returns: 0 on success, -errno on failure.
|
* Returns: 0 on success, -errno on failure.
|
||||||
*/
|
*/
|
||||||
static int coroutine_fn preallocate_co(BlockDriverState *bs, uint64_t offset,
|
static int coroutine_fn preallocate_co(BlockDriverState *bs, uint64_t offset,
|
||||||
uint64_t new_length)
|
uint64_t new_length, Error **errp)
|
||||||
{
|
{
|
||||||
BDRVQcow2State *s = bs->opaque;
|
BDRVQcow2State *s = bs->opaque;
|
||||||
uint64_t bytes;
|
uint64_t bytes;
|
||||||
|
@ -2738,6 +2738,7 @@ static int coroutine_fn preallocate_co(BlockDriverState *bs, uint64_t offset,
|
||||||
ret = qcow2_alloc_cluster_offset(bs, offset, &cur_bytes,
|
ret = qcow2_alloc_cluster_offset(bs, offset, &cur_bytes,
|
||||||
&host_offset, &meta);
|
&host_offset, &meta);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "Allocating clusters failed");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2746,6 +2747,7 @@ static int coroutine_fn preallocate_co(BlockDriverState *bs, uint64_t offset,
|
||||||
|
|
||||||
ret = qcow2_alloc_cluster_link_l2(bs, meta);
|
ret = qcow2_alloc_cluster_link_l2(bs, meta);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "Mapping clusters failed");
|
||||||
qcow2_free_any_clusters(bs, meta->alloc_offset,
|
qcow2_free_any_clusters(bs, meta->alloc_offset,
|
||||||
meta->nb_clusters, QCOW2_DISCARD_NEVER);
|
meta->nb_clusters, QCOW2_DISCARD_NEVER);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2775,6 +2777,7 @@ static int coroutine_fn preallocate_co(BlockDriverState *bs, uint64_t offset,
|
||||||
ret = bdrv_pwrite(s->data_file, (host_offset + cur_bytes) - 1,
|
ret = bdrv_pwrite(s->data_file, (host_offset + cur_bytes) - 1,
|
||||||
&data, 1);
|
&data, 1);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "Writing to EOF failed");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3748,9 +3751,8 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PREALLOC_MODE_METADATA:
|
case PREALLOC_MODE_METADATA:
|
||||||
ret = preallocate_co(bs, old_length, offset);
|
ret = preallocate_co(bs, old_length, offset, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_setg_errno(errp, -ret, "Preallocation failed");
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -3766,9 +3768,8 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
|
||||||
/* With a data file, preallocation means just allocating the metadata
|
/* With a data file, preallocation means just allocating the metadata
|
||||||
* and forwarding the truncate request to the data file */
|
* and forwarding the truncate request to the data file */
|
||||||
if (has_data_file(bs)) {
|
if (has_data_file(bs)) {
|
||||||
ret = preallocate_co(bs, old_length, offset);
|
ret = preallocate_co(bs, old_length, offset, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_setg_errno(errp, -ret, "Preallocation failed");
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue