虚拟机热迁移的api请求经过wsgi分发最终到达nova api的实现,由api处理并经过rpc调用最终由nova compute处理。本文整理api部分的处理流程。
nova.api.openstack.compute.contrib.admin_actions._migrate_live方法接受请求
nova.api.openstack.compute.contrib.admin_actions._migrate_live
a.调用authorize,鉴权
b.取出三个参数:block_migration,disk_over_commit,host
c.从instance表中查找记录
d.调用compute.api.API.live_migration
compute.api.API.live_migration:a.检查锁,检查cell,检查vm_stateb.修改task_state,并记录动作c.调用conductor.api.ComputeTaskAPI.live_migrationconductor.api.ComputeTaskAPI.live_migration:a.调用conductor.manager.ComputeTaskManager.migrate_server
conductor.manager.ComputeTaskManager.migrate_server:
a.调用conductor.manager.ComputeTaskManager._live_migrate
conductor.manager.ComputeTaskManager._live_migrate:
a.调用conductor.tasks.live_migratie.execute
conductor.tasks.live_migratie.execute:
a.调用conductor.tasks.live_migrate.LiveMigrationTask.execute
conductor.tasks.live_migrate.LiveMigrationTask.execute:
a.若未给定目标主机,调用conductor.tasks.live_migrate.LiveMigrationTask._find_destination,获取主机若已给定,检查目标主机是否满足要求
b.调用compute.rpcapi.computeAPI.live_migration,将消息请求放到消息队列中