<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From 22a87de5268437cb1b1f7e044817ea70d4ebeb49 Mon Sep 17 00:00:00 2001
From: Naphtali Sprei &lt;nsprei@redhat.com&gt;
Date: Wed, 7 Apr 2010 16:44:21 -0300
Subject: [PATCH 10/21] block: saner flags filtering in bdrv_open2

RH-Author: Naphtali Sprei &lt;nsprei@redhat.com&gt;
Message-id: &lt;1270658667-14294-11-git-send-email-nsprei@redhat.com&gt;
Patchwork-id: 8447
O-Subject: [RHEL6 kvm PATCH v3 rebase 10/16] block: saner flags filtering in
	bdrv_open2
Bugzilla: 537164
RH-Acked-by: Daniel P. Berrange &lt;berrange@redhat.com&gt;
RH-Acked-by: Christoph Hellwig &lt;chellwig@redhat.com&gt;
RH-Acked-by: Juan Quintela &lt;quintela@redhat.com&gt;
RH-Acked-by: Kevin Wolf &lt;kwolf@redhat.com&gt;

From: Christoph Hellwig &lt;hch@lst.de&gt;

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.

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=537164
upstream commit: 15dc2697a51ab39a0e9da95c8ce01675c1cb7090

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Anthony Liguori &lt;aliguori@us.ibm.com&gt;
Signed-off-by: Naphtali Sprei &lt;nsprei@redhat.com&gt;
---
 block.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

Signed-off-by: Eduardo Habkost &lt;ehabkost@redhat.com&gt;
---
 block.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/block.c b/block.c
index 252b7a8..bed5b88 100644
--- a/block.c
+++ b/block.c
@@ -451,13 +451,20 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
         bs-&gt;enable_write_cache = 1;
 
     bs-&gt;read_only = (flags &amp; BDRV_O_RDWR) == 0;
-    if (!(flags &amp; BDRV_O_FILE)) {
-        open_flags = (flags &amp; (BDRV_O_RDWR | BDRV_O_CACHE_MASK|BDRV_O_NATIVE_AIO));
-        if (bs-&gt;is_temporary) { /* snapshot should be writeable */
-            open_flags |= BDRV_O_RDWR;
-        }
-    } else {
-        open_flags = flags &amp; ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);
+
+    /*
+     * Clear flags that are internal to the block layer before opening the
+     * image.
+     */
+    open_flags = flags &amp; ~(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 &amp; BDRV_O_FILE) &amp;&amp; bs-&gt;is_temporary) {
+        open_flags |= BDRV_O_RDWR;
     }
 
     ret = drv-&gt;bdrv_open(bs, filename, open_flags);
-- 
1.7.0.3

</pre></body></html>