Skip to content
This repository
Browse code

Move everything over to using Fhs.ml / @ substitution

Note that there should be no user visible change in this changeset;
everything should be the same as it was before.

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
  • Loading branch information...
commit 13b8348e30f1630c21941ce5bc38832ecd204b88 1 parent d6a7d77
Jon Ludlam authored December 06, 2011

Showing 139 changed files with 312 additions and 302 deletions. Show diff stats Hide diff stats

  1. 2  .gitignore
  2. 18  Makefile
  3. 2  OMakefile
  4. 4  ocaml/OMakefile
  5. 2  ocaml/auth/OMakefile
  6. 8  ocaml/auth/extauth.ml
  7. 2  ocaml/auth/extauth_plugin_ADlikewise.ml
  8. 2  ocaml/cdrommon/OMakefile
  9. 6  ocaml/database/OMakefile
  10. 2  ocaml/database/redo_log.ml
  11. 2  ocaml/db_process/OMakefile
  12. 2  ocaml/gpg/OMakefile
  13. 2  ocaml/gpg/gpg.ml
  14. 2  ocaml/idl/ocaml_backend/OMakefile
  15. 5  ocaml/license/OMakefile
  16. 2  ocaml/license/v6client.ml
  17. 2  ocaml/license/v6d_reopen_logs.ml
  18. 2  ocaml/license/v6daemon.ml
  19. 2  ocaml/lvhdrt/OMakefile
  20. 4  ocaml/mpathalert/OMakefile
  21. 2  ocaml/mpathalert/mpathalert.ml
  22. 8  ocaml/perftest/OMakefile
  23. 2  ocaml/perftest/apiperf.ml
  24. 2  ocaml/perftest/client_stunnel.conf
  25. 2  ocaml/perftest/perfutil.ml
  26. 4  ocaml/ptoken/OMakefile
  27. 2  ocaml/ptoken/genptoken.ml
  28. 8  ocaml/sm-cli/OMakefile
  29. 2  ocaml/sm-cli/main.ml
  30. 2  ocaml/sm-cli/test.ml
  31. 3  ocaml/util/OMakefile
  32. 2  ocaml/util/util_globs_inventory.ml
  33. 2  ocaml/util/util_inventory.ml
  34. 4  ocaml/vncproxy/OMakefile
  35. 2  ocaml/vncproxy/vncproxy.ml
  36. 12  ocaml/xapi/OMakefile
  37. 2  ocaml/xapi/certificates.ml
  38. 1  ocaml/xapi/config_constants.ml.in
  39. 2  ocaml/xapi/console.ml
  40. 2  ocaml/xapi/create_misc.ml
  41. 2  ocaml/xapi/events.ml
  42. 2  ocaml/xapi/helpers.ml
  43. 2  ocaml/xapi/monitor.ml
  44. 2  ocaml/xapi/monitor_fake_common.ml
  45. 2  ocaml/xapi/nm.ml
  46. 2  ocaml/xapi/pool_db_backup.ml
  47. 2  ocaml/xapi/quicktest_storage.ml
  48. 2  ocaml/xapi/sm_exec.ml
  49. 2  ocaml/xapi/sparse_dd_wrapper.ml
  50. 2  ocaml/xapi/static_vdis.ml
  51. 2  ocaml/xapi/static_vdis_list.ml
  52. 2  ocaml/xapi/storage_impl.ml
  53. 2  ocaml/xapi/vmops.ml
  54. 8  ocaml/xapi/xapi.ml
  55. 69  ocaml/xapi/xapi_globs.ml
  56. 18  ocaml/xapi/xapi_ha.ml
  57. 6  ocaml/xapi/xapi_host.ml
  58. 4  ocaml/xapi/xapi_host_backup.ml
  59. 2  ocaml/xapi/xapi_logs_download.ml
  60. 8  ocaml/xapi/xapi_message.ml
  61. 2  ocaml/xapi/xapi_mgmt_iface.ml
  62. 2  ocaml/xapi/xapi_pci.ml
  63. 6  ocaml/xapi/xapi_pool_patch.ml
  64. 2  ocaml/xapi/xapi_services.ml
  65. 2  ocaml/xapi/xapi_support.ml
  66. 2  ocaml/xapi/xapi_sync.ml
  67. 2  ocaml/xapi/xapi_templates_install.ml
  68. 8  ocaml/xapi/xapi_udhcpd.ml
  69. 2  ocaml/xapi/xapi_vif.ml
  70. 2  ocaml/xapi/xha_interface.ml
  71. 4  ocaml/xe-cli/OMakefile
  72. 2  ocaml/xe-cli/cli.ml
  73. 2  ocaml/xe-cli/newcli.ml
  74. 4  ocaml/xenops/OMakefile
  75. 6  ocaml/xenops/device.ml
  76. 2  ocaml/xenops/xenguestHelper.ml
  77. 2  ocaml/xenops/xenops.ml
  78. 2  ocaml/xenops/xenvm.readme
  79. 4  ocaml/xiu/OMakefile
  80. 6  ocaml/xiu/xiu.ml
  81. 4  scripts/InterfaceReconfigure.py
  82. 30  scripts/OMakefile
  83. 6  scripts/backup-metadata-cron
  84. 4  scripts/bugtool-plugin/xapi/stuff.xml
  85. 2  scripts/db.conf.skel
  86. 4  scripts/examples/bash-cli/install-debian
  87. 4  scripts/examples/bash-cli/install-debian.html
  88. 2  scripts/examples/python/inventory.py
  89. 2  scripts/examples/python/monitor-unwanted-domains.py
  90. 2  scripts/fake-pv-drivers.sh
  91. 2  scripts/fence
  92. 2  scripts/host-backup-restore/host-restore
  93. 2  scripts/host-bugreport-upload
  94. 4  scripts/init.d-genptoken
  95. 4  scripts/init.d-management-interface
  96. 4  scripts/init.d-perfmon
  97. 8  scripts/init.d-sdkinit
  98. 2  scripts/init.d-squeezed
  99. 2  scripts/init.d-v6d
  100. 8  scripts/init.d-xapi
  101. 8  scripts/init.d-xapi-domains
  102. 12  scripts/init.d-xapissl
  103. 12  scripts/init.d-xenservices
  104. 4  scripts/install.sh
  105. 2  scripts/interface-reconfigure
  106. 2  scripts/interface-reconfigure-test
  107. 2  scripts/interface-reconfigure-test-setup
  108. 2  scripts/interface-visualise
  109. 4  scripts/license-check.py
  110. 2  scripts/mpathalert-daemon
  111. 2  scripts/plugins/iovirt
  112. 2  scripts/poweron/iLO.py
  113. 4  scripts/rewrite-management-interface
  114. 2  scripts/rio.db.conf.skel
  115. 2  scripts/runtests
  116. 4  scripts/set-dom0-memory-target-from-packs
  117. 2  scripts/sm_diagnostics
  118. 2  scripts/static-vdis
  119. 2  scripts/sysconfig-perfmon
  120. 2  scripts/templates/debian
  121. 2  scripts/thread_diagnostics
  122. 2  scripts/vif
  123. 4  scripts/vncterm-wrapper
  124. 2  scripts/with-vdi
  125. 2  scripts/xapi-autostart-vms
  126. 2  scripts/xapi-logrotate
  127. 4  scripts/xapi-rolling-upgrade-miami
  128. 4  scripts/xapi.conf
  129. 12  scripts/xe-backup-metadata
  130. 6  scripts/xe-edit-bootloader
  131. 4  scripts/xe-mount-iso-sr
  132. 6  scripts/xe-reset-networking
  133. 12  scripts/xe-restore-metadata
  134. 6  scripts/xe-set-iscsi-iqn
  135. 6  scripts/xe-toolstack-restart
  136. 6  scripts/xe-xentrace
  137. 8  scripts/xen-backend.agent
  138. 8  scripts/xen-backend.rules
  139. 2  scripts/xen-frontend.rules
2  .gitignore
@@ -197,3 +197,5 @@ ocaml/xenops/memory_breakdown
197 197
 ocaml/xenops/squeezed
198 198
 ocaml/xenops/squeezed_client
199 199
 xapi.spec
  200
+
  201
+ocaml/fhs.*
18  Makefile
@@ -32,13 +32,17 @@ PLUGINDIR=/etc/xapi.d/plugins
32 32
 HOOKSDIR=/etc/xapi.d
33 33
 INVENTORY=/etc/xensource-inventory
34 34
 XAPICONF=/etc/xapi.conf
35  
-LIBEXECDIR=$(OPTDIR)/libexec
  35
+LIBEXECDIR=/opt/xensource/libexec
36 36
 SCRIPTSDIR=/etc/xensource/scripts
  37
+SHAREDIR=/opt/xensource
  38
+WEBDIR=/opt/xensource/www
  39
+XHADIR=/opt/xensource/xha
  40
+BINDIR=/opt/xensource/bin
37 41
 
38  
-export VARDIR ETCDIR OPTDIR PLUGINDIR HOOKSDIR INVENTORY VARPATCHDIR LIBEXECDIR XAPICONF SCRIPTSDIR
  42
+export VARDIR ETCDIR OPTDIR PLUGINDIR HOOKSDIR INVENTORY VARPATCHDIR LIBEXECDIR XAPICONF SCRIPTSDIR SHAREDIR WEBDIR XHADIR BINDIR
39 43
 
40 44
 .PHONY: all
41  
-all: version
  45
+all: version ocaml/fhs.ml
42 46
 	omake phase1
43 47
 	omake phase2
44 48
 	omake phase3
@@ -116,9 +120,13 @@ ocaml/fhs.ml :
116 120
 	let libexecdir=\"$(LIBEXECDIR)\"\n \
117 121
 	let xapiconf=\"$(XAPICONF)\"\n \
118 122
 	let scriptsdir=\"$(SCRIPTSDIR)\"\n \
119  
-	let varpatchdir=\"$(VARPATCHDIR)\"\n" \
  123
+	let varpatchdir=\"$(VARPATCHDIR)\"\n \
  124
+	let webdir=\"$(WEBDIR)\"\n \
  125
+	let xhadir=\"$(XHADIR)\"\n \
  126
+	let bindir=\"$(BINDIR)\"\n \
  127
+	let sharedir=\"$(SHAREDIR)\"\n" \
120 128
 	> ocaml/fhs.ml
121  
-	 
  129
+ 
122 130
 .PHONY: clean
123 131
  clean:
124 132
 
2  OMakefile
@@ -79,7 +79,7 @@ export
79 79
 .PHONY: none
80 80
 
81 81
 # Ocaml #############################################################################
82  
-OCAML_PHASE1= generate_constants autogen_idl
  82
+OCAML_PHASE1= autogen_idl
83 83
 OCAML_PHASE2= $(if $(BYTE_ENABLED), ocaml/idl/ocaml_backend/xapi_client.cma) $(if $(NATIVE_ENABLED), ocaml/idl/ocaml_backend/xapi_client.cmxa)
84 84
 
85 85
 # JS ################################################################################
4  ocaml/OMakefile
... ...
@@ -1,9 +1,11 @@
1 1
 # You must set your XEN_ROOT env var before building
2 2
 XEN_CFLAGS    = -I$(XEN_ROOT)/usr/include
3 3
 OCAMLINCLUDES = +ocamldoc
4  
-OCAML_LIBS    = $(ROOT)/ocaml/util/version $(ROOT)/ocaml/util/stats
  4
+OCAML_LIBS    = $(ROOT)/ocaml/fhs $(ROOT)/ocaml/util/version $(ROOT)/ocaml/util/stats
5 5
 OCAMLPACKS    = stdext log
6 6
 
  7
+OCamlLibrary(fhs, fhs)
  8
+
7 9
 .SUBDIRS: \
8 10
 	ptoken \
9 11
 	autogen \
2  ocaml/auth/OMakefile
... ...
@@ -1,5 +1,5 @@
1 1
 OTHER_CLIBS = -cclib -lpam
2  
-OCAMLINCLUDES += ../autogen ../idl/ocaml_backend ../idl ../xapi 
  2
+OCAMLINCLUDES += ../autogen ../idl/ocaml_backend ../idl ../xapi ..
3 3
 
4 4
 StaticCLibrary(auth_stubs, xa_auth xa_auth_stubs)
5 5
 OCamlLibraryClib(pam, pam, auth_stubs)
8  ocaml/auth/extauth.ml
@@ -74,7 +74,7 @@ struct
74 74
 end
75 75
 
76 76
 (* some constants *)
77  
-let extauth_hook_script_name = "extauth-hook" (* script name in /etc/xapi.d/plugins/ *)
  77
+let extauth_hook_script_name = "extauth-hook" (* script name in @PLUGINDIR@/ *)
78 78
 let event_name_after_subject_add = "after-subject-add"
79 79
 let event_name_after_subject_remove = "after-subject-remove"
80 80
 let event_name_after_xapi_initialize = "after-xapi-initialize"
@@ -102,10 +102,10 @@ let can_execute_extauth_hook_script ~__context host event_name =
102 102
 (* use the generic call below to avoid concurrency problems between the script and host.{enable,disable}_extauth *)
103 103
 let call_extauth_hook_script_in_host_wrapper ~__context host event_name ~call_plugin_fn =
104 104
 	(* CP-709: call extauth-hook-script *)
105  
-	(* Forkhelpers.execute_command_get_output hook-script "/etc/xapi.d/plugins/extauth-hook" *)
  105
+	(* Forkhelpers.execute_command_get_output hook-script "@PLUGINDIR@/extauth-hook" *)
106 106
 	(* fork a new thread and call new xapi.host.call-subject-add-hook-script method *)
107 107
 	(* see xapi_sync.ml *)
108  
-	(* host.call-plugins scriptname (calls /etc/xapi.d/plugins/scriptname*)
  108
+	(* host.call-plugins scriptname (calls @PLUGINDIR@/scriptname*)
109 109
 
110 110
 	if can_execute_extauth_hook_script ~__context host event_name
111 111
 	then begin
@@ -148,7 +148,7 @@ let call_extauth_hook_script_in_host ~__context host event_name =
148 148
 	let call_plugin_fn () = 
149 149
 		Helpers.call_api_functions ~__context (fun rpc session_id ->
150 150
 			Client.Client.Host.call_plugin rpc session_id host (* will call extauth plugin with mutex *) 
151  
-			extauth_hook_script_name (* script name in /etc/xapi.d/plugins/ *) 
  151
+			extauth_hook_script_name (* script name in @PLUGINDIR@/ *) 
152 152
 			event_name (* event name sent to script *)
153 153
 			event_params (* parameters sent to event name *)
154 154
 		)
2  ocaml/auth/extauth_plugin_ADlikewise.ml
@@ -700,7 +700,7 @@ let on_disable config_params =
700 700
 	debug "Doing a manual Likewise domain-leave cleanup...";
701 701
 	(* When likewise raises an exception during domain-leave, we try again, using *)
702 702
 	(* some of the command-line workarounds that Kyle describes in CA-27627: *)
703  
-	let lw_force_domain_leave_script = Xapi_globs.base_path ^ "/libexec/lw-force-domain-leave" in
  703
+	let lw_force_domain_leave_script = Filename.concat Fhs.libexecdir "lw-force-domain-leave" in
704 704
 	(try
705 705
 		let output, stderr = Forkhelpers.execute_command_get_output lw_force_domain_leave_script [] in
706 706
 		debug "execute %s: stdout=[%s],stderr=[%s]" lw_force_domain_leave_script (Stringext.String.replace "\n" ";" output) (Stringext.String.replace "\n" ";" stderr)
2  ocaml/cdrommon/OMakefile
... ...
@@ -1,4 +1,4 @@
1  
-OCAML_LIBS    = ../util/version ../idl/ocaml_backend/common
  1
+OCAML_LIBS    = ../fhs ../util/version ../idl/ocaml_backend/common
2 2
 OCAMLINCLUDES = ../xapi
3 3
 OCAMLPACKS += unix cdrom
4 4
 
6  ocaml/database/OMakefile
... ...
@@ -1,5 +1,5 @@
1 1
 
2  
-OCAMLINCLUDES = ../idl/ocaml_backend ../xapi ../idl ../util ../autogen
  2
+OCAMLINCLUDES = ../idl/ocaml_backend ../xapi ../idl ../util ../autogen ..
3 3
 OCAMLPACKS    = xml-light2 stdext stunnel http-svr log sexpr rpc-light
4 4
 #OCAMLPPFLAGS  = -pp "camlp4o" 
5 5
 #OCAMLDEPFLAGS = -pp "camlp4o"
@@ -13,7 +13,7 @@ OCamlProgram(unit_test_sql, unit_test_sql)
13 13
 BLOCK_DEVICE_IO_FILES = \
14 14
 	block_device_io_errors \
15 15
 	block_device_io \
16  
-	../xapi/config_constants ../xapi/xapi_globs ../idl/ocaml_backend/ref \
  16
+	../xapi/xapi_globs ../idl/ocaml_backend/ref \
17 17
 	../xapi/helper_process ../xapi/helper_hostname ../idl/api_errors
18 18
 
19 19
 OCamlProgram(block_device_io, $(BLOCK_DEVICE_IO_FILES))
@@ -28,7 +28,7 @@ section:
28 28
 	OCamlProgram(database_test, $(DATABASE_TEST_FILES))
29 29
 
30 30
 section:
31  
-	OCAML_LIBS +=  ../idl/ocaml_backend/common ../idl/ocaml_backend/client ../idl/ocaml_backend/server
  31
+	OCAML_LIBS += ../idl/ocaml_backend/common ../idl/ocaml_backend/client ../idl/ocaml_backend/server
32 32
 	OCamlProgram(unit_test_marshall, unit_test_marshall db_remote_cache_access_v1)
33 33
 
34 34
 .PHONY: install
2  ocaml/database/redo_log.ml
@@ -202,7 +202,7 @@ let string_to_redo_log_entry str =
202 202
 exception RedoLogFailure of string
203 203
 exception CommunicationsProblem of string
204 204
 
205  
-let prog = Xapi_globs.base_path ^ "/libexec/block_device_io"
  205
+let prog = Filename.concat Fhs.libexecdir "block_device_io"
206 206
 
207 207
 let generation_size = 16
208 208
 let length_size = 16
2  ocaml/db_process/OMakefile
... ...
@@ -1,4 +1,4 @@
1  
-OCAML_LIBS    = ../util/version ../idl/ocaml_backend/common ../idl/ocaml_backend/client ../util/stats ../idl/ocaml_backend/server
  1
+OCAML_LIBS    = ../fhs ../util/version ../idl/ocaml_backend/common ../idl/ocaml_backend/client ../util/stats ../idl/ocaml_backend/server
2 2
 OCAMLINCLUDES = ../idl/ocaml_backend ../xapi ../database
3 3
 OCAMLPACKS    =  xml-light2 uuid sexpr log stunnel http-svr
4 4
 
2  ocaml/gpg/OMakefile
... ...
@@ -1,4 +1,4 @@
1  
-OCAMLINCLUDES += ../xapi
  1
+OCAMLINCLUDES += ../xapi ..
2 2
 
3 3
 .PHONY: clean
4 4
 clean:
2  ocaml/gpg/gpg.ml
@@ -23,7 +23,7 @@ open D
23 23
 let filename = ref ""
24 24
 
25 25
 let gpg_binary_path = "/usr/bin/gpg"
26  
-let gpg_homedir = Xapi_globs.base_path ^ "/gpg/"
  26
+let gpg_homedir = Filename.concat Fhs.optdir "gpg/"
27 27
 let gpg_pub_keyring = gpg_homedir ^ "pubring.gpg"
28 28
 let allowed_gpg_checksum =
29 29
 	[ "be00ee82bffad791edfba477508d5d84"; (* centos52 version *)
2  ocaml/idl/ocaml_backend/OMakefile
@@ -52,7 +52,7 @@ autogen_idl: $(AUTOGEN_DIR)/client.ml $(AUTOGEN_DIR)/aPI.ml $(AUTOGEN_DIR)/serve
52 52
 
53 53
 COMMON_OBJS = ref \
54 54
 	../datamodel_types event_types \
55  
-	../api_errors ../api_messages ../../xapi/config_constants ../../xapi/xapi_globs \
  55
+	../api_errors ../api_messages ../../xapi/xapi_globs \
56 56
 	../constants
57 57
 CLIENT_OBJS = $(AUTOGEN_DIR)/aPI $(AUTOGEN_DIR)/client event_helper
58 58
 SERVER_OBJS = ../../database/escaping locking_helpers \
5  ocaml/license/OMakefile
... ...
@@ -1,10 +1,11 @@
1 1
 OCAML_LIBS    = ../util/version ../idl/ocaml_backend/xapi_client
2  
-OCAMLINCLUDES = ../idl/ocaml_backend ../idl ../autogen ../xapi ../gpg ../util
  2
+OCAMLINCLUDES = ../idl/ocaml_backend ../idl ../autogen ../xapi ../gpg ../util ..
3 3
 OCAMLPACKS    = xml-light2 stdext stunnel http-svr log rpc-light
4 4
 
5 5
 UseCamlp4(rpc-light.syntax, v6rpc v6errors)
6 6
 
7 7
 V6FILES = \
  8
+	../fhs \
8 9
 	fakev6 \
9 10
 	v6rpc \
10 11
 	v6errors \
@@ -18,7 +19,7 @@ V6D = v6d
18 19
 OCamlProgram($(V6D), $(V6FILES))
19 20
 OCamlDocProgram($(V6D), $(V6FILES))
20 21
 
21  
-OCamlProgram(v6d-reopen-logs, v6d_reopen_logs)
  22
+OCamlProgram(v6d-reopen-logs, v6d_reopen_logs ../fhs)
22 23
 
23 24
 .PHONY: install
24 25
 install: $(V6D)
2  ocaml/license/v6client.ml
@@ -20,7 +20,7 @@ exception V6DaemonFailure
20 20
 let retry = ref true
21 21
 
22 22
 (* RPC function for communication with the v6 daemon *)
23  
-let socket = "/var/xapi/v6"
  23
+let socket = Filename.concat Fhs.vardir "v6"
24 24
 let v6rpc call =
25 25
 	let open Xmlrpc_client in
26 26
 	XMLRPC_protocol.rpc ~transport:(Unix socket) ~http:(xmlrpc ~version:"1.0" "/") call
2  ocaml/license/v6d_reopen_logs.ml
@@ -13,7 +13,7 @@
13 13
  *)
14 14
 (** Small executable that sends a reopen-logs XML/RPC message to the licensing daemon *)
15 15
  
16  
-let socket = "/var/xapi/v6"
  16
+let socket = Filename.concat Fhs.vardir "v6"
17 17
 
18 18
 (* RPC function for communication with the v6 daemon *)
19 19
 let v6rpc xml = 
2  ocaml/license/v6daemon.ml
@@ -42,7 +42,7 @@ let daemon_init post_daemonize_hook process =
42 42
 	post_daemonize_hook ();
43 43
 	
44 44
 	(* unix socket *)
45  
-	let unix_socket_path = "/var/xapi/v6" in
  45
+	let unix_socket_path = Filename.concat Fhs.vardir "v6" in
46 46
 	Unixext.mkdir_safe (Filename.dirname unix_socket_path) 0o700;
47 47
 	Unixext.unlink_safe unix_socket_path;
48 48
 	let domain_sock = Http_svr.bind (Unix.ADDR_UNIX(unix_socket_path)) "unix_rpc" in
2  ocaml/lvhdrt/OMakefile
... ...
@@ -1,4 +1,4 @@
1  
-OCAML_LIBS    = ../util/version ../idl/ocaml_backend/common ../idl/ocaml_backend/client
  1
+OCAML_LIBS    = ../fhs ../util/version ../idl/ocaml_backend/common ../idl/ocaml_backend/client 
2 2
 OCAMLINCLUDES = ../xapi ../idl/ocaml_backend/ ../idl ../autogen
3 3
 OCAMLPACKS    = xml-light2 stdext stunnel http-svr log rpc-light
4 4
 
4  ocaml/mpathalert/OMakefile
... ...
@@ -1,8 +1,8 @@
1 1
 OCAML_LIBS    = ../util/version ../idl/ocaml_backend/common ../idl/ocaml_backend/client
2  
-OCAMLINCLUDES = ../idl/ocaml_backend/ ../idl ../autogen
  2
+OCAMLINCLUDES = ../idl/ocaml_backend/ ../idl ../autogen ..
3 3
 OCAMLPACKS    = xml-light2 stdext stunnel http-svr log rpc-light
4 4
 
5  
-OCamlProgram(mpathalert, mpathalert)
  5
+OCamlProgram(mpathalert, mpathalert ../fhs)
6 6
 OCamlDocProgram(mpathalert, mpathalert)
7 7
 
8 8
 .PHONY: clean
2  ocaml/mpathalert/mpathalert.ml
@@ -296,7 +296,7 @@ let _ =
296 296
 	let rpc xml =
297 297
 		let open Xmlrpc_client in
298 298
 		let http = xmlrpc ~version:"1.0" "/" in
299  
-		XML_protocol.rpc ~transport:(Unix "/var/xapi/xapi") ~http xml in
  299
+		XML_protocol.rpc ~transport:(Unix (Filename.concat Fhs.vardir "xapi")) ~http xml in
300 300
 	let queue = Queue.create () in
301 301
 	let msg = Buffer.create 1024 in
302 302
 
8  ocaml/perftest/OMakefile
... ...
@@ -1,11 +1,11 @@
1  
-OCAML_LIBS    = ../util/version ../idl/ocaml_backend/common ../idl/ocaml_backend/client
2  
-OCAMLINCLUDES = ../idl/ocaml_backend ../xapi ../idl ../autogen ../client_records
  1
+OCAML_LIBS    = ../fhs ../util/version ../idl/ocaml_backend/common ../idl/ocaml_backend/client
  2
+OCAMLINCLUDES = ../idl/ocaml_backend ../xapi ../idl ../autogen ../client_records ..
3 3
 OCAMLPACKS    = xml-light2 stdext stunnel http-svr log rpc-light
4 4
 
5  
-PERFTEST_FILES = scenario perfutil createVM createpool testtypes perftest tests ../xapi/xapi_inventory perfdebug
  5
+PERFTEST_FILES = scenario perfutil createVM createpool testtypes perftest tests ../xapi/xapi_inventory perfdebug 
6 6
 OCamlProgram(perftest, $(PERFTEST_FILES))
7 7
 OCamlDocProgram(perftest, $(PERFTEST_FILES))
8  
-OCamlProgram(apiperf, perfutil apiperf)
  8
+OCamlProgram(apiperf, perfutil apiperf ../fhs)
9 9
 OCamlProgram(histogram, statistics histogram gnuplot testtypes perfdebug graphutil)
10 10
 OCamlProgram(cumulative_time, cumulative_time gnuplot testtypes perfdebug graphutil)
11 11
 
2  ocaml/perftest/apiperf.ml
@@ -30,7 +30,7 @@ let use_stunnel_cache = ref false
30 30
 let master = ref false
31 31
 let slave_limit = ref 0
32 32
 let threads = ref 1
33  
-let url = ref "file:///var/xapi/xapi"
  33
+let url = ref ("file://" ^ Fhs.vardir ^ "xapi")
34 34
 
35 35
 
36 36
 type url = 
2  ocaml/perftest/client_stunnel.conf
@@ -9,6 +9,6 @@ client=yes
9 9
 [localhost-xapi]
10 10
 accept = 80
11 11
 connect = 10.80.226.181:443
12  
-cert = /etc/xensource/xapi-ssl.pem
  12
+cert = @ETCDIR@/xapi-ssl.pem
13 13
 
14 14
 
2  ocaml/perftest/perfutil.ml
@@ -18,7 +18,7 @@ open Stringext
18 18
 
19 19
 let rpc xml =
20 20
 	let open Xmlrpc_client in
21  
-	XML_protocol.rpc ~transport:(Unix "/var/xapi/xapi") ~http:(xmlrpc ~version:"1.0" "/") xml
  21
+	XML_protocol.rpc ~transport:(Unix (Filename.concat Fhs.vardir "xapi")) ~http:(xmlrpc ~version:"1.0" "/") xml
22 22
 
23 23
 let remoterpc host xml =
24 24
 	let open Xmlrpc_client in
4  ocaml/ptoken/OMakefile
... ...
@@ -1,9 +1,9 @@
1 1
 OCAMLPACKS = uuid
2  
-
  2
+OCAMLINCLUDES = ..
3 3
 GENSECRET_SRC_FILES = genptoken.ml
4 4
 
5 5
 section
6  
-	OCamlProgram(genptoken, genptoken)
  6
+	OCamlProgram(genptoken, genptoken ../fhs)
7 7
 
8 8
 .PHONY: clean
9 9
 clean:
2  ocaml/ptoken/genptoken.ml
@@ -2,7 +2,7 @@
2 2
 
3 3
 type options = { force : bool; tgtfile : string }
4 4
 
5  
-let options = ref { force = false; tgtfile = "/etc/xensource/ptoken" }
  5
+let options = ref { force = false; tgtfile = Filename.concat Fhs.etcdir "ptoken" }
6 6
 
7 7
 let set_force _ = options := { !options with force = true }
8 8
 let set_target s = options := { !options with tgtfile = s }
8  ocaml/sm-cli/OMakefile
... ...
@@ -1,12 +1,12 @@
1 1
 OCAML_LIBS    =
2  
-OCAMLINCLUDES = ../xapi
  2
+OCAMLINCLUDES = ../xapi ..
3 3
 OCAMLPACKS    = xml-light2 stdext stunnel log http-svr oUnit
4 4
 
5 5
 section
6  
-	OCAMLINCLUDES += .
  6
+	OCAMLINCLUDES += . 
7 7
 	OCAMLFLAGS = -dtypes -thread -warn-error F
8  
-	CLI_FILES = main ../xapi/storage_interface ../xapi/vdi_automaton
9  
-	TEST_FILES = test ../xapi/storage_interface ../xapi/vdi_automaton
  8
+	CLI_FILES = main ../xapi/storage_interface ../xapi/vdi_automaton ../fhs
  9
+	TEST_FILES = test ../xapi/storage_interface ../xapi/vdi_automaton ../fhs
10 10
 	OCamlProgram(sm, $(CLI_FILES))
11 11
 	OCamlDocProgram(sm, $(CLI_FILES))
12 12
 	OCamlProgram(smtest, $(TEST_FILES))
2  ocaml/sm-cli/main.ml
@@ -20,7 +20,7 @@ open Fun
20 20
 open Stringext
21 21
 open Xmlrpc_client
22 22
 
23  
-let url = ref (Http.Url.File ({ Http.Url.path = "/var/xapi/storage" }, "/"))
  23
+let url = ref (Http.Url.File ({ Http.Url.path = Filename.concat Fhs.vardir "storage" }, "/"))
24 24
 
25 25
 module RPC = struct
26 26
 let rpc call =
2  ocaml/sm-cli/test.ml
@@ -22,7 +22,7 @@ open Stringext
22 22
 
23 23
 open Xmlrpc_client
24 24
 
25  
-let default_path = "/var/xapi/storage"
  25
+let default_path = Filename.concat Fhs.vardir "storage"
26 26
 let transport = ref (Unix default_path)
27 27
 
28 28
 let rpc call =
3  ocaml/util/OMakefile
... ...
@@ -1,3 +1,6 @@
  1
+OCAMLINCLUDES = ..
  2
+OCAML_LIBS = ../fhs
  3
+
1 4
 #OCamlLibrary(util_globs_inventory, util_globs_inventory)
2 5
 OCamlLibrary(util_inventory, util_globs_inventory util_inventory)
3 6
 OCamlLibrary(version,        util_globs_inventory util_inventory version)
2  ocaml/util/util_globs_inventory.ml
... ...
@@ -1,2 +1,2 @@
1 1
 (* path to the xensource inventory file *)
2  
-let inventory_filename = "/etc/xensource-inventory"
  2
+let inventory_filename = Fhs.inventory
2  ocaml/util/util_inventory.ml
@@ -81,7 +81,7 @@ let read_inventory_contents () =
81 81
 		match parse_inventory_entry line with
82 82
 			| Some (k, v) -> Hashtbl.add inventory k v
83 83
 			| None -> warn
84  
-				"Failed to parse line from xensource-inventory file: %s" line)
  84
+				"Failed to parse line from inventory file: %s" line)
85 85
 		inventory_filename;
86 86
 	loaded_inventory := true
87 87
 
4  ocaml/vncproxy/OMakefile
... ...
@@ -1,8 +1,8 @@
1 1
 OCAML_LIBS    = ../util/version ../idl/ocaml_backend/common ../idl/ocaml_backend/client
2  
-OCAMLINCLUDES = ../idl/ocaml_backend ../idl ../autogen
  2
+OCAMLINCLUDES = ../idl/ocaml_backend ../idl ../autogen ..
3 3
 OCAMLPACKS    = xml-light2 stdext stunnel http-svr rpc-light
4 4
 
5  
-OCamlProgram(vncproxy, vncproxy)
  5
+OCamlProgram(vncproxy, vncproxy ../fhs)
6 6
 
7 7
 .PHONY: install
8 8
 install: 
2  ocaml/vncproxy/vncproxy.ml
@@ -65,7 +65,7 @@ let _ =
65 65
 	  let open Xmlrpc_client in
66 66
 	  let http = xmlrpc ~version:"1.0" "/" in
67 67
 	  match !server with
68  
-		  | "" -> XML_protocol.rpc ~transport:(Unix "/var/xapi/xapi") ~http xml
  68
+		  | "" -> XML_protocol.rpc ~transport:(Unix (Filename.concat Fhs.vardir "xapi")) ~http xml
69 69
 		  | host -> XML_protocol.rpc ~transport:(SSL(SSL.make ~use_fork_exec_helper:false (), host, 443)) ~http xml in
70 70
 
71 71
   let find_vm rpc session_id vm = 
12  ocaml/xapi/OMakefile
... ...
@@ -1,10 +1,10 @@
1 1
 OCAMLPACKS    = xml-light2 cdrom pciutil sexpr log stunnel http-svr rss xen-utils netdev tapctl vhd xenstore rpc-light
2  
-OCAML_LIBS    = ../util/version ../util/vm_memory_constraints ../util/sanitycheck ../util/stats \
  2
+OCAML_LIBS    = ../fhs ../util/version ../util/vm_memory_constraints ../util/sanitycheck ../util/stats \
3 3
 	../idl/ocaml_backend/common ../idl/ocaml_backend/client ../idl/ocaml_backend/server ../util/ocamltest
4 4
 OCAMLINCLUDES = ../idl ../idl/ocaml_backend \
5 5
 	../autogen ../database/ \
6 6
 	../xenops ../xva ../util \
7  
-	../auth ../license ../client_records ../rfb ../gpg
  7
+	../auth ../license ../client_records ../rfb ../gpg ..
8 8
 
9 9
 UseCamlp4(rpc-light.syntax, features rrd monitor_fake monitor_fake_common vdi_automaton storage_impl xapi_udhcpd)
10 10
 UseCamlp4(rpc-light.idl, storage_interface)
@@ -278,13 +278,6 @@ OCamlProgram(at_least_once_more, at_least_once_more at_least_once_more_test)
278 278
 
279 279
 .DEFAULT: xapi
280 280
 
281  
-.PHONY: generate_constants
282  
-
283  
-generate_constants: config_constants.ml
284  
-
285  
-config_constants.ml: config_constants.ml.in
286  
-	sed "s!@OPTDIR@!\"$(OPTDIR)\"!" $< > $@
287  
-
288 281
 .PHONY: install
289 282
 install:
290 283
 	mkdir -p $(DESTDIR)$(OPTDIR)/bin
@@ -306,6 +299,5 @@ sdk-install: install
306 299
 .PHONY: clean
307 300
 clean:
308 301
 	rm -rf $(CLEAN_OBJS) *.aux *.log *.fig xapi
309  
-	rm -f config_constants.ml
310 302
 	rm -f binpack xapi_unit_test sparse_dd fakeguestagent monitor_fake_plugin rrddump quicktestbin
311 303
 
2  ocaml/xapi/certificates.ml
@@ -23,7 +23,7 @@ open Client
23 23
 module D=Debug.Debugger(struct let name="certificates" end)
24 24
 open D
25 25
 
26  
-let server_cert = "/etc/xensource/xapi-ssl.pem"
  26
+let server_cert = Filename.concat Fhs.etcdir "xapi-ssl.pem"
27 27
 let c_rehash = "/usr/bin/c_rehash"
28 28
 let pem_certificate_header = "-----BEGIN CERTIFICATE-----"
29 29
 let pem_certificate_footer = "-----END CERTIFICATE-----"
1  ocaml/xapi/config_constants.ml.in
... ...
@@ -1 +0,0 @@
1  
-let base_path = @OPTDIR@
2  ocaml/xapi/console.ml
@@ -62,7 +62,7 @@ let ws_proxy __context req protocol port s =
62 62
     | `rdp -> "rdp"
63 63
   in
64 64
 
65  
-  let real_path = "/var/xapi/wsproxy" in    
  65
+  let real_path = Filename.concat Fhs.vardir "wsproxy" in    
66 66
   let sock = 
67 67
     try
68 68
       Some (Fecomms.open_unix_domain_sock_client real_path)
2  ocaml/xapi/create_misc.ml
@@ -407,7 +407,7 @@ let create_host_cpu ~__context =
407 407
 		if !i >= 0 then String.sub s 0 (!i + 1) else "" in
408 408
 
409 409
 
410  
-	(* The boot-time CPU info is copied into a file in /etc/xensource/ in the xenservices init script;
  410
+	(* The boot-time CPU info is copied into a file in @ETCDIR@/ in the xenservices init script;
411 411
 	   we use that to generate CPU records from. This ensures that if xapi is started after someone has
412 412
 	   modified dom0's VCPUs we don't change out host config... [Important to get this right, otherwise
413 413
 	   pool homogeneity checks fail] *)
2  ocaml/xapi/events.ml
@@ -48,7 +48,7 @@ module Crashdump = struct
48 48
   let to_file domid filename =
49 49
 	if true then (
50 50
 		(* opensource version *)
51  
-		let path = Xapi_globs.base_path ^ "/libexec/dumpcore" in
  51
+		let path = Filename.concat Fhs.libexecdir "dumpcore" in
52 52
 		let args = [ "-domid"; string_of_int domid;
53 53
 		              "-file"; filename ] in
54 54
 		let pid = Forkhelpers.safe_close_and_exec None None None [] path args in
2  ocaml/xapi/helpers.ml
@@ -644,7 +644,7 @@ let on_oem ~__context =
644 644
 
645 645
 exception File_doesnt_exist of string
646 646
 
647  
-let find_partition_path = Xapi_globs.base_path ^ "/libexec/find-partition"
  647
+let find_partition_path = Filename.concat Fhs.libexecdir "find-partition"
648 648
 
649 649
 let find_secondary_partition () =
650 650
 	try
2  ocaml/xapi/monitor.ml
@@ -467,7 +467,7 @@ let set_cache_sr sr_uuid =
467 467
 let unset_cache_sr () =
468 468
 	Mutex.execute cache_sr_lock (fun () -> cache_sr_uuid := None)
469 469
 
470  
-let tapdisk_cache_stats = Xapi_globs.base_path ^ "/bin/tapdisk-cache-stats"
  470
+let tapdisk_cache_stats = Filename.concat Fhs.bindir "tapdisk-cache-stats"
471 471
 
472 472
 let read_cache_stats timestamp =
473 473
 	let cache_sr_opt = Mutex.execute cache_sr_lock (fun () -> !cache_sr_uuid) in
2  ocaml/xapi/monitor_fake_common.ml
@@ -10,5 +10,5 @@ type fake_ds = {
10 10
 
11 11
 type fake_ds_list = fake_ds list with rpc
12 12
 
13  
-let fake_dir = "/var/xapi/fake_data"
  13
+let fake_dir = Filename.concat Fhs.vardir "fake_data"
14 14
 
2  ocaml/xapi/nm.ml
@@ -35,7 +35,7 @@ let update_inventory ~__context =
35 35
 	let bridges = List.map (fun (_, pif_r) -> Db.Network.get_bridge ~__context ~self:pif_r.API.pIF_network) pifs in
36 36
 	Xapi_inventory.update Xapi_inventory._current_interfaces (String.concat " " bridges)
37 37
 
38  
-let interface_reconfigure_script = Xapi_globs.base_path ^ "/libexec/interface-reconfigure"
  38
+let interface_reconfigure_script = Filename.concat Fhs.libexecdir "interface-reconfigure"
39 39
 
40 40
 (* Call the interface reconfigure script. For development ignore the exn if it doesn't exist *)
41 41
 let reconfigure_pif ~__context (pif: API.ref_PIF) args =
2  ocaml/xapi/pool_db_backup.ml
@@ -91,7 +91,7 @@ let prepare_database_for_restore ~old_context ~new_context =
91 91
 		let physical = List.filter (fun self -> Db.PIF.get_physical ~__context:old_context ~self) all_pifs in
92 92
 		List.map (fun self -> Db.PIF.get_device ~__context:old_context ~self, self) physical in
93 93
   
94  
-	(* Since it's difficult for us to change the /etc/xensource-inventory and the ifcfg-
  94
+	(* Since it's difficult for us to change the @INVENTORY@ and the ifcfg-
95 95
        files, we /preserve/ the current management PIF across the restore. NB this interface
96 96
        might be a bond or a vlan. *)
97 97
 	let mgmt_dev = 
2  ocaml/xapi/quicktest_storage.ml
@@ -467,7 +467,7 @@ let sr_scan_test caps session_id sr =
467 467
   Client.SR.scan !rpc session_id sr;
468 468
   success test
469 469
 
470  
-let iso_path = Xapi_globs.base_path ^ "/packages/iso"
  470
+let iso_path = Filename.concat Fhs.sharedir "packages/iso"
471 471
 
472 472
 let packages_iso_test session_id =
473 473
   let test = make_test ("ISO SR should be able to create VDIs for " ^ iso_path) 2 in
2  ocaml/xapi/sm_exec.ml
@@ -23,7 +23,7 @@ open Smint
23 23
 module D=Debug.Debugger(struct let name="sm_exec" end)
24 24
 open D
25 25
 
26  
-let sm_daemon_dir = "/var/xapi/sm"
  26
+let sm_daemon_dir = Filename.concat Fhs.vardir "sm"
27 27
 
28 28
 let cmd_name driver = sprintf "%s/%sSR" Xapi_globs.sm_dir driver
29 29
 let daemon_path driver = sprintf "%s/%s" sm_daemon_dir driver
2  ocaml/xapi/sparse_dd_wrapper.ml
@@ -21,7 +21,7 @@ open Printf
21 21
 module D=Debug.Debugger(struct let name="xapi" end)
22 22
 open D
23 23
 
24  
-let sparse_dd_path = Xapi_globs.base_path ^ "/libexec/sparse_dd"
  24
+let sparse_dd_path = Filename.concat Fhs.libexecdir "sparse_dd"
25 25
 
26 26
 (** Use the new external sparse_dd program *)
27 27
 let dd ~__context prezeroed infile outfile size = 
2  ocaml/xapi/static_vdis.ml
@@ -22,7 +22,7 @@ open Stringext
22 22
 open Pervasiveext
23 23
 include Static_vdis_list (* include the vdi type and the list() function *)
24 24
 
25  
-let static_vdis = Xapi_globs.base_path ^ "/bin/static-vdis"
  25
+let static_vdis = Filename.concat Fhs.bindir "static-vdis"
26 26
 
27 27
 (** Generate the static configuration and attach the VDI now *)
28 28
 let permanent_vdi_attach ~__context ~vdi ~reason =
2  ocaml/xapi/static_vdis_list.ml
@@ -27,7 +27,7 @@ type vdi = {
27 27
 (** Returns a list of vdi records, one for each VDI statically configured on this host *)
28 28
 let list () = 
29 29
   (* Read the filesystem structure directly *)
30  
-  let main_dir = "/etc/xensource/static-vdis" in
  30
+  let main_dir = Filename.concat Fhs.etcdir "static-vdis" in
31 31
   let all = try Array.to_list (Sys.readdir main_dir) with Sys_error _ -> [] in
32 32
   List.map (fun x ->
33 33
 	      let path = Filename.concat main_dir x in
2  ocaml/xapi/storage_impl.ml
@@ -646,7 +646,7 @@ module Local_domain_socket = struct
646 646
 
647 647
 	let socket = ref None
648 648
 
649  
-	let path = "/var/xapi/storage"
  649
+	let path = Filename.concat Fhs.vardir "storage"
650 650
 
651 651
 	let xmlrpc_handler process req bio _ =
652 652
 		let body = Http_svr.read_body req bio in
2  ocaml/xapi/vmops.ml
@@ -577,7 +577,7 @@ let create_device_emulator ~__context ~xc ~xs ~self ?(restore=false) ?vnc_statef
577 577
 					List.map (String.strip String.isspace) l
578 578
 				with _ -> []
579 579
 			in
580  
-		let dmpath = Xapi_globs.base_path ^ "/libexec/qemu-dm-wrapper" in
  580
+		let dmpath = Filename.concat Fhs.libexecdir "qemu-dm-wrapper" in
581 581
 		let dmstart = if restore then Device.Dm.restore else Device.Dm.start in
582 582
 
583 583
 		(* Display and input devices are usually conflated *)
8  ocaml/xapi/xapi.ml
@@ -675,7 +675,7 @@ let common_http_handlers = [
675 675
   ("get_export_metadata", (Http_svr.FdIO Export.metadata_handler));
676 676
   ("connect_console", Http_svr.FdIO (Console.handler Console.real_proxy));
677 677
   ("connect_console_ws", Http_svr.FdIO (Console.handler Console.ws_proxy));
678  
-  ("get_root", Http_svr.BufIO (Fileserver.send_file "/" (Xapi_globs.base_path ^ "/www")));
  678
+  ("get_root", Http_svr.BufIO (Fileserver.send_file "/" Fhs.webdir));
679 679
   ("post_cli", (Http_svr.BufIO Xapi_cli.handler));
680 680
   ("get_host_backup", (Http_svr.FdIO Xapi_host_backup.host_backup_handler));
681 681
   ("put_host_restore", (Http_svr.FdIO Xapi_host_backup.host_restore_handler));
@@ -1201,10 +1201,10 @@ let _ =
1201 1201
     Unixext.daemonize ();
1202 1202
   Unixext.pidfile_write "/var/run/xapi.pid";
1203 1203
 
1204  
-  (* chdir to /var/xapi/debug so that's where xapi coredumps go 
  1204
+  (* chdir to @VARDIR@/debug so that's where xapi coredumps go 
1205 1205
      (in the unlikely event that there are any ;) *)
1206  
-  Unixext.mkdir_rec "/var/xapi/debug" 0o700;
1207  
-  Unix.chdir "/var/xapi/debug";
  1206
+  Unixext.mkdir_rec (Filename.concat Fhs.vardir "debug") 0o700;
  1207
+  Unix.chdir (Filename.concat Fhs.vardir "debug");
1208 1208
 
1209 1209
 	set_thread_queue_params ();
1210 1210
 
69  ocaml/xapi/xapi_globs.ml
@@ -22,7 +22,7 @@ module D = Debug.Debugger(struct let name="xapi_globs" end)
22 22
 (* xapi process returns this code on exit when it wants to be restarted *)
23 23
 let restart_return_code = 123
24 24
 
25  
-let pool_secret_path = "/etc/xensource/ptoken"
  25
+let pool_secret_path = Filename.concat Fhs.etcdir "ptoken"
26 26
 let pool_secret = ref ""
27 27
 
28 28
 let localhost_ref : [`host] Ref.t ref = ref Ref.null
@@ -49,7 +49,7 @@ let xencenter_max_verstring = "1.10"
49 49
 
50 50
 (* linux pack vsn key in host.software_version (used for a pool join restriction *)
51 51
 let linux_pack_vsn_key = "xs:linux"
52  
-let packs_dir = "/etc/xensource/installed-repos"
  52
+let packs_dir = Filename.concat Fhs.etcdir "installed-repos"
53 53
 
54 54
 let ssl_pid = ref 0
55 55
 
@@ -63,10 +63,10 @@ let https_port = ref default_ssl_port
63 63
 
64 64
 let xapi_gc_debug = ref true
65 65
 
66  
-let unix_domain_socket = "/var/xapi/xapi"
67  
-let local_storage_unix_domain_socket = "/var/xapi/storage-local"
68  
-let storage_unix_domain_socket = "/var/xapi/storage"
69  
-let local_database = "/var/xapi/local.db"
  66
+let unix_domain_socket = Filename.concat Fhs.vardir "xapi"
  67
+let local_storage_unix_domain_socket = Filename.concat Fhs.vardir "storage-local"
  68
+let storage_unix_domain_socket = Filename.concat Fhs.vardir "storage"
  69
+let local_database = Filename.concat Fhs.vardir "local.db"
70 70
 
71 71
 
72 72
 (* if a slave in emergency "cannot see master mode" then this flag is set *)
@@ -83,17 +83,16 @@ let xe_key = "/mh/XenSource-TM_XenEnterprise-TM"
83 83
 let xe_val = "XenSource(TM) and XenEnterprise(TM) are registered trademarks of XenSource Inc."
84 84
 
85 85
 (* Base path and some of its immediate dependencies. *)
86  
-let base_path = Config_constants.base_path
87  
-let xe_path = base_path ^ "/bin/xe"
88  
-let sm_dir = base_path ^ "/sm"
89  
-
90  
-let config_file = ref "/etc/xapi.conf"
91  
-let log_config_file = ref "/etc/xensource/log.conf"
92  
-let db_conf_path = "/etc/xensource/db.conf"
93  
-let remote_db_conf_fragment_path = "/etc/xensource/remote.db.conf"
  86
+let xe_path = Filename.concat Fhs.bindir "xe"
  87
+let sm_dir = Filename.concat Fhs.optdir "sm"
  88
+
  89
+let config_file = ref Fhs.xapiconf
  90
+let log_config_file = ref (Filename.concat Fhs.etcdir "log.conf")
  91
+let db_conf_path = Filename.concat Fhs.etcdir "db.conf"
  92
+let remote_db_conf_fragment_path = Filename.concat Fhs.etcdir "remote.db.conf"
94 93
 let simulator_config_file = ref "/etc/XenServer-simulator.conf"
95  
-let pool_config_file = "/etc/xensource/pool.conf"
96  
-let cpu_info_file = "/etc/xensource/boot_time_cpus"
  94
+let pool_config_file = Filename.concat Fhs.etcdir "pool.conf"
  95
+let cpu_info_file = Filename.concat Fhs.etcdir "boot_time_cpus"
97 96
 let initial_host_free_memory_file = "/var/run/xapi/boot_time_memory"
98 97
 let using_rrds = ref false
99 98
 
@@ -174,7 +173,7 @@ let tools_sr_tag = "xenserver_tools_sr"
174 173
 let rio_tools_sr_name = "XenSource Tools"
175 174
 let miami_tools_sr_name = "XenServer Tools"
176 175
 
177  
-let tools_sr_dir = base_path ^ "/packages/iso"
  176
+let tools_sr_dir = Filename.concat Fhs.sharedir "packages/iso"
178 177
 
179 178
 let default_template_key = "default_template"
180 179
 let linux_template_key = "linux_template"
@@ -191,7 +190,7 @@ let logrot_max = ref (1024*16*1024)
191 190
 (* logrotate is called without a stdin, and when it fork-and-execs gzip, it opens the src *)
192 191
 (* getting fd 0, opens the dest getting fd 3, then forks, then dups 0 to 0, dups 3 to 1 and *)
193 192
 (* then closes 0 and 3! *)
194  
-let logrot_cmd = base_path ^ "/libexec/logrotate.sh"
  193
+let logrot_cmd = Filename.concat Fhs.libexecdir "logrotate.sh"
195 194
 let logrot_arg = [ ]
196 195
 
197 196
 (* Error codes for internal storage backends -- these have counterparts in sm.hg/drivers/XE_SR_ERRORCODES.xml *)
@@ -203,16 +202,16 @@ let sm_error_generic_VDI_create_failure = 78
203 202
 let sm_error_generic_VDI_delete_failure = 80
204 203
 
205 204
 (* temporary restore path for db *)
206  
-let db_temporary_restore_path = "/var/xapi/restore_db.db"
  205
+let db_temporary_restore_path = Filename.concat Fhs.vardir "restore_db.db"
207 206
 
208 207
 (* temporary path for the HA metadata database *)
209  
-let ha_metadata_db = "/var/xapi/ha_metadata.db"
  208
+let ha_metadata_db = Filename.concat Fhs.vardir "ha_metadata.db"
210 209
 
211 210
 (* temporary path for the general metadata database *)
212  
-let gen_metadata_db = "/var/xapi/gen_metadata.db"
  211
+let gen_metadata_db = Filename.concat Fhs.vardir "gen_metadata.db"
213 212
 
214 213
 (* temporary path for opening a foreign metadata database *)
215  
-let foreign_metadata_db = "/var/xapi/foreign.db"
  214
+let foreign_metadata_db = Filename.concat Fhs.vardir "foreign.db"
216 215
 
217 216
 let migration_failure_test_key = "migration_wings_fall_off" (* set in other-config to simulate migration failures *)
218 217
 
@@ -252,14 +251,14 @@ let pool_ha_num_host_failures = "ha_tolerated_host_failures"
252 251
 (* the other-config key that reflects whether the pool is overprovisioned *)
253 252
 let pool_ha_currently_over_provisioned = "ha_currently_over_provisioned"
254 253
 
255  
-let backup_db = "/var/xapi/state-backup.db"
  254
+let backup_db = Filename.concat Fhs.vardir "state-backup.db"
256 255
 
257 256
 (* Place where database XML backups are kept *)
258  
-let backup_db_xml = "/var/xapi/state-backup.xml"
  257
+let backup_db_xml = Filename.concat Fhs.vardir "state-backup.xml"
259 258
 
260 259
 (* Directory containing scripts which are executed when a node becomes master
261 260
    and when a node gives up the master role *)
262  
-let master_scripts_dir = "/etc/xensource/master.d"
  261
+let master_scripts_dir = Filename.concat Fhs.etcdir "master.d"
263 262
 
264 263
 (* Indicates whether we should allow clones of suspended VMs via VM.clone *)
265 264
 let pool_allow_clone_suspended_vm = "allow_clone_suspended_vm"
@@ -268,8 +267,8 @@ let pool_allow_clone_suspended_vm = "allow_clone_suspended_vm"
268 267
 let shared_db_vdi_size = 134217728L (* 128 * 1024 * 1024 = 128 megs *)
269 268
 
270 269
 (* Mount point for the shared DB *)
271  
-let shared_db_mount_point = "/var/xapi/shared_db"
272  
-let snapshot_db = "/var/xapi/snapshot.db"
  270
+let shared_db_mount_point = Filename.concat Fhs.vardir "shared_db"
  271
+let snapshot_db = Filename.concat Fhs.vardir "snapshot.db"
273 272
 
274 273
 (* Device for shared DB VBD *)
275 274
 let shared_db_device = "15"
@@ -337,10 +336,10 @@ let default_ha_timeout = "default_ha_timeout"
337 336
 
338 337
 (* Executed during startup when the API/database is online but before storage or networks
339 338
    are fully initialised. *)
340  
-let startup_script_hook = base_path ^ "/libexec/xapi-startup-script"
  339
+let startup_script_hook = Filename.concat Fhs.libexecdir "xapi-startup-script"
341 340
 
342 341
 (* Executed when a rolling upgrade is detected starting or stopping *)
343  
-let rolling_upgrade_script_hook = base_path ^ "/libexec/xapi-rolling-upgrade"
  342
+let rolling_upgrade_script_hook = Filename.concat Fhs.libexecdir "xapi-rolling-upgrade"
344 343
 
345 344
 (* When set to true indicates that the host has still booted so we're initialising everything
346 345
    from scratch e.g. shared storage, sampling boot free mem etc *)
@@ -353,12 +352,12 @@ let listen_backlog = 128
353 352
 let artificial_reboot_delay = "artificial-reboot-delay"
354 353
 
355 354
 (* Xapi script hooks root *)
356  
-let xapi_hooks_root = "/etc/xapi.d/"
  355
+let xapi_hooks_root = Fhs.hooksdir 
357 356
 
358 357
 (* RRD storage location *)
359  
-let xapi_rrd_location = "/var/xapi/blobs/rrds"
  358
+let xapi_rrd_location = Filename.concat Fhs.vardir "blobs/rrds"
360 359
 
361  
-let xapi_blob_location = "/var/xapi/blobs"
  360
+let xapi_blob_location = Filename.concat Fhs.vardir "blobs"
362 361
 
363 362
 let last_blob_sync_time = "last_blob_sync_time"
364 363
 
@@ -378,13 +377,13 @@ let http_limit_max_rrd_size = 2 * 1024 * 1024 (* 2M -- FIXME : need to go below
378 377
 
379 378
 let message_limit=10000
380 379
 
381  
-let xapi_message_script = base_path ^ "/libexec/mail-alarm"
  380
+let xapi_message_script = Filename.concat Fhs.libexecdir "mail-alarm"
382 381
 
383 382
 (* Emit a warning if more than this amount of clock skew detected *)
384 383
 let max_clock_skew = 5. *. 60. (* 5 minutes *)
385 384
 
386 385
 (* Optional directory containing XenAPI plugins *)
387  
-let xapi_plugins_root = "/etc/xapi.d/plugins"
  386
+let xapi_plugins_root = Fhs.plugindir 
388 387
 
389 388
 
390 389
 
@@ -514,7 +513,7 @@ let serialize_pool_enable_disable_extauth = Mutex.create()
514 513
 let event_hook_auth_on_xapi_initialize_succeeded = ref false
515 514
 
516 515
 (** Directory used by the v6 license policy engine for caching *)
517  
-let upgrade_grace_file = "/var/xapi/ugp"
  516
+let upgrade_grace_file = Filename.concat Fhs.vardir "ugp"
518 517
 
519 518
 (** Where the ballooning daemon writes the initial overhead value *)
520 519
 let squeezed_reserved_host_memory = "/squeezed/reserved-host-memory"
18  ocaml/xapi/xapi_ha.ml
@@ -36,15 +36,15 @@ let ha_redo_log = Redo_log.create ~name:"HA redo log" ~state_change_callback:Non
36 36
 (*********************************************************************************************)
37 37
 (* Interface with the low-level HA subsystem                                                 *)
38 38
 
39  
-let ha_set_pool_state = Xapi_globs.base_path ^ "/xha/ha_set_pool_state"
40  
-let ha_start_daemon = Xapi_globs.base_path ^ "/xha/ha_start_daemon"
41  
-let ha_stop_daemon = Xapi_globs.base_path ^ "/xha/ha_stop_daemon"
42  
-let ha_query_liveset = Xapi_globs.base_path ^ "/xha/ha_query_liveset"
43  
-let ha_propose_master = Xapi_globs.base_path ^ "/xha/ha_propose_master"
44  
-let ha_disarm_fencing = Xapi_globs.base_path ^  "/xha/ha_disarm_fencing"
45  
-let ha_set_excluded = Xapi_globs.base_path ^ "/xha/ha_set_excluded"
46  
-let fence_path = Xapi_globs.base_path ^ "/libexec/fence"
47  
-(* Unused: let ha_clear_excluded = Xapi_globs.base_path ^ "/xha/ha_clear_excluded" *)
  39
+let ha_set_pool_state = Filename.concat Fhs.xhadir "ha_set_pool_state"
  40
+let ha_start_daemon = Filename.concat Fhs.xhadir "ha_start_daemon"
  41
+let ha_stop_daemon = Filename.concat Fhs.xhadir "ha_stop_daemon"
  42
+let ha_query_liveset = Filename.concat Fhs.xhadir "ha_query_liveset"
  43
+let ha_propose_master = Filename.concat Fhs.xhadir "ha_propose_master"
  44
+let ha_disarm_fencing = Filename.concat Fhs.xhadir "ha_disarm_fencing"
  45
+let ha_set_excluded = Filename.concat Fhs.xhadir "ha_set_excluded"
  46
+let fence_path = Filename.concat Fhs.libexecdir "fence"
  47
+(* Unused: let ha_clear_excluded = Filename.concat Fhs.xhadir "ha_clear_excluded" *)
48 48
 
49 49
 (** The xHA scripts throw these exceptions: *)
50 50
 exception Xha_error of Xha_errno.code
6  ocaml/xapi/xapi_host.ml
@@ -24,8 +24,8 @@ open Workload_balancing
24 24
 module D = Debug.Debugger(struct let name="xapi" end)
25 25
 open D
26 26
 
27  
-let host_bugreport_upload = Xapi_globs.base_path ^ "/libexec/host-bugreport-upload"
28  
-let set_hostname = Xapi_globs.base_path ^ "/libexec/set-hostname"
  27
+let host_bugreport_upload = Filename.concat Fhs.libexecdir "host-bugreport-upload"
  28
+let set_hostname = Filename.concat Fhs.libexecdir "set-hostname"
29 29
 
30 30
 let set_emergency_mode_error code params = Xapi_globs.emergency_mode_error := Api_errors.Server_error(code, params)
31 31
 
@@ -711,7 +711,7 @@ let syslog_config_write host host_only enable_remote =
711 711
 		   else "") ^
712 712
 			  (if enable_remote then "SYSLOGD_OPTIONS=\"-r $SYSLOGD_OPTIONS\"\n" else "")
713 713
 		  in
714  
-	let fd = Unix.openfile "/etc/xensource/syslog.conf"
  714
+	let fd = Unix.openfile (Filename.concat Fhs.etcdir "syslog.conf")
715 715
 						   [ Unix.O_WRONLY; Unix.O_CREAT; Unix.O_TRUNC; ]
716 716
 				   0o640 in
717 717
 	ignore (Unix.write fd buf 0 (String.length buf));
4  ocaml/xapi/xapi_host_backup.ml
@@ -23,8 +23,8 @@ open Helpers
23 23
 module D = Debug.Debugger(struct let name="xapi" end)
24 24
 open D
25 25
 
26  
-let host_backup = Xapi_globs.base_path ^ "/libexec/host-backup"
27  
-let host_restore = Xapi_globs.base_path ^ "/libexec/host-restore"
  26
+let host_backup = Filename.concat Fhs.libexecdir "host-backup"
  27
+let host_restore = Filename.concat Fhs.libexecdir "host-restore"
28 28
 
29 29
 let host_backup_handler_core ~__context s =
30 30
 	match
2  ocaml/xapi/xapi_logs_download.ml
@@ -18,7 +18,7 @@ open Forkhelpers
18 18
 module D = Debug.Debugger(struct let name="xapi" end)
19 19
 open D
20 20
 
21  
-let logs_download = Xapi_globs.base_path ^ "/libexec/logs-download"
  21
+let logs_download = Filename.concat Fhs.libexecdir "logs-download"
22 22
 
23 23
 let logs_download_handler (req: Request.t) s _ =
24 24
   debug "running logs-download handler";
8  ocaml/xapi/xapi_message.ml
@@ -19,13 +19,13 @@
19 19
 (** Message store *)
20 20
 
21 21
 (* We use a filesystem based 'database': 
22  
- *  Base directory: /var/xapi/blobs/messages
  22
+ *  Base directory: @VARDIR@/blobs/messages
23 23
  *  All messages go in there, filename=timestamp
24 24
  *  
25 25
  *  Symlinks are created to the messages for fast indexing:
26  
- *  /var/xapi/blobs/messages/VM/<uuid>/<timestamp> -> message
27  
- *  /var/xapi/blobs/messages/uuid/<message uuid> -> message
28  
- *  /var/xapi/blobs/messages/ref/<message ref> -> message
  26
+ *  @VARDIR@/blobs/messages/VM/<uuid>/<timestamp> -> message
  27
+ *  @VARDIR@/blobs/messages/uuid/<message uuid> -> message
  28
+ *  @VARDIR@/blobs/messages/ref/<message ref> -> message
29 29
  *)
30 30
 
31 31
 open Listext   
2  ocaml/xapi/xapi_mgmt_iface.ml
@@ -24,7 +24,7 @@ open D
24 24
 let management_interface_server = ref None
25 25
 let management_m = Mutex.create ()
26 26
 
27  
-let rewrite_management_interface_script = Xapi_globs.base_path ^ "/libexec/rewrite-management-interface"
  27
+let rewrite_management_interface_script = Filename.concat Fhs.libexecdir "rewrite-management-interface"
28 28
 
29 29
 let rewrite_management_interface interface =
30 30
 	(* XXX: probably should decompose this into Xapi_inventory.update <k> <v> and
2  ocaml/xapi/xapi_pci.ml
@@ -30,7 +30,7 @@ type pci = {
30 30
 
31 31
 type pci_class = Display_controller | Network_controller
32 32
 
33  
-let prog = Xapi_globs.base_path ^ "/libexec/pci-info"
  33
+let prog = Filename.concat Fhs.libexecdir "pci-info"
34 34
 
35 35
 let find_class_id = function
36 36
 	| Display_controller -> "03"
6  ocaml/xapi/xapi_pool_patch.ml
@@ -273,10 +273,10 @@ let sync () =
273 273
       | Success(output, _) -> ()
274 274
 
275 275
 let patch_header_length = 8
276  
-let skip_signature_flag = "/etc/xensource/skipsignature"
  276
+let skip_signature_flag = Filename.concat Fhs.etcdir "skipsignature"
277 277
 
278  
-let update_upload_pre_script = Xapi_globs.base_path ^ "/libexec/update-upload-pre"
279  
-let update_upload_post_script = Xapi_globs.base_path ^ "/libexec/update-upload-post"
  278
+let update_upload_pre_script = Filename.concat Fhs.libexecdir "update-upload-pre"
  279
+let update_upload_post_script = Filename.concat Fhs.libexecdir "update-upload-post"
280 280
 
281 281
 let skip_signature_test () = Sys.file_exists skip_signature_flag
282 282
 
2  ocaml/xapi/xapi_services.ml
@@ -89,7 +89,7 @@ let get_handler (req: Http.Request.t) s _ =
89 89
 			debug "uri = %s" req.Http.Request.uri;
90 90
 			match String.split '/' req.Http.Request.uri with
91 91
 				| [ ""; services; "xenops" ] when services = _services ->
92  
-					hand_over_connection req s "/var/xapi/xenopsd.forwarded"
  92
+					hand_over_connection req s (Filename.concat Fhs.vardir "xenopsd.forwarded")
93 93
 				| [ ""; services; "SM"; driver ] when services = _services ->
94 94
 					begin
95 95
 						try
2  ocaml/xapi/xapi_support.ml
@@ -31,7 +31,7 @@ let do_upload label file url options =
31 31
 
32 32
 	match with_logfile_fd label
33 33
 		(fun log_fd ->
34  
-			let upload_wrapper = Xapi_globs.base_path ^ "/libexec/upload-wrapper" in
  34
+			let upload_wrapper = Filename.concat Fhs.libexecdir "upload-wrapper" in
35 35
 			let pid = safe_close_and_exec None (Some log_fd) (Some log_fd) [] upload_wrapper [file; url; proxy] in
36 36
 			waitpid_fail_if_bad_exit pid) with
37 37
 			| Success _ -> debug "Upload succeeded"
2  ocaml/xapi/xapi_sync.ml
@@ -38,7 +38,7 @@ let sync_host ~__context host =
38 38
 				let output,log = Forkhelpers.execute_command_get_output
39 39
 					~env:(Unix.environment ())
40 40
 					"/usr/bin/rsync"
41  
-					["--delete";"--stats";"-az";localpath;remotepath;"-e"; Xapi_globs.base_path ^ "/bin/xsh"] in
  41
+					["--delete";"--stats";"-az";localpath;remotepath;"-e"; Filename.concat Fhs.bindir "xsh"] in
42 42
 				debug "sync output: \n%s" output;
43 43
 				debug "log output: '%s'" log;
44 44
 
2  ocaml/xapi/xapi_templates_install.ml
@@ -25,7 +25,7 @@ module D = Debug.Debugger(struct let name="xapi" end)
25 25
 open D
26 26
 
27 27
 let allowed_dom0_directory_for_provision_scripts =
28  
-  Xapi_globs.base_path ^ "/packages/post-install-scripts/"
  28
+  Filename.concat Fhs.sharedir "packages/post-install-scripts/"
29 29
 
30 30
 let is_whitelisted script =
31 31
   let safe_char = function 'a'..'z'-> true |'-'->true |'/'->true |_ -> false in
8  ocaml/xapi/xapi_udhcpd.ml
@@ -25,9 +25,9 @@ open Threadext
25 25
 let ip_begin_key = "ip_begin"
26 26
 let ip_end_key = "ip_end"
27 27
 
28