Skip to contentSkip to conversation

ocaml/xs: prefer using character device

PATCH Applied Doug Goldstein 4 participants 5 messages Sep 1, 2015 – Sep 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ocaml/xs: prefer using character device

Since 9c89dc95201ffed5fead17b35754bf9440fdbdc0 libxenstore prefers using /dev/xen/xenbus over /proc/xen/xenbus. This makes the OCaml xenstore library contain the same preference.

---
 tools/ocaml/libs/xs/xs.ml | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/ocaml/libs/xs/xs.ml +7 -1
index 5757571..7e14487 100644
@@ -162,7 +162,13 @@ let daemon_open () =
 	with _ -> raise Failed_to_connect
 
 let domain_open () =
-	let path = "/proc/xen/xenbus" in
+	let path = try
+		let devpath = "/dev/xen/xenbus" in
+		Unix.access devpath [ Unix.F_OK ];
+		devpath
+	with Unix.Unix_error(_, _, _) ->
+		"/proc/xen/xenbus" in
+
 	let fd = Unix.openfile path [ Unix.O_RDWR ] 0o550 in
 	Unix.set_close_on_exec fd;
 	make fd
Signature · 1 line
2.1.4
#1 lore raw

Cc Dave

Quoted 36 lines · Doug Goldstein

Since 9c89dc95201ffed5fead17b35754bf9440fdbdc0 libxenstore prefers using /dev/xen/xenbus over /proc/xen/xenbus. This makes the OCaml xenstore library contain the same preference.

---
 tools/ocaml/libs/xs/xs.ml | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/ocaml/libs/xs/xs.ml +7 -1
index 5757571..7e14487 100644
@@ -162,7 +162,13 @@ let daemon_open () =
 	with _ -> raise Failed_to_connect
 
 let domain_open () =
-	let path = "/proc/xen/xenbus" in
+	let path = try
+		let devpath = "/dev/xen/xenbus" in
+		Unix.access devpath [ Unix.F_OK ];
+		devpath
+	with Unix.Unix_error(_, _, _) ->
+		"/proc/xen/xenbus" in
+
 	let fd = Unix.openfile path [ Unix.O_RDWR ] 0o550 in
 	Unix.set_close_on_exec fd;
 	make fd
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v1 1/1
#2 lore raw
In reply to Doug Goldstein

Looks fine to me.

Quoted 38 lines · Doug Goldstein

Since 9c89dc95201ffed5fead17b35754bf9440fdbdc0 libxenstore prefers using /dev/xen/xenbus over /proc/xen/xenbus. This makes the OCaml xenstore library contain the same preference.

---
tools/ocaml/libs/xs/xs.ml | 8 +++++++-

1 file changed, 7 insertions(+), 1 deletion(-)
tools/ocaml/libs/xs/xs.ml +0 -0
index 5757571..7e14487 100644
@@ -162,7 +162,13 @@ let daemon_open () =
 	with _ -> raise Failed_to_connect
 

let domain_open () =

tools/ocaml/libs/xs/xs.ml +7 -1
-	let path = "/proc/xen/xenbus" in
+	let path = try
+		let devpath = "/dev/xen/xenbus" in
+		Unix.access devpath [ Unix.F_OK ];
+		devpath
+	with Unix.Unix_error(_, _, _) ->
+		"/proc/xen/xenbus" in
+
	let fd = Unix.openfile path [ Unix.O_RDWR ] 0o550 in
	Unix.set_close_on_exec fd;
	make fd
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Applied
#3 lore raw
Quoted 3 lines · Dave Scott

Looks fine to me.

Applied.

Quoted 32 lines
Quoted 32 lines · Doug Goldstein

Since 9c89dc95201ffed5fead17b35754bf9440fdbdc0 libxenstore prefers using
/dev/xen/xenbus over /proc/xen/xenbus. This makes the OCaml xenstore library contain the same preference.

---
tools/ocaml/libs/xs/xs.ml | 8 +++++++-

1 file changed, 7 insertions(+), 1 deletion(-)
tools/ocaml/libs/xs/xs.ml +0 -0
index 5757571..7e14487 100644
@@ -162,7 +162,13 @@ let daemon_open () =
 	with _ -> raise Failed_to_connect
 

let domain_open () =

tools/ocaml/libs/xs/xs.ml +7 -1
-	let path = "/proc/xen/xenbus" in
+	let path = try
+		let devpath = "/dev/xen/xenbus" in
+		Unix.access devpath [ Unix.F_OK ];
+		devpath
+	with Unix.Unix_error(_, _, _) ->
+		"/proc/xen/xenbus" in
+
	let fd = Unix.openfile path [ Unix.O_RDWR ] 0o550 in
	Unix.set_close_on_exec fd;
	make fd
#4 lore raw
In reply to Doug Goldstein
Quoted 5 lines · Doug Goldstein

Since 9c89dc95201ffed5fead17b35754bf9440fdbdc0 libxenstore prefers using /dev/xen/xenbus over /proc/xen/xenbus. This makes the OCaml xenstore library contain the same preference.

Quoted 31 lines
---
 tools/ocaml/libs/xs/xs.ml | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/ocaml/libs/xs/xs.ml +7 -1
index 5757571..7e14487 100644
@@ -162,7 +162,13 @@ let daemon_open () =
 	with _ -> raise Failed_to_connect
 
 let domain_open () =
-	let path = "/proc/xen/xenbus" in
+	let path = try
+		let devpath = "/dev/xen/xenbus" in
+		Unix.access devpath [ Unix.F_OK ];
+		devpath
+	with Unix.Unix_error(_, _, _) ->
+		"/proc/xen/xenbus" in
+
 	let fd = Unix.openfile path [ Unix.O_RDWR ] 0o550 in
 	Unix.set_close_on_exec fd;
 	make fd
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel