From patchwork Thu Jan 28 14:19:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 43871 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id ACF6CB7CE7 for ; Fri, 29 Jan 2010 01:32:43 +1100 (EST) Received: from localhost ([127.0.0.1]:53784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NaVNK-0007Pf-Cs for incoming@patchwork.ozlabs.org; Thu, 28 Jan 2010 09:29:38 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NaVDM-0008UM-Cy for qemu-devel@nongnu.org; Thu, 28 Jan 2010 09:19:20 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NaVDH-0008Sr-U2 for qemu-devel@nongnu.org; Thu, 28 Jan 2010 09:19:20 -0500 Received: from [199.232.76.173] (port=33688 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NaVDH-0008So-Jz for qemu-devel@nongnu.org; Thu, 28 Jan 2010 09:19:15 -0500 Received: from verein.lst.de ([213.95.11.210]:58289) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1NaVDG-00065p-Ol for qemu-devel@nongnu.org; Thu, 28 Jan 2010 09:19:15 -0500 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id o0SEJCWY003501 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Thu, 28 Jan 2010 15:19:12 +0100 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id o0SEJCIb003500 for qemu-devel@nongnu.org; Thu, 28 Jan 2010 15:19:12 +0100 Date: Thu, 28 Jan 2010 15:19:12 +0100 From: Christoph Hellwig To: qemu-devel@nongnu.org Message-ID: <20100128141912.GA3454@lst.de> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Spam-Score: 0 () X-Scanned-By: MIMEDefang 2.39 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH] block: saner flags filtering in bdrv_open2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Clean up the current mess about figuring out which flags to pass to the driver. BDRV_O_FILE, BDRV_O_SNAPSHOT and BDRV_O_NO_BACKING are flags only used by the block layer internally so filter them out directly. Previously BDRV_O_NO_BACKING could accidentally be passed to the drivers, but wasn't ever used. Signed-off-by: Christoph Hellwig Index: qemu/block.c =================================================================== --- qemu.orig/block.c 2010-01-28 15:12:52.316024386 +0100 +++ qemu/block.c 2010-01-28 15:13:33.419004083 +0100 @@ -451,13 +451,20 @@ int bdrv_open2(BlockDriverState *bs, con bs->enable_write_cache = 1; bs->read_only = (flags & BDRV_O_RDWR) == 0; - if (!(flags & BDRV_O_FILE)) { - open_flags = (flags & (BDRV_O_RDWR | BDRV_O_CACHE_MASK|BDRV_O_NATIVE_AIO)); - if (bs->is_temporary) { /* snapshot should be writeable */ - open_flags |= BDRV_O_RDWR; - } - } else { - open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT); + + /* + * Clear flags that are internal to the block layer before opening the + * image. + */ + open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); + + /* + * Snapshots should be writeable. + * + * XXX(hch): and what is the point of a snapshot during a read-only open? + */ + if (!(flags & BDRV_O_FILE) && bs->is_temporary) { + open_flags |= BDRV_O_RDWR; } ret = drv->bdrv_open(bs, filename, open_flags);