Blame SOURCES/0018-qcow2-Deprecation-warning-when-opening-v2-images-rw.patch

29b115
From 54f9157a918e1404f2f17ce89a9c8b9088c1bc06 Mon Sep 17 00:00:00 2001
a83cc2
From: Kevin Wolf <kwolf@redhat.com>
a83cc2
Date: Fri, 20 Aug 2021 18:25:12 +0200
77609c
Subject: qcow2: Deprecation warning when opening v2 images rw
a83cc2
MIME-Version: 1.0
a83cc2
Content-Type: text/plain; charset=UTF-8
a83cc2
Content-Transfer-Encoding: 8bit
a83cc2
a83cc2
RH-Author: Kevin Wolf <kwolf@redhat.com>
a83cc2
RH-MergeRequest: 37: qcow2: Deprecation warning when opening v2 images rw
a83cc2
RH-Commit: [1/1] f450d0ae32d35063b28c72c4f2d2ebb9e6d8db3e (kmwolf/centos-qemu-kvm)
a83cc2
RH-Bugzilla: 1951814
a83cc2
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
a83cc2
RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
a83cc2
RH-Acked-by: Thomas Huth <thuth@redhat.com>
a83cc2
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
a83cc2
a83cc2
qcow2 v3 has been around for a long time (since QEMU 1.1/RHEL 7), so
a83cc2
there is no real reason any more to use it. People still using it might
a83cc2
do so unintentionally. Warn about it and suggest upgrading during the
a83cc2
RHEL 9 timeframe so that the code can possibly be disabled in RHEL 10.
a83cc2
a83cc2
The warning is restricted to read-write mode and the system emulator.
a83cc2
The primary motivation for not having it in qemu-img is that 'qemu-img
a83cc2
amend' for upgrades would warn otherwise. It also avoids having to make
a83cc2
too many changes to the test suite.
a83cc2
a83cc2
bdrv_uses_whitelist() is used as a proxy for deciding whether we are
a83cc2
running in a tool or the system emulator. This is not entirely clean,
a83cc2
but it's what is available and the same function qcow2_do_open() already
a83cc2
uses it this way for another warning.
a83cc2
a83cc2
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
77609c
77609c
patch_name: kvm-qcow2-Deprecation-warning-when-opening-v2-images-rw.patch
77609c
present_in_specfile: true
77609c
location_in_specfile: 116
77609c
---
77609c
Rebase notes (6.1.0):
77609c
- Replace bs->read_only with bdrv_is_read_only
a83cc2
---
a83cc2
 block/qcow2.c                    | 6 ++++++
a83cc2
 tests/qemu-iotests/common.filter | 1 +
a83cc2
 2 files changed, 7 insertions(+)
a83cc2
a83cc2
diff --git a/block/qcow2.c b/block/qcow2.c
29b115
index b5c47931ef..a795e457ac 100644
a83cc2
--- a/block/qcow2.c
a83cc2
+++ b/block/qcow2.c
29b115
@@ -1337,6 +1337,12 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
a83cc2
         ret = -ENOTSUP;
a83cc2
         goto fail;
a83cc2
     }
77609c
+    if (header.version < 3 && !bdrv_is_read_only(bs) && bdrv_uses_whitelist()) {
a83cc2
+        warn_report_once("qcow2 v2 images are deprecated and may not be "
a83cc2
+                         "supported in future versions. Please consider "
a83cc2
+                         "upgrading the image with 'qemu-img amend "
a83cc2
+                         "-o compat=v3'.");
a83cc2
+    }
a83cc2
 
a83cc2
     s->qcow_version = header.version;
a83cc2
 
a83cc2
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
29b115
index cc9f1a5891..6a13757177 100644
a83cc2
--- a/tests/qemu-iotests/common.filter
a83cc2
+++ b/tests/qemu-iotests/common.filter
29b115
@@ -83,6 +83,7 @@ _filter_qemu()
a83cc2
 {
29b115
     gsed -e "s#\\(^\\|(qemu) \\)$(basename $QEMU_PROG):#\1QEMU_PROG:#" \
a83cc2
         -e 's#^QEMU [0-9]\+\.[0-9]\+\.[0-9]\+ monitor#QEMU X.Y.Z monitor#' \
a83cc2
+        -e "/qcow2 v2 images are deprecated/d" \
a83cc2
         -e $'s#\r##' # QEMU monitor uses \r\n line endings
a83cc2
 }
a83cc2
 
a83cc2
-- 
29b115
2.31.1
a83cc2