]> git.proxmox.com Git - mirror_qemu.git/blobdiff - block.c
block: Move initialisation of BlockLimits to bdrv_refresh_limits()
[mirror_qemu.git] / block.c
diff --git a/block.c b/block.c
index 2106ae9ceebdd3f955de04c79ff24edb9758b8ef..0a3d12c32801030ddbac3b138859b35af8297680 100644 (file)
--- a/block.c
+++ b/block.c
@@ -483,6 +483,19 @@ int bdrv_create_file(const char* filename, QEMUOptionParameter *options,
     return ret;
 }
 
+static int bdrv_refresh_limits(BlockDriverState *bs)
+{
+    BlockDriver *drv = bs->drv;
+
+    memset(&bs->bl, 0, sizeof(bs->bl));
+
+    if (drv && drv->bdrv_refresh_limits) {
+        return drv->bdrv_refresh_limits(bs);
+    }
+
+    return 0;
+}
+
 /*
  * Create a uniquely-named empty temporary file.
  * Return 0 upon success, otherwise a negative errno value.
@@ -872,6 +885,8 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
         goto free_and_fail;
     }
 
+    bdrv_refresh_limits(bs);
+
 #ifndef _WIN32
     if (bs->is_temporary) {
         assert(bs->filename[0] != '\0');
@@ -1085,6 +1100,9 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
                 bs->backing_hd->file->filename);
     }
 
+    /* Recalculate the BlockLimits with the backing file */
+    bdrv_refresh_limits(bs);
+
     return 0;
 }