block: Add errp to b{lk,drv}_truncate()

For one thing, this allows us to drop the error message generation from
qemu-img.c and blockdev.c and instead have it unified in
bdrv_truncate().

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20170328205129.15138-3-mreitz@redhat.com
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Max Reitz 2017-03-28 22:51:27 +02:00
parent 55b9392b98
commit ed3d2ec98a
22 changed files with 73 additions and 90 deletions

View file

@ -1567,6 +1567,7 @@ static const cmdinfo_t flush_cmd = {
static int truncate_f(BlockBackend *blk, int argc, char **argv)
{
Error *local_err = NULL;
int64_t offset;
int ret;
@ -1576,9 +1577,9 @@ static int truncate_f(BlockBackend *blk, int argc, char **argv)
return 0;
}
ret = blk_truncate(blk, offset);
ret = blk_truncate(blk, offset, &local_err);
if (ret < 0) {
printf("truncate: %s\n", strerror(-ret));
error_report_err(local_err);
return 0;
}