From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: Eric Blake <eblake@redhat.com>
Cc: kwolf@redhat.com, armbru@redhat.com,
Pavel Hrdina <phrdina@redhat.com>,
qemu-devel@nongnu.org, lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 03/12] savevm: update bdrv_snapshot_find() to find snapshot by id or name and add error parameter
Date: Fri, 26 Apr 2013 10:37:31 +0800 [thread overview]
Message-ID: <5179E86B.4060903@linux.vnet.ibm.com> (raw)
In-Reply-To: <51791E83.1050708@redhat.com>
于 2013-4-25 20:16, Eric Blake 写道:
> On 04/25/2013 12:31 AM, Wenchao Xia wrote:
>>
>>> +
>>> + if (!found) {
>>> + error_setg(errp, "Failed to find snapshot '%s'", name ? name : id);
>> suggest not to set error, since it is a normal case.
>
> The way I understand it, failure to find a snapshot might need to be
> treated as an error - it's up to the caller's needs. Also, there pretty
> much is only one failure mode - the requested snapshot was not found -
> even if there are multiple ways that we can fail to find a requested
> snapshot, so I'm fine with treating all 'false' returns as an error path.
>
> Thus, a caller that wants to probe for a snapshot existence but not set
> an error calls:
> bdrv_snapshot_find(bs, snapshot, name, id, NULL, false);
>
> while a caller that wants to report a missing snapshot as an error calls:
> bdrv_snapshot_find(bs, snapshot, name, id, &local_err, false);
> and then propagates local_err on upwards.
>
>
> Or are you worried about a possible third case, where a caller cares
> about failure during bdrv_snapshot_list(), differently than failure to
> find a snapshot? What callers have that semantics? If that is a real
> concern, then maybe returning a bool is the wrong approach, and we
> should instead return an int. A return < 0 is a fatal error
> (bdrv_snapshot_list failed to even look up snapshots); a return of 0
> means our lookup attempt hit no fatal errors but the snapshot was not
> found, and a return of 1 means the snapshot was found. Then there would
> be three calling styles:
>
> Probe for existence, with no error reporting:
> if (bdrv_snapshot_find(bs, snapshot, name, id, NULL, false) > 0) {
> // exists
> }
> Probe for existence but with error reporting on fatal errors:
> exist = bdrv_snapshot_find(bs, snapshot, name, id, &local_err, false);
> if (exist < 0) {
> // propagate local_err
> } else if (exist) {
> // exists
> }
> Probe for snapshot, with error reporting even for failed lookup:
> if (bdrv_snapshot_find(bs, snapshot, name, id, &local_err, false) <= 0) {
> // propagate local_err
> }
>
> But I don't know what the existing callers need, to make a decision on
> whether a signature change is warranted. Again, more reason to defer
> this series to 1.6.
>
Personally I prefer internal layer have clean meaning, setting error
only for exception. But I am not strongly against it, if caller can
make easier use of it, a document for this function is also OK.
--
Best Regards
Wenchao Xia
next prev parent reply other threads:[~2013-04-26 2:38 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-24 15:31 [Qemu-devel] [PATCH v2 00/12] covert savevm, loadvm and delvm into qapi Pavel Hrdina
2013-04-24 15:31 ` [Qemu-devel] [PATCH v2 01/12] qemu-img: introduce qemu_img_handle_error() Pavel Hrdina
2013-04-24 16:44 ` Eric Blake
2013-04-25 2:53 ` Wenchao Xia
2013-04-25 3:00 ` Eric Blake
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 02/12] block: update error reporting for bdrv_snapshot_delete() and related functions Pavel Hrdina
2013-04-24 20:05 ` Eric Blake
2013-04-25 3:19 ` Wenchao Xia
2013-04-25 13:42 ` Stefan Hajnoczi
2013-05-03 9:53 ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 03/12] savevm: update bdrv_snapshot_find() to find snapshot by id or name and add error parameter Pavel Hrdina
2013-04-24 21:26 ` Eric Blake
2013-04-25 6:46 ` Pavel Hrdina
2013-04-25 8:18 ` Pavel Hrdina
2013-04-25 6:31 ` Wenchao Xia
2013-04-25 6:52 ` Pavel Hrdina
2013-04-25 12:16 ` Eric Blake
2013-04-26 2:37 ` Wenchao Xia [this message]
2013-05-03 10:24 ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 04/12] qapi: Convert delvm Pavel Hrdina
2013-04-24 22:54 ` Eric Blake
2013-04-25 6:58 ` Wenchao Xia
2013-04-25 12:21 ` Eric Blake
2013-04-26 2:39 ` Wenchao Xia
2013-05-03 10:50 ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 05/12] block: update error reporting for bdrv_snapshot_goto() and related functions Pavel Hrdina
2013-04-25 17:06 ` Eric Blake
2013-05-03 11:03 ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 06/12] block: update error reporting for bdrv_snapshot_list() " Pavel Hrdina
2013-04-25 18:55 ` Eric Blake
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 07/12] savevm: update error reporting for qemu_loadvm_state() Pavel Hrdina
2013-05-03 11:17 ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 08/12] qapi: Convert loadvm Pavel Hrdina
2013-05-03 11:31 ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 09/12] block: update error reporting for bdrv_snapshot_create() and related functions Pavel Hrdina
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 10/12] savevm: update error reporting of qemu_savevm_state() " Pavel Hrdina
2013-05-03 12:40 ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 11/12] qapi: Convert savevm Pavel Hrdina
2013-05-03 12:52 ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 12/12] savevm: remove backward compatibility from bdrv_snapshot_find() Pavel Hrdina
2013-05-03 12:55 ` Kevin Wolf
2013-04-24 16:15 ` [Qemu-devel] [PATCH v2 00/12] covert savevm, loadvm and delvm into qapi Eric Blake
2013-04-24 17:12 ` Luiz Capitulino
2013-04-25 13:34 ` Stefan Hajnoczi
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=5179E86B.4060903@linux.vnet.ibm.com \
--to=xiawenc@linux.vnet.ibm.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.