Merge "Avoid using the disk cache on volume initialisation"

This commit is contained in:
Jenkins 2014-09-16 14:22:14 +00:00 committed by Gerrit Code Review
commit 4b2600fe3e
2 changed files with 16 additions and 13 deletions

View File

@ -64,11 +64,15 @@ def qemu_img_info(path):
def convert_image(source, dest, out_format, bps_limit=None):
"""Convert image to other format."""
start_time = timeutils.utcnow()
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)
cgcmd = volume_utils.setup_blkio_cgroup(source, dest, bps_limit)
if cgcmd:
cmd = tuple(cgcmd) + cmd
cmd += ('-t', 'none') # required to enable ratelimit by blkio cgroup
utils.execute(*cmd, run_as_root=True)
duration = timeutils.delta_seconds(start_time, timeutils.utcnow())

View File

@ -89,8 +89,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()
@ -236,11 +237,10 @@ class TestUtils(test.TestCase):
if has_qemu and dest_inf:
if bps_limit:
prefix = ('cgexec', '-g', 'blkio:test')
postfix = ('-t', 'none')
else:
prefix = postfix = ()
cmd = prefix + ('qemu-img', 'convert', '-O', 'raw',
self.TEST_DEV_PATH, self.TEST_DEV_PATH) + postfix
prefix = ()
cmd = prefix + ('qemu-img', 'convert', '-t', 'none', '-O', 'raw',
self.TEST_DEV_PATH, self.TEST_DEV_PATH)
volume_utils.setup_blkio_cgroup(
self.TEST_DEV_PATH, self.TEST_DEV_PATH,
@ -441,11 +441,10 @@ class TestUtils(test.TestCase):
if bps_limit:
CONF.set_override('volume_copy_bps_limit', bps_limit)
prefix = ('cgexec', '-g', 'blkio:test')
postfix = ('-t', 'none')
else:
prefix = postfix = ()
cmd = prefix + ('qemu-img', 'convert', '-O', 'qcow2',
mox.IgnoreArg(), mox.IgnoreArg()) + postfix
prefix = ()
cmd = prefix + ('qemu-img', 'convert', '-t', 'none', '-O', 'qcow2',
mox.IgnoreArg(), mox.IgnoreArg())
m = self._mox
m.StubOutWithMock(utils, 'execute')
@ -495,7 +494,7 @@ class TestUtils(test.TestCase):
m = self._mox
m.StubOutWithMock(utils, 'execute')
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',