Skip to content

Commit 8009546

Browse files
author
Jon Ludlam
committed
Merge pull request #1899 from jonludlam/udhcpd-xscore
Use busybox for udhcpd
2 parents 9252a15 + b254077 commit 8009546

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

ocaml/xapi/xapi_globs.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,10 @@ let server_cert_path = ref (Filename.concat "/etc/xensource" "xapi-ssl.pem")
731731

732732
let udhcpd_conf = ref (Filename.concat "/etc/xensource" "udhcpd.conf")
733733
let udhcpd_skel = ref (Filename.concat "/etc/xensource" "udhcpd.skel")
734+
let udhcpd_leases_db = ref "/var/lib/xcp/dhcp-leases.db"
735+
let udhcpd_pidfile = ref "/var/run/udhcpd.pid"
734736

735-
let udhcpd = ref "udhcpd"
737+
let busybox = ref "busybox"
736738

737739
let xe_path = ref "xe"
738740

@@ -890,7 +892,7 @@ module Resources = struct
890892

891893
let essential_executables = [
892894
"xapissl", xapissl_path, "Script for starting stunnel";
893-
"udhcpd", udhcpd, "DHCP server";
895+
"busybox", busybox, "Swiss army knife executable - used as DHCP server";
894896
"lw-force-domain-leave-script", lw_force_domain_leave_script, "Executed when likewise domain-leave fails";
895897
"redo-log-block-device-io", redo_log_block_device_io, "Used by the redo log for block device I/O";
896898
"sparse_dd", sparse_dd, "Path to sparse_dd";

ocaml/xapi/xapi_udhcpd.ml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ let ip_begin_key = "ip_begin"
2626
let ip_end_key = "ip_end"
2727
let ip_disable_gw_key = "ip_disable_gw"
2828

29-
let leases_db = Filename.concat "/var/lib/xcp" "dhcp-leases.db"
30-
let pidfile = "/var/run/udhcpd.pid"
31-
3229
let (|>) x f = f x
3330

3431
module Ip = struct
@@ -95,16 +92,16 @@ let update_db_nolock ~__context =
9592

9693
(** Called on startup to reload the leases database *)
9794
let load_db_nolock () =
98-
let s = Unixext.string_of_file leases_db in
95+
let s = Unixext.string_of_file !Xapi_globs.udhcpd_leases_db in
9996
let rpc = Jsonrpc.of_string s in
10097
assigned := static_leases_of_rpc rpc;
101-
info "Host internal management network successfully loaded DHCP leases db from %s" leases_db
98+
info "Host internal management network successfully loaded DHCP leases db from %s" !Xapi_globs.udhcpd_leases_db
10299

103100
(** Called before every update to save the leases database *)
104101
let save_db_nolock () =
105102
let rpc = rpc_of_static_leases !assigned in
106103
let s = Jsonrpc.to_string rpc in
107-
Unixext.write_string_to_file leases_db s
104+
Unixext.write_string_to_file !Xapi_globs.udhcpd_leases_db s
108105

109106
module Udhcpd_conf = struct
110107
type t = {
@@ -151,9 +148,9 @@ let write_config_nolock ~__context ip_router =
151148
Unixext.write_string_to_file !Xapi_globs.udhcpd_conf (Udhcpd_conf.to_string ~__context config)
152149

153150
let restart_nolock () =
154-
let pid = try Unixext.pidfile_read pidfile with _ -> None in
151+
let pid = try Unixext.pidfile_read !Xapi_globs.udhcpd_pidfile with _ -> None in
155152
Opt.iter Unixext.kill_and_wait pid;
156-
let (_: string * string) = execute_command_get_output !Xapi_globs.udhcpd [ !Xapi_globs.udhcpd_conf ] in
153+
let (_: string * string) = execute_command_get_output !Xapi_globs.busybox [ "udhcpd"; !Xapi_globs.udhcpd_conf ] in
157154
()
158155

159156
let find_lease_nolock vif =
@@ -226,6 +223,6 @@ let init () =
226223
try
227224
load_db_nolock ()
228225
with e ->
229-
info "Caught exception %s loading %s: creating new empty leases database" (Printexc.to_string e) leases_db;
226+
info "Caught exception %s loading %s: creating new empty leases database" (Printexc.to_string e) !Xapi_globs.udhcpd_leases_db;
230227
assigned := []
231228
)

xapi.spec.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ XCP toolstack.
2020
%package core
2121
Summary: The xapi toolstack
2222
Group: System/Hypervisor
23+
Requires: busybox
2324

2425
%description core
2526
This package contains the xapi toolstack.

0 commit comments

Comments
 (0)