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>
This commit is contained in:
parent
059e2fbbca
commit
8732901e1b
@ -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)
|
void qmp_block_resize(const char *device, int64_t size, Error **errp)
|
||||||
{
|
{
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
|
int ret;
|
||||||
|
|
||||||
bs = bdrv_find(device);
|
bs = bdrv_find(device);
|
||||||
if (!bs) {
|
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 */
|
/* complete all in-flight operations before resizing the device */
|
||||||
bdrv_drain_all();
|
bdrv_drain_all();
|
||||||
|
|
||||||
switch (bdrv_truncate(bs, size)) {
|
ret = bdrv_truncate(bs, size);
|
||||||
|
switch (ret) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case -ENOMEDIUM:
|
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);
|
error_set(errp, QERR_DEVICE_IN_USE, device);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error_set(errp, QERR_UNDEFINED_ERROR);
|
error_setg_errno(errp, -ret, "Could not resize");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user