Skip to content

Commit

Permalink
Merge pull request #41 from avsm/djs55-io-page-fix
Browse files Browse the repository at this point in the history
release 1.3.0 (tweak the tweaked branch of tweaks)
  • Loading branch information
avsm committed Jan 29, 2015
2 parents 7f683b7 + 6140e71 commit ad50b04
Show file tree
Hide file tree
Showing 12 changed files with 211 additions and 143 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.3.0 (29-Jan-2015)
* Update to `io-page.1.4.0` interface.
* Add an `opam` 1.2 file for more convenient development.
* Simplify travis configuration via centralised scripts.

1.2.0 (3-Oct-2014)
* blkback: add 'force_close' to more forcibly tear down the device
* blkback: make 'destroy' idempotent
Expand Down
6 changes: 3 additions & 3 deletions _oasis
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
OASISFormat: 0.3
OASISFormat: 0.4
Name: mirage-block-xen
Version: 1.2.0
Version: 1.3.0
Synopsis: Xen block frontend and backend driver implementation
Authors: Jonathan Ludlam, Anil Madhavapeddy, David Scott
License: ISC
Plugins: META (0.3)
Plugins: META (0.4)
BuildTools: ocamlbuild

Library mirage_block_xen
Expand Down
29 changes: 15 additions & 14 deletions _tags
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# OASIS_START
# DO NOT EDIT (digest: d02f21f6203a697a3781518ec94d0798)
# DO NOT EDIT (digest: 237c0feece202e117a00c80385e93d38)
# Ignore VCS directories, you can use the same kind of rule outside
# OASIS_START/STOP if you want to exclude directories that contains
# useless stuff for the build process
true: annot, bin_annot
<**/.svn>: -traverse
<**/.svn>: not_hygienic
".bzr": -traverse
Expand All @@ -17,21 +18,21 @@
"lib/mirage_block_xen.cmxs": use_mirage_block_xen
# Library mirage_block_xen_front
"lib/mirage_block_xen_front.cmxs": use_mirage_block_xen_front
<lib/*.ml{,i}>: pkg_mirage-types
<lib/*.ml{,i}>: pkg_mirage-xen
<lib/*.ml{,i,y}>: pkg_mirage-types
<lib/*.ml{,i,y}>: pkg_mirage-xen
# Library mirage_block_xen_back
"lib/mirage_block_xen_back.cmxs": use_mirage_block_xen_back
<lib/*.ml{,i}>: pkg_cstruct
<lib/*.ml{,i}>: pkg_cstruct.syntax
<lib/*.ml{,i}>: pkg_io-page
<lib/*.ml{,i}>: pkg_lwt
<lib/*.ml{,i}>: pkg_lwt.syntax
<lib/*.ml{,i}>: pkg_shared-memory-ring
<lib/*.ml{,i}>: pkg_shared-memory-ring.lwt
<lib/*.ml{,i}>: pkg_xen-evtchn
<lib/*.ml{,i}>: pkg_xen-gnt
<lib/*.ml{,i}>: pkg_xenstore
<lib/*.ml{,i}>: use_mirage_block_xen
<lib/*.ml{,i,y}>: pkg_cstruct
<lib/*.ml{,i,y}>: pkg_cstruct.syntax
<lib/*.ml{,i,y}>: pkg_io-page
<lib/*.ml{,i,y}>: pkg_lwt
<lib/*.ml{,i,y}>: pkg_lwt.syntax
<lib/*.ml{,i,y}>: pkg_shared-memory-ring
<lib/*.ml{,i,y}>: pkg_shared-memory-ring.lwt
<lib/*.ml{,i,y}>: pkg_xen-evtchn
<lib/*.ml{,i,y}>: pkg_xen-gnt
<lib/*.ml{,i,y}>: pkg_xenstore
<lib/*.ml{,i,y}>: use_mirage_block_xen
# OASIS_STOP
<configure.*>: not_hygienic
<*/*>: syntax_camlp4o, pkg_lwt.syntax, pkg_cstruct.syntax
8 changes: 4 additions & 4 deletions lib/META
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OASIS_START
# DO NOT EDIT (digest: ef2563e00b0437fbbf4ee7999f4628e5)
version = "1.2.0"
# DO NOT EDIT (digest: 46114d54a10176c0176c5adcaf31ad1a)
version = "1.3.0"
description = "Xen block frontend and backend driver implementation"
requires = "cstruct cstruct.syntax"
archive(byte) = "mirage_block_xen.cma"
Expand All @@ -9,7 +9,7 @@ archive(native) = "mirage_block_xen.cmxa"
archive(native, plugin) = "mirage_block_xen.cmxs"
exists_if = "mirage_block_xen.cma"
package "front" (
version = "1.2.0"
version = "1.3.0"
description = "Xen block frontend and backend driver implementation"
requires =
"lwt lwt.syntax cstruct cstruct.syntax mirage-types io-page shared-memory-ring shared-memory-ring.lwt mirage-block-xen xen-evtchn xen-gnt mirage-xen"
Expand All @@ -21,7 +21,7 @@ package "front" (
)

package "back" (
version = "1.2.0"
version = "1.3.0"
description = "Xen block frontend and backend driver implementation"
requires =
"lwt lwt.syntax cstruct cstruct.syntax io-page shared-memory-ring shared-memory-ring.lwt mirage-block-xen xen-evtchn xen-gnt xenstore"
Expand Down
2 changes: 1 addition & 1 deletion lib/blkback.ml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ let service_thread t stats =
printf "FATAL: failed to map batch of %d grant references\n%!" (List.length grants);
failwith "Failed to map grants" (* TODO: handle this error cleanly *)
| Some x ->
let buf = Cstruct.of_bigarray (Gnttab.Local_mapping.to_buf x) in
let buf = Io_page.to_cstruct (Gnttab.Local_mapping.to_buf x) in
let _ = List.fold_left (fun i gref -> Hashtbl.add grant_table (Int32.of_int gref.Gnttab.ref) (Cstruct.sub buf (4096 * i) 4096); i + 1) 0 grants in
Some x
end in
Expand Down
8 changes: 3 additions & 5 deletions lib/blkfront.ml
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,10 @@ let connect id =

let id t = string_of_int t.vdev

exception Buffer_is_not_page_aligned
exception Buffer_is_more_than_one_page
exception Buffer_not_exactly_one_page
let to_iopage x =
if x.Cstruct.off <> 0 then raise Buffer_is_not_page_aligned;
if x.Cstruct.len > 4096 then raise Buffer_is_more_than_one_page;
x.Cstruct.buffer
if x.Cstruct.len <> 4096 then raise Buffer_not_exactly_one_page;
Io_page.of_cstruct_exn x

let to_iopages x =
try return (List.map to_iopage x)
Expand Down
5 changes: 5 additions & 0 deletions lib/mirage_block_xen.mldylib
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: f5917e73e0f394c5663700e03468ff1b)
Blkproto
Device_number
# OASIS_STOP
5 changes: 5 additions & 0 deletions lib/mirage_block_xen_back.mldylib
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: 60009a0d2e33b1b08a67635f9cf6ee81)
Blkback
Block_request
# OASIS_STOP
5 changes: 5 additions & 0 deletions lib/mirage_block_xen_front.mldylib
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: 107f6e4120747abbdecbbf87d3539115)
Blkfront
Block
# OASIS_STOP
88 changes: 51 additions & 37 deletions myocamlbuild.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* OASIS_START *)
(* DO NOT EDIT (digest: 35406e9c83bbe811163a3c1eaa885295) *)
(* DO NOT EDIT (digest: cf484bacf932e22726d9672383c1297d) *)
module OASISGettext = struct
(* # 22 "src/oasis/OASISGettext.ml" *)

Expand Down Expand Up @@ -249,6 +249,9 @@ module MyOCamlbuildFindlib = struct
*)
open Ocamlbuild_plugin

