Skip to content

Commit 6c9167f

Browse files
authored
CA-411766: Detach VBDs right after VM Halted (#6501)
In XSI-1915, MCS shutdowned a VM and tried to destroy VBD right after MCS received the event which came from power_state's change and failed. The failure reason is below: 1. The update for VM's power_state and the update for VBDs is not a transaction, so the client may receive the event from the update for power_state and operate VBDs before the update for VBDs. 2. The VM's running on supporter. The DB operation needs to send RPC to the coordinator. This needs time. 3. Between the update for VM's power_state and the update for VBD, xapi also updates the field pending_guildencs which needs at least 8 DB operation. This also delays the update for VBDs. It's not straightforward to add transactions for these DB operations. The workaround is to move the update for pending_guildencs to the end of the DB operation of VBDs, VIFs, GPUs, etc. So that VBD will be updated after the update for VM's power_state immediately.
2 parents 7ad7f88 + 19e1704 commit 6c9167f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ocaml/xapi/xapi_vm_lifecycle.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,8 +856,6 @@ let force_state_reset_keep_current_operations ~__context ~self ~value:state =
856856
if state = `Suspended then
857857
remove_pending_guidance ~__context ~self ~value:`restart_device_model ;
858858
if state = `Halted then (
859-
remove_pending_guidance ~__context ~self ~value:`restart_device_model ;
860-
remove_pending_guidance ~__context ~self ~value:`restart_vm ;
861859
(* mark all devices as disconnected *)
862860
List.iter
863861
(fun vbd ->
@@ -899,7 +897,9 @@ let force_state_reset_keep_current_operations ~__context ~self ~value:state =
899897
)
900898
(Db.VM.get_VUSBs ~__context ~self) ;
901899
(* Blank the requires_reboot flag *)
902-
Db.VM.set_requires_reboot ~__context ~self ~value:false
900+
Db.VM.set_requires_reboot ~__context ~self ~value:false ;
901+
remove_pending_guidance ~__context ~self ~value:`restart_device_model ;
902+
remove_pending_guidance ~__context ~self ~value:`restart_vm
903903
) ;
904904
(* Do not clear resident_on for VM and VGPU in a checkpoint operation *)
905905
if

0 commit comments

Comments
 (0)