]> xenbits.xensource.com Git - xcp/xen-api.git/commitdiff
Pass the writable flag to the SM backends on activate as well as attach. This is...
authorJon Ludlam <jonathan.ludlam@eu.citrix.com>
Fri, 24 Sep 2010 15:46:04 +0000 (16:46 +0100)
committerJon Ludlam <jonathan.ludlam@eu.citrix.com>
Fri, 24 Sep 2010 15:46:04 +0000 (16:46 +0100)
an implementation hurdle in the backends.

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
ocaml/xapi/sm.ml
ocaml/xapi/storage_access.ml
ocaml/xapi/storage_access.mli
ocaml/xapi/xapi_vm_migrate.ml

index d81e569cff87ac767b48cd63fdefac8e033b1e7f..99aa788a21b1891cd90d698d448390b7a501e492 100644 (file)
@@ -156,9 +156,9 @@ let vdi_detach dconf driver sr vdi =
   let call = Sm_exec.make_call ~sr_ref:sr ~vdi_ref:vdi dconf "vdi_detach" [] in
   Sm_exec.parse_unit (Sm_exec.exec_xmlrpc (driver_type driver)  (driver_filename driver) call)
 
-let vdi_activate dconf driver sr vdi =
+let vdi_activate dconf driver sr vdi writable =
   debug "vdi_activate" driver (sprintf "sr=%s vdi=%s" (Ref.string_of sr) (Ref.string_of vdi));
-  let call = Sm_exec.make_call ~sr_ref:sr ~vdi_ref:vdi dconf "vdi_activate" [] in
+  let call = Sm_exec.make_call ~sr_ref:sr ~vdi_ref:vdi dconf "vdi_activate" [ sprintf "%b" writable ] in
   Sm_exec.parse_unit (Sm_exec.exec_xmlrpc (driver_type driver)  (driver_filename driver) call)
                        
 let vdi_deactivate dconf driver sr vdi =
index 6d9fc567dfb1b86b13d9d64a17db2a81e7ccfd07..a23a9ec2acc2404c19e3bf13fe647f7bf6b38097 100644 (file)
@@ -218,14 +218,15 @@ module VDI =
           debug "Executed detach succesfully on VDI '%s'; attach refcount now: %d" (Uuid.to_string uuid) newval
        )
 
-    let activate ~__context ~self =
+    let activate ~__context ~self ~mode =
     with_vdi_lock
       (fun () ->
         if (check_enclosing_sr_for_capability __context Smint.Vdi_activate self) then
           begin
+                  if mode=`RW then debug "foo";
             Sm.call_sm_vdi_functions ~__context ~vdi:self
               (fun device_config sr_type sr ->
-                 Sm.vdi_activate device_config sr_type sr self);
+                 Sm.vdi_activate device_config sr_type sr self (mode = `RW));
             let newval = increment_activate_refcount self in
             debug "Executed activate succesfully on VDI '%s'; activate refcount now: %d" (Ref.string_of self) newval
           end
@@ -270,7 +271,7 @@ module VDI =
 let use_vdi ~__context ~vdi ~mode =
   VDI.attach ~__context ~self:vdi ~mode;
   try
-    VDI.activate ~__context ~self:vdi
+    VDI.activate ~__context ~self:vdi ~mode;
   with e ->
     (* if activate fails then best effort detach VDI before propogating original exception *)
     begin
@@ -311,7 +312,7 @@ let with_careful_attach_and_activate ~__context ~vdis ~leave_activated f =
       let do_single_attach (vdi,mode) =
        VDI.attach ~__context ~self:vdi ~mode;
        Hashtbl.replace attached vdi ();
-       VDI.activate ~__context ~self:vdi;
+       VDI.activate ~__context ~self:vdi ~mode;
        Hashtbl.replace activated vdi () in
       (* Attach/activate vbds recording what we've done *)
       List.iter do_single_attach vdis;
index bf533b21bbbb058ad928eb99eab0ffec98b0d3f1..315b26176b65a5eba9c3a3a723d58dbecc366b7e 100644 (file)
@@ -27,7 +27,7 @@ sig
 
   val attach     : __context:Context.t -> self:API.ref_VDI -> mode:[`RO|`RW] -> unit
   val detach     : __context:Context.t -> self:API.ref_VDI -> unit
-  val activate   : __context:Context.t -> self:API.ref_VDI -> unit
+  val activate   : __context:Context.t -> self:API.ref_VDI -> mode:[`RO|`RW] -> unit
   val deactivate : __context:Context.t -> self:API.ref_VDI -> unit
 
   val check_enclosing_sr_for_capability : Context.t -> Smint.capability -> [ `VDI ] Ref.t -> bool
index 8a16674606ada2c5277a145739ed6e644db89b4d..21c5bac249992080b86b771f53aa8c0cefb9f626 100644 (file)
@@ -479,7 +479,7 @@ let receiver ~__context ~localhost is_localhost_migration fd vm xc xs memory_req
      else
        begin
         debug "Receiver 7a. Activating VDIs";
-        List.iter (fun (vdi,_) -> Storage_access.VDI.activate ~__context ~self:vdi) needed_vdis
+        List.iter (fun (vdi,mode) -> Storage_access.VDI.activate ~__context ~self:vdi ~mode) needed_vdis
        end;
      
      if delay_device_create_until_after_activate then