diff --git a/ocaml/xapi/helpers.ml b/ocaml/xapi/helpers.ml index 492c463f8fd..54e4bcce971 100644 --- a/ocaml/xapi/helpers.ml +++ b/ocaml/xapi/helpers.ml @@ -180,6 +180,15 @@ let update_pif_address ~__context ~self = with _ -> debug "Bridge %s is not up; not updating IP" bridge +let update_getty () = + (* Running update-issue service on best effort basis *) + try + ignore (Forkhelpers.execute_command_get_output !Xapi_globs.update_issue_script []); + ignore (Forkhelpers.execute_command_get_output !Xapi_globs.kill_process_script ["-q"; "-HUP"; "mingetty"; "agetty"]) + with e -> + debug "update_getty at %s caught exception: %s" + __LOC__ (Printexc.to_string e) + let set_gateway ~__context ~pif ~bridge = let dbg = Context.string_of_task __context in try diff --git a/ocaml/xapi/xapi.ml b/ocaml/xapi/xapi.ml index 0dca8f87351..9c15ce0325f 100644 --- a/ocaml/xapi/xapi.ml +++ b/ocaml/xapi/xapi.ml @@ -294,7 +294,8 @@ let bring_up_management_if ~__context () = warn "Failed to acquire a management IP address" end; (* Start the Host Internal Management Network, if needed. *) - Xapi_network.check_himn ~__context + Xapi_network.check_himn ~__context; + Helpers.update_getty () with e -> debug "Caught exception bringing up management interface: %s" (ExnHelper.string_of_exn e) diff --git a/ocaml/xapi/xapi_mgmt_iface.ml b/ocaml/xapi/xapi_mgmt_iface.ml index 74faf017e46..591ecc483a0 100644 --- a/ocaml/xapi/xapi_mgmt_iface.ml +++ b/ocaml/xapi/xapi_mgmt_iface.ml @@ -165,15 +165,6 @@ let wait_for_management_ip ~__context = done; end); !ip -let update_getty () = - (* Running update-issue service on best effort basis *) - try - ignore (Forkhelpers.execute_command_get_output !Xapi_globs.update_issue_script []); - ignore (Forkhelpers.execute_command_get_output !Xapi_globs.kill_process_script ["-q"; "-HUP"; "mingetty"; "agetty"]) - with e -> - debug "update_getty at %s caught exception: %s" - __LOC__ (Printexc.to_string e) - let on_dom0_networking_change ~__context = debug "Checking to see if hostname or management IP has changed"; (* Need to update: @@ -192,17 +183,19 @@ let on_dom0_networking_change ~__context = Db.Host.set_name_label ~__context ~self:localhost ~value:new_hostname; begin match Helpers.get_management_ip_addr ~__context with | Some ip -> + (* WARNING: this does NOT detect IP address changes that happen before + xapi's startup (see CA-242706) *) if Db.Host.get_address ~__context ~self:localhost <> ip then begin debug "Changing Host.address in database to: %s" ip; Db.Host.set_address ~__context ~self:localhost ~value:ip; debug "Refreshing console URIs"; - update_getty (); + Helpers.update_getty (); Dbsync_master.refresh_console_urls ~__context end | None -> if Db.Host.get_address ~__context ~self:localhost <> "" then begin debug "Changing Host.address in database to: '' (host has no management IP address)"; - update_getty (); + Helpers.update_getty (); Db.Host.set_address ~__context ~self:localhost ~value:"" end end;