Skip to content

Commit

Permalink
qcow2: Emit errp when truncating the image tail
Browse files Browse the repository at this point in the history
bdrv_truncate() has an errp parameter which is always set when an error
occurs.  Let's use that instead of a plain strerror().

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20171009155431.14093-1-mreitz@redhat.com
Reviewed-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
  • Loading branch information
XanClic committed Oct 26, 2017
1 parent b66df84 commit 233521b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions block/qcow2.c
Expand Up @@ -3145,12 +3145,13 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,
return last_cluster;
}
if ((last_cluster + 1) * s->cluster_size < old_file_size) {
ret = bdrv_truncate(bs->file, (last_cluster + 1) * s->cluster_size,
PREALLOC_MODE_OFF, NULL);
if (ret < 0) {
warn_report("Failed to truncate the tail of the image: %s",
strerror(-ret));
ret = 0;
Error *local_err = NULL;

bdrv_truncate(bs->file, (last_cluster + 1) * s->cluster_size,
PREALLOC_MODE_OFF, &local_err);
if (local_err) {
warn_reportf_err(local_err,
"Failed to truncate the tail of the image: ");
}
}
} else {
Expand Down

0 comments on commit 233521b

Please sign in to comment.