def _create_images_and_backing(self, context, instance, instance_dir, disk_info_json):
    ':param context: security context\n           :param instance:\n               nova.db.sqlalchemy.models.Instance object\n               instance object that is migrated.\n           :param instance_dir:\n               instance path to use, calculated externally to handle block\n               migrating an instance with an old style instance path\n           :param disk_info_json:\n               json strings specified in get_instance_disk_info\n\n        '
    if (not disk_info_json):
        disk_info = []
    else:
        disk_info = jsonutils.loads(disk_info_json)
    for info in disk_info:
        base = os.path.basename(info['path'])
        instance_disk = os.path.join(instance_dir, base)
        if ((not info['backing_file']) and (not os.path.exists(instance_disk))):
            libvirt_utils.create_image(info['type'], instance_disk, info['virt_disk_size'])
        elif info['backing_file']:
            cache_name = os.path.basename(info['backing_file'])
            image = self.image_backend.image(instance, instance_disk, CONF.libvirt.images_type)
            if cache_name.startswith('ephemeral'):
                image.cache(fetch_func=self._create_ephemeral, fs_label=cache_name, os_type=instance['os_type'], filename=cache_name, size=info['virt_disk_size'], ephemeral_size=instance['ephemeral_gb'])
            elif cache_name.startswith('swap'):
                inst_type = flavors.extract_flavor(instance)
                swap_mb = inst_type['swap']
                image.cache(fetch_func=self._create_swap, filename=('swap_%s' % swap_mb), size=(swap_mb * units.Mi), swap_mb=swap_mb)
            else:
                image.cache(fetch_func=libvirt_utils.fetch_image, context=context, filename=cache_name, image_id=instance['image_ref'], user_id=instance['user_id'], project_id=instance['project_id'], size=info['virt_disk_size'])
    self._fetch_instance_kernel_ramdisk(context, instance)
:param context: security context
:param instance:
    nova.db.sqlalchemy.models.Instance object
    instance object that is migrated.
:param instance_dir:
    instance path to use, calculated externally to handle block
    migrating an instance with an old style instance path
:param disk_info_json:
    json strings specified in get_instance_disk_info
def _create_images_and_backing(self, context, instance, instance_dir, disk_info_json):
    ':param context: security context\n           :param instance:\n               nova.db.sqlalchemy.models.Instance object\n               instance object that is migrated.\n           :param instance_dir:\n               instance path to use, calculated externally to handle block\n               migrating an instance with an old style instance path\n           :param disk_info_json:\n               json strings specified in get_instance_disk_info\n\n        '
    if (not disk_info_json):
        disk_info = []
    else:
        disk_info = jsonutils.loads(disk_info_json)
    for info in disk_info:
        base = os.path.basename(info['path'])
        instance_disk = os.path.join(instance_dir, base)
        if ((not info['backing_file']) and (not os.path.exists(instance_disk))):
            libvirt_utils.create_image(info['type'], instance_disk, info['virt_disk_size'])
        elif info['backing_file']:
            cache_name = os.path.basename(info['backing_file'])
            image = self.image_backend.image(instance, instance_disk, CONF.libvirt.images_type)
            if cache_name.startswith('ephemeral'):
                image.cache(fetch_func=self._create_ephemeral, fs_label=cache_name, os_type=instance['os_type'], filename=cache_name, size=info['virt_disk_size'], ephemeral_size=instance['ephemeral_gb'])
            elif cache_name.startswith('swap'):
                inst_type = flavors.extract_flavor(instance)
                swap_mb = inst_type['swap']
                image.cache(fetch_func=self._create_swap, filename=('swap_%s' % swap_mb), size=(swap_mb * units.Mi), swap_mb=swap_mb)
            else:
                image.cache(fetch_func=libvirt_utils.fetch_image, context=context, filename=cache_name, image_id=instance['image_ref'], user_id=instance['user_id'], project_id=instance['project_id'], size=info['virt_disk_size'])
    self._fetch_instance_kernel_ramdisk(context, instance)