@@ -417,41 +417,31 @@ let migrate_send' ~__context ~vm ~dest ~live ~vdi_map ~vif_map ~options =
417417 let suspend_sr_ref =
418418 let pool_suspend_SR = XenAPI.Pool. get_suspend_image_SR remote_rpc session_id dest_pool
419419 and host_suspend_SR = XenAPI.Host. get_suspend_image_sr remote_rpc session_id dest_host_ref in
420- match pool_suspend_SR, host_suspend_SR with
421- | p_ref , _ when p_ref <> Ref. null -> p_ref
422- | _ , h_ref when h_ref <> Ref. null -> h_ref
423- | _ -> default_sr_ref in
424-
420+ if pool_suspend_SR <> Ref. null then pool_suspend_SR else host_suspend_SR in
425421
426422 let vdi_copy_fun ((vdi , dp , location , sr , xenops_locator , size , snapshot_of , do_mirror ) as vconf ) =
427423 TaskHelper. exn_if_cancelling ~__context;
428424 let open Storage_access in
429- let ( dest_sr_ref, dest_sr) =
425+ let dest_sr_ref =
430426 match List. mem_assoc vdi vdi_map, List. mem_assoc snapshot_of vdi_map with
431- | true , _ ->
432- debug " VDI has been specified in the vdi_map" ;
433- let dest_sr_ref = List. assoc vdi vdi_map in
434- let dest_sr = XenAPI.SR. get_uuid remote_rpc session_id dest_sr_ref in
435- (dest_sr_ref, dest_sr)
436- | false , true ->
437- debug " snapshot VDI's snapshot_of has been specified in the vdi_map" ;
438- let dest_sr_ref = List. assoc snapshot_of vdi_map in
439- let dest_sr = XenAPI.SR. get_uuid remote_rpc session_id dest_sr_ref in
440- (dest_sr_ref, dest_sr)
441- | false , false ->
442- if List. mem vconf suspends_vdis && suspend_sr_ref <> Ref. null then
443- let dest_sr_ref = suspend_sr_ref in
444- let dest_sr = XenAPI.SR. get_uuid remote_rpc session_id dest_sr_ref in
445- (dest_sr_ref, dest_sr)
446- else if default_sr_ref <> Ref. null then
447- let dest_sr_ref = default_sr_ref in
448- let dest_sr = XenAPI.SR. get_uuid remote_rpc session_id dest_sr_ref in
449- (dest_sr_ref, dest_sr)
450- else
451- let vdi_uuid = Db.VDI. get_uuid ~__context ~self: vdi in
452- error " VDI:SR map not fully specified for VDI %s" vdi_uuid;
453- raise (Api_errors. Server_error (Api_errors. vdi_not_in_map, [ Ref. string_of vdi ]))
427+ | true , _ ->
428+ debug " VDI has been specified in the vdi_map" ;
429+ List. assoc vdi vdi_map
430+ | false , true ->
431+ debug " snapshot VDI's snapshot_of has been specified in the vdi_map" ;
432+ List. assoc snapshot_of vdi_map
433+ | false , false ->
434+ begin match List. mem vconf suspends_vdis, suspend_sr_ref <> Ref. null, default_sr_ref <> Ref. null with
435+ | true , true , _ -> suspend_sr_ref
436+ | true , false , true
437+ | false , _ , true -> default_sr_ref
438+ | _ ->
439+ let vdi_uuid = Db.VDI. get_uuid ~__context ~self: vdi in
440+ error " VDI:SR map not fully specified for VDI %s" vdi_uuid;
441+ raise (Api_errors. Server_error (Api_errors. vdi_not_in_map, [ Ref. string_of vdi ]))
442+ end
454443 in
444+ let dest_sr_uuid = XenAPI.SR. get_uuid remote_rpc session_id dest_sr_ref in
455445
456446 (* Plug the destination shared SR into destination host and pool master if unplugged.
457447 Plug the local SR into destination host only if unplugged *)
@@ -488,7 +478,7 @@ let migrate_send' ~__context ~vm ~dest ~live ~vdi_map ~vif_map ~options =
488478 use case is for a shared raw iSCSI SR (same uuid, same VDI uuid) *)
489479 let vdi_uuid = Db.VDI. get_uuid ~__context ~self: vdi in
490480 let mirror = if ! Xapi_globs. relax_xsm_sr_check then
491- if (dest_sr = sr) then
481+ if (dest_sr_uuid = sr) then
492482 begin
493483 (* Check if the VDI uuid already exists in the target SR *)
494484 if (dest_vdi_exists_on_sr vdi_uuid dest_sr_ref true ) then
@@ -499,7 +489,7 @@ let migrate_send' ~__context ~vm ~dest ~live ~vdi_map ~vif_map ~options =
499489 else
500490 true
501491 else
502- (not is_intra_pool) || (dest_sr <> sr)
492+ (not is_intra_pool) || (dest_sr_uuid <> sr)
503493 in
504494
505495 let remote_vdi,remote_vdi_reference,newdp =
@@ -527,10 +517,10 @@ let migrate_send' ~__context ~vm ~dest ~live ~vdi_map ~vif_map ~options =
527517 in
528518
529519 let task = if not do_mirror then
530- SMAPI.DATA. copy ~dbg ~sr ~vdi: location ~dp: newdp ~url ~dest: dest_sr
520+ SMAPI.DATA. copy ~dbg ~sr ~vdi: location ~dp: newdp ~url ~dest: dest_sr_uuid
531521 else begin
532522 ignore(Storage_access. register_mirror __context location);
533- SMAPI.DATA.MIRROR. start ~dbg ~sr ~vdi: location ~dp: newdp ~url ~dest: dest_sr
523+ SMAPI.DATA.MIRROR. start ~dbg ~sr ~vdi: location ~dp: newdp ~url ~dest: dest_sr_uuid
534524 end
535525 in
536526
@@ -578,10 +568,10 @@ let migrate_send' ~__context ~vm ~dest ~live ~vdi_map ~vif_map ~options =
578568 mr_mirrored = mirror;
579569 mr_local_sr = sr;
580570 mr_local_vdi = location;
581- mr_remote_sr = dest_sr ;
571+ mr_remote_sr = dest_sr_uuid ;
582572 mr_remote_vdi = remote_vdi;
583573 mr_local_xenops_locator = xenops_locator;
584- mr_remote_xenops_locator = Xapi_xenops. xenops_vdi_locator_of_strings dest_sr remote_vdi;
574+ mr_remote_xenops_locator = Xapi_xenops. xenops_vdi_locator_of_strings dest_sr_uuid remote_vdi;
585575 mr_remote_vdi_reference = remote_vdi_reference; }) in
586576
587577 let suspends_map = List. map vdi_copy_fun suspends_vdis in
0 commit comments