Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
CA-187691: VIF plug/unplug must fail under certain VM Lifecycle opera…
…tions

VIF plug/unplug must fail gracefully when VM undergoing operations
like clean_shutdown, hard_shutdown, pause and suspend.

Signed-off-by: Sharad Yadav <[email protected]>
  • Loading branch information
sharady committed Dec 15, 2015
commit 8f8acab3162128800257e75b5666e2cf7cb4a050
11 changes: 11 additions & 0 deletions ocaml/xapi/xapi_vif_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ let valid_operations ~__context record _ref' : table =
let expected = Record_util.power_to_string `Running in
set_errors Api_errors.vm_bad_power_state [ Ref.string_of vm; expected; actual ] [ `plug; `unplug ]);

(* VIF plug/unplug must fail for current_operations
* like [clean_shutdown; hard_shutdown; suspend; pause] on VM *)
let vm_current_ops = Db.VM.get_current_operations ~__context ~self:vm in
List.iter (fun (task,op) ->
if List.mem op [ `clean_shutdown; `hard_shutdown; `suspend; `pause ] then begin
let current_op_str = "Current operation on VM:" ^ (Ref.string_of vm) ^ " is "
^ (Record_util.vm_operation_to_string op) in
set_errors Api_errors.operation_not_allowed [ current_op_str ] [ `plug; `unplug ]
end
) vm_current_ops;

(* HVM guests only support plug/unplug IF they have PV drivers *)
let vm_gm = Db.VM.get_guest_metrics ~__context ~self:vm in
let vm_gmr = try Some (Db.VM_guest_metrics.get_record_internal ~__context ~self:vm_gm) with _ -> None in
Expand Down