Move image conversion to privsep.
Following a similar pattern to previous changes, move calls to qemu-img to convert between image formats to use privsep. Change-Id: I2c3df909a783e1480d3ab4ca10b34b84ac9e4b5f blueprint: hurrah-for-privsep
This commit is contained in:
committed by
Matt Riedemann
parent
7e2f459032
commit
e38caa2de0
@@ -20,11 +20,9 @@
|
||||
import contextlib
|
||||
import copy
|
||||
import datetime
|
||||
import errno
|
||||
import functools
|
||||
import hashlib
|
||||
import inspect
|
||||
import mmap
|
||||
import os
|
||||
import pyclbr
|
||||
import random
|
||||
@@ -1341,53 +1339,6 @@ def get_endpoint(ksa_adapter):
|
||||
"interfaces: %s" % interfaces)
|
||||
|
||||
|
||||
def supports_direct_io(dirpath):
|
||||
|
||||
if not hasattr(os, 'O_DIRECT'):
|
||||
LOG.debug("This python runtime does not support direct I/O")
|
||||
return False
|
||||
|
||||
testfile = os.path.join(dirpath, ".directio.test")
|
||||
|
||||
hasDirectIO = True
|
||||
fd = None
|
||||
try:
|
||||
fd = os.open(testfile, os.O_CREAT | os.O_WRONLY | os.O_DIRECT)
|
||||
# Check is the write allowed with 512 byte alignment
|
||||
align_size = 512
|
||||
m = mmap.mmap(-1, align_size)
|
||||
m.write(b"x" * align_size)
|
||||
os.write(fd, m)
|
||||
LOG.debug("Path '%(path)s' supports direct I/O",
|
||||
{'path': dirpath})
|
||||
except OSError as e:
|
||||
if e.errno == errno.EINVAL:
|
||||
LOG.debug("Path '%(path)s' does not support direct I/O: "
|
||||
"'%(ex)s'", {'path': dirpath, 'ex': e})
|
||||
hasDirectIO = False
|
||||
else:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error("Error on '%(path)s' while checking "
|
||||
"direct I/O: '%(ex)s'",
|
||||
{'path': dirpath, 'ex': e})
|
||||
except Exception as e:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error("Error on '%(path)s' while checking direct I/O: "
|
||||
"'%(ex)s'", {'path': dirpath, 'ex': e})
|
||||
finally:
|
||||
# ensure unlink(filepath) will actually remove the file by deleting
|
||||
# the remaining link to it in close(fd)
|
||||
if fd is not None:
|
||||
os.close(fd)
|
||||
|
||||
try:
|
||||
os.unlink(testfile)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return hasDirectIO
|
||||
|
||||
|
||||
def generate_hostid(host, project_id):
|
||||
"""Generate an obfuscated host id representing the host.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user