Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

CA-91927: Reduce the frequency of VM.allowed_operations updates.

When xapi receives a VM update from xenopsd, allowed_operations should
only be updated if a VM field which could affect the allowed_operations
was changed.

Signed-off-by: John Else <>
  • Loading branch information...
commit 9f8183d27afc6c72c62651da3e368645734cf008 1 parent 0cbfab0
@johnelse johnelse authored jonludlam committed
Showing with 9 additions and 1 deletion.
  1. +9 −1 ocaml/xapi/
10 ocaml/xapi/
@@ -766,6 +766,7 @@ let update_vm ~__context id =
else begin
debug "xenopsd event: processing event for VM %s" id;
if info = None then debug "xenopsd event: VM state missing: assuming VM has shut down";
+ let should_update_allowed_operations = ref false in
let different f =
let a = (fun x -> f (snd x)) info in
let b = f previous in
@@ -777,6 +778,8 @@ let update_vm ~__context id =
inject artificial events IF there has been an event sync failure? *)
if different (fun x -> x.power_state) then begin
+ debug "Will update VM.allowed_operations because power_state has changed.";
+ should_update_allowed_operations := true;
let power_state = xenapi_of_xenops_power_state ( (fun x -> (snd x).power_state) info) in
debug "xenopsd event: Updating VM %s power_state <- %s" id (Record_util.power_state_to_string power_state);
(* This will mark VBDs, VIFs as detached and clear resident_on
@@ -805,6 +808,8 @@ let update_vm ~__context id =
if different (fun x -> x.domids) then begin
+ debug "Will update VM.allowed_operations because domid has changed.";
+ should_update_allowed_operations := true;
debug "xenopsd event: Updating VM %s domid" id;
(fun (_, state) ->
@@ -895,6 +900,8 @@ let update_vm ~__context id =
error "Caught %s: while updating VM %s rtc/timeoffset" (Printexc.to_string e) id
let check_guest_agent () =
+ debug "Will update VM.allowed_operations because guest_agent has changed.";
+ should_update_allowed_operations := true;
(fun (_, state) ->
@@ -990,7 +997,8 @@ let update_vm ~__context id =
error "Caught %s: while updating VM %s HVM_shadow_multiplier" (Printexc.to_string e) id
Xenops_cache.update_vm id ( snd info);
- Xapi_vm_lifecycle.update_allowed_operations ~__context ~self;
+ if !should_update_allowed_operations then
+ Xapi_vm_lifecycle.update_allowed_operations ~__context ~self;
with e ->
error "xenopsd event: Caught %s while updating VM: has this VM been removed while this host is offline?" (string_of_exn e)
Please sign in to comment.
Something went wrong with that request. Please try again.