[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 14/14] block: use proper qerrors in qmp_block_re
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH 14/14] block: use proper qerrors in qmp_block_resize |
Date: |
Tue, 24 Jan 2012 10:35:04 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) |
A bit late, but here goes anyway:
Luiz Capitulino <address@hidden> writes:
> From: Stefan Hajnoczi <address@hidden>
>
> Let's report specific errors so that management tools and users can
> identify the problem.
>
> Two new qerrors are needed:
> * QERR_DEVICE_HAS_NO_MEDIUM for ENOMEDIUM
> * QERR_DEVICE_IS_READ_ONLY for EACCES
[...]
> diff --git a/blockdev.c b/blockdev.c
> index 5d16137..1f83c88 100644
> --- a/blockdev.c
> +++ b/blockdev.c
[...]
> @@ -864,12 +859,27 @@ void qmp_block_resize(const char *device, int64_t size,
> Error **errp)
> }
>
> if (size < 0) {
> - error_set(errp, QERR_UNDEFINED_ERROR);
> + error_set(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size");
> return;
> }
>
> - if (bdrv_truncate(bs, size)) {
> + switch (bdrv_truncate(bs, size)) {
> + case 0:
> + break;
> + case -ENOMEDIUM:
> + error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
> + break;
> + case -ENOTSUP:
> + error_set(errp, QERR_UNSUPPORTED);
> + break;
> + case -EACCES:
> + error_set(errp, QERR_DEVICE_IS_READ_ONLY, device);
> + break;
Are you sure "read only" is (and will remain) the only possible reason
for EACCES here? I mean bdrv_truncate() obviously uses it for that, but
what about all the driver methods?
Aside: bdrv_truncate()'s use of EACCES is a somewhat unusual. System
calls generally use EBADF when refusing to change a read-only file.
Outside this patch's scope.
> + case -EBUSY:
> + error_set(errp, QERR_DEVICE_IN_USE, device);
> + break;
> + default:
> error_set(errp, QERR_UNDEFINED_ERROR);
> - return;
> + break;
> }
> }
[...]
- [Qemu-devel] [PATCH 03/14] qapi: Convert expire_password, (continued)
- [Qemu-devel] [PATCH 03/14] qapi: Convert expire_password, Luiz Capitulino, 2012/01/18
- [Qemu-devel] [PATCH 05/14] qapi: Convert eject, Luiz Capitulino, 2012/01/18
- [Qemu-devel] [PATCH 04/14] block: eject_device(): Use error_set(), Luiz Capitulino, 2012/01/18
- [Qemu-devel] [PATCH 06/14] monitor: expose readline state, Luiz Capitulino, 2012/01/18
- [Qemu-devel] [PATCH 07/14] qapi: Introduce change-vnc-password, Luiz Capitulino, 2012/01/18
- [Qemu-devel] [PATCH 08/14] qerror: Extend QERR_DEVICE_ENCRYPTED, Luiz Capitulino, 2012/01/18
- [Qemu-devel] [PATCH 09/14] qapi: Convert change, Luiz Capitulino, 2012/01/18
- [Qemu-devel] [PATCH 10/14] qapi: Convert block_set_io_throttle, Luiz Capitulino, 2012/01/18
- [Qemu-devel] [PATCH 13/14] qerror: restore alphabetical order over qerrors, Luiz Capitulino, 2012/01/18
- [Qemu-devel] [PATCH 14/14] block: use proper qerrors in qmp_block_resize, Luiz Capitulino, 2012/01/18
- Re: [Qemu-devel] [PATCH 14/14] block: use proper qerrors in qmp_block_resize,
Markus Armbruster <=
- [Qemu-devel] [PATCH 12/14] qerror: add check-qerror.sh to verify alphabetical order, Luiz Capitulino, 2012/01/18
- [Qemu-devel] [PATCH 11/14] qmp: Add missing gcc format attribute and fix format string, Luiz Capitulino, 2012/01/18
- Re: [Qemu-devel] [PULL 00/14]: QMP queue, Anthony Liguori, 2012/01/19