From: Luiz Capitulino <lcapitulino@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Pavel Hrdina <phrdina@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 02/18] block: add error parameter to bdrv_snapshot_create() and related functions
Date: Fri, 31 Aug 2012 10:09:47 -0300 [thread overview]
Message-ID: <20120831100947.4ef52a4d@doriath.home> (raw)
In-Reply-To: <87ipbz1srl.fsf@blackfin.pond.sub.org>
On Fri, 31 Aug 2012 08:26:38 +0200
Markus Armbruster <armbru@redhat.com> wrote:
> Luiz Capitulino <lcapitulino@redhat.com> writes:
>
> > On Wed, 15 Aug 2012 09:41:43 +0200
> > Pavel Hrdina <phrdina@redhat.com> wrote:
> >
> >> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> >> ---
> >> block.c | 25 +++++++++++++++++--------
> >> block.h | 3 ++-
> >> block/qcow2-snapshot.c | 9 ++++++++-
> >> block/qcow2.h | 4 +++-
> >> block/rbd.c | 20 ++++++++++++++------
> >> block/sheepdog.c | 17 +++++++++--------
> >> block_int.h | 3 ++-
> >> qemu-img.c | 2 +-
> >> savevm.c | 2 +-
> >> 9 files changed, 57 insertions(+), 28 deletions(-)
> >>
> >> diff --git a/block.c b/block.c
> >> index 016858b..8bc49b7 100644
> >> --- a/block.c
> >> +++ b/block.c
> >> @@ -2661,16 +2661,25 @@ BlockDriverState *bdrv_snapshots(void)
> >> }
> >>
> >> int bdrv_snapshot_create(BlockDriverState *bs,
> >> - QEMUSnapshotInfo *sn_info)
> >> + QEMUSnapshotInfo *sn_info,
> >> + Error **errp)
> >> {
> >> BlockDriver *drv = bs->drv;
> >> - if (!drv)
> >> - return -ENOMEDIUM;
> >> - if (drv->bdrv_snapshot_create)
> >> - return drv->bdrv_snapshot_create(bs, sn_info);
> >> - if (bs->file)
> >> - return bdrv_snapshot_create(bs->file, sn_info);
> >> - return -ENOTSUP;
> >> + int ret;
> >> +
> >> + if (!drv) {
> >> + error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs));
> >
> > We should only use QERR_ macros for the errors listed in the ErrorClass enum
> > (except GenericError), all other errors should generally use error_setg(), like
> > this:
> >
> > error_setg(errp, "device '%s' has no medium);
> >
> >> + ret = -ENOMEDIUM;
> >
> > And, usually, we should get rid of errno propagation. There are two cases here:
>
> The block layer consistently[*] uses -errno return values. Its
> consistency is valuable, and I'm a bit reluctant to break it. Maybe a
> new rule "returns -errno, except when it has an Error ** argument" could
> work. I'd like to hear Kevin's advice on this.
>
> >
> > 1. errno is propagated up so that upper layers can print a decent error
> > message to the user.
> >
> > In this case, it's safe to eliminate errno. error_setg() will store a
> > decent message already and the Error object can be propagated up.
> >
> > 2. errno is propagated up so that upper layers can distinguish among
> > error causes and take different actions accordingly.
> >
> > Doesn't seem to be the case of bdrv_snapshot_create() (ie. errno is only
> > used to communicate the error to the user). However, I'm pretty sure that
> > such usage exists in qemu and the error API will break it, as most of our
> > errors are generic.
> >
> > I see two solutions to this problem:
> >
> > A. Add specific errors to ErrorClass. I don't like this very much,
> > as it's possible that such errors are going to be useful only internally.
>
> Let's not reinvent errno, poorly.
>
> > B. Add two new functions:
> >
> > void error_sete(Error **err, ErrorClass err_class, int errno, const char *fmt, ...);
> > int error_get_errno(const Error **err);
> >
> > So that we can maintain errno when it's used to communicate
> > error cause among functions.
>
> Better.
>
> What's ErrorClass doing there?
There might be cases where we will have to report an error other than GenericError,
we could have error_sete_generic(), but this is starting to get weird :)
>
> [...]
>
>
> [*] Almost; it's still QEMU after all.
>
next prev parent reply other threads:[~2012-08-31 13:09 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-15 7:41 [Qemu-devel] [PATCH 00/18] qapi: Convert savevm, loadvm, delvm and info snapshots Pavel Hrdina
2012-08-15 7:41 ` [Qemu-devel] [PATCH 01/18] qerror: introduce QERR_GENERIC_ERROR Pavel Hrdina
2012-08-30 12:11 ` Luiz Capitulino
2012-09-06 8:34 ` Pavel Hrdina
2012-08-15 7:41 ` [Qemu-devel] [PATCH 02/18] block: add error parameter to bdrv_snapshot_create() and related functions Pavel Hrdina
2012-08-30 14:47 ` Luiz Capitulino
2012-08-31 6:26 ` Markus Armbruster
2012-08-31 12:18 ` Kevin Wolf
2012-08-31 13:13 ` Luiz Capitulino
2012-08-31 13:09 ` Luiz Capitulino [this message]
2012-09-06 9:07 ` Pavel Hrdina
2012-09-10 17:03 ` Luiz Capitulino
2012-08-15 7:41 ` [Qemu-devel] [PATCH 03/18] block: add error parameter to bdrv_snapshot_goto() " Pavel Hrdina
2012-08-30 15:07 ` Luiz Capitulino
2012-08-15 7:41 ` [Qemu-devel] [PATCH 04/18] block: add error parameter to bdrv_snapshot_delete() " Pavel Hrdina
2012-08-15 7:41 ` [Qemu-devel] [PATCH 05/18] block: add error parameter to bdrv_snapshot_list() " Pavel Hrdina
2012-08-15 7:41 ` [Qemu-devel] [PATCH 06/18] block: add error parameter to bdrv_snapshot_find() Pavel Hrdina
2012-08-15 7:41 ` [Qemu-devel] [PATCH 07/18] block: add error parameter to del_existing_snapshots() Pavel Hrdina
2012-08-15 7:41 ` [Qemu-devel] [PATCH 08/18] savevm: add error parameter to qemu_savevm_state_begin() Pavel Hrdina
2012-08-15 7:41 ` [Qemu-devel] [PATCH 09/18] savevm: add error parameter to qemu_savevm_state_iterate() Pavel Hrdina
2012-08-15 7:41 ` [Qemu-devel] [PATCH 10/18] savevm: add error parameter to qemu_savevm_state_complete() Pavel Hrdina
2012-08-15 7:41 ` [Qemu-devel] [PATCH 11/18] savevm: add error parameter to qemu_savevm_state() Pavel Hrdina
2012-08-15 7:41 ` [Qemu-devel] [PATCH 12/18] savevm: add error parameter to qemu_loadvm_state() Pavel Hrdina
2012-08-30 17:09 ` Luiz Capitulino
2012-09-06 8:33 ` Pavel Hrdina
2012-08-15 7:41 ` [Qemu-devel] [PATCH 13/18] qapi: Convert savevm Pavel Hrdina
2012-08-15 19:49 ` Eric Blake
2012-08-16 10:16 ` Pavel Hrdina
2012-08-15 7:41 ` [Qemu-devel] [PATCH 14/18] qapi: Convert loadvm Pavel Hrdina
2012-08-16 3:31 ` Eric Blake
2012-08-16 4:34 ` Eric Blake
2012-08-15 7:41 ` [Qemu-devel] [PATCH 15/18] qapi: Convert delvm Pavel Hrdina
2012-08-15 7:41 ` [Qemu-devel] [PATCH 16/18] qapi: Convert info snapshots Pavel Hrdina
2012-08-16 4:36 ` Eric Blake
2012-08-16 10:17 ` Pavel Hrdina
2012-08-15 7:41 ` [Qemu-devel] [PATCH 17/18] hmp: allow "bool" parameter to be optional Pavel Hrdina
2012-08-16 4:39 ` Eric Blake
2012-08-15 7:41 ` [Qemu-devel] [PATCH 18/18] vm-snapshot-save: add force parameter Pavel Hrdina
2012-08-16 5:00 ` Eric Blake
2012-08-16 10:19 ` Pavel Hrdina
2012-08-30 17:15 ` [Qemu-devel] [PATCH 00/18] qapi: Convert savevm, loadvm, delvm and info snapshots Luiz Capitulino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120831100947.4ef52a4d@doriath.home \
--to=lcapitulino@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=phrdina@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).