From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:44619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaRc5-00040w-1T for qemu-devel@nongnu.org; Tue, 13 Dec 2011 07:37:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaRbx-0004Fc-Uu for qemu-devel@nongnu.org; Tue, 13 Dec 2011 07:37:40 -0500 Received: from mail-yw0-f45.google.com ([209.85.213.45]:63177) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaRbx-0004Es-Q2 for qemu-devel@nongnu.org; Tue, 13 Dec 2011 07:37:33 -0500 Received: by mail-yw0-f45.google.com with SMTP id g71so370792yhg.4 for ; Tue, 13 Dec 2011 04:37:33 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 13 Dec 2011 13:37:05 +0100 Message-Id: <1323779840-4235-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1323779840-4235-1-git-send-email-pbonzini@redhat.com> References: <1323779840-4235-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 02/17] block: store actual flags in bs->open_flags List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org The passed flags are changed slightly before passing them to bdrv_open. Store the same flags in bs->open_flags, so that they are used correctly in bdrv_snapshot_goto. In addition, this way we will be able to query them and get back consistent values. Signed-off-by: Paolo Bonzini --- block.c | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-) diff --git a/block.c b/block.c index a96f080..fa11e3a 100644 --- a/block.c +++ b/block.c @@ -566,12 +566,26 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename, trace_bdrv_open_common(bs, filename, flags, drv->format_name); + /* + * Clear flags that are internal to the block layer before opening the + * image. + */ + open_flags = flags & ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); + + /* + * Snapshots should be writable. + */ + if (bs->is_temporary) { + open_flags |= BDRV_O_RDWR; + } + + bs->file = NULL; bs->total_sectors = 0; bs->encrypted = 0; bs->valid_key = 0; bs->sg = 0; - bs->open_flags = flags; + bs->open_flags = open_flags; bs->growable = 0; bs->buffer_alignment = 512; @@ -591,20 +605,6 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename, bs->opaque = g_malloc0(drv->instance_size); bs->enable_write_cache = !!(flags & BDRV_O_CACHE_WB); - - /* - * Clear flags that are internal to the block layer before opening the - * image. - */ - open_flags = flags & ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); - - /* - * Snapshots should be writable. - */ - if (bs->is_temporary) { - open_flags |= BDRV_O_RDWR; - } - bs->keep_read_only = bs->read_only = !(open_flags & BDRV_O_RDWR); /* Open the image, either directly or using a protocol */ -- 1.7.7.1