]> xenbits.xensource.com Git - xcp/xen-api.git/commitdiff
CP-1833: check for lsu vmpr during snapshot
authorMarcus Granado <marcus.granado@eu.citrix.com>
Mon, 23 Aug 2010 14:54:36 +0000 (15:54 +0100)
committerMarcus Granado <marcus.granado@eu.citrix.com>
Mon, 23 Aug 2010 14:54:36 +0000 (15:54 +0100)
Signed-off-by: Marcus Granado <marcus.granado@eu.citrix.com>
ocaml/xapi/xapi_vm_clone.ml

index 53279b40325de0db5995dd910036bea31094d680..7e1634eee22a881995a4d0b2c266f781fc0e9000 100644 (file)
@@ -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