def _get_guest_storage_config(self, instance, image_meta, disk_info, rescue, block_device_info, inst_type):
    devices = []
    disk_mapping = disk_info['mapping']
    block_device_mapping = driver.block_device_info_get_mapping(block_device_info)
    if (CONF.libvirt.virt_type == 'lxc'):
        fs = vconfig.LibvirtConfigGuestFilesys()
        fs.source_type = 'mount'
        fs.source_dir = os.path.join(libvirt_utils.get_instance_path(instance), 'rootfs')
        devices.append(fs)
    else:
        if rescue:
            diskrescue = self._get_guest_disk_config(instance, 'disk.rescue', disk_mapping, inst_type)
            devices.append(diskrescue)
            diskos = self._get_guest_disk_config(instance, 'disk', disk_mapping, inst_type)
            devices.append(diskos)
        else:
            if ('disk' in disk_mapping):
                diskos = self._get_guest_disk_config(instance, 'disk', disk_mapping, inst_type)
                devices.append(diskos)
            if ('disk.local' in disk_mapping):
                disklocal = self._get_guest_disk_config(instance, 'disk.local', disk_mapping, inst_type)
                devices.append(disklocal)
                instance.default_ephemeral_device = block_device.prepend_dev(disklocal.target_dev)
                instance.save()
            for (idx, eph) in enumerate(driver.block_device_info_get_ephemerals(block_device_info)):
                diskeph = self._get_guest_disk_config(instance, blockinfo.get_eph_disk(idx), disk_mapping, inst_type)
                devices.append(diskeph)
            if ('disk.swap' in disk_mapping):
                diskswap = self._get_guest_disk_config(instance, 'disk.swap', disk_mapping, inst_type)
                devices.append(diskswap)
                instance.default_swap_device = block_device.prepend_dev(diskswap.target_dev)
                instance.save()
            for vol in block_device_mapping:
                connection_info = vol['connection_info']
                vol_dev = block_device.prepend_dev(vol['mount_device'])
                info = disk_mapping[vol_dev]
                cfg = self._connect_volume(connection_info, info)
                devices.append(cfg)
                vol['connection_info'] = connection_info
                vol.save()
        if ('disk.config' in disk_mapping):
            diskconfig = self._get_guest_disk_config(instance, 'disk.config', disk_mapping, inst_type, 'raw')
            devices.append(diskconfig)
    for d in devices:
        self._set_cache_mode(d)
    if (image_meta and image_meta.get('properties', {}).get('hw_scsi_model')):
        hw_scsi_model = image_meta['properties']['hw_scsi_model']
        scsi_controller = vconfig.LibvirtConfigGuestController()
        scsi_controller.type = 'scsi'
        scsi_controller.model = hw_scsi_model
        devices.append(scsi_controller)
    return devices
def _get_guest_storage_config(self, instance, image_meta, disk_info, rescue, block_device_info, inst_type):
    devices = []
    disk_mapping = disk_info['mapping']
    block_device_mapping = driver.block_device_info_get_mapping(block_device_info)
    if (CONF.libvirt.virt_type == 'lxc'):
        fs = vconfig.LibvirtConfigGuestFilesys()
        fs.source_type = 'mount'
        fs.source_dir = os.path.join(libvirt_utils.get_instance_path(instance), 'rootfs')
        devices.append(fs)
    else:
        if rescue:
            diskrescue = self._get_guest_disk_config(instance, 'disk.rescue', disk_mapping, inst_type)
            devices.append(diskrescue)
            diskos = self._get_guest_disk_config(instance, 'disk', disk_mapping, inst_type)
            devices.append(diskos)
        else:
            if ('disk' in disk_mapping):
                diskos = self._get_guest_disk_config(instance, 'disk', disk_mapping, inst_type)
                devices.append(diskos)
            if ('disk.local' in disk_mapping):
                disklocal = self._get_guest_disk_config(instance, 'disk.local', disk_mapping, inst_type)
                devices.append(disklocal)
                instance.default_ephemeral_device = block_device.prepend_dev(disklocal.target_dev)
                instance.save()
            for (idx, eph) in enumerate(driver.block_device_info_get_ephemerals(block_device_info)):
                diskeph = self._get_guest_disk_config(instance, blockinfo.get_eph_disk(idx), disk_mapping, inst_type)
                devices.append(diskeph)
            if ('disk.swap' in disk_mapping):
                diskswap = self._get_guest_disk_config(instance, 'disk.swap', disk_mapping, inst_type)
                devices.append(diskswap)
                instance.default_swap_device = block_device.prepend_dev(diskswap.target_dev)
                instance.save()
            for vol in block_device_mapping:
                connection_info = vol['connection_info']
                vol_dev = block_device.prepend_dev(vol['mount_device'])
                info = disk_mapping[vol_dev]
                cfg = self._connect_volume(connection_info, info)
                devices.append(cfg)
                vol['connection_info'] = connection_info
                vol.save()
        if ('disk.config' in disk_mapping):
            diskconfig = self._get_guest_disk_config(instance, 'disk.config', disk_mapping, inst_type, 'raw')
            devices.append(diskconfig)
    for d in devices:
        self._set_cache_mode(d)
    if (image_meta and image_meta.get('properties', {}).get('hw_scsi_model')):
        hw_scsi_model = image_meta['properties']['hw_scsi_model']
        scsi_controller = vconfig.LibvirtConfigGuestController()
        scsi_controller.type = 'scsi'
        scsi_controller.model = hw_scsi_model
        devices.append(scsi_controller)
    return devices