From 3d3e9b1f669b60d9d3cb857edbfc3d54cbb9c0ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Thu, 4 Feb 2021 12:48:28 +0000 Subject: block: rename and alter bdrv_all_find_snapshot semantics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Daniel P. Berrangé Message-Id: <20210204124834.774401-7-berrange@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/savevm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'migration') diff --git a/migration/savevm.c b/migration/savevm.c index cdd201e..a2a842d 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2977,10 +2977,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 false; + } bs_vm_state = bdrv_all_find_vmstate_bs(NULL, false, NULL, errp); if (!bs_vm_state) { -- cgit v1.1