From: Wei Liu Date: Mon, 10 Aug 2015 08:00:18 +0000 (+0100) Subject: oxenstored: fix systemd socket activation X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~2637 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=da743d1c9091e3f2046dee35bae9ae23e73b84f0;p=xen.git oxenstored: fix systemd socket activation Use the correct API sd_listen_fds to determine whether the process is started by systemd. Change sd_booted to launched_by_systemd to avoid confusion with systemd's API. Signed-off-by: Wei Liu Acked-by: Dave Scott Acked-by: Ian Campbell Tested-by: Andrew Cooper --- diff --git a/tools/ocaml/xenstored/systemd.ml b/tools/ocaml/xenstored/systemd.ml index 2aa39eaf71..732446d8e5 100644 --- a/tools/ocaml/xenstored/systemd.ml +++ b/tools/ocaml/xenstored/systemd.ml @@ -13,5 +13,5 @@ *) external sd_listen_fds: string -> Unix.file_descr = "ocaml_sd_listen_fds" -external sd_booted: unit -> bool = "ocaml_sd_booted" +external launched_by_systemd: unit -> bool = "ocaml_launched_by_systemd" external sd_notify_ready: unit -> unit = "ocaml_sd_notify_ready" diff --git a/tools/ocaml/xenstored/systemd.mli b/tools/ocaml/xenstored/systemd.mli index 85c9f2eb85..538fc5e1b5 100644 --- a/tools/ocaml/xenstored/systemd.mli +++ b/tools/ocaml/xenstored/systemd.mli @@ -17,8 +17,8 @@ * us do sanity checks on the expected sockets *) val sd_listen_fds: string -> Unix.file_descr -(** Tells us whether or not systemd support was compiled in *) -val sd_booted: unit -> bool +(** Tells us whether the process is launched by systemd *) +val launched_by_systemd: unit -> bool (** Tells systemd we're ready *) external sd_notify_ready: unit -> unit = "ocaml_sd_notify_ready" diff --git a/tools/ocaml/xenstored/systemd_stubs.c b/tools/ocaml/xenstored/systemd_stubs.c index d924ff1bd7..1bd5deaf53 100644 --- a/tools/ocaml/xenstored/systemd_stubs.c +++ b/tools/ocaml/xenstored/systemd_stubs.c @@ -92,14 +92,14 @@ CAMLprim value ocaml_sd_listen_fds(value connect_to) CAMLreturn(sock_ret); } -CAMLprim value ocaml_sd_booted(value ignore) +CAMLprim value ocaml_launched_by_systemd(value ignore) { CAMLparam1(ignore); CAMLlocal1(ret); ret = Val_false; - if (sd_booted()) + if (sd_listen_fds(0) > 0) ret = Val_true; CAMLreturn(ret); @@ -129,7 +129,7 @@ CAMLprim value ocaml_sd_listen_fds(value connect_to) CAMLreturn(sock_ret); } -CAMLprim value ocaml_sd_booted(value ignore) +CAMLprim value ocaml_launched_by_systemd(value ignore) { CAMLparam1(ignore); CAMLlocal1(ret); diff --git a/tools/ocaml/xenstored/utils.ml b/tools/ocaml/xenstored/utils.ml index 61321c619b..9f82c1ca8d 100644 --- a/tools/ocaml/xenstored/utils.ml +++ b/tools/ocaml/xenstored/utils.ml @@ -84,7 +84,7 @@ let create_regular_unix_socket name = sock let create_unix_socket name = - if Systemd.sd_booted() then + if Systemd.launched_by_systemd() then Systemd.sd_listen_fds name else create_regular_unix_socket name diff --git a/tools/ocaml/xenstored/xenstored.ml b/tools/ocaml/xenstored/xenstored.ml index bfe689b0f8..f4840247b6 100644 --- a/tools/ocaml/xenstored/xenstored.ml +++ b/tools/ocaml/xenstored/xenstored.ml @@ -431,7 +431,7 @@ let _ = while not !quit do try - if Systemd.sd_booted() then + if Systemd.launched_by_systemd() then Systemd.sd_notify_ready (); main_loop () with exc ->