diff --git a/Makefile.am b/Makefile.am index 98d8a4f9e7c565b87846e431f824fbd25ae0c705..fd31cd31369773618f499a235f0d097059895855 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/configure.ac b/configure.ac index 52587437ac64ea05a6dbf9fe6fc26b5e2dc6fa08..6d47a54ba2ee8fbfe8c3fe81299ace6d3a0c9220 100644 --- a/configure.ac +++ b/configure.ac @@ -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], []) diff --git a/lib/constants.py b/lib/constants.py index 003774c588b98e76ac4f3d05fb011a24dd9cdf40..18c3f4d03a500eb09ba7d0e4d028a7527f7230a8 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -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 diff --git a/lib/ovf.py b/lib/ovf.py index eabc71a8ee812d4e9eb54f972f4c6167a799f83d..ac0a709693f48ddfd0a60371e7c4f305752ddb09 100644 --- a/lib/ovf.py +++ b/lib/ovf.py @@ -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: