thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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