OpenStack nova compute supports two flavors of Virtual Machine (VM) migration:

  • Cold migration -- migration of a VM which requires the VM to be powered off during the migrate operation during which time the VM is inaccessible.
  • Hot or live migration -- zero down-time migration whereupon the VM is not powered off during the migration and thus remains accessible.

Understanding these VM migration operations from an OpenStack internals perspective can be a daunting task. I had the pleasure of digging into these flows in the latter part of 2013 and as part of that effort created a rough outline of the internal flows. Other's I've worked with found these flow outlines useful and thus they're provided below.

Note -- The outlines below were created based on the OpenStack source in late 2013 and thus reflect the state of OpenStack at that point in time.

Live Migration Flow:
  • nova.api.openstack.compute.contrib.admin_actions._migrate_live()
  • nova.compute.api.live_migrate()
    • update instance state to MIGRATING state
    • call into scheduler to live migrate (scheduler hint will be set to the host select (which may be none)).
  • nova.scheduler.manager.live_migration()
  • nova.scheduler.manager._schedule_live_migration()
  • nova.conductor.tasks.live_migrate.LiveMigrationTask.execute()
    • check that the instance is running
    • check that the instance's host is up
    • if destination host provided, check that it..
      1. is different than the instance's host
      2. is up
      3. has enough memory
      4. is compatible with the instance's host (i.e. hypervisor type and version)
      5. passes live migration checks (call using amqp rpc into nova manager check_can_live_migrate_destination)
    • else destination host not provided, find a candidate destination host and check that it...
      1. is compatible with the instance's host (i.e. hypervisor type and version)
      2. passes live migration checks (call using amqp rpc into nova manager check_can_live_migrate_destination)
    • call using amqp rpc into nova manager live_migration
      Note: Migration data is initially set by check_can_live_migrate_destination and can be used for implementation specific parameters from this point.
  • nova.compute.manager.check_can_live_migrate_destination()
    • driver.check_can_live_migrate_destination()
    • call using amqp rpc into nova manager check_can_live_migrate_source
    • driver.check_can_live_migrate_destination_cleanup()
  • nova.compute.manager.check_can_live_migrate_source()
    • determine if the instance is volume backed and add result to the migration data
    • driver.check_can_live_migrate_source()
  • nova.compute.manager.live_migration()
    • if block migration request then driver.get_instance_disk_info()
    • call using amqp rpc into nova manager pre_live_migration
      • Error handler: _rollback_live_migration
    • driver.live_migration()
  • nova.compute.manager.pre_live_migration()
    • get the block device information for the instance
    • get the network information for the instance
    • driver.pre_live_migration()
    • setup networks on destination host by calling the network API setup_networks_on_host
    • driver.ensure_filtering_rules_for_instance()
  • nova.compute.manager._rollback_live_migration()
    • update instance state to ACTIVE state
    • re-setup networks on source host by calling the network API setup_networks_on_host
    • for each instance volume connection call using amqp rpc into nova manager remove_volume_connection
    • if block migration or volume backed migration without shared storage
      • call using amqp rpc into nova manager rollback_live_migration_at_destination
  • nova.compute.manager._post_live_migration()
    • driver.get_volume_connector()
    • for each instance volume connection call the volume API terminate_connection
    • driver.unfilter_instance()
    • call into conductor to network_migrate_instance_start which will eventually call the network API migrate_instance_start
    • call using amqp rpc into nova manager post_live_migration_at_destination
    • if block migration or not shared storage driver.destroy()
    • else driver.unplug_vifs()
    • tear down networks on source host by calling the network API setup_networks_on_host
  • nova.compute.manager.post_live_migration_at_destination()
    • setup networks on destination host by calling the network API setup_networks_on_host
    • call into conductor to network_migrate_instance_finish which will eventually call the network API migrate_instance_finish
    • driver.post_live_migration_at_destination()
    • update instance to ACTIVE state
    • setup networks on destination host by calling the network API setup_networks_on_host
  • nova.compute.manager.rollback_live_migration_at_destination()
    • tear down networks on destination host by calling the network API setup_networks_on_host
    • driver.destroy()
  • nova.compute.manager.remove_volume_connection()
    • call _detach_volume
    • driver.get_volume_connector()
    • remove the volume connection by calling the volume API terminate_connection
  • nova.compute.manager._detach_volume()
    • driver.detach_volume()

      • Since the live migration failed the VM should not be on the destination host.  So this should be a no-op.
    • If there is an exception detaching the volume then rollback the detach by calling the volume API roll_detaching
 
Cold Migration Flow:
  • nova.api.openstack.compute.servers._resize()
  • nova.api.openstack.compute.contrib.admin_actions._migrate()
  • nova.compute.api.resize()
    • if flavor_id is not passed, migrate host only and keep the original flavor
    • else flavor_id is given, migrate host and resize to new flavor
    • lookup the image for the instance by calling the image API show
    • check quota headroom and reserve
    • update instance to RESIZE_PREP state
    • determine if the instance's current host should be ignored as a migration target and update filter properties for the scheduler accordingly
    • call into scheduler to prep_resize
  • nova.scheduler.manager.prep_resize()
    • call scheduler driver to schedule_prep_resize
    • if no valid host was found then update instance to ACTIVE state and rollback quota reservation
    • if error occurred then update instance to ERROR state and rollback quota reservation
  • nova.scheduler.filter_scheduler.schedule_prep_resize()
    • run through scheduler filters to select host
    • call using amqp rpc into nova manager prep_resize
  • nova.compute.manager.prep_resize()
    • if no node specified call driver.get_available_nodes()
    • call _prep_resize
      • if an exception occurs then call into scheduler to prep_resize again if possible
  • nova.compute.manager._prep_resize()
    • if same host is used then ensure that the same host is allowed (as per configuration)
    • call using amqp rpc into nova manager resize_instance
  • nova.compute.manager.resize_instance()
    • get network and instance information
    • update instance to RESIZE_MIGRATING state
    • get block device information
    • call driver.migrate_disk_and_power_off()
    • call _terminate_volume_connections
    • call into conductor to network_migrate_instance_start which will eventually call the network API migrate_instance_start
    • update instance to RESIZE_MIGRATED state
    • call using amqp rpc into nova manager finish_resize
  • nova.compute.manager._terminate_volume_connections()
    • if there is a volume connection to terminate

      • driver.get_volume_connector()
      • for each volume connection remove the connection by calling the volume API terminate_connection
  • nova.compute.manager.finish_resize()
    • call _finish_resize
    • if successful commit the quota reservation
    • else rollback the quota reservation and update instance to ERROR state
  • nova.compute.manager._finish_resize()
    • if the flavor is changing then update the instance with the new flavor
    • setup networks on destination host by calling the network API setup_networks_on_host
    • call into conductor to network_migrate_instance_finish which will eventually call the network API migrate_instance_finish
    • update instance to RESIZE_FINISHED state
    • refresh and get block device information
    • driver.finish_migration()
    • update instance to RESIZED state
Cold migration confirm flow:
Cold migration revert flow:
    • nova.api.openstack.compute.servers._action_revert_resize()
    • nova.compute.api.revert_resize()
      • reserve quota for increase in resource usage
      • update instance task state to RESIZE_REVERTING
      • call amqp rpc into nova manager revert_resize
    • nova.compute.manager.revert_resize()
      • tear down networks on destination host by calling the network API setup_networks_on_host
      • call into conductor to network_migrate_instance_start which will eventually call the network API migrate_instance_start
      • get block device information
      • driver.destroy()
      • call _terminate_volume_connections
      • drop resize resources claimed on destination
      • call amqp rpc into nova manager finish_revert_resize
    • nova.compute.manager.finish_revert_resize()
      • update instance back to pre-resize values
      • re-setup networks on source host by calling the network API setup_networks_on_host
      • refresh and get block device information
      • driver.finish_revert_migration()
      • update instance to RESIZE_REVERTING state
      • call into conductor to network_migrate_instance_finish which will eventually call the network API migrate_instance_finish
      • update instance to ACTIVE (or possibly STOPPED) state
      • commit the quota usage

Source: http://bodenr.blogspot.com/2014/03/openstack-nova-vm-migration-live-and.html

