Skip to content

Commit 78ea48e

Browse files
thomassagaborigloi
authored andcommitted
CA-265469: start xapi-nbd from xapi
An interim commit, this uses systemctl to start the xapi-nbd service unconditionally at the end of the xapi startup sequence. This means that on first boot, xapi-nbd is started only after the autogenerated TLS certificate has been created. Signed-off-by: Thomas Sanders <[email protected]>
1 parent 9f03496 commit 78ea48e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ocaml/xapi/xapi.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,14 @@ let set_stunnel_legacy_db ~__context () =
680680
Xapi_host.set_stunnel_legacy ~__context legacy_db
681681
end
682682

683+
(* Consult database to see if this host has any interfaces on networks
684+
* that we want to use for NBD. If so, start the NBD server listening
685+
* on those interfaces only. (TODO: do the interface/network checking. *)
686+
let start_xapi_nbd () =
687+
(* TODO refactor this systemctl code so that we can share it with xapi_gpumon.ml *)
688+
info "Starting xapi-nbd";
689+
ignore (Forkhelpers.execute_command_get_output "/usr/bin/systemctl" ["start"; "xapi-nbd"])
690+
683691
let server_init() =
684692
let print_server_starting_message() = debug "(Re)starting xapi"; debug "on_system_boot=%b pool_role=%s" !Xapi_globs.on_system_boot (Pool_role.string_of (Pool_role.get_role ())) in
685693
Unixext.unlink_safe "/etc/xensource/boot_time_info_updated";
@@ -961,6 +969,8 @@ let server_init() =
961969
(fun () -> Helpers.call_api_functions ~__context (fun rpc session_id -> Xapi_pool_update.detach_attached_updates __context));
962970
"Resync the applied updates of the host when start", [ Startup.NoExnRaising ],
963971
(fun () -> Helpers.call_api_functions ~__context (fun rpc session_id -> Xapi_pool_update.resync_host __context (Helpers.get_localhost ~__context)));
972+
"Start the xapi-nbd daemon if needed", [ Startup.NoExnRaising ],
973+
(fun () -> start_xapi_nbd ());
964974
];
965975

966976
debug "startup: startup sequence finished");

0 commit comments

Comments
 (0)