WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] SMAPI: Pass writable flag on vdi_activate as well as v

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH] SMAPI: Pass writable flag on vdi_activate as well as vdi_attach
From: Jon Ludlam <jonathan.ludlam@xxxxxxxxxxxxx>
Date: Fri, 24 Sep 2010 17:27:23 +0100
Delivery-date: Fri, 24 Sep 2010 09:27:47 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.4.3
# HG changeset patch
# User Jon Ludlam <jonathan.ludlam@xxxxxxxxxxxxx>
# Date 1285343164 -3600
# Node ID e8da99c62c3e9ae692285a3b5d016547bc503192
# Parent  b3d298b4ebab2ccfe6e481410008f54758615f2a
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 <jonathan.ludlam@xxxxxxxxxxxxx>

diff -r b3d298b4ebab -r e8da99c62c3e ocaml/xapi/sm.ml
--- a/ocaml/xapi/sm.ml
+++ b/ocaml/xapi/sm.ml
@@ -156,9 +156,9 @@
   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 -r b3d298b4ebab -r e8da99c62c3e ocaml/xapi/storage_access.ml
--- a/ocaml/xapi/storage_access.ml
+++ b/ocaml/xapi/storage_access.ml
@@ -218,14 +218,15 @@
           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 @@
 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 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 -r b3d298b4ebab -r e8da99c62c3e ocaml/xapi/storage_access.mli
--- a/ocaml/xapi/storage_access.mli
+++ b/ocaml/xapi/storage_access.mli
@@ -27,7 +27,7 @@
 
   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 -r b3d298b4ebab -r e8da99c62c3e ocaml/xapi/xapi_vm_migrate.ml
--- a/ocaml/xapi/xapi_vm_migrate.ml
+++ b/ocaml/xapi/xapi_vm_migrate.ml
@@ -479,7 +479,7 @@
      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

Attachment: xen-api2.hg.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] SMAPI: Pass writable flag on vdi_activate as well as vdi_attach, Jon Ludlam <=