Merge "XenAPI: Use direct IO for writing config drive"

This commit is contained in:
Jenkins 2014-02-10 00:18:40 +00:00 committed by Gerrit Code Review
commit 126ae5f65f
3 changed files with 28 additions and 1 deletions

View File

@ -219,3 +219,7 @@ rbd: CommandFilter, rbd, root
# nova/virt/libvirt/volume.py: 'cp', '/dev/stdin', delete_control..
cp: CommandFilter, cp, root
# nova/virt/xenapi/vm_utils.py:
sync: CommandFilter, sync, root

View File

@ -185,7 +185,7 @@ class GenerateConfigDriveTestCase(VMUtilsTestBase):
'-J', '-r', '-V', 'config-2', mox.IgnoreArg(),
attempts=1, run_as_root=False).AndReturn(None)
utils.execute('dd', mox.IgnoreArg(), mox.IgnoreArg(),
run_as_root=True).AndReturn(None)
mox.IgnoreArg(), run_as_root=True).AndReturn(None)
self.mox.StubOutWithMock(vm_utils, 'create_vbd')
vm_utils.create_vbd('session', 'vm_ref', 'vdi_ref', mox.IgnoreArg(),
@ -1698,6 +1698,25 @@ class GetAllVdisTestCase(VMUtilsTestBase):
session.call_xenapi.assert_called_once_with("SR.get_VDIs", sr_ref)
class VDIAttachedHere(VMUtilsTestBase):
@mock.patch.object(vm_utils, 'destroy_vbd')
@mock.patch.object(vm_utils, '_get_this_vm_ref')
@mock.patch.object(vm_utils, 'create_vbd')
@mock.patch.object(volume_utils, 'vbd_plug')
@mock.patch.object(vm_utils, '_remap_vbd_dev')
@mock.patch.object(vm_utils, '_wait_for_device')
@mock.patch.object(utils, 'execute')
@mock.patch.object(vm_utils, 'unplug_vbd')
def test_sync_called(self, mock_unplug_vbd, mock_execute,
mock_wait_for_device, mock_remap_vbd_dev,
mock_vbd_plug, mock_create_vbd,
mock_get_this_vm_ref, mock_destroy_vbd):
session = mock.Mock()
with vm_utils.vdi_attached_here(session, 'vdi_ref'):
pass
mock_execute.assert_called_with('sync', run_as_root=True)
class SnapshotAttachedHereTestCase(VMUtilsTestBase):
@mock.patch.object(vm_utils, '_snapshot_attached_here_impl')
def test_snapshot_attached_here(self, mock_impl):

View File

@ -1208,6 +1208,7 @@ def generate_configdrive(session, instance, vm_ref, userdevice,
utils.execute('dd',
'if=%s' % tmp_file,
'of=%s' % dev_path,
'oflag=direct,sync',
run_as_root=True)
create_vbd(session, vm_ref, vdi_ref, userdevice, bootable=False,
@ -2199,6 +2200,7 @@ def vdi_attached_here(session, vdi_ref, read_only=False):
_wait_for_device(dev)
yield dev
finally:
utils.execute('sync', run_as_root=True)
LOG.debug(_('Destroying VBD for VDI %s ... '), vdi_ref)
unplug_vbd(session, vbd_ref, this_vm_ref)
finally:
@ -2427,6 +2429,8 @@ def _copy_partition(session, src_ref, dst_ref, partition, virtual_size):
'if=%s' % src_path,
'of=%s' % dst_path,
'count=%d' % num_blocks,
'iflag=direct,sync',
'oflag=direct,sync',
run_as_root=True)