Commit a002ed79 authored by Agata Murawska's avatar Agata Murawska
Browse files

Check for qemu-img in configure and Makefile


Signed-off-by: default avatarAgata Murawska <agatamurawska@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent b3ed0d9a
......@@ -985,6 +985,7 @@ lib/_autoconf.py: Makefile | lib/.dir
echo "NODED_USER = '$(NODED_USER)'"; \
echo "NODED_GROUP = '$(NODED_GROUP)'"; \
echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
if [ "$(HTOOLS)" ]; then \
echo "HTOOLS = True"; \
else \
......
......@@ -335,6 +335,14 @@ fi
if test "$enable_htools" != "no"; then
# Check for qemu-img
AC_ARG_VAR(QEMUIMG_PATH, [qemu-img path])
AC_PATH_PROG(QEMUIMG_PATH, [qemu-img], [])
if test -z "$QEMUIMG_PATH"
then
AC_MSG_WARN([qemu-img not found, using ovfconverter will not be possible])
fi
# Check for ghc
AC_ARG_VAR(GHC, [ghc path])
AC_PATH_PROG(GHC, [ghc], [])
......
......@@ -1700,6 +1700,9 @@ VALID_ALLOC_POLICIES = [
# Temporary external/shared storage parameters
BLOCKDEV_DRIVER_MANUAL = "manual"
# qemu-img path, required for ovfconverter
QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
# Whether htools was enabled at compilation time
HTOOLS = _autoconf.HTOOLS
# The hail iallocator
......
......@@ -143,6 +143,15 @@ DISK_FORMAT = {
COW: "http://www.gnome.org/~markmc/qcow-image-format.html",
}
def CheckQemuImg():
""" Make sure that qemu-img is present before performing operations.
@raise errors.OpPrereqError: when qemu-img was not found in the system
"""
if not constants.QEMUIMG_PATH:
raise errors.OpPrereqError("qemu-img not found at build time, unable"
" to continue")
def LinkFile(old_path, prefix=None, suffix=None, directory=None):
"""Create link with a given prefix and suffix.
......@@ -916,6 +925,7 @@ class Converter(object):
@raise errors.OpPrereqError: convertion of the disk failed
"""
CheckQemuImg()
disk_file = os.path.basename(disk_path)
(disk_name, disk_extension) = os.path.splitext(disk_file)
if disk_extension != disk_format:
......@@ -953,6 +963,7 @@ class Converter(object):
@raise errors.OpPrereqError: format information cannot be retrieved
"""
CheckQemuImg()
args = ["qemu-img", "info", disk_path]
run_result = utils.RunCmd(args, cwd=os.getcwd())
if run_result.failed:
......@@ -1317,6 +1328,7 @@ class OVFImporter(Converter):
information or size information is invalid or creation failed
"""
CheckQemuImg()
assert self.options.disks
results = {}
for (disk_id, disk_desc) in self.options.disks:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment