Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #821 from johnelse/ca-88388

  • Loading branch information...
commit e1f60878d298a1fa9e5b09cc6d0c8957b5312960 2 parents f003243 + 3efde3e
xen-git authored
2  ocaml/xapi/cli_frontend.ml
View
@@ -1156,7 +1156,7 @@ let rec cmdtable_data : (string*cmd_spec) list =
"vm-migrate",
{
reqd=[];
- optn=["live"; "host"; "host-uuid"; "remote-address"; "remote-username"; "remote-password"; "remote-network"; "destination-sr-uuid"; "encrypt"; "force"; "vif"; "vdi"];
+ optn=["live"; "host"; "host-uuid"; "remote-address"; "remote-username"; "remote-password"; "remote-network"; "destination-sr-uuid"; "encrypt"; "force"; "vif:"; "vdi:"];
help="Migrate the selected VM(s). The parameter '--live' will migrate the VM without shutting it down. The 'host' parameter matches can be either the name or the uuid of the host. The parameter '--encrypt' will encrypt the memory image transfer.";
implementation=No_fd Cli_operations.vm_migrate;
flags=[Standard; Vm_selectors];
17 ocaml/xapi/import.ml
View
@@ -841,25 +841,40 @@ module VIF : HandlerTools = struct
let vif_exists () = try ignore (get_vif ()); true with _ -> false in
if config.full_restore && vif_exists () then begin
+ (* If there's already a VIF with the same UUID and we're preserving UUIDs, use that one. *)
let vif = get_vif () in
Found_VIF vif
end else
(* If not restoring a full backup then blank the MAC so it is regenerated *)
let vif_record = { vif_record with API.vIF_MAC =
if config.full_restore then vif_record.API.vIF_MAC else "" } in
+ (* Determine the VM to which we're going to attach this VIF. *)
let vm = log_reraise
("Failed to find VIF's VM: " ^ (Ref.string_of vif_record.API.vIF_VM))
(lookup vif_record.API.vIF_VM) state.table in
+ (* Determine the network to which we're going to attach this VIF. *)
let net =
+ (* If we find the cross-pool migration key, attach the VIF to that network... *)
if List.mem_assoc Constants.storage_migrate_vif_map_key vif_record.API.vIF_other_config
then Ref.of_string (List.assoc Constants.storage_migrate_vif_map_key vif_record.API.vIF_other_config)
else
+ (* ...otherwise fall back to looking up the network from the state table. *)
log_reraise
("Failed to find VIF's Network: " ^ (Ref.string_of vif_record.API.vIF_network))
(lookup vif_record.API.vIF_network) state.table in
+ (* Make sure we remove the cross-pool migration VIF mapping key from the other_config
+ * before creating a VIF - otherwise we'll risk sending this key on to another pool
+ * during a future cross-pool migration and it won't make sense. *)
+ let other_config =
+ List.filter
+ (fun (k, _) -> k <> Constants.storage_migrate_vif_map_key)
+ vif_record.API.vIF_other_config
+ in
+ (* Construct the VIF record we're going to try to create locally. *)
let vif_record = { vif_record with
API.vIF_VM = vm;
- API.vIF_network = net } in
+ API.vIF_network = net;
+ API.vIF_other_config = other_config } in
Create vif_record
let handle_dry_run __context config rpc session_id state x precheck_result =
31 ocaml/xapi/xapi_vm_migrate.ml
View
@@ -164,7 +164,15 @@ let intra_pool_vdi_remap ~__context vm vdi_map =
Db.VBD.set_VDI ~__context ~self:vbd ~value:mirror_record.mr_remote_vdi_reference) vbds
-let inter_pool_metadata_transfer ~__context ~remote_rpc ~session_id ~remote_address ~vm ~vdi_map ~dry_run ~live =
+let inter_pool_metadata_transfer ~__context ~remote_rpc ~session_id ~remote_address ~vm ~vdi_map ~vif_map ~dry_run ~live =
+ List.iter (fun (vdi,mirror_record) ->
+ Db.VDI.remove_from_other_config ~__context ~self:vdi ~key:Constants.storage_migrate_vdi_map_key;
+ Db.VDI.add_to_other_config ~__context ~self:vdi ~key:Constants.storage_migrate_vdi_map_key ~value:(Ref.string_of mirror_record.mr_remote_vdi_reference)) vdi_map;
+
+ List.iter (fun (vif,network) ->
+ Db.VIF.remove_from_other_config ~__context ~self:vif ~key:Constants.storage_migrate_vif_map_key;
+ Db.VIF.add_to_other_config ~__context ~self:vif ~key:Constants.storage_migrate_vif_map_key ~value:(Ref.string_of network)) vif_map;
+
let vm_export_import = {
Importexport.vm = vm; dry_run = dry_run; live = live; send_snapshots=true;
} in
@@ -173,10 +181,13 @@ let inter_pool_metadata_transfer ~__context ~remote_rpc ~session_id ~remote_addr
Importexport.remote_metadata_export_import ~__context
~rpc:remote_rpc ~session_id ~remote_address (`Only vm_export_import))
(fun () ->
- (* Make sure we clean up the remote VDI mapping keys. *)
+ (* Make sure we clean up the remote VDI and VIF mapping keys. *)
List.iter
(fun (vdi, _) -> Db.VDI.remove_from_other_config ~__context ~self:vdi ~key:Constants.storage_migrate_vdi_map_key)
- vdi_map)
+ vdi_map;
+ List.iter
+ (fun (vif, _) -> Db.VIF.remove_from_other_config ~__context ~self:vif ~key:Constants.storage_migrate_vif_map_key)
+ vif_map)
let migrate_send' ~__context ~vm ~dest ~live ~vdi_map ~vif_map ~options =
SMPERF.debug "vm.migrate_send called vm:%s" (Db.VM.get_uuid ~__context ~self:vm);
@@ -343,16 +354,6 @@ let migrate_send' ~__context ~vm ~dest ~live ~vdi_map ~vif_map ~options =
let xenops_vdi_map = List.map (fun (_, mirror_record) -> (mirror_record.mr_local_xenops_locator, mirror_record.mr_remote_xenops_locator)) (snapshots_map @ vdi_map) in
- List.iter (fun (vdi,mirror_record) ->
- let other_config = Db.VDI.get_other_config ~__context ~self:vdi in
- if List.mem_assoc Constants.storage_migrate_vdi_map_key other_config then
- Db.VDI.remove_from_other_config ~__context ~self:vdi ~key:Constants.storage_migrate_vdi_map_key;
- Db.VDI.add_to_other_config ~__context ~self:vdi ~key:Constants.storage_migrate_vdi_map_key ~value:(Ref.string_of mirror_record.mr_remote_vdi_reference)) (snapshots_map @ vdi_map);
-
- List.iter (fun (vif,network) ->
- Db.VIF.remove_from_other_config ~__context ~self:vif ~key:Constants.storage_migrate_vif_map_key;
- Db.VIF.add_to_other_config ~__context ~self:vif ~key:Constants.storage_migrate_vif_map_key ~value:(Ref.string_of network)) vif_map;
-
(* Wait for delay fist to disappear *)
if Xapi_fist.pause_storage_migrate () then begin
TaskHelper.add_to_other_config ~__context "fist" "pause_storage_migrate";
@@ -374,7 +375,7 @@ let migrate_send' ~__context ~vm ~dest ~live ~vdi_map ~vif_map ~options =
intra_pool_vdi_remap ~__context vm (snapshots_map @ vdi_map) ;
intra_pool_fix_suspend_sr ~__context (Ref.of_string dest_host) vm
end
- else inter_pool_metadata_transfer ~__context ~remote_rpc ~session_id ~remote_address:remote_master_address ~vm ~vdi_map:(snapshots_map @ vdi_map) ~dry_run:false ~live:true;
+ else inter_pool_metadata_transfer ~__context ~remote_rpc ~session_id ~remote_address:remote_master_address ~vm ~vdi_map:(snapshots_map @ vdi_map) ~vif_map ~dry_run:false ~live:true;
if Xapi_fist.pause_storage_migrate2 () then begin
TaskHelper.add_to_other_config ~__context "fist" "pause_storage_migrate2";
@@ -576,7 +577,7 @@ let assert_can_migrate ~__context ~vm ~dest ~live ~vdi_map ~vif_map ~options =
~remote:(remote_rpc, session_id) ();
(* Ignore vdi_map for now since we won't be doing any mirroring. *)
- try inter_pool_metadata_transfer ~__context ~remote_rpc ~session_id ~remote_address ~vm ~vdi_map:[] ~dry_run:true ~live:true
+ try inter_pool_metadata_transfer ~__context ~remote_rpc ~session_id ~remote_address ~vm ~vdi_map:[] ~vif_map ~dry_run:true ~live:true
with Xmlrpc_client.Connection_reset ->
raise (Api_errors.Server_error(Api_errors.cannot_contact_host, [remote_address]))
Please sign in to comment.
Something went wrong with that request. Please try again.