* [Qemu-devel] [PATCH] block: do_commit() does not pass along error messages for all errors
@ 2013-01-16 23:04 Jeff Cody
2013-01-17 7:49 ` Markus Armbruster
0 siblings, 1 reply; 4+ messages in thread
From: Jeff Cody @ 2013-01-16 23:04 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, armbru, stefanha
The non-live bdrv_commit() function may return one of the following
errors: -ENOTSUP, -EBUSY, -EACCES, -EIO. The only error that is
checked in the HMP handler is -EBUSY, so the monitor command 'commit'
silently fails for all error cases other than 'Device is in use'.
This patch adds the appropriate error messages for the errors
explicitely returned by bdrv_commit().
Signed-off-by: Jeff Cody <jcody@redhat.com>
---
blockdev.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/blockdev.c b/blockdev.c
index d724e2d..7db7d8e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -657,6 +657,20 @@ void do_commit(Monitor *mon, const QDict *qdict)
qerror_report(QERR_DEVICE_IN_USE, device);
return;
}
+ if (ret == -EACCES) {
+ qerror_report(QERR_DEVICE_IS_READ_ONLY, device);
+ return;
+ }
+ if (ret == -EIO) {
+ qerror_report(QERR_IO_ERROR);
+ return;
+ }
+ if (ret == -ENOTSUP) {
+ const char *format = bdrv_get_format_name(bs);
+ qerror_report(QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
+ format ? format : "NULL", device, "commit");
+
+ }
}
}
--
1.8.0.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] block: do_commit() does not pass along error messages for all errors
2013-01-16 23:04 [Qemu-devel] [PATCH] block: do_commit() does not pass along error messages for all errors Jeff Cody
@ 2013-01-17 7:49 ` Markus Armbruster
2013-01-17 11:57 ` Luiz Capitulino
0 siblings, 1 reply; 4+ messages in thread
From: Markus Armbruster @ 2013-01-17 7:49 UTC (permalink / raw)
To: Jeff Cody; +Cc: kwolf, qemu-devel, stefanha, Luiz Capitulino
[Cc: Luiz for error stuff]
Jeff Cody <jcody@redhat.com> writes:
> The non-live bdrv_commit() function may return one of the following
> errors: -ENOTSUP, -EBUSY, -EACCES, -EIO. The only error that is
> checked in the HMP handler is -EBUSY, so the monitor command 'commit'
> silently fails for all error cases other than 'Device is in use'.
>
> This patch adds the appropriate error messages for the errors
> explicitely returned by bdrv_commit().
>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
> blockdev.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/blockdev.c b/blockdev.c
> index d724e2d..7db7d8e 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -657,6 +657,20 @@ void do_commit(Monitor *mon, const QDict *qdict)
> qerror_report(QERR_DEVICE_IN_USE, device);
> return;
> }
> + if (ret == -EACCES) {
> + qerror_report(QERR_DEVICE_IS_READ_ONLY, device);
> + return;
> + }
> + if (ret == -EIO) {
> + qerror_report(QERR_IO_ERROR);
> + return;
> + }
> + if (ret == -ENOTSUP) {
> + const char *format = bdrv_get_format_name(bs);
> + qerror_report(QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
> + format ? format : "NULL", device, "commit");
> +
> + }
> }
> }
A switch could be more obvious than the if cascade. Matter of taste.
We're trying to avoid QERR_ in new code. This case isn't bad, because
it doesn't add new QERR_ defines. Should we convert the function to
error_setg() instead? Perhaps a few cases could be collapsed into a
single error_setg_errno() then.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] block: do_commit() does not pass along error messages for all errors
2013-01-17 7:49 ` Markus Armbruster
@ 2013-01-17 11:57 ` Luiz Capitulino
2013-01-18 14:27 ` Jeff Cody
0 siblings, 1 reply; 4+ messages in thread
From: Luiz Capitulino @ 2013-01-17 11:57 UTC (permalink / raw)
To: Markus Armbruster; +Cc: kwolf, Jeff Cody, qemu-devel, stefanha
On Thu, 17 Jan 2013 08:49:38 +0100
Markus Armbruster <armbru@redhat.com> wrote:
> [Cc: Luiz for error stuff]
>
> Jeff Cody <jcody@redhat.com> writes:
>
> > The non-live bdrv_commit() function may return one of the following
> > errors: -ENOTSUP, -EBUSY, -EACCES, -EIO. The only error that is
> > checked in the HMP handler is -EBUSY, so the monitor command 'commit'
> > silently fails for all error cases other than 'Device is in use'.
> >
> > This patch adds the appropriate error messages for the errors
> > explicitely returned by bdrv_commit().
> >
> > Signed-off-by: Jeff Cody <jcody@redhat.com>
> > ---
> > blockdev.c | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
> >
> > diff --git a/blockdev.c b/blockdev.c
> > index d724e2d..7db7d8e 100644
> > --- a/blockdev.c
> > +++ b/blockdev.c
> > @@ -657,6 +657,20 @@ void do_commit(Monitor *mon, const QDict *qdict)
> > qerror_report(QERR_DEVICE_IN_USE, device);
> > return;
> > }
> > + if (ret == -EACCES) {
> > + qerror_report(QERR_DEVICE_IS_READ_ONLY, device);
> > + return;
> > + }
> > + if (ret == -EIO) {
> > + qerror_report(QERR_IO_ERROR);
> > + return;
> > + }
> > + if (ret == -ENOTSUP) {
> > + const char *format = bdrv_get_format_name(bs);
> > + qerror_report(QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
> > + format ? format : "NULL", device, "commit");
> > +
> > + }
> > }
> > }
>
> A switch could be more obvious than the if cascade. Matter of taste.
>
> We're trying to avoid QERR_ in new code. This case isn't bad, because
> it doesn't add new QERR_ defines. Should we convert the function to
> error_setg() instead? Perhaps a few cases could be collapsed into a
> single error_setg_errno() then.
I'd suggest to convert do_commit() to the qapi. However, we already
have block-commit in QMP. So I'm not sure this is a good idea.
If it isn't, then maybe we could drop all qerro_report() calls and
use monitor_printf() instead (building the error message with
strerror()), as do_commit() seems to be used only from HMP.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] block: do_commit() does not pass along error messages for all errors
2013-01-17 11:57 ` Luiz Capitulino
@ 2013-01-18 14:27 ` Jeff Cody
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Cody @ 2013-01-18 14:27 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: kwolf, Markus Armbruster, stefanha, qemu-devel
On Thu, Jan 17, 2013 at 09:57:28AM -0200, Luiz Capitulino wrote:
> On Thu, 17 Jan 2013 08:49:38 +0100
> Markus Armbruster <armbru@redhat.com> wrote:
>
> > [Cc: Luiz for error stuff]
> >
> > Jeff Cody <jcody@redhat.com> writes:
> >
> > > The non-live bdrv_commit() function may return one of the following
> > > errors: -ENOTSUP, -EBUSY, -EACCES, -EIO. The only error that is
> > > checked in the HMP handler is -EBUSY, so the monitor command 'commit'
> > > silently fails for all error cases other than 'Device is in use'.
> > >
> > > This patch adds the appropriate error messages for the errors
> > > explicitely returned by bdrv_commit().
> > >
> > > Signed-off-by: Jeff Cody <jcody@redhat.com>
> > > ---
> > > blockdev.c | 14 ++++++++++++++
> > > 1 file changed, 14 insertions(+)
> > >
> > > diff --git a/blockdev.c b/blockdev.c
> > > index d724e2d..7db7d8e 100644
> > > --- a/blockdev.c
> > > +++ b/blockdev.c
> > > @@ -657,6 +657,20 @@ void do_commit(Monitor *mon, const QDict *qdict)
> > > qerror_report(QERR_DEVICE_IN_USE, device);
> > > return;
> > > }
> > > + if (ret == -EACCES) {
> > > + qerror_report(QERR_DEVICE_IS_READ_ONLY, device);
> > > + return;
> > > + }
> > > + if (ret == -EIO) {
> > > + qerror_report(QERR_IO_ERROR);
> > > + return;
> > > + }
> > > + if (ret == -ENOTSUP) {
> > > + const char *format = bdrv_get_format_name(bs);
> > > + qerror_report(QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
> > > + format ? format : "NULL", device, "commit");
> > > +
> > > + }
> > > }
> > > }
> >
> > A switch could be more obvious than the if cascade. Matter of taste.
> >
> > We're trying to avoid QERR_ in new code. This case isn't bad, because
> > it doesn't add new QERR_ defines. Should we convert the function to
> > error_setg() instead? Perhaps a few cases could be collapsed into a
> > single error_setg_errno() then.
>
> I'd suggest to convert do_commit() to the qapi. However, we already
> have block-commit in QMP. So I'm not sure this is a good idea.
>
> If it isn't, then maybe we could drop all qerro_report() calls and
> use monitor_printf() instead (building the error message with
> strerror()), as do_commit() seems to be used only from HMP.
I think I agree in keeping do_commit() HMP only. I'll submit a v2 to
just use monitor_printf() for all error strings, rather than
qerror_report().
Thanks,
Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-01-18 14:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-16 23:04 [Qemu-devel] [PATCH] block: do_commit() does not pass along error messages for all errors Jeff Cody
2013-01-17 7:49 ` Markus Armbruster
2013-01-17 11:57 ` Luiz Capitulino
2013-01-18 14:27 ` Jeff Cody
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).