Blame SOURCES/0026-blockdev-ignore-aio-native-for-empty-drives.patch

383d26
From d4fe1e7fd6002d201088870c1e019b607c168454 Mon Sep 17 00:00:00 2001
383d26
From: John Snow <jsnow@redhat.com>
383d26
Date: Thu, 11 May 2017 20:53:51 +0200
383d26
Subject: blockdev: ignore aio=native for empty drives
383d26
383d26
RH-Author: John Snow <jsnow@redhat.com>
383d26
Message-id: <20170511205351.6337-2-jsnow@redhat.com>
383d26
Patchwork-id: 75070
383d26
O-Subject: [RHV-7.4 qemu-kvm-rhev PATCH 1/1] blockdev: ignore aio=native for empty drives
383d26
Bugzilla: 1402645
383d26
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
383d26
RH-Acked-by: Eric Blake <eblake@redhat.com>
383d26
RH-Acked-by: Max Reitz <mreitz@redhat.com>
383d26
383d26
This is a bit of a gross one; Upstream QEMU changed the way it handles
383d26
cache options with regards to removable media, associating options more
383d26
with the medium instead of the device. As part of that, it became
383d26
impossible to specify cache options on empty drives.
383d26
383d26
In the future, one would use blockdev-add instead to choose cache options
383d26
per-medium instead of per-device, but we're not there yet in libvirt so
383d26
we added a workaround downstream to simply ignore cache options on empty
383d26
CDROMs under the premise of "It actually never worked anyway."
383d26
383d26
As fallout from this decision, it is now no longer possible to specify
383d26
aio=native on empty CDROM devices either, as that requires the use of a
383d26
cache option that you can no longer specify. As a bad, gross, disgusting
383d26
workaround, simply ignore aio=native on empty drives until such time that
383d26
libvirt stops providing such configurations.
383d26
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
(cherry picked from commit cda174ad842c9a61bc275315bf3155139ba19bc0)
383d26
(cherry picked from commit a72f1c0f7b02ea571ec2ce35dfbe8c17c4dfa6d9)
383d26
(cherry picked from commit 313ffb6aba9419fe620b898c9b4a5ab4b0bff205)
383d26
(cherry picked from commit fa1666d4f59412a324067a1bd9b4fed7ca8c71f2)
383d26
(cherry picked from commit 62a7f6391872a32c3fdcbce988e2b7b760fca0c9)
383d26
---
383d26
 blockdev.c | 17 ++++++++++++++++-
383d26
 1 file changed, 16 insertions(+), 1 deletion(-)
383d26
383d26
diff --git a/blockdev.c b/blockdev.c
383d26
index cf10108..60b37dc 100644
383d26
--- a/blockdev.c
383d26
+++ b/blockdev.c
383d26
@@ -486,6 +486,21 @@ static bool __redhat_com_has_bs_opts(QDict *bs_opts)
383d26
     return s != n;
383d26
 }
383d26
 
383d26
+/**
383d26
+ * libvirt expects to be able to pass io driver options (aio=native) for CDROM
383d26
+ * drives without inserted media. While this has worked historically, given the
383d26
+ * above workaround and lack of a supported alternative in current versions of
383d26
+ * libvirt, certain options such as aio=native cannot be supported as it
383d26
+ * requires the use of an accompanying cache option, which we also ignore.
383d26
+ * Until libvirt learns how to supply cache options to inserted media, ignore
383d26
+ * the aio= preference on empty CDROMs with the understanding that un-tuned
383d26
+ * performance is preferable to being unable to use the CDROM at all.
383d26
+ */
383d26
+static int __redhat_com_filter_flags(int flags)
383d26
+{
383d26
+    return flags & ~BDRV_O_NATIVE_AIO;
383d26
+}
383d26
+
383d26
 /* Takes the ownership of bs_opts */
383d26
 static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
383d26
                                    Error **errp)
383d26
@@ -598,7 +613,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
383d26
 
383d26
         blk = blk_new(0, BLK_PERM_ALL);
383d26
         blk_rs = blk_get_root_state(blk);
383d26
-        blk_rs->open_flags    = bdrv_flags;
383d26
+        blk_rs->open_flags    = __redhat_com_filter_flags(bdrv_flags);
383d26
         blk_rs->read_only     = read_only;
383d26
         blk_rs->detect_zeroes = detect_zeroes;
383d26
 
383d26
-- 
383d26
1.8.3.1
383d26