From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> --- block.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index 09aada5..9e7632e 100644 --- a/block.c +++ b/block.c @@ -1135,27 +1135,32 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, BlockDriverState *bs1; int64_t total_size; + total_size = qdict_get_try_int(options, "snapshot.size", -1); + qdict_del(options, "snapshot.size"); + if (qdict_size(options) != 0) { error_setg(errp, "Can't use snapshot=on with driver-specific options"); ret = -EINVAL; goto fail; } - bs1 = bdrv_new_int("", NULL); - ret = bdrv_open(bs1, filename, NULL, 0, drv, &local_err); - if (ret < 0) { + if (total_size == -1) { + bs1 = bdrv_new_int("", NULL); + ret = bdrv_open(bs1, filename, NULL, 0, drv, &local_err); + if (ret < 0) { + bdrv_unref(bs1); + goto fail; + } + total_size = bdrv_getlength(bs1); bdrv_unref(bs1); - goto fail; } - total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK; - bdrv_unref(bs1); - ret = make_snapshot(bs, total_size, &filename, &drv, errp); if (ret < 0) { goto fail; } } + qdict_del(options, "snapshot.size"); /* Open image file without format layer */ if (flags & BDRV_O_RDWR) { -- 1.8.3.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel