]> xenbits.xensource.com Git - xcp/xen-api.git/commitdiff
CP-1833: fix check for lsu vmpr during snapshot in slaves
authorMarcus Granado <marcus.granado@eu.citrix.com>
Tue, 12 Oct 2010 09:41:58 +0000 (10:41 +0100)
committerMarcus Granado <marcus.granado@eu.citrix.com>
Tue, 12 Oct 2010 09:41:58 +0000 (10:41 +0100)
Signed-off-by: Marcus Granado <marcus.granado@eu.citrix.com>
ocaml/xapi/xapi_session.ml
ocaml/xapi/xapi_session.mli
ocaml/xapi/xapi_vm_clone.ml

index f1479e5fd83b8bfd5934d56b45f6d7a29174013e..b69f2dc9747723a841d07e8a1ecd8f1c3814dd70 100644 (file)
@@ -691,3 +691,25 @@ let logout_subject_identifier ~__context ~subject_identifier=
        (* kill all filtered sessions *)
        List.iter (fun s -> destroy_db_session ~__context ~self:s) sessions
 
+
+(* returns the ancestry chain of session s, starting with s *)
+let rec get_ancestry ~__context ~self =
+  if (self=Ref.null) then [] (* top of session tree *)
+  else (
+    let parent =
+      try Db.Session.get_parent ~__context ~self
+      with e->
+        debug "error %s getting ancestry for session %s"
+          (ExnHelper.string_of_exn e) (trackid self)
+        ;
+        Ref.null
+    in
+      self::(get_ancestry ~__context ~self:parent)
+  )
+
+(* returns the original session up the ancestry chain that created s *)
+let get_top ~__context ~self =
+  let ancestry = get_ancestry ~__context ~self in
+  match ancestry with
+  | [] -> Ref.null
+  | ancestry -> List.nth ancestry ((List.length ancestry)-1)
index 32f2cfb61fcdf9d9087e680f9999467a6f6113d9..70f598c283c4930101ad4eb156a5384fab46c246 100644 (file)
@@ -34,3 +34,4 @@ val local_logout: __context:Context.t -> unit
 val get_group_subject_identifier_from_session: __context:Context.t -> session:[ `session ] Ref.t -> string
 val get_all_subject_identifiers: __context:Context.t -> string list
 val logout_subject_identifier: __context:Context.t -> subject_identifier:string -> unit
+val get_top: __context:Context.t -> self:API.ref_session -> API.ref_session
index 04577366ef3d70a5657c99c7a4f4497279771eca..c2a287fa993ab6788bda628abd4e6acdc138e126 100644 (file)
@@ -251,7 +251,7 @@ let copy_vm_record ~__context ~vm ~disk_op ~new_name ~new_power_state =
   let is_snapshot_from_vmpp =
     (try
       is_a_snapshot &&
-      (let session = Context.get_session_id __context in
+      (let session = Xapi_session.get_top ~__context ~self:(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 = Xapi_vmpp.vmpr_username)