diff options
Diffstat (limited to 'block')
-rw-r--r-- | block/snapshot.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/block/snapshot.c b/block/snapshot.c index ed0422df9f..61a6ad12dc 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -381,3 +381,25 @@ bool bdrv_all_can_snapshot(BlockDriverState **first_bad_bs) *first_bad_bs = bs; return ok; } + +int bdrv_all_delete_snapshot(const char *name, BlockDriverState **first_bad_bs, + Error **err) +{ + int ret = 0; + BlockDriverState *bs = NULL; + QEMUSnapshotInfo sn1, *snapshot = &sn1; + + while (ret == 0 && (bs = bdrv_next(bs))) { + AioContext *ctx = bdrv_get_aio_context(bs); + + aio_context_acquire(ctx); + if (bdrv_can_snapshot(bs) && + bdrv_snapshot_find(bs, snapshot, name) >= 0) { + ret = bdrv_snapshot_delete_by_id_or_name(bs, name, err); + } + aio_context_release(ctx); + } + + *first_bad_bs = bs; + return ret; +} |