mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
tools/oxenstored: Load the plugin for Xenctrl.domain_getinfo
Oxenstored dynamically loads the plugin provided in ocaml/libs/xsd_glue. The plugin is verified to be providing the specified plugin_interface during its loading. If a V2 of the plugin is produced, V1 will still be present, and a new version should only be loaded if it's verified to exist (New oxenstored can run in an environment with only V1 of the plugin). The plugin is not switched to as of yet, the old Xenctrl stubs are still used. Signed-off-by: Andrii Sultanov <andrii.sultanov@cloud.com> Acked-by: Christian Lindig <christian.lindig@cloud.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
1 parent
a6576011a4
commit
8d3ca1b23b
3 files changed
+33
-1
No files matched your search
@@ -15,7 +15,8 @@ OCAMLINCLUDE += \
|
||||
-I $(OCAML_TOPLEVEL)/libs/xb \
|
||||
-I $(OCAML_TOPLEVEL)/libs/mmap \
|
||||
-I $(OCAML_TOPLEVEL)/libs/xc \
|
||||
-I $(OCAML_TOPLEVEL)/libs/eventchn
|
||||
-I $(OCAML_TOPLEVEL)/libs/eventchn \
|
||||
-I $(OCAML_TOPLEVEL)/libs/xsd_glue
|
||||
|
||||
LIBS = syslog.cma syslog.cmxa poll.cma poll.cmxa
|
||||
syslog_OBJS = syslog
|
||||
@@ -59,6 +60,7 @@ INTF = symbol.cmi trie.cmi syslog.cmi systemd.cmi poll.cmi
|
||||
|
||||
XENSTOREDLIBS = \
|
||||
unix.cmxa \
|
||||
dynlink.cmxa \
|
||||
-ccopt -L -ccopt . syslog.cmxa \
|
||||
-ccopt -L -ccopt . systemd.cmxa \
|
||||
-ccopt -L -ccopt . poll.cmxa \
|
||||
@@ -66,6 +68,7 @@ XENSTOREDLIBS = \
|
||||
-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/eventchn $(OCAML_TOPLEVEL)/libs/eventchn/xeneventchn.cmxa \
|
||||
-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xc $(OCAML_TOPLEVEL)/libs/xc/xenctrl.cmxa \
|
||||
-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xb $(OCAML_TOPLEVEL)/libs/xb/xenbus.cmxa \
|
||||
-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xsd_glue $(OCAML_TOPLEVEL)/libs/xsd_glue/plugin_interface_v1.cmxa \
|
||||
-ccopt -L -ccopt $(XEN_ROOT)/tools/libs/ctrl
|
||||
|
||||
PROGRAMS = oxenstored
|
||||
|
||||
@@ -20,6 +20,34 @@ let warn fmt = Logging.warn "domains" fmt
|
||||
|
||||
let xc = Xenctrl.interface_open ()
|
||||
|
||||
let load_plug fname =
|
||||
let fail_with fmt = Printf.ksprintf failwith fmt in
|
||||
let fname = Dynlink.adapt_filename fname in
|
||||
if Sys.file_exists fname then
|
||||
try Dynlink.loadfile fname with
|
||||
| Dynlink.Error err as e ->
|
||||
error "ERROR loading plugin '%s': %s\n%!" fname
|
||||
(Dynlink.error_message err);
|
||||
raise e
|
||||
| _ -> fail_with "Unknown error while loading plugin"
|
||||
else fail_with "Plugin file '%s' does not exist" fname
|
||||
|
||||
let () =
|
||||
let plugins_dir = Paths.libexec ^ "/ocaml/xsd_glue/xenctrl_plugin/" in
|
||||
let filepath = plugins_dir ^ "domain_getinfo_v1.cmxs" in
|
||||
debug "Trying to load plugin '%s'\n%!" filepath;
|
||||
let list_files = Sys.readdir plugins_dir in
|
||||
debug "Directory listing of '%s'\n%!" plugins_dir ;
|
||||
Array.iter (fun x -> debug "\t%s\n%!" x) list_files;
|
||||
Dynlink.allow_only [ "Plugin_interface_v1" ];
|
||||
load_plug filepath
|
||||
|
||||
module Plugin =
|
||||
(val Plugin_interface_v1.get_plugin_v1 ()
|
||||
: Plugin_interface_v1.Domain_getinfo_V1)
|
||||
|
||||
let handle = Plugin.interface_open ()
|
||||
|
||||
type domains = {
|
||||
eventchn: Event.t;
|
||||
table: (Xenctrl.domid, Domain.t) Hashtbl.t;
|
||||
|
||||
@@ -2,3 +2,4 @@ let xen_log_dir = "@XEN_LOG_DIR@"
|
||||
let xen_config_dir = "@XEN_CONFIG_DIR@"
|
||||
let xen_run_dir = "@XEN_RUN_DIR@"
|
||||
let xen_run_stored = "@XEN_RUN_STORED@"
|
||||
let libexec = "@LIBEXEC@"
|
||||