From a3ed80a59e2ea9771408c55678d64a04a512d917 Mon Sep 17 00:00:00 2001 From: Gabor Igloi Date: Tue, 28 Mar 2017 11:01:17 +0100 Subject: [PATCH 1/2] CA-242706: call update_getty at xapi startup During xapi startup, the on_dom0_networking_change function does not recognize the IP address change, as it gets set in the database at an earlier startup phase. This commit adds an unconditional call to the update_getty function during startup. Signed-off-by: Gabor Igloi (cherry picked from commit a2891f4a54cb073f69ec356074e50ce4872ff854) Signed-off-by: Gabor Igloi --- ocaml/xapi/helpers.ml | 9 +++++++++ ocaml/xapi/xapi.ml | 3 ++- ocaml/xapi/xapi_mgmt_iface.ml | 13 ++----------- 3 files changed, 13 insertions(+), 12 deletions(-) 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..f2143898b40 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: @@ -196,13 +187,13 @@ let on_dom0_networking_change ~__context = 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; From 0a2d836ab9d07fed2d53578c5d01abcc9780c147 Mon Sep 17 00:00:00 2001 From: Gabor Igloi Date: Mon, 22 May 2017 15:37:04 +0100 Subject: [PATCH 2/2] CA-242706: Add "warning" comment explaining issue Signed-off-by: Gabor Igloi --- ocaml/xapi/xapi_mgmt_iface.ml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ocaml/xapi/xapi_mgmt_iface.ml b/ocaml/xapi/xapi_mgmt_iface.ml index f2143898b40..591ecc483a0 100644 --- a/ocaml/xapi/xapi_mgmt_iface.ml +++ b/ocaml/xapi/xapi_mgmt_iface.ml @@ -183,6 +183,8 @@ 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;