OpenStack nova VM migration (live and cold) call flow的更多相关文章

  1. OpenStack Nova Release(Rocky to Train)

    目录 文章目录 目录 前言 演进方向 Cellv2 更新 Rocky Support disabling a cell Stein Handling a down cell Train Count q ...

  2. OpenStack Nova 制作 Windows 镜像

    OpenStack Nova 制作 Windows 镜像   windows虚拟机ubuntuimage防火墙云计算 本贴转自http://www.vpsee.com 上次 VPSee 给 OpenS ...

  3. OpenStack Nova 高性能虚拟机之 CPU 绑定

    目录 文章目录 目录 前文列表 KVM KVM 的功能列表 KVM 工具集 KVM 虚拟机的本质是什么 vCPU 的调度与性能问题 Nova 支持的 vCPU 绑定 vcpu\_pin\_set 配置 ...

  4. Openstack Nova 源码分析 — 使用 VCDriver 创建 VMware Instance

    目录 目录 前言 流程图 nova-compute vCenter 前言 在上一篇Openstack Nova 源码分析 - Create instances (nova-conductor阶段)中, ...

  5. Openstack Nova 源码分析 — RPC 远程调用过程

    目录 目录 Nova Project Services Project 的程序入口 setuppy Nova中RPC远程过程调用 nova-compute RPC API的实现 novacompute ...

  6. 如何删除 OpenStack Nova 僵尸实例

    转自:http://www.vpsee.com/2011/11/how-to-delete-a-openstack-nova-zombie-instance/ 前天强制重启一台 OpenStack N ...

  7. 深挖Openstack Nova - Scheduler调度策略

    深挖Openstack Nova - Scheduler调度策略   一.  Scheduler的作用就是在创建实例(instance)时,为实例选择出合适的主机(host).这个过程分两步:过滤(F ...

  8. OpenStack Nova

    OpenStack Nova 简介 OpenStack 中的 Nova 负责维护和管理云环境的计算资源 Nova 在现有 Linux 服务器上作为一组守护线程来提供服务 Nova 由多个服务器进程组成 ...

  9. OpenStack Nova 高性能虚拟机之 NUMA 架构亲和

    目录 文章目录 目录 写在前面 计算平台体系结构 SMP 对称多处理结构 NUMA 非统一内存访问结构 MPP 大规模并行处理结构 Linux 上的 NUMA 基本对象概念 NUMA 调度策略 获取宿 ...

随机推荐

  1. 《高级Web应用程序设计》课程学习资料

    任务1:什么是ASP.NET MVC 1.1  ASP.NET MVC简介 1.2 认识ASP.NET MVC项目结构 1.3 ASP.NET MVC生命周期 任务2:初识ASP.NET MVC项目开 ...

  2. 常用js,css文件统一加载方法,并在加载之后调用回调函数

    原创内容,转载请注明出处! 为了方便资源管理和提升工作效率,常用的js和css文件的加载应该放在一个统一文件里面完成,也方便后续的资源维护.所以我用js写了以下方法,存放在“sourceControl ...

  3. Android实现接口方式注册监听器

      初学Android,新手大都倾向使用匿名类的方式注册监听器, 如下: public class MainActivity extends Activity { private Button but ...

  4. ROS实际问题解决方法

    1.建立软链接 在路径cd /etc/udev/rules.d中,建立例如50-rfid.rules的文件,它会根据文件名之前的50 51等判断优先级,50的优先级就大于51 如:  KERNEL== ...

  5. z-index、display、selector选择器优先级css优先级面试用到

    z-index:控制元素叠放顺序,哪个z-index数值越大,那个优先被叠放在上面. relative.absolute.fixed这三种情况可以使用z-index. static不可以使用. dis ...

  6. 获取LocationProvider

    Android的定位信息由LocationProvider对象来提供,该对象代表一个抽象的定位组件.在开始编程之前,需要先获得LocationProvider对象. 一.获取所有可用的Location ...

  7. C# 跨线程操作无效

    提示此错误的原因就是控件由主线程创建,在另一个线程进行操作时就会被阻止,防止数据间随意篡改. 如果一定要跨线程作业,如进度条或状态显示等,基本有三种方法解决: 1.Control.CheckForIl ...

  8. vector 的 push_back[转]

    vector是用数组实现的,每次执行push_back操作,相当于底层的数组实现要重新分配大小(即先free掉原存储,后重新malloc):这种实现体现到vector实现就是每当push_back一个 ...

  9. c#新手之1-如何组织类及相互调用

    不知道这个文章的名字起的对不对,姑且这么叫吧.我在这之前用c语言写程序几乎很少用函数调用来解决问题,都是用全局变量然后面向过程对数据做简单的处理,这就造成了我在学习c@之后仍有这个毛病,好点的时候有个 ...

  10. Python学习笔记-字符串

    Python之使用字符串 1.所有的标准序列操作(索引,分片,乘法,判断成员资格,求长度,取最小值,最大值)对字符串同样适用.但是字符串都是不可变的. 2.字符串格式化使用字符串格式化操作符即%. f ...