type conf =
{ no_automatic_syntax: bool;
}

(* these functions are not really officially exported *)
let run_and_read =
Expand Down Expand Up @@ -315,7 +318,7 @@ module MyOCamlbuildFindlib = struct

(* This lists all supported packages. *)
let find_packages () =
List.map before_space (split_nl & run_and_read "ocamlfind list")
List.map before_space (split_nl & run_and_read (exec_from_conf "ocamlfind" ^ " list"))


(* Mock to list available syntaxes. *)
Expand All @@ -338,7 +341,7 @@ module MyOCamlbuildFindlib = struct
]


let dispatch =
let dispatch conf =
function
| After_options ->
(* By using Before_options one let command line options have an higher
Expand All @@ -357,31 +360,39 @@ module MyOCamlbuildFindlib = struct
* -linkpkg *)
flag ["ocaml"; "link"; "program"] & A"-linkpkg";

(* For each ocamlfind package one inject the -package option when
* compiling, computing dependencies, generating documentation and
* linking. *)
List.iter
begin fun pkg ->
let base_args = [A"-package"; A pkg] in
(* TODO: consider how to really choose camlp4o or camlp4r. *)
let syn_args = [A"-syntax"; A "camlp4o"] in
let args =
(* Heuristic to identify syntax extensions: whether they end in
".syntax"; some might not.
*)
if Filename.check_suffix pkg "syntax" ||
List.mem pkg well_known_syntax then
syn_args @ base_args
else
base_args
in
flag ["ocaml"; "compile"; "pkg_"^pkg] & S args;
flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args;
flag ["ocaml"; "doc"; "pkg_"^pkg] & S args;
flag ["ocaml"; "link"; "pkg_"^pkg] & S base_args;
flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S args;
end
(find_packages ());
if not (conf.no_automatic_syntax) then begin
(* For each ocamlfind package one inject the -package option when
* compiling, computing dependencies, generating documentation and
* linking. *)
List.iter
begin fun pkg ->
let base_args = [A"-package"; A pkg] in
(* TODO: consider how to really choose camlp4o or camlp4r. *)
let syn_args = [A"-syntax"; A "camlp4o"] in
let (args, pargs) =
(* Heuristic to identify syntax extensions: whether they end in
".syntax"; some might not.
*)
if Filename.check_suffix pkg "syntax" ||
List.mem pkg well_known_syntax then
(syn_args @ base_args, syn_args)
else
(base_args, [])
in
flag ["ocaml"; "compile"; "pkg_"^pkg] & S args;
flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args;
flag ["ocaml"; "doc"; "pkg_"^pkg] & S args;
flag ["ocaml"; "link"; "pkg_"^pkg] & S base_args;
flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S args;

