diff options
author | Lee Yarwood <lyarwood@redhat.com> | 2020-02-10 14:09:10 +0000 |
---|---|---|
committer | Lee Yarwood <lyarwood@redhat.com> | 2020-03-16 09:45:31 +0000 |
commit | 28f3e0070a214f750ecad8bd8001ccb5c5c27fd4 (patch) | |
tree | 8420462eeb7040240b742b03c72035ef4df00b01 /nova/privsep | |
parent | 03d6eb500f85a417f84a7bf4a9f4ceb275c9a67e (diff) | |
download | nova-28f3e0070a214f750ecad8bd8001ccb5c5c27fd4.tar.gz |
images: Allow the output format of qemu-img info to be controlled
This will allow for the use of the JSON output format that is easier to
parse within QemuImgInfo and should allow additional information to be
extracted from qemu-img calls in the future.
Change-Id: I0b6d1a98726ffa1ebc78fb3c4563a2e4b40ddeff
Diffstat (limited to 'nova/privsep')
-rw-r--r-- | nova/privsep/qemu.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/nova/privsep/qemu.py b/nova/privsep/qemu.py index 07db81a381..55bdfe2a77 100644 --- a/nova/privsep/qemu.py +++ b/nova/privsep/qemu.py @@ -85,17 +85,20 @@ def unprivileged_convert_image(source, dest, in_format, out_format, @nova.privsep.sys_admin_pctxt.entrypoint -def privileged_qemu_img_info(path, format=None, qemu_version=None): +def privileged_qemu_img_info(path, format=None, qemu_version=None, + output_format=None): """Return an oject containing the parsed output from qemu-img info This is a privileged call to qemu-img info using the sys_admin_pctxt entrypoint allowing host block devices etc to be accessed. """ return unprivileged_qemu_img_info( - path, format=format, qemu_version=qemu_version) + path, format=format, qemu_version=qemu_version, + output_format=output_format) -def unprivileged_qemu_img_info(path, format=None, qemu_version=None): +def unprivileged_qemu_img_info(path, format=None, qemu_version=None, + output_format=None): """Return an object containing the parsed output from qemu-img info.""" try: # The following check is about ploop images that reside within @@ -107,6 +110,8 @@ def unprivileged_qemu_img_info(path, format=None, qemu_version=None): cmd = ('env', 'LC_ALL=C', 'LANG=C', 'qemu-img', 'info', path) if format is not None: cmd = cmd + ('-f', format) + if output_format is not None: + cmd = cmd + ("--output=%s" % (output_format),) # Check to see if the qemu version is >= 2.10 because if so, we need # to add the --force-share flag. if qemu_version and operator.ge(qemu_version, QEMU_VERSION_REQ_SHARED): |