[PATCH 09/12] block: add "snapshot.size" option to avoid extra bdrv_open()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
 block.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/block.c b/block.c
index 5db8fa1..b421083 100644
--- a/block.c
+++ b/block.c
@@ -1046,20 +1046,25 @@ 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_report("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);
-        if (ret < 0) {
+        if (total_size == -1) {
+            bs1 = bdrv_new_int("", NULL);
+            ret = bdrv_open(bs1, filename, NULL, 0, drv);
+            if (ret < 0) {
+                bdrv_delete(bs1);
+                goto fail;
+            }
+            total_size = bdrv_getlength(bs1);
             bdrv_delete(bs1);
-            goto fail;
         }
-        total_size = bdrv_getlength(bs1);
-        bdrv_delete(bs1);
 
         ret = make_snapshot(bs, total_size, &filename, &drv);
         if (ret < 0) {
-- 
1.8.3.rc1.49.g8d97506

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]