|
|
7711c0 |
From 043d71d0340799feafee434f8eec0360840ec777 Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Date: Fri, 15 Mar 2019 18:10:04 +0100
|
|
|
7711c0 |
Subject: [PATCH 008/163] file-posix: Fix bdrv_open_flags() for snapshot=on
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Message-id: <20190315181010.14964-9-kwolf@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 84885
|
|
|
7711c0 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 08/14] file-posix: Fix bdrv_open_flags() for snapshot=on
|
|
|
7711c0 |
Bugzilla: 1685989
|
|
|
7711c0 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
Using a different read-only setting for bs->open_flags than for the
|
|
|
7711c0 |
flags to the driver's open function is just inconsistent and a bad idea.
|
|
|
7711c0 |
After this patch, the temporary snapshot keeps being opened read-only if
|
|
|
7711c0 |
read-only=on,snapshot=on is passed.
|
|
|
7711c0 |
|
|
|
7711c0 |
If we wanted to change this behaviour to make only the orginal image
|
|
|
7711c0 |
file read-only, but the temporary overlay read-write (as the comment in
|
|
|
7711c0 |
the removed code suggests), that change would have to be made in
|
|
|
7711c0 |
bdrv_temp_snapshot_options() (where the comment suggests otherwise).
|
|
|
7711c0 |
|
|
|
7711c0 |
Addressing this inconsistency before introducing dynamic auto-read-only
|
|
|
7711c0 |
is important because otherwise we would immediately try to reopen the
|
|
|
7711c0 |
temporary overlay even though the file is already unlinked.
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit 30855137783c0c762007044821a6f11e14e6af33)
|
|
|
7711c0 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
block.c | 7 -------
|
|
|
7711c0 |
tests/qemu-iotests/051 | 7 +++++++
|
|
|
7711c0 |
tests/qemu-iotests/051.out | 9 +++++++++
|
|
|
7711c0 |
tests/qemu-iotests/051.pc.out | 9 +++++++++
|
|
|
7711c0 |
4 files changed, 25 insertions(+), 7 deletions(-)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/block.c b/block.c
|
|
|
7711c0 |
index 25b3fe5..bcf277d 100644
|
|
|
7711c0 |
--- a/block.c
|
|
|
7711c0 |
+++ b/block.c
|
|
|
7711c0 |
@@ -1100,13 +1100,6 @@ static int bdrv_open_flags(BlockDriverState *bs, int flags)
|
|
|
7711c0 |
*/
|
|
|
7711c0 |
open_flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_PROTOCOL);
|
|
|
7711c0 |
|
|
|
7711c0 |
- /*
|
|
|
7711c0 |
- * Snapshots should be writable.
|
|
|
7711c0 |
- */
|
|
|
7711c0 |
- if (flags & BDRV_O_TEMPORARY) {
|
|
|
7711c0 |
- open_flags |= BDRV_O_RDWR;
|
|
|
7711c0 |
- }
|
|
|
7711c0 |
-
|
|
|
7711c0 |
return open_flags;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051
|
|
|
7711c0 |
index 4899f84..23f9678 100755
|
|
|
7711c0 |
--- a/tests/qemu-iotests/051
|
|
|
7711c0 |
+++ b/tests/qemu-iotests/051
|
|
|
7711c0 |
@@ -357,6 +357,13 @@ $QEMU_IO -c "read -P 0x33 0 4k" "$TEST_IMG" | _filter_qemu_io
|
|
|
7711c0 |
# Using snapshot=on with a non-existent TMPDIR
|
|
|
7711c0 |
TMPDIR=/nonexistent run_qemu -drive driver=null-co,snapshot=on
|
|
|
7711c0 |
|
|
|
7711c0 |
+# Using snapshot=on together with read-only=on
|
|
|
7711c0 |
+echo "info block" |
|
|
|
7711c0 |
+ run_qemu -drive file="$TEST_IMG",snapshot=on,read-only=on,if=none,id=$device_id |
|
|
|
7711c0 |
+ _filter_qemu_io |
|
|
|
7711c0 |
+ sed -e 's#/[^"]*/vl\.[A-Za-z0-9]\{6\}#SNAPSHOT_PATH#g'
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+
|
|
|
7711c0 |
# success, all done
|
|
|
7711c0 |
echo "*** done"
|
|
|
7711c0 |
rm -f $seq.full
|
|
|
7711c0 |
diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out
|
|
|
7711c0 |
index 793af2a..e2f91fc 100644
|
|
|
7711c0 |
--- a/tests/qemu-iotests/051.out
|
|
|
7711c0 |
+++ b/tests/qemu-iotests/051.out
|
|
|
7711c0 |
@@ -458,4 +458,13 @@ read 4096/4096 bytes at offset 0
|
|
|
7711c0 |
Testing: -drive driver=null-co,snapshot=on
|
|
|
7711c0 |
QEMU_PROG: -drive driver=null-co,snapshot=on: Could not get temporary filename: No such file or directory
|
|
|
7711c0 |
|
|
|
7711c0 |
+Testing: -drive file=TEST_DIR/t.qcow2,snapshot=on,read-only=on,if=none,id=drive0
|
|
|
7711c0 |
+QEMU X.Y.Z monitor - type 'help' for more information
|
|
|
7711c0 |
+(qemu) info block
|
|
|
7711c0 |
+drive0 (NODE_NAME): SNAPSHOT_PATH (qcow2, read-only)
|
|
|
7711c0 |
+ Removable device: not locked, tray closed
|
|
|
7711c0 |
+ Cache mode: writeback, ignore flushes
|
|
|
7711c0 |
+ Backing file: TEST_DIR/t.qcow2 (chain depth: 1)
|
|
|
7711c0 |
+(qemu) quit
|
|
|
7711c0 |
+
|
|
|
7711c0 |
*** done
|
|
|
7711c0 |
diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out
|
|
|
7711c0 |
index ca64eda..3f71f9e 100644
|
|
|
7711c0 |
--- a/tests/qemu-iotests/051.pc.out
|
|
|
7711c0 |
+++ b/tests/qemu-iotests/051.pc.out
|
|
|
7711c0 |
@@ -530,4 +530,13 @@ read 4096/4096 bytes at offset 0
|
|
|
7711c0 |
Testing: -drive driver=null-co,snapshot=on
|
|
|
7711c0 |
QEMU_PROG: -drive driver=null-co,snapshot=on: Could not get temporary filename: No such file or directory
|
|
|
7711c0 |
|
|
|
7711c0 |
+Testing: -drive file=TEST_DIR/t.qcow2,snapshot=on,read-only=on,if=none,id=drive0
|
|
|
7711c0 |
+QEMU X.Y.Z monitor - type 'help' for more information
|
|
|
7711c0 |
+(qemu) info block
|
|
|
7711c0 |
+drive0 (NODE_NAME): SNAPSHOT_PATH (qcow2, read-only)
|
|
|
7711c0 |
+ Removable device: not locked, tray closed
|
|
|
7711c0 |
+ Cache mode: writeback, ignore flushes
|
|
|
7711c0 |
+ Backing file: TEST_DIR/t.qcow2 (chain depth: 1)
|
|
|
7711c0 |
+(qemu) quit
|
|
|
7711c0 |
+
|
|
|
7711c0 |
*** done
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|