summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
Diffstat (limited to 'block')
-rw-r--r--block/monitor/block-hmp-cmds.c2
-rw-r--r--block/snapshot.c19
2 files changed, 13 insertions, 8 deletions
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index 9cc5d4b51e..75d7fa9510 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -954,7 +954,7 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
total = 0;
for (i = 0; i < nb_sns; i++) {
SnapshotEntry *next_sn;
- if (bdrv_all_find_snapshot(sn_tab[i].name, false, NULL, NULL) == 0) {
+ if (bdrv_all_has_snapshot(sn_tab[i].name, false, NULL, NULL) == 1) {
global_snapshots[total] = i;
total++;
QTAILQ_FOREACH(image_entry, &image_list, next) {
diff --git a/block/snapshot.c b/block/snapshot.c
index 0b129bee8f..e8ae9a28c1 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -603,9 +603,9 @@ int bdrv_all_goto_snapshot(const char *name,
return 0;
}
-int bdrv_all_find_snapshot(const char *name,
- bool has_devices, strList *devices,
- Error **errp)
+int bdrv_all_has_snapshot(const char *name,
+ bool has_devices, strList *devices,
+ Error **errp)
{
g_autoptr(GList) bdrvs = NULL;
GList *iterbdrvs;
@@ -627,15 +627,20 @@ int bdrv_all_find_snapshot(const char *name,
}
aio_context_release(ctx);
if (ret < 0) {
- error_setg(errp, "Could not find snapshot '%s' on '%s'",
- name, bdrv_get_device_or_node_name(bs));
- return -1;
+ if (ret == -ENOENT) {
+ return 0;
+ } else {
+ error_setg_errno(errp, errno,
+ "Could not check snapshot '%s' on '%s'",
+ name, bdrv_get_device_or_node_name(bs));
+ return -1;
+ }
}
iterbdrvs = iterbdrvs->next;
}
- return 0;
+ return 1;
}
int bdrv_all_create_snapshot(QEMUSnapshotInfo *sn,