Skip to content

Commit d308a91

Browse files
committed
CA-422282 Fix race condition about xenops cache
There is race condition about vm cache between pool_migrate_complete and VM event. In the cross-pool migration case, it is designed to create vm with power_state Halted in XAPI db. In pool_migrate_complete, add_caches create an empty xenops_chae for the VM, then refresh_vm compares the cache powerstate None with its real state Running to update the right powerstate to XAPI db. In the fail case, it is found that: -> VM event 1 update_vm -> pool_migrate_complete add_caches (cache power_state None) -> pool_migrate_complete refresh_vm -> VM event 1 update cache (cache power_state Running) -> VM event 2 update_vm (Running <-> Running, XAPI DB not update) When pool_migrate_complete add_caches, the cache update of previous VM event 1 breaks the design intention. This commit add a wait in pool_migrate_complete to ensure all in-flight events complete before add_caches. Then there will be no race condition. Signed-off-by: Changlei Li <changlei.li@cloud.com>
1 parent 1878ccc commit d308a91

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

ocaml/xapi/xapi_vm_migrate.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ let pool_migrate_complete ~__context ~vm ~host:_ =
492492
if Xapi_xenops.vm_exists_in_xenopsd queue_name dbg id then (
493493
remove_stale_pcis ~__context ~vm ;
494494
Xapi_xenops.set_resident_on ~__context ~self:vm ;
495+
Xapi_xenops.Events_from_xenopsd.wait queue_name dbg id () ;
495496
Xapi_xenops.add_caches id ;
496497
Xapi_xenops.refresh_vm ~__context ~self:vm ;
497498
Monitor_dbcalls_cache.clear_cache_for_vm ~vm_uuid:id

0 commit comments

Comments
 (0)