aboutsummaryrefslogtreecommitdiff
path: root/blockdev.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2013-05-02 15:32:55 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2013-05-03 10:31:58 +0200
commit8732901e1b8a5add02a2b747875202133413d565 (patch)
tree0273d3ecb560f59bd945c8df58340ff4393a19a5 /blockdev.c
parent059e2fbbca484a68ac7fd99d1d76409294551586 (diff)
blockdev: Replace "undefined error" in qmp_block_resize
We have an errno value that can be displayed, so we should just do that. An easy way to reproduce this case is to resize a raw image to a size that is too large for the host file system. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/blockdev.c b/blockdev.c
index 6e293e9550..7c9d8dd0ac 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1118,6 +1118,7 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
void qmp_block_resize(const char *device, int64_t size, Error **errp)
{
BlockDriverState *bs;
+ int ret;
bs = bdrv_find(device);
if (!bs) {
@@ -1133,7 +1134,8 @@ void qmp_block_resize(const char *device, int64_t size, Error **errp)
/* complete all in-flight operations before resizing the device */
bdrv_drain_all();
- switch (bdrv_truncate(bs, size)) {
+ ret = bdrv_truncate(bs, size);
+ switch (ret) {
case 0:
break;
case -ENOMEDIUM:
@@ -1149,7 +1151,7 @@ void qmp_block_resize(const char *device, int64_t size, Error **errp)
error_set(errp, QERR_DEVICE_IN_USE, device);
break;
default:
- error_set(errp, QERR_UNDEFINED_ERROR);
+ error_setg_errno(errp, -ret, "Could not resize");
break;
}
}