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

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