Skip to content

Commit 40b86f2

Browse files
committed
Adding debug logs on setting ha_always_run flag on vm
Signed-off-by: Sharad Yadav <[email protected]>
1 parent 0175b2c commit 40b86f2

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

ocaml/xapi/xapi_vm.ml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ let set_ha_restart_priority ~__context ~self ~value =
101101
(* If the VM is running then immediately turn on or off "protection"
102102
for the VM by setting ha_always_run *)
103103
if Db.VM.get_power_state ~__context ~self = `Running
104-
then Db.VM.set_ha_always_run ~__context ~self ~value:(value = Constants.ha_restart)
104+
then begin
105+
Db.VM.set_ha_always_run ~__context ~self ~value:(value = Constants.ha_restart);
106+
debug "Setting ha_always_run on vm=%s as %b during VM.set_ha_restart_priority" (Ref.string_of self) (value = Constants.ha_restart)
107+
end;
105108
end
106109

107110

@@ -187,7 +190,11 @@ let start ~__context ~vm ~start_paused ~force =
187190
let vmr = Db.VM.get_record ~__context ~self:vm in
188191
Vgpuops.create_vgpus ~__context (vm, vmr) (Helpers.will_boot_hvm ~__context ~self:vm);
189192
if vmr.API.vM_ha_restart_priority = Constants.ha_restart
190-
then Db.VM.set_ha_always_run ~__context ~self:vm ~value:true;
193+
then begin
194+
Db.VM.set_ha_always_run ~__context ~self:vm ~value:true;
195+
debug "Setting ha_always_run on vm=%s as true during VM.start" (Ref.string_of vm)
196+
end;
197+
191198

192199
(* Clear out any VM guest metrics record. Guest metrics will be updated by
193200
* the running VM and for now they might be wrong, especially network
@@ -230,6 +237,7 @@ let hard_reboot ~__context ~vm =
230237

231238
let hard_shutdown ~__context ~vm =
232239
Db.VM.set_ha_always_run ~__context ~self:vm ~value:false;
240+
debug "Setting ha_always_run on vm=%s as false during VM.hard_shutdown" (Ref.string_of vm);
233241
if Db.VM.get_power_state ~__context ~self:vm = `Suspended then begin
234242
debug "hard_shutdown: destroying any suspend VDI";
235243
let vdi = Db.VM.get_suspend_VDI ~__context ~self:vm in
@@ -250,6 +258,7 @@ let clean_reboot ~__context ~vm =
250258

251259
let clean_shutdown_with_timeout ~__context ~vm timeout =
252260
Db.VM.set_ha_always_run ~__context ~self:vm ~value:false;
261+
debug "Setting ha_always_run on vm=%s as false during VM.clean_shutdown" (Ref.string_of vm);
253262
Xapi_xenops.shutdown ~__context ~self:vm (Some timeout)
254263

255264
let clean_shutdown ~__context ~vm =
@@ -326,13 +335,17 @@ let power_state_reset ~__context ~vm =
326335

327336
let suspend ~__context ~vm =
328337
Db.VM.set_ha_always_run ~__context ~self:vm ~value:false;
338+
debug "Setting ha_always_run on vm=%s as false during VM.suspend" (Ref.string_of vm);
329339
Xapi_xenops.suspend ~__context ~self:vm;
330340
let vm_uuid = Db.VM.get_uuid ~__context ~self:vm in
331341
log_and_ignore_exn (fun () -> Rrdd.archive_rrd ~vm_uuid ~remote_address:(try Some (Pool_role.get_master_address ()) with _ -> None))
332342

333343
let resume ~__context ~vm ~start_paused ~force =
334344
if Db.VM.get_ha_restart_priority ~__context ~self:vm = Constants.ha_restart
335-
then Db.VM.set_ha_always_run ~__context ~self:vm ~value:true;
345+
then begin
346+
Db.VM.set_ha_always_run ~__context ~self:vm ~value:true;
347+
debug "Setting ha_always_run on vm=%s as true during VM.resume" (Ref.string_of vm)
348+
end;
336349

337350
let host = Helpers.get_localhost ~__context in
338351
if not force then Cpuid_helpers.assert_vm_is_compatible ~__context ~vm ~host ();

0 commit comments

Comments
 (0)