def pre_live_migration(self, context, instance, block_device_info, network_info, disk_info, migrate_data=None):
    'Preparation live migration.'
    is_shared_block_storage = True
    is_shared_instance_path = True
    is_block_migration = True
    instance_relative_path = None
    if migrate_data:
        is_shared_block_storage = migrate_data.get('is_shared_block_storage', True)
        is_shared_instance_path = migrate_data.get('is_shared_instance_path', True)
        is_block_migration = migrate_data.get('block_migration', True)
        instance_relative_path = migrate_data.get('instance_relative_path')
    if (not (is_shared_instance_path and is_shared_block_storage)):
        if configdrive.required_by(instance):
            raise exception.NoLiveMigrationForConfigDriveInLibVirt()
    if (not is_shared_instance_path):
        if instance_relative_path:
            instance_dir = os.path.join(CONF.instances_path, instance_relative_path)
        else:
            instance_dir = libvirt_utils.get_instance_path(instance)
        if os.path.exists(instance_dir):
            raise exception.DestinationDiskExists(path=instance_dir)
        os.mkdir(instance_dir)
        if (not is_shared_block_storage):
            self._create_images_and_backing(context, instance, instance_dir, disk_info)
    if (not (is_block_migration or is_shared_instance_path)):
        console_file = self._get_console_log_path(instance)
        libvirt_utils.file_open(console_file, 'a').close()
        self._fetch_instance_kernel_ramdisk(context, instance)
    block_device_mapping = driver.block_device_info_get_mapping(block_device_info)
    for vol in block_device_mapping:
        connection_info = vol['connection_info']
        disk_info = blockinfo.get_info_from_bdm(CONF.libvirt.virt_type, vol)
        self._connect_volume(connection_info, disk_info)
    max_retry = CONF.live_migration_retry_count
    for cnt in range(max_retry):
        try:
            self.plug_vifs(instance, network_info)
            break
        except processutils.ProcessExecutionError:
            if (cnt == (max_retry - 1)):
                raise
            else:
                LOG.warn(_LW('plug_vifs() failed %(cnt)d. Retry up to %(max_retry)d.'), {'cnt': cnt, 'max_retry': max_retry}, instance=instance)
                greenthread.sleep(1)
    res_data = {'graphics_listen_addrs': {}}
    res_data['graphics_listen_addrs']['vnc'] = CONF.vncserver_listen
    res_data['graphics_listen_addrs']['spice'] = CONF.spice.server_listen
    return res_data
Preparation live migration.
def pre_live_migration(self, context, instance, block_device_info, network_info, disk_info, migrate_data=None):
    
    is_shared_block_storage = True
    is_shared_instance_path = True
    is_block_migration = True
    instance_relative_path = None
    if migrate_data:
        is_shared_block_storage = migrate_data.get('is_shared_block_storage', True)
        is_shared_instance_path = migrate_data.get('is_shared_instance_path', True)
        is_block_migration = migrate_data.get('block_migration', True)
        instance_relative_path = migrate_data.get('instance_relative_path')
    if (not (is_shared_instance_path and is_shared_block_storage)):
        if configdrive.required_by(instance):
            raise exception.NoLiveMigrationForConfigDriveInLibVirt()
    if (not is_shared_instance_path):
        if instance_relative_path:
            instance_dir = os.path.join(CONF.instances_path, instance_relative_path)
        else:
            instance_dir = libvirt_utils.get_instance_path(instance)
        if os.path.exists(instance_dir):
            raise exception.DestinationDiskExists(path=instance_dir)
        os.mkdir(instance_dir)
        if (not is_shared_block_storage):
            self._create_images_and_backing(context, instance, instance_dir, disk_info)
    if (not (is_block_migration or is_shared_instance_path)):
        console_file = self._get_console_log_path(instance)
        libvirt_utils.file_open(console_file, 'a').close()
        self._fetch_instance_kernel_ramdisk(context, instance)
    block_device_mapping = driver.block_device_info_get_mapping(block_device_info)
    for vol in block_device_mapping:
        connection_info = vol['connection_info']
        disk_info = blockinfo.get_info_from_bdm(CONF.libvirt.virt_type, vol)
        self._connect_volume(connection_info, disk_info)
    max_retry = CONF.live_migration_retry_count
    for cnt in range(max_retry):
        try:
            self.plug_vifs(instance, network_info)
            break
        except processutils.ProcessExecutionError:
            if (cnt == (max_retry - 1)):
                raise
            else:
                LOG.warn(_LW('plug_vifs() failed %(cnt)d. Retry up to %(max_retry)d.'), {'cnt': cnt, 'max_retry': max_retry}, instance=instance)
                greenthread.sleep(1)
    res_data = {'graphics_listen_addrs': {}}
    res_data['graphics_listen_addrs']['vnc'] = CONF.vncserver_listen
    res_data['graphics_listen_addrs']['spice'] = CONF.spice.server_listen
    return res_data