block: push error reporting into bdrv_all_*_snapshot functions

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.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
[PMD: Initialize variables]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210204124834.774401-2-berrange@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2021-02-04 12:48:23 +00:00 committed by Dr. David Alan Gilbert
parent a64aec725e
commit e26f98e209
7 changed files with 68 additions and 90 deletions

View file

@ -148,7 +148,7 @@ static char *replay_find_nearest_snapshot(int64_t icount,
*snapshot_icount = -1;
bs = bdrv_all_find_vmstate_bs();
bs = bdrv_all_find_vmstate_bs(NULL);
if (!bs) {
goto fail;
}
@ -159,7 +159,7 @@ static char *replay_find_nearest_snapshot(int64_t icount,
aio_context_release(aio_context);
for (i = 0; i < nb_sns; i++) {
if (bdrv_all_find_snapshot(sn_tab[i].name, &bs) == 0) {
if (bdrv_all_find_snapshot(sn_tab[i].name, NULL) == 0) {
if (sn_tab[i].icount != -1ULL
&& sn_tab[i].icount <= icount
&& (!nearest || nearest->icount < sn_tab[i].icount)) {