On 1/20/21 4:44 AM, Daniel P. Berrangé wrote:
> Currently bdrv_all_find_snapshot() will return 0 if it finds
> a snapshot, -1 if an error occurs, or if it fails to find a
> snapshot. New callers to be added want to distinguish between
> the error scenario and failing to find a snapshot.
>
> Rename it to bdrv_all_has_snapshot and make it return -1 on
> error, 0 if no snapshot is found and 1 if snapshot is found.
>
> Reviewed-by: Eric Blake <[email protected]>
> Signed-off-by: Daniel P. Berrangé <[email protected]>
> ---
> +++ b/migration/savevm.c
> @@ -2942,10 +2942,15 @@ bool load_snapshot(const char *name, Error **errp)
> if (!bdrv_all_can_snapshot(false, NULL, errp)) {
> return false;
> }
> - ret = bdrv_all_find_snapshot(name, false, NULL, errp);
> + ret = bdrv_all_has_snapshot(name, false, NULL, errp);
> if (ret < 0) {
> return false;
> }
> + if (ret == 0) {
> + error_setg(errp, "Snapshot '%s' does not exist in one or more
> devices",
> + name);
> + return -1;
s/-1/false/ (hoist that hunk from 11/11).
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org