From: Marcus Granado Date: Mon, 23 Aug 2010 14:54:36 +0000 (+0100) Subject: CP-1833: check for lsu vmpr during snapshot X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d126e5367bd1b1a1bfc0f5b2dec067b21c103f0c;p=xcp%2Fxen-api.git CP-1833: check for lsu vmpr during snapshot Signed-off-by: Marcus Granado --- diff --git a/ocaml/xapi/xapi_vm_clone.ml b/ocaml/xapi/xapi_vm_clone.ml index 53279b40..7e1634ee 100644 --- a/ocaml/xapi/xapi_vm_clone.ml +++ b/ocaml/xapi/xapi_vm_clone.ml @@ -247,6 +247,21 @@ let copy_vm_record ~__context ~vm ~disk_op ~new_name ~new_power_state = | Disk_op_snapshot | Disk_op_checkpoint -> Db.VM.set_parent ~__context ~self:vm ~value:ref end; + (* verify if this action is happening due to a VM protection policy *) + let is_snapshot_from_vmpp = + (try + is_a_snapshot && + (let session = Context.get_session_id __context in + let uname = Db.Session.get_auth_user_name ~__context ~self:session in + let is_lsu = Db.Session.get_is_local_superuser ~__context ~self:session in + is_lsu && (uname = "__dom0__vmpr") + ) + with e -> + debug "Error obtaining is_snapshot_from_vmpp: %s" (Printexc.to_string e); + false + ) + in + (* create a new VM *) Db.VM.create ~__context ~ref @@ -309,7 +324,7 @@ let copy_vm_record ~__context ~vm ~disk_op ~new_name ~new_power_state = ~tags:all.Db_actions.vM_tags ~bios_strings:all.Db_actions.vM_bios_strings ~protection_policy:Ref.null - ~is_snapshot_from_vmpp:false(*from_protection_policy*) + ~is_snapshot_from_vmpp ; ref, uuid