[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH for-4.9 0/2] oxenstored: make it work on FreeBSD



> On 14. Apr 2017, at 11:20, Wei Liu <wei.liu2@xxxxxxxxxx> wrote:
> 
> Unfortunately there is an easy way to determine system name in the standard
> library so I wrote a wrapper for uname syscall.

I think there are two solutions to using the correct path:

(1) Determine the path at compile time and use the mechanism in config.ml to 
read the path at startup.

https://github.com/mirage/xen/blob/master/tools/ocaml/xenstored/oxenstored.conf.in
https://github.com/mirage/xen/blob/master/tools/ocaml/xenstored/xenstored.ml#L90

(2) Determine the path at runtime and this is what the patch does by using 
uname:

-let xenstored_proc_kva = "/proc/xen/xsd_kva"
-let xenstored_proc_port = "/proc/xen/xsd_port"
+let xenstored_proc_kva =
+  let info = Unix_syscalls.uname () in
+  match info.sysname with
+  | "Linux" -> "/proc/xen/xsd_kva"
+  | "FreeBSD" -> "/dev/xen/xenstored"
+  | _ -> "nonexistent"
+let xenstored_proc_port =
+  let info = Unix_syscalls.uname () in
+  match info.sysname with
+  | "Linux" -> "/proc/xen/xsd_port"
+  | "FreeBSD" -> "/dev/xen/xenstored"
+  | _ -> "nonexistent"

I wonder whether this could be simplified without binding a system call in C by 
simply checking the presence of the two paths (using Sys.is_directory) and 
picking the one that does exist. In general I’m in favour of (1) but would also 
consider a simple run-time check.

- Christian


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.