@@ -162,26 +162,11 @@ module Copy = struct
162162 (Printf. sprintf " Remote SR %s not found"
163163 (Storage_interface.Sr. string_of dest)
164164 ) ;
165- let vdis = Remote.SR. scan dbg dest in
166- let remote_vdi =
167- try List. find (fun x -> x.vdi = dest_vdi) vdis
168- with Not_found ->
169- failwith
170- (Printf. sprintf " Remote VDI %s not found"
171- (Storage_interface.Vdi. string_of dest_vdi)
172- )
173- in
165+
166+ let remote_vdi, _ = find_vdi ~dbg ~sr: dest ~vdi: dest_vdi (module Remote ) in
174167 let dest_content_id = remote_vdi.content_id in
175168 (* Find the local VDI *)
176- let vdis = Local.SR. scan dbg sr in
177- let local_vdi =
178- try List. find (fun x -> x.vdi = vdi) vdis
179- with Not_found ->
180- failwith
181- (Printf. sprintf " Local VDI %s not found"
182- (Storage_interface.Vdi. string_of vdi)
183- )
184- in
169+ let local_vdi, vdis = find_vdi ~dbg ~sr ~vdi (module Local ) in
185170 D. debug " copy local content_id=%s" local_vdi.content_id ;
186171 D. debug " copy remote content_id=%s" dest_content_id ;
187172 if local_vdi.virtual_size > remote_vdi.virtual_size then (
@@ -293,6 +278,10 @@ module Copy = struct
293278 (* PR-1255: XXX: this is useful because we don't have content_ids by default *)
294279 D. debug " setting local content_id <- %s" local_vdi.content_id ;
295280 Local.VDI. set_content_id dbg sr local_vdi.vdi local_vdi.content_id ;
281+ (* Re-find the VDI to get the updated content_id info *)
282+ let remote_vdi, _ =
283+ find_vdi ~dbg ~sr: dest ~vdi: dest_vdi (module Remote )
284+ in
296285 Some (Vdi_info remote_vdi)
297286 with e ->
298287 D. error " Caught %s: performing cleanup actions" (Printexc. to_string e) ;
@@ -312,11 +301,7 @@ module Copy = struct
312301 let (module Remote ) = get_remote_backend url verify_dest in
313302 (* Find the local VDI *)
314303 try
315- let vdis = Local.SR. scan dbg sr in
316- let local_vdi =
317- try List. find (fun x -> x.vdi = vdi) vdis
318- with Not_found -> failwith (Printf. sprintf " Local VDI not found" )
319- in
304+ let local_vdi, _ = find_vdi ~dbg ~sr ~vdi (module Local ) in
320305 try
321306 let similar_vdis = Local.VDI. similar_content dbg sr vdi in
322307 let similars = List. map (fun vdi -> vdi.content_id) similar_vdis in
0 commit comments