Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

CA-93559: Change code ordering within force_state_reset.

A VM's power_state and allowed_operations are now updated after its
devices are updated. This makes more sense for clients which are
watching for VM.power_state to become halted.

Signed-off-by: John Else <>
  • Loading branch information...
1 parent dbd1565 commit 127a3b675ef4ae52d30bee73d46cb7a63ad7048a @johnelse johnelse committed
Showing with 7 additions and 6 deletions.
  1. +7 −6 ocaml/xapi/
13 ocaml/xapi/
@@ -393,11 +393,6 @@ let update_allowed_operations ~__context ~self =
(** Called on new VMs (clones, imports) and on server start to manually refresh
the power state, allowed_operations field etc *)
let force_state_reset ~__context ~self ~value:state =
- Db.VM.set_power_state ~__context ~self ~value:state;
- if (Db.VM.get_current_operations ~__context ~self)<>[] then
- Db.VM.set_current_operations ~__context ~self ~value:[];
- update_allowed_operations ~__context ~self;
if state = `Halted then begin
(* mark all devices as disconnected *)
@@ -421,12 +416,18 @@ let force_state_reset ~__context ~self ~value:state =
Db.PCI.remove_attached_VMs ~__context ~self:pci ~value:self)
(Db.VM.get_attached_PCIs ~__context ~self);
if state = `Halted || state = `Suspended then begin
Db.VM.set_resident_on ~__context ~self ~value:Ref.null;
(* make sure we aren't reserving any memory for this VM *)
Db.VM.set_scheduled_to_be_resident_on ~__context ~self ~value:Ref.null;
Db.VM.set_domid ~__context ~self ~value:(-1L)
- end
+ end;
+ Db.VM.set_power_state ~__context ~self ~value:state;
+ if (Db.VM.get_current_operations ~__context ~self)<>[] then
+ Db.VM.set_current_operations ~__context ~self ~value:[];
+ update_allowed_operations ~__context ~self
(** Someone is cancelling a task so remove it from the current_operations *)
let cancel_task ~__context ~self ~task_id =

0 comments on commit 127a3b6

Please sign in to comment.
Something went wrong with that request. Please try again.