From: Max Reitz <mreitz@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>,
qemu-block@nongnu.org, "Juan Quintela" <quintela@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Pavel Dovgalyuk" <pavel.dovgaluk@ispras.ru>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH 1/3] block: push error reporting into bdrv_all_*_snapshot functions
Date: Mon, 12 Oct 2020 13:09:59 +0200 [thread overview]
Message-ID: <f68d175a-68f0-3d6a-78d0-8a5981a9d983@redhat.com> (raw)
In-Reply-To: <7a77479f-5ce5-d89a-bee1-02bd2a521495@redhat.com>
On 12.10.20 12:16, Philippe Mathieu-Daudé wrote:
> On 10/12/20 12:07 PM, Max Reitz wrote:
>> On 08.10.20 19:48, Philippe Mathieu-Daudé wrote:
>>> From: Daniel P. Berrangé <berrange@redhat.com>
>>>
>>> The bdrv_all_*_snapshot functions return a BlockDriverState pointer
>>> for the invalid backend, which the callers then use to report an
>>> error message. In some cases multiple callers are reporting the
>>> same error message, but with slightly different text. In the future
>>> there will be more error scenarios for some of these methods, which
>>> will benefit from fine grained error message reporting. So it is
>>> helpful to push error reporting down a level.
>>>
>>> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
>>> ---
>>> include/block/snapshot.h | 14 +++----
>>> block/monitor/block-hmp-cmds.c | 7 ++--
>>> block/snapshot.c | 77 +++++++++++++++++-----------------
>>> migration/savevm.c | 37 +++++-----------
>>> monitor/hmp-cmds.c | 7 +---
>>> replay/replay-debugging.c | 4 +-
>>> tests/qemu-iotests/267.out | 10 ++---
>>> 7 files changed, 67 insertions(+), 89 deletions(-)
>>
>> Looks good overall to me, but for some reason this patch pulls in the
>> @ok and @ret variables from the top scope of all concerned functions
>> into the inner scopes of the BDS loops, and drops their initialization.
>> That’s wrong, because we only call the respective snapshotting
>> functions on some BDSs, so the return value stays uninitialized for all
>> other BDSs:
>
> Indeed, thanks for catching that.
>
> [...]
>>> int bdrv_all_create_snapshot(QEMUSnapshotInfo *sn,
>>> BlockDriverState *vm_state_bs,
>>> uint64_t vm_state_size,
>>> - BlockDriverState **first_bad_bs)
>>> + Error **errp)
>>> {
>>> - int err = 0;
>>> BlockDriverState *bs;
>>> BdrvNextIterator it;
>>> for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
>>> AioContext *ctx = bdrv_get_aio_context(bs);
>>> + int ret;
>>
>> And one final time.
>>
>> Max
>>
>>> aio_context_acquire(ctx);
>>> if (bs == vm_state_bs) {
>>> sn->vm_state_size = vm_state_size;
>>> - err = bdrv_snapshot_create(bs, sn);
>>> + ret = bdrv_snapshot_create(bs, sn);
>>> } else if (bdrv_all_snapshots_includes_bs(bs)) {
>>> sn->vm_state_size = 0;
>>> - err = bdrv_snapshot_create(bs, sn);
>>> + ret = bdrv_snapshot_create(bs, sn);
>
> This one is not needed.
Why not? Is bdrv_all_snapshots_includes_bs(bs) guaranteed to be true?
(I don’t see any a plain “else” branch, or where ret would be set
outside of these two “if” blocks.)
Max
>>> }
>>> aio_context_release(ctx);
>>> - if (err < 0) {
>>> + if (ret < 0) {
>>> + error_setg(errp, "Could not create snapshot '%s' on '%s'",
>>> + sn->name, bdrv_get_device_or_node_name(bs));
>>> bdrv_next_cleanup(&it);
>>> - goto fail;
>>> + return -1;
>>> }
>>> }
>>
>
next prev parent reply other threads:[~2020-10-12 11:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-08 17:48 [PATCH 0/3] migration: Make save/load_snapshot() return boolean Philippe Mathieu-Daudé
2020-10-08 17:48 ` [PATCH 1/3] block: push error reporting into bdrv_all_*_snapshot functions Philippe Mathieu-Daudé
2020-10-12 10:07 ` Max Reitz
2020-10-12 10:16 ` Philippe Mathieu-Daudé
2020-10-12 11:09 ` Max Reitz [this message]
2020-10-12 11:56 ` Philippe Mathieu-Daudé
2020-10-08 17:48 ` [PATCH 2/3] migration: Make save_snapshot() return bool, not 0/-1 Philippe Mathieu-Daudé
2020-10-09 12:09 ` Pavel Dovgalyuk
2020-10-09 13:57 ` Philippe Mathieu-Daudé
2020-10-08 17:48 ` [PATCH 3/3] migration: stop returning errno from load_snapshot() Philippe Mathieu-Daudé
2020-10-09 12:10 ` Pavel Dovgalyuk
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=f68d175a-68f0-3d6a-78d0-8a5981a9d983@redhat.com \
--to=mreitz@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=kwolf@redhat.com \
--cc=pavel.dovgaluk@ispras.ru \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/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).