@@ -57,15 +57,25 @@ open Storage_interface
5757open Listext
5858open Fun
5959
60- let assert_vdi_on_rawhba ~__context ~vdi_map ~remote_rpc ~session_id =
60+ let assert_sr_support_migration ~__context ~vdi_map ~remote_rpc ~session_id =
61+ (* Get destination host SM record *)
62+ let sm_record = XenAPI.SM. get_all_records remote_rpc session_id in
6163 List. iter (fun (vdi , sr ) ->
64+ (* Check VDIs must not be present on SR which doesn't have snapshot capability *)
6265 let source_sr = Db.VDI. get_SR ~__context ~self: vdi in
63- (* Check VDIs must not be present on rawHBA source SR
64- * OR VDIs must not be mirrored to rawHBA destination SR
65- * *)
66- if (Db.SR. get_type ~__context ~self: source_sr = " rawhba" ) ||
67- (XenAPI.SR. get_type remote_rpc session_id sr = " rawhba" ) then
68- raise (Api_errors. Server_error (Api_errors. vdi_on_rawhba_sr, [Ref. string_of vdi]))
66+ let sr_record = Db.SR. get_record_internal ~__context ~self: source_sr in
67+ let sr_features = Xapi_sr_operations. features_of_sr ~__context sr_record in
68+ if not Smint. (has_capability Vdi_snapshot sr_features) then
69+ raise (Api_errors. Server_error (Api_errors. sr_does_not_support_migration, [Ref. string_of source_sr]));
70+ (* Check VDIs must not be mirrored to SR which doesn't have snapshot capability *)
71+ let sr_type = XenAPI.SR. get_type remote_rpc session_id sr in
72+ let sm_capabilities =
73+ match List. filter (fun (_ , r ) -> r.API. sM_type = sr_type) sm_record with
74+ | [ _, plugin ] -> plugin.API. sM_capabilities
75+ | _ -> []
76+ in
77+ if not (List. exists (fun cp -> cp = " Vdi_snapshot" ) sm_capabilities) then
78+ raise (Api_errors. Server_error (Api_errors. sr_does_not_support_migration, [Ref. string_of sr]))
6979 ) vdi_map
7080
7181let assert_licensed_storage_motion ~__context =
@@ -837,8 +847,8 @@ let assert_can_migrate ~__context ~vm ~dest ~live ~vdi_map ~vif_map ~options =
837847 ~host_to ;
838848 (* Check the host can support the VM's required version of virtual hardware platform *)
839849 Xapi_vm_helpers. assert_hardware_platform_support ~__context ~vm ~host: host_to;
840- (* Check VDIs are not on rawHBA SR *)
841- assert_vdi_on_rawhba ~__context ~vdi_map ~remote_rpc ~session_id ;
850+ (* Check VDIs are not on SR which doesn't have snapshot capability *)
851+ assert_sr_support_migration ~__context ~vdi_map ~remote_rpc ~session_id ;
842852
843853 (* Check that the remote host is enabled and not in maintenance mode*)
844854 let check_host_enabled = XenAPI.Host. get_enabled remote_rpc session_id (dest_host_ref) in
0 commit comments