From fbd64ced685ff5baaa1e467275117af3fcb16c1e Mon Sep 17 00:00:00 2001 From: Tomasz Wroblewski Date: Thu, 10 Dec 2009 13:39:47 +0000 Subject: [PATCH] XC-817 xenvm - make action after halt/reboot/crash customisable --- xenvm/vmconfig.ml | 11 +++++++---- xenvm/xenvm.ml | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/xenvm/vmconfig.ml b/xenvm/vmconfig.ml index af905e8..be96b4b 100644 --- a/xenvm/vmconfig.ml +++ b/xenvm/vmconfig.ml @@ -658,11 +658,11 @@ let of_file uuid error_report file = and memory = ref (-1) in - let set_action ref_var s = + let action_of_string s = match s with - | "restart" -> ref_var := ActionRestart - | "destroy" -> ref_var := ActionDestroy - | "preserve" -> ref_var := ActionPreserve + | "restart" -> ActionRestart + | "destroy" -> ActionDestroy + | "preserve" -> ActionPreserve | _ -> failwith "unknown action state" in let set_startup s = @@ -687,6 +687,9 @@ let of_file uuid error_report file = | "disk" | "vif" | "nic" | "pci" | "cpuid" | "cpus-affinity" | "extra-hvm" | "extra-local-watch" | "extra-vm-watch" -> cfg := list_add !cfg k v + | "on_halt" -> cfg := { !cfg with on_halt = action_of_string v } + | "on_restart" -> cfg := { !cfg with on_restart = action_of_string v } + | "on_crash" -> cfg := { !cfg with on_crash = action_of_string v } | _ -> cfg := set !cfg k v in diff --git a/xenvm/xenvm.ml b/xenvm/xenvm.ml index ff4fa4c..3a81378 100644 --- a/xenvm/xenvm.ml +++ b/xenvm/xenvm.ml @@ -271,6 +271,7 @@ let monitor_vm state = | Xal.Vanished -> ActionPreserve | Xal.Halted -> state.vm_cfg.on_halt | Xal.Rebooted -> + Vmact.stop_vm xc xs state; Vmact.change_vmstate state VmRebooted; state.vm_cfg.on_restart | Xal.Suspended -> state.vm_on_suspend_action -- 2.39.5