diff options
author | Max Reitz <mreitz@redhat.com> | 2017-10-09 17:54:31 +0200 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2017-10-26 15:01:14 +0200 |
commit | 233521b1999810036f63d060ce021d30a8ce0504 (patch) | |
tree | 86fdd0d63f87a9929ad731a7398aea24d0e3fa0b /block | |
parent | b66df843b442924745d196bd0a05f0639b808164 (diff) |
qcow2: Emit errp when truncating the image tail
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>
Diffstat (limited to 'block')
-rw-r--r-- | block/qcow2.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/block/qcow2.c b/block/qcow2.c index f77b490cc6..d3e114bce5 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -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 { |