Move xenapi partition copies to privsep.

I am unsure if I should be concerned about the lack of error
checking here, but this is how it was originally.

Change-Id: I9c1dfd5a90a53d90a44baae4874965bf8f48cea1
blueprint: hurrah-for-privsep
This commit is contained in:
Michael Still 2018-03-16 07:14:18 +11:00
parent e2926a2046
commit fd154e71c2
2 changed files with 13 additions and 8 deletions

View File

@ -24,3 +24,14 @@ import nova.privsep
@nova.privsep.sys_admin_pctxt.entrypoint
def xenstore_read(path):
return processutils.execute('xenstore-read', path)
@nova.privsep.sys_admin_pctxt.entrypoint
def block_copy(src_path, dst_path, block_size, num_blocks):
processutils.execute('dd',
'if=%s' % src_path,
'of=%s' % dst_path,
'bs=%d' % block_size,
'count=%d' % num_blocks,
'iflag=direct,sync',
'oflag=direct,sync')

View File

@ -2399,14 +2399,8 @@ def _copy_partition(session, src_ref, dst_ref, partition, virtual_size):
_sparse_copy(src_path, dst_path, virtual_size)
else:
num_blocks = virtual_size / SECTOR_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',
run_as_root=True)
nova.privsep.xenapi.block_copy(
src_path, dst_path, DD_BLOCKSIZE, num_blocks)
def _mount_filesystem(dev_path, mount_point):