mirror of
https://github.com/qemu/qemu.git
synced 2024-11-30 07:13:38 +08:00
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>
This commit is contained in:
parent
b66df843b4
commit
233521b199
@ -3145,12 +3145,13 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,
|
|||||||
return last_cluster;
|
return last_cluster;
|
||||||
}
|
}
|
||||||
if ((last_cluster + 1) * s->cluster_size < old_file_size) {
|
if ((last_cluster + 1) * s->cluster_size < old_file_size) {
|
||||||
ret = bdrv_truncate(bs->file, (last_cluster + 1) * s->cluster_size,
|
Error *local_err = NULL;
|
||||||
PREALLOC_MODE_OFF, NULL);
|
|
||||||
if (ret < 0) {
|
bdrv_truncate(bs->file, (last_cluster + 1) * s->cluster_size,
|
||||||
warn_report("Failed to truncate the tail of the image: %s",
|
PREALLOC_MODE_OFF, &local_err);
|
||||||
strerror(-ret));
|
if (local_err) {
|
||||||
ret = 0;
|
warn_reportf_err(local_err,
|
||||||
|
"Failed to truncate the tail of the image: ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user