From bc10d29e418bd998fe408ccb5e544d72e1e52dda Mon Sep 17 00:00:00 2001 From: Jianghua Wang Date: Fri, 8 Apr 2016 11:14:23 +0100 Subject: [PATCH] XenAPI: specify block size for writing config drive. When writing config drive, dd by default uses 512B as the block size. It costs more than 3mins to write the 64M config drive. It's longer than expected: Some health checking(fuel's heat checking) on XenServer may failed due to timeout. So we need improve the performance via specifying a bigger block size with dd. Change-Id: I359e17d6d5838f4028df0bd47e4825de420eb383 Closes-Bug: #1567857 --- nova/tests/unit/virt/xenapi/test_vm_utils.py | 2 +- nova/virt/xenapi/vm_utils.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/nova/tests/unit/virt/xenapi/test_vm_utils.py b/nova/tests/unit/virt/xenapi/test_vm_utils.py index c4bdc0ce1430..e98162fe08fe 100644 --- a/nova/tests/unit/virt/xenapi/test_vm_utils.py +++ b/nova/tests/unit/virt/xenapi/test_vm_utils.py @@ -190,7 +190,7 @@ class GenerateConfigDriveTestCase(VMUtilsTestBase): '-publisher', mox.IgnoreArg(), '-quiet', '-J', '-r', '-V', 'config-2', mox.IgnoreArg(), attempts=1, run_as_root=False).AndReturn(None) - utils.execute('dd', mox.IgnoreArg(), mox.IgnoreArg(), + utils.execute('dd', mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg(), run_as_root=True).AndReturn(None) self.mox.StubOutWithMock(vm_utils, 'create_vbd') diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 5ed5aa05aaf2..fc8575a4d5aa 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -78,6 +78,7 @@ MBR_SIZE_BYTES = MBR_SIZE_SECTORS * SECTOR_SIZE KERNEL_DIR = '/boot/guest' MAX_VDI_CHAIN_SIZE = 16 PROGRESS_INTERVAL_SECONDS = 300 +DD_BLOCKSIZE = 65536 # Fudge factor to allow for the VHD chain to be slightly larger than # the partitioned space. Otherwise, legitimate images near their @@ -1100,6 +1101,7 @@ def generate_configdrive(session, instance, vm_ref, userdevice, utils.execute('dd', 'if=%s' % tmp_file, 'of=%s' % dev_path, + 'bs=%d' % DD_BLOCKSIZE, 'oflag=direct,sync', run_as_root=True) @@ -2367,6 +2369,7 @@ def _copy_partition(session, src_ref, dst_ref, partition, virtual_size): utils.execute('dd', 'if=%s' % src_path, 'of=%s' % dst_path, + 'bs=%d' % DD_BLOCKSIZE, 'count=%d' % num_blocks, 'iflag=direct,sync', 'oflag=direct,sync',