From: Jon Ludlam Date: Fri, 24 Sep 2010 15:46:04 +0000 (+0100) Subject: Pass the writable flag to the SM backends on activate as well as attach. This is... X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d1d9aebb4368d8b5f6ed938a7cd2d963f59e7299;p=xcp%2Fxen-api.git Pass the writable flag to the SM backends on activate as well as attach. This is a temporary fix to work around an implementation hurdle in the backends. Signed-off-by: Jon Ludlam --- diff --git a/ocaml/xapi/sm.ml b/ocaml/xapi/sm.ml index d81e569c..99aa788a 100644 --- a/ocaml/xapi/sm.ml +++ b/ocaml/xapi/sm.ml @@ -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 = diff --git a/ocaml/xapi/storage_access.ml b/ocaml/xapi/storage_access.ml index 6d9fc567..a23a9ec2 100644 --- a/ocaml/xapi/storage_access.ml +++ b/ocaml/xapi/storage_access.ml @@ -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; diff --git a/ocaml/xapi/storage_access.mli b/ocaml/xapi/storage_access.mli index bf533b21..315b2617 100644 --- a/ocaml/xapi/storage_access.mli +++ b/ocaml/xapi/storage_access.mli @@ -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 diff --git a/ocaml/xapi/xapi_vm_migrate.ml b/ocaml/xapi/xapi_vm_migrate.ml index 8a166746..21c5bac2 100644 --- a/ocaml/xapi/xapi_vm_migrate.ml +++ b/ocaml/xapi/xapi_vm_migrate.ml @@ -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