Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP-4498: Added relaxed check mode to allow iSCSI SRs during XSM #1116

Merged
merged 1 commit into from Apr 23, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions ocaml/xapi/xapi_config.ml
Expand Up @@ -25,6 +25,7 @@ let read_config filename =
let configargs = [
"use-xenopsd", Config.Set_bool Xapi_globs.use_xenopsd;
Config_shared.disable_logging_for;
"relax-xsm-sr-check", Config.Set_bool Xapi_globs.relax_xsm_sr_check;
] in
try
Config.read filename configargs (fun _ _ -> ())
Expand Down
3 changes: 3 additions & 0 deletions ocaml/xapi/xapi_globs.ml
Expand Up @@ -22,6 +22,9 @@ module D = Debug.Debugger(struct let name="xapi_globs" end)
(* set this to true to use the experimental codepath *)
let use_xenopsd = ref false

(* set this to true to enable XSM to out-of-pool SRs with matching UUID *)
let relax_xsm_sr_check = ref false

(* xapi process returns this code on exit when it wants to be restarted *)
let restart_return_code = 123

Expand Down
39 changes: 37 additions & 2 deletions ocaml/xapi/xapi_vm_migrate.ml
Expand Up @@ -274,11 +274,46 @@ let migrate_send' ~__context ~vm ~dest ~live ~vdi_map ~vif_map ~options =
let vdi_uuid = Db.VDI.get_uuid ~__context ~self:vdi in
failwith ("No SR specified in VDI map for VDI " ^ vdi_uuid)
in
let mirror = (not is_intra_pool) || (dest_sr <> sr) in


let rec dest_vdi_exists_on_sr vdi_uuid sr_ref retry =
try
let dest_vdi_ref = XenAPI.VDI.get_by_uuid remote_rpc session_id vdi_uuid in
let dest_vdi_sr_ref = XenAPI.VDI.get_SR remote_rpc session_id dest_vdi_ref in
if dest_vdi_sr_ref = sr_ref then
true
else
false
with _ ->
if retry then
begin
XenAPI.SR.scan remote_rpc session_id sr_ref;
dest_vdi_exists_on_sr vdi_uuid sr_ref false
end
else
false
in

let vdi_uuid = Db.VDI.get_uuid ~__context ~self:vdi in
let mirror = if !Xapi_globs.relax_xsm_sr_check then
if (dest_sr = sr) then
begin
(* Check if the VDI uuid already exists in the target SR *)
if (dest_vdi_exists_on_sr vdi_uuid dest_sr_ref true) then
false
else
failwith ("SR UUID matches on destination but VDI does not exist")
end
else
true
else
(not is_intra_pool) || (dest_sr <> sr)
in

let remote_vdi,remote_vdi_reference,newdp =
if not mirror then
location,vdi,"none"
let dest_vdi_ref = XenAPI.VDI.get_by_uuid remote_rpc session_id vdi_uuid in
location,dest_vdi_ref,"none"
else begin
let newdp = Printf.sprintf "mirror_%s" dp in
ignore(SMAPI.VDI.attach ~dbg ~dp:newdp ~sr ~vdi:location ~read_write:false);
Expand Down