File 0001-Avoid-using-the-disk-cache-on-volume-initialisation.patch of Package openstack-cinder
From f0928627a033502402739c801afc8c7c0a21d120 Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dirk@dmllr.de>
Date: Tue, 5 Aug 2014 16:13:33 +0200
Subject: [PATCH] Avoid using the disk cache on volume initialisation
When caching is involved, the volume might be
unmapped before the copy actually hit the disk or the
VM starts booting before all of the data has been flushed,
which causes the VM to crash at an arbitrary point in time.
Change-Id: I7a04f683add8c23b9125fe837c4048ccc3ac224d
---
cinder/image/image_utils.py | 7 ++++++-
cinder/tests/test_image_utils.py | 11 ++++++-----
2 files changed, 12 insertions(+), 6 deletions(-)
Index: cinder-2014.1.5.dev9/cinder/image/image_utils.py
===================================================================
--- cinder-2014.1.5.dev9.orig/cinder/image/image_utils.py
+++ cinder-2014.1.5.dev9/cinder/image/image_utils.py
@@ -61,7 +61,12 @@ def qemu_img_info(path):
def convert_image(source, dest, out_format):
"""Convert image to other format."""
- cmd = ('qemu-img', 'convert', '-O', out_format, source, dest)
+ # Always set -t none. First it is needed for cgroup io/limiting
+ # and it is needed to ensure that all data hit the device before
+ # it gets unmapped remotely from the host
+ cmd = ('qemu-img', 'convert',
+ '-t', 'none',
+ '-O', out_format, source, dest)
utils.execute(*cmd, run_as_root=True)
Index: cinder-2014.1.5.dev9/cinder/tests/test_image_utils.py
===================================================================
--- cinder-2014.1.5.dev9.orig/cinder/tests/test_image_utils.py
+++ cinder-2014.1.5.dev9/cinder/tests/test_image_utils.py
@@ -80,8 +80,9 @@ class TestUtils(test.TestCase):
TEST_SOURCE = 'img/qemu.img'
TEST_DEST = '/img/vmware.vmdk'
- utils.execute('qemu-img', 'convert', '-O', TEST_OUT_FORMAT,
- TEST_SOURCE, TEST_DEST, run_as_root=True)
+ utils.execute(
+ 'qemu-img', 'convert', '-t', 'none', '-O', TEST_OUT_FORMAT,
+ TEST_SOURCE, TEST_DEST, run_as_root=True)
mox.ReplayAll()
@@ -224,7 +225,7 @@ class TestUtils(test.TestCase):
if has_qemu and dest_inf:
utils.execute(
- 'qemu-img', 'convert', '-O', 'raw',
+ 'qemu-img', 'convert', '-t', 'none', '-O', 'raw',
self.TEST_DEV_PATH, self.TEST_DEV_PATH, run_as_root=True)
utils.execute(
@@ -400,7 +401,7 @@ class TestUtils(test.TestCase):
'env', 'LC_ALL=C', 'qemu-img', 'info',
mox.IgnoreArg(), run_as_root=True).AndReturn(
(TEST_RET, 'ignored'))
- utils.execute('qemu-img', 'convert', '-O', 'qcow2',
+ utils.execute('qemu-img', 'convert', '-t', 'none', '-O', 'qcow2',
mox.IgnoreArg(), mox.IgnoreArg(), run_as_root=True)
utils.execute(
'env', 'LC_ALL=C', 'qemu-img', 'info',
@@ -442,7 +443,7 @@ class TestUtils(test.TestCase):
'env', 'LC_ALL=C', 'qemu-img', 'info',
mox.IgnoreArg(), run_as_root=True).AndReturn(
(TEST_RET, 'ignored'))
- utils.execute('qemu-img', 'convert', '-O', 'qcow2',
+ utils.execute('qemu-img', 'convert', '-t', 'none', '-O', 'qcow2',
mox.IgnoreArg(), mox.IgnoreArg(), run_as_root=True)
utils.execute(
'env', 'LC_ALL=C', 'qemu-img', 'info',