summaryrefslogtreecommitdiff
path: root/qemu-img.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2017-03-28 22:51:27 +0200
committerMichael Roth <mdroth@linux.vnet.ibm.com>2017-08-03 14:29:55 -0500
commit5797a36abd2069232c39c7acd57a34220fe11d21 (patch)
treecf3a574f0cef35438e48d8e45f2985f98af92ea2 /qemu-img.c
parent73aa7ad7d2249a602a93b6c2a8ecbd57bacbc482 (diff)
downloadqemu-5797a36abd2069232c39c7acd57a34220fe11d21.tar.gz
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> (cherry picked from commit ed3d2ec98a33fbdeabc471b11ff807075f07e996) * prereq for 698bdfa Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'qemu-img.c')
-rw-r--r--qemu-img.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/qemu-img.c b/qemu-img.c
index 26ded22338..e4a2686f56 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3500,20 +3500,11 @@ static int img_resize(int argc, char **argv)
goto out;
}
- ret = blk_truncate(blk, total_size);
- switch (ret) {
- case 0:
+ ret = blk_truncate(blk, total_size, &err);
+ if (!ret) {
qprintf(quiet, "Image resized.\n");
- break;
- case -ENOTSUP:
- error_report("This image does not support resize");
- break;
- case -EACCES:
- error_report("Image is read-only");
- break;
- default:
- error_report("Error resizing image: %s", strerror(-ret));
- break;
+ } else {
+ error_report_err(err);
}
out:
blk_unref(blk);