(* TODO: Check if this is allowed for OCaml < 3.12.1 *)
flag ["ocaml"; "compile"; "package("^pkg^")"] & S pargs;
flag ["ocaml"; "ocamldep"; "package("^pkg^")"] & S pargs;
flag ["ocaml"; "doc"; "package("^pkg^")"] & S pargs;
flag ["ocaml"; "infer_interface"; "package("^pkg^")"] & S pargs;
end
(find_packages ());
end;

(* Like -package but for extensions syntax. Morover -syntax is useless
* when linking. *)
Expand Down Expand Up @@ -546,12 +557,13 @@ module MyOCamlbuildBase = struct

(* When ocaml link something that use the C library, then one
need that file to be up to date.
This holds both for programs and for libraries.
*)
dep ["link"; "ocaml"; "program"; tag_libstubs lib]
[dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
dep ["link"; "ocaml"; tag_libstubs lib]
[dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];

dep ["compile"; "ocaml"; "program"; tag_libstubs lib]
[dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
dep ["compile"; "ocaml"; tag_libstubs lib]
[dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];

(* TODO: be more specific about what depends on headers *)
(* Depends on .h files *)
Expand Down Expand Up @@ -580,18 +592,18 @@ module MyOCamlbuildBase = struct
()


let dispatch_default t =
let dispatch_default conf t =
dispatch_combine
[
dispatch t;
MyOCamlbuildFindlib.dispatch;
MyOCamlbuildFindlib.dispatch conf;
]


end


# 594 "myocamlbuild.ml"
# 606 "myocamlbuild.ml"
open Ocamlbuild_plugin;;
let package_default =
{
Expand All @@ -607,8 +619,10 @@ let package_default =
}
;;

let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;
let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}

let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;

# 613 "myocamlbuild.ml"
# 627 "myocamlbuild.ml"
(* OASIS_STOP *)
Ocamlbuild_plugin.dispatch dispatch_default;;
2 changes: 1 addition & 1 deletion opam
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ depends: [
"shared-memory-ring" {>= "0.4.1"}
"mirage-types" {>= "1.1.0"}
"ipaddr"
"io-page" {>= "1.0.0" & < "1.3.0"}
"io-page" {>= "1.4.0"}
"mirage-xen" {>= "1.0.1" }
]
ocaml-version: [>= "4.00.0"]
Expand Down
Loading

0 comments on commit ad50b04

Please sign in to comment.