[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 02/97] qcow2: Add errp to preallocate_co()
From: |
Michael Roth |
Subject: |
[PATCH 02/97] qcow2: Add errp to preallocate_co() |
Date: |
Tue, 1 Oct 2019 18:44:41 -0500 |
From: Kevin Wolf <address@hidden>
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: address@hidden
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
(cherry picked from commit 360bd07471dfd1830246e8403ffdc9ba9d82f9d4)
Signed-off-by: Michael Roth <address@hidden>
---
block/qcow2.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index dfac74c264..b4f9f5a240 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2721,7 +2721,7 @@ static int qcow2_set_up_encryption(BlockDriverState *bs,
* Returns: 0 on success, -errno on failure.
*/
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;
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,
&host_offset, &meta);
if (ret < 0) {
+ error_setg_errno(errp, -ret, "Allocating clusters failed");
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);
if (ret < 0) {
+ error_setg_errno(errp, -ret, "Mapping clusters failed");
qcow2_free_any_clusters(bs, meta->alloc_offset,
meta->nb_clusters,
QCOW2_DISCARD_NEVER);
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,
&data, 1);
if (ret < 0) {
+ error_setg_errno(errp, -ret, "Writing to EOF failed");
return ret;
}
}
@@ -3748,9 +3751,8 @@ static int coroutine_fn
qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
break;
case PREALLOC_MODE_METADATA:
- ret = preallocate_co(bs, old_length, offset);
+ ret = preallocate_co(bs, old_length, offset, errp);
if (ret < 0) {
- error_setg_errno(errp, -ret, "Preallocation failed");
goto fail;
}
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
* and forwarding the truncate request to the data file */
if (has_data_file(bs)) {
- ret = preallocate_co(bs, old_length, offset);
+ ret = preallocate_co(bs, old_length, offset, errp);
if (ret < 0) {
- error_setg_errno(errp, -ret, "Preallocation failed");
goto fail;
}
break;
--
2.17.1
- [PATCH 28/97] target/ppc: Fix xxbrq, xxbrw, (continued)
- [PATCH 28/97] target/ppc: Fix xxbrq, xxbrw, Michael Roth, 2019/10/01
- [PATCH 01/97] qcow2: Avoid COW during metadata preallocation, Michael Roth, 2019/10/01
- [PATCH 30/97] target/ppc: Fix lxvw4x, lxvh8x and lxvb16x, Michael Roth, 2019/10/01
- [PATCH 13/97] block/file-posix: Unaligned O_DIRECT block-status, Michael Roth, 2019/10/01
- [PATCH 29/97] target/ppc: Fix vsum2sws, Michael Roth, 2019/10/01
- [PATCH 34/97] target/i386: define md-clear bit, Michael Roth, 2019/10/01
- [PATCH 14/97] iotests: Test unaligned raw images with O_DIRECT, Michael Roth, 2019/10/01
- [PATCH 20/97] QEMUMachine: add events_wait method, Michael Roth, 2019/10/01
- [PATCH 33/97] target/i386: add MDS-NO feature, Michael Roth, 2019/10/01
- [PATCH 25/97] vhost: fix vhost_log size overflow during migration, Michael Roth, 2019/10/01
- [PATCH 02/97] qcow2: Add errp to preallocate_co(),
Michael Roth <=
- [PATCH 37/97] usbredir: fix buffer-overflow on vmload, Michael Roth, 2019/10/01
- [PATCH 40/97] sphinx: add qmp_lexer, Michael Roth, 2019/10/01
- [PATCH 31/97] q35: Revert to kernel irqchip, Michael Roth, 2019/10/01
- [PATCH 27/97] target/ppc: Fix xvxsigdp, Michael Roth, 2019/10/01
- [PATCH 26/97] target/ppc: Fix xvabs[sd]p, xvnabs[sd]p, xvneg[sd]p, xvcpsgn[sd]p, Michael Roth, 2019/10/01
- [PATCH 46/97] i386/acpi: show PCI Express bus on pxb-pcie expanders, Michael Roth, 2019/10/01
- [PATCH 56/97] tpm: Exit in reset when backend indicates failure, Michael Roth, 2019/10/01
- [PATCH 35/97] docs: recommend use of md-clear feature on all Intel CPUs, Michael Roth, 2019/10/01
- [PATCH 38/97] virtio-balloon: fix QEMU 4.0 config size migration incompatibility, Michael Roth, 2019/10/01
- [PATCH 49/97] virtio-balloon: Simplify deflate with pbp, Michael Roth, 2019/10/01