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

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