Example #1
0
 def check_backingfile(self):
     error_context.context(
         "check image('%s') backing file" % self.image_filename,
         logging.info)
     out = self.get_info()
     try:
         backingfile = re.search(r'backing file: +(.*)', out, re.M).group(1)
         if not self.base_tag or self.base_tag == "null":
             msg = ("Expected backing file is null")
             msg += " Actual backing file: %s" % backingfile
             raise exceptions.TestFail(msg)
         else:
             base_params = self.params.object_params(self.base_tag)
             base_image_repr = qemu_storage.get_image_repr(
                 self.base_tag, base_params, self.root_dir)
             if base_image_repr != backingfile:
                 msg = ("Expected backing file: %s" %
                        self.base_image_filename)
                 msg += " Actual backing file: %s" % backingfile
                 raise exceptions.TestFail(msg)
     except AttributeError:
         if self.base_tag and self.base_tag != "null":
             msg = ("Could not find backing file for image '%s'" %
                    self.image_filename)
             raise exceptions.TestFail(msg)
Example #2
0
 def __init__(self, params, local_image):
     super(QemuNBDExportImage, self).__init__(params, local_image)
     self._qemu_nbd = utils_misc.get_qemu_nbd_binary(self._params)
     filename_repr = 'json' if self._image_params.get(
         'nbd_export_format') == 'luks' else 'filename'
     self._local_filename = qemu_storage.get_image_repr(
         self._tag, self._image_params, data_dir.get_data_dir(),
         filename_repr)
     self._nbd_server_pid = None
Example #3
0
 def verify_backing_file(image):
     """Verify image backing file."""
     info_output = json.loads(image.info(output="json"))
     backing_params = image.params.object_params(image.base_tag)
     backing_file = qemu_storage.get_image_repr(image.base_tag,
                                                backing_params, root_dir)
     backing_file_info = info_output["backing-filename"]
     if backing_file != backing_file_info:
         err_msg = "backing file mismatch, got %s, expected %s." % \
             (backing_file_info, backing_file)
         raise ValueError(err_msg)
Example #4
0
 def verify_backing_chain(info):
     """Verify image's backing chain."""
     for image, img_info in zip(images, reversed(info)):
         base_image = None
         if image.base_tag:
             base_params = params.object_params(image.base_tag)
             base_image = qemu_storage.get_image_repr(image.base_tag,
                                                      base_params, root_dir)
         base_image_from_info = img_info.get("full-backing-filename")
         if base_image != base_image_from_info:
             test.fail(("backing chain check for image %s failed, backing"
                        " file from info is %s, which should be %s.") %
                       (image.image_filename, base_image_from_info,
                        base_image))
 def _verify_image_backing_file(info_output, base):
     """Verify backing image filename and format."""
     backing_filename = info_output["backing-filename"]
     backing_format = info_output.get("backing-filename-format")
     backing_filename_desired = qemu_storage.get_image_repr(
         base.tag, params, root_dir)
     if backing_filename != backing_filename_desired:
         test.fail("backing image name mismatch, got %s, expect %s" %
                   (backing_filename, backing_filename_desired))
     if backing_format:
         backing_format_desired = base.image_format
         if backing_format != backing_format_desired:
             test.fail("backing image format mismatch, got %s, expect %s" %
                       (backing_format, backing_format_desired))
    def verify_qemu_img_info_backing_chain(output):
        """Verify qemu-img info output for this case."""
        def _get_compat_version():
            """Get compat version from params."""
            return params.get("qcow2_compatible", "1.1")

        logging.info("Verify snapshot's backing file information.")
        for image, img_info in zip(images, reversed(output)):
            # skip base layer
            if not image.base_tag:
                continue
            base_params = params.object_params(image.base_tag)
            base_image = qemu_storage.get_image_repr(image.base_tag,
                                                     base_params, root_dir)
            base_format = image.base_format
            compat = _get_compat_version()
            base_image_info = img_info.get("backing-filename")
            assert base_image == base_image_info, "backing image mismatches"
            if base_image_info and not base_image_info.startswith("json"):
                base_format_info = img_info.get("backing-filename-format")
                assert base_format == base_format_info, \
                    "backing format mismatches"
            compat_info = img_info["format-specific"]["data"]["compat"]
            assert compat == compat_info, "compat mode mismatches"