summaryrefslogtreecommitdiff
path: root/nova/virt/images.py
diff options
context:
space:
mode:
authorThomas Goirand <zigo@debian.org>2017-11-28 23:22:56 +0100
committermelanie witt <melwittt@gmail.com>2017-11-29 22:33:39 +0000
commite6ce9557f84cdcdf4ffdd12ce73a008c96c7b94a (patch)
tree5f5169a968318b399a2bf071097ad48544793248 /nova/virt/images.py
parent42706270b92dd12456ba385ebfce38b99431940d (diff)
downloadnova-e6ce9557f84cdcdf4ffdd12ce73a008c96c7b94a.tar.gz
qemu-img do not use cache=none if no O_DIRECT support
If /var/lib/nova/instances is mounted on a filesystem like tmpfs that doesn't have support for O_DIRECT, "qemu-img convert" currently crashes because it's unconditionally using the "-t none" flag. This patch therefore: - moves the _supports_direct_io() function out of the libvirt driver, from nova/virt/libvirt/driver.py to nova/utils.py and makes it public. - uses that function to decide to use -t none or -t writethrough when converting images with qemu-img. Closes-Bug: #1734784 Co-Authored-By: melanie witt <melwittt@gmail.com> Change-Id: Ifb47de00abf3f83442ca5264fbc24885df924a19
Diffstat (limited to 'nova/virt/images.py')
-rw-r--r--nova/virt/images.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/nova/virt/images.py b/nova/virt/images.py
index be2a9d9e06..b78389000c 100644
--- a/nova/virt/images.py
+++ b/nova/virt/images.py
@@ -118,7 +118,18 @@ def _convert_image(source, dest, in_format, out_format, run_as_root):
# on persistent storage when the command exits. Without (2), a host crash
# may leave a corrupt image in the image cache, which Nova cannot recover
# automatically.
- cmd = ('qemu-img', 'convert', '-t', 'none', '-O', out_format)
+ # NOTE(zigo): we cannot use -t none if the instances dir is mounted on a
+ # filesystem that doesn't have support for O_DIRECT, which is the case
+ # for example with tmpfs. This simply crashes "openstack server create"
+ # in environments like live distributions. In such case, the best choice
+ # is writethrough, which is power-failure safe, but still faster than
+ # writeback.
+ if utils.supports_direct_io(CONF.instances_path):
+ cache_mode = 'none'
+ else:
+ cache_mode = 'writethrough'
+ cmd = ('qemu-img', 'convert', '-t', cache_mode, '-O', out_format)
+
if in_format is not None:
cmd = cmd + ('-f', in_format)
cmd = cmd + (source, dest)