Received: from eggs.gnu.org ([2001:4830:134:3::10]:46722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn6sg-00066h-Ei for qemu-devel@nongnu.org; Thu, 22 Sep 2016 12:29:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn6sd-00057K-L2 for qemu-devel@nongnu.org; Thu, 22 Sep 2016 12:29:50 -0400 From: Kevin Wolf Date: Thu, 22 Sep 2016 18:29:07 +0200 Message-Id: <1474561774-19256-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1474561774-19256-1-git-send-email-kwolf@redhat.com> References: <1474561774-19256-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 06/33] block: Update bs->open_flags earlier in bdrv_open_common() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Alberto Garcia We're only doing this immediately before opening the image, but bs->open_flags is used earlier in the function. At the moment this is not causing problems because none of the checked flags are modified by update_flags_from_options(), but this will change when we introduce the "read-only" option. This patch calls update_flags_from_options() at the beginning of the function, immediately after creating the QemuOpts. Signed-off-by: Alberto Garcia Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 324dbe7..a98b75e 100644 --- a/block.c +++ b/block.c @@ -961,6 +961,8 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file, goto fail_opts; } + update_flags_from_options(&bs->open_flags, opts); + driver_name = qemu_opt_get(opts, "driver"); drv = bdrv_find_format(driver_name); assert(drv != NULL); @@ -1022,9 +1024,6 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file, bs->drv = drv; bs->opaque = g_malloc0(drv->instance_size); - /* Apply cache mode options */ - update_flags_from_options(&bs->open_flags, opts); - /* Open the image, either directly or using a protocol */ open_flags = bdrv_open_flags(bs, bs->open_flags); if (drv->bdrv_file_open) { -- 1.8.3.1