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