Signed-off-by: Jon Ludlam <[email protected]>

 ocaml/xapi/message_forwarding.ml |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)


# HG changeset patch
# User Jonathan Ludlam <[email protected]>
# Date 1269962117 -3600
# Node ID c1c916da866462f4ec983827a318bcee6a11752d
# Parent  419d6473c6afec9cf87b2d8554ef5fb641294026
CA-38601: Make the VM.query_data_source API call lock free

Signed-off-by: Jon Ludlam <[email protected]>

diff -r 419d6473c6af -r c1c916da8664 ocaml/xapi/message_forwarding.ml
--- a/ocaml/xapi/message_forwarding.ml	Tue Mar 30 14:22:11 2010 +0100
+++ b/ocaml/xapi/message_forwarding.ml	Tue Mar 30 16:15:17 2010 +0100
@@ -674,7 +674,10 @@
 
     (* Read resisdent-on field from vm to determine who to forward to  *)
     let forward_vm_op ~local_fn ~__context ~vm op =
-      do_op_on ~local_fn ~__context ~host:(Db.VM.get_resident_on ~__context ~self:vm) op      
+      let state = Db.VM.get_power_state ~__context ~self:vm in
+      match state with
+	| `Running | `Paused ->  do_op_on ~local_fn ~__context ~host:(Db.VM.get_resident_on ~__context ~self:vm) op 
+	| _ -> raise (Api_errors.Server_error(Api_errors.vm_bad_power_state, [Ref.string_of vm; "running"; Record_util.power_to_string state]))
 
     (* Notes on memory checking/reservation logic:
        When computing the hosts free memory we consider all VMs resident_on (ie running
@@ -1563,10 +1566,8 @@
     let query_data_source ~__context ~self ~data_source =
       info "VM.query_data_source: VM = '%s'; data source = '%s'" (vm_uuid ~__context self) data_source;
       let local_fn = Local.VM.query_data_source ~self ~data_source in
-      with_vm_operation ~__context ~self ~doc:"VM.query_data_source" ~op:`data_source_op
-	(fun () -> 
-	  forward_vm_op ~local_fn ~__context ~vm:self
-	    (fun session_id rpc -> Client.VM.query_data_source rpc session_id self data_source))
+      forward_vm_op ~local_fn ~__context ~vm:self
+	(fun session_id rpc -> Client.VM.query_data_source rpc session_id self data_source)
 
     let forget_data_source_archives ~__context ~self ~data_source =
       info "VM.forget_data_source_archives: VM = '%s'; data source = '%s'" (vm_uuid ~__context self) data_source;
_______________________________________________
xen-api mailing list
[email protected]
http://lists.xensource.com/mailman/listinfo/xen-api

Reply via email to