summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nova/tests/test_libvirt.py7
-rw-r--r--nova/virt/libvirt/connection.py6
2 files changed, 13 insertions, 0 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index cdc9121d7a..5163b32d41 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -899,6 +899,13 @@ class LibvirtConnTestCase(test.TestCase):
self.stubs.Set(os, 'open', os_open_stub)
+ def connection_supports_direct_io_stub(*args, **kwargs):
+ return directio_supported
+
+ self.stubs.Set(connection.LibvirtConnection,
+ '_supports_direct_io',
+ connection_supports_direct_io_stub)
+
user_context = context.RequestContext(self.user_id, self.project_id)
instance_ref = db.instance_create(user_context, self.test_instance)
network_info = _fake_network_info(self.stubs, 1)
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index 5facc1091f..00345d2613 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -1037,7 +1037,13 @@ class LibvirtConnection(driver.ComputeDriver):
@staticmethod
def _supports_direct_io(dirpath):
+
+ if not hasattr(os, 'O_DIRECT'):
+ LOG.debug("This python runtime does not support direct I/O")
+ return False
+
testfile = os.path.join(dirpath, ".directio.test")
+
hasDirectIO = True
try:
f = os.open(testfile, os.O_CREAT | os.O_WRONLY | os.O_DIRECT)