@@ -113,42 +113,6 @@ let receive progress_cb format protocol (s : Unix.file_descr)
113113 in
114114 run_vhd_tool progress_cb args s s' path
115115
116- (* * [find_backend_device path] returns [Some path'] where [path'] is the backend path in
117- the driver domain corresponding to the frontend device [path] in this domain. *)
118- let find_backend_device path =
119- try
120- let open Ezxenstore_core.Xenstore in
121- (* If we're looking at a xen frontend device, see if the backend
122- is in the same domain. If so check if it looks like a .vhd *)
123- let rdev = (Unix. stat path).Unix. st_rdev in
124- let major = rdev / 256 and minor = rdev mod 256 in
125- let link =
126- Unix. readlink (Printf. sprintf " /sys/dev/block/%d:%d/device" major minor)
127- in
128- match List. rev (String. split '/' link) with
129- | id :: " xen" :: " devices" :: _
130- when Astring.String. is_prefix ~affix: " vbd-" id ->
131- let id = int_of_string (String. sub id 4 (String. length id - 4 )) in
132- with_xs (fun xs ->
133- let self = xs.Xs. read " domid" in
134- let backend =
135- xs.Xs. read (Printf. sprintf " device/vbd/%d/backend" id)
136- in
137- let params = xs.Xs. read (Printf. sprintf " %s/params" backend) in
138- match String. split '/' backend with
139- | "local" :: "domain" :: bedomid :: _ ->
140- if not (self = bedomid) then
141- Helpers. internal_error
142- " find_backend_device: Got domid %s but expected %s" bedomid
143- self ;
144- Some params
145- | _ ->
146- raise Not_found
147- )
148- | _ ->
149- raise Not_found
150- with _ -> None
151-
152116(* * [vhd_of_device path] returns (Some vhd) where 'vhd' is the vhd leaf backing a particular device [path] or None.
153117 [path] may either be a blktap2 device *or* a blkfront device backed by a blktap2 device. If the latter then
154118 the script must be run in the same domain as blkback. *)
@@ -178,22 +142,27 @@ let vhd_of_device path =
178142 debug " Device %s has an unknown driver" path ;
179143 None
180144 in
181- find_backend_device path |> Option. value ~default: path |> tapdisk_of_path
145+ Common_tool_wrapper. find_backend_device path
146+ |> Option. value ~default: path
147+ |> tapdisk_of_path
182148
183149let send progress_cb ?relative_to (protocol : string ) (dest_format : string )
184150 (s : Unix.file_descr ) (path : string ) (size : Int64.t ) (prefix : string ) =
185151 let s' = Uuidx. (to_string (make () )) in
152+ debug " GTNDEBUG: path is %s" path ;
153+ debug " GTNDEBUG: prefix is %s" prefix ;
186154 let source_format, source =
187- debug " GTNDEBUG: get_nbd_device %s" path ;
188- debug " GTNDEBUG: s' is %s" s' ;
189155 match (Stream_vdi. get_nbd_device path, vhd_of_device path, relative_to) with
190156 | Some (nbd_server , exportname ), _ , None ->
157+ debug " GTNDEBUG: nbdhybrid %s:%s:%s:%Ld" path nbd_server exportname size ;
191158 ( " nbdhybrid"
192159 , Printf. sprintf " %s:%s:%s:%Ld" path nbd_server exportname size
193160 )
194161 | Some _ , Some vhd , Some _ | None , Some vhd , _ ->
162+ debug " GTNDEBUG: hybrid %s" (path ^ " :" ^ vhd) ;
195163 (" hybrid" , path ^ " :" ^ vhd)
196164 | None , None , None ->
165+ debug " GTNDEBUG: raw %s" path ;
197166 (" raw" , path)
198167 | _ , None , Some _ ->
199168 let msg = " Cannot compute differences on non-VHD images" in
0 commit comments