-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CP-26352 Port xcp-idl/network interface from Camlp4 to PPX #189
Conversation
@robhoes @jonludlam Please have a look and help confirm whether I am on the right direction. |
@minishrink, could you please review this, since you have the most experience with this stuff now? |
network/network_interface.ml
Outdated
interface_config = []; | ||
bridge_config = []; | ||
gateway_interface = None; | ||
dns_interface = None | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need these default_* any more because you've got the in-line defaults defined above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, idl do not need this anymore, but xcp-networkd need them, so I will move them to xcp-networkd repo.
xcp-networkd need them, or I can move them to xcp-networkd repo
________________________________
From: Jon Ludlam <notifications@github.com>
Sent: Wednesday, January 17, 2018 7:15:02 PM
To: xapi-project/xcp-idl
Cc: Yang Qian; Author
Subject: Re: [xapi-project/xcp-idl] CP-26352 Port xcp-idl/network interface from Camlp4 to PPX (#189)
@jonludlam commented on this pull request.
________________________________
In network/network_interface.ml<#189 (comment)>:
let default_config = {
- interface_config = [];
- bridge_config = [];
- gateway_interface = None;
- dns_interface = None
+ interface_config = [];
+ bridge_config = [];
+ gateway_interface = None;
+ dns_interface = None
}
I don't think you need these default_* any more because you've got the in-line defaults defined above.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#189 (review)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ADNcadL5SDc0gCSatFLtKM8oatyXLKHjks5tLdY2gaJpZM4Rg8FD>.
|
network/jbuild
Outdated
@@ -32,7 +32,7 @@ let () = Printf.ksprintf Jbuild_plugin.V1.send {| | |||
((name xcp_network_interface) | |||
(public_name xcp.network.interface) | |||
(modules (network_interface)) | |||
(flags (:standard -w -39 %s)) | |||
(flags (:standard -w -39 -w -34 -w -27 %s)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not silence warnings 27 and 34. In general they can be fixed prefixing variables or types with _
or deleting them if they are unused or unexposed. They can also be silenced locally if really needed. But I'd rather see them than ignore them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-w -34
has been deleted, but I cannot delete -w -27
because if delete it the compiler will complains
File "network/network_interface.ml", line 116, characters 0-611:
Warning 27: unused variable x.
The corresponding code is:
type interface_config_t = { (* Line 116 *)
ipv4_conf: ipv4 [@default None4];
ipv4_gateway: Unix.inet_addr option [@default None];
ipv6_conf: ipv6 [@default None6];
ipv6_gateway: Unix.inet_addr option [@default None];
(* Change from ipv4_routes: (Unix.inet_addr * int * Unix.inet_addr) list; *)
ipv4_routes: ipv4_route_t list [@default []];
dns: Unix.inet_addr list * string list [@default [], []];
mtu: int [@default 1500];
ethtool_settings: (string * string) list [@default []];
ethtool_offload: (string * string) list [@default ["lro", "off"]];
persistent_i: bool [@default false];
}
[@@deriving rpcty]
Any idea about the warning? I think it comes from ppx_core
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning above should not break the compilation though, we could live with the warning. I'll have a look at the generated file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a bug of ocaml-rpc
that does generate some code like:
typ_of_interface_config_t =
let open! Rpc.Types in
Struct
({
fields =
[BoxedField interface_config_t_ipv4_conf;
BoxedField interface_config_t_ipv4_gateway;
BoxedField interface_config_t_ipv6_conf;
BoxedField interface_config_t_ipv6_gateway;
BoxedField interface_config_t_ipv4_routes;
BoxedField interface_config_t_dns;
BoxedField interface_config_t_mtu;
BoxedField interface_config_t_ethtool_settings;
BoxedField interface_config_t_ethtool_offload;
BoxedField interface_config_t_persistent_i];
sname = "interface_config_t";
version = None;
constructor =
(fun getter ->
let open Rresult.R in
(match getter.Rpc.Types.fget "persistent_i"
(let open! Rpc.Types in Basic Bool)
with
| Result.Ok x as y -> y
| Result.Error _ -> Result.Ok false) >>=
(fun interface_config_t_persistent_i ->
(match getter.Rpc.Types.fget "ethtool_offload"
(let open! Rpc.Types in
Dict
(String,
(let open! Rpc.Types in Basic String)))
with
| Result.Ok x as y -> y
| Result.Error _ -> Result.Ok [("lro", "off")]) >>=
(fun interface_config_t_ethtool_offload ->
(match getter.Rpc.Types.fget "ethtool_settings"
(let open! Rpc.Types in
Dict
(String,
(let open! Rpc.Types in
Basic String)))
with
| Result.Ok x as y -> y
| Result.Error _ -> Result.Ok []) >>=
(fun interface_config_t_ethtool_settings ->
(match getter.Rpc.Types.fget "mtu"
(let open! Rpc.Types in Basic Int)
[...]
We'll fix it there, please leave the warning on and instead modify the Makefile
as follows:
Change
build:
jbuilder build @install --dev -j $$(getconf _NPROCESSORS_ONLN)
release:
jbuilder build @install
into
release:
jbuilder build @install -j $$(getconf _NPROCESSORS_ONLN)
build:
jbuilder build @install --dev
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made a PR to fix the issue upstream: mirage/ocaml-rpc#77
We will get it in xenserver after the opam-next
merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mseri ! BTW, can you show me how to get the code that generated by ocaml-rpc that as you showed above so I can check them when I get a compilation error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After jbuilder build
, if you enter into _build/default
, you can run the ppx rewriters generated by jbuilder as follows
$ .ppx/ppx_deriving_rpc/ppx.exe --impl network/network_interface.ml > network_interface.generated.ml
Depending on the file, you may need to use ppx_deriving_rpc+ppx_sexp_conv
instead of ppx_deriving_rpc
, or some other combination or rewriters, but you get the idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mseri However I cannot find .ppx/ppx_deriving_rpc/ppx.exe
after executing jbuilder build
in xcp-idl
repo.
I have tried to build the executable file by
ocamlfind ocamlopt -predicates ppx_driver -o ppx -linkpkg -package ppx_deriving_rpc -package ppx_bin_prot -package ppx_driver.runner
but when executing it complains
[planex xcp-idl]$ ./ppx --impl network/network_interface.ml
File "network/network_interface.ml", line 67, characters 37-42:
Error: ppx_type_conv: 'rpcty' is not a supported type type-conv generator
network/jbuild
Outdated
@@ -23,7 +23,7 @@ let coverage_rewriter = | |||
"" | |||
|
|||
let rewriters_camlp4 = ["rpclib.idl -syntax camlp4o"] | |||
let rewriters_ppx = ["ppx_deriving_rpc"; "ppx_sexp_conv"] | |||
let rewriters_ppx = ["ppx_deriving_rpc"; "ppx_sexp_conv";] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last semicolon should not be there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
728ab6b
to
2442376
Compare
network/network_interface.ml
Outdated
@@ -11,8 +11,8 @@ | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU Lesser General Public License for more details. | |||
*) | |||
|
|||
(** {2 Helper functions} *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave this header below the module openings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
let masks = List.map ((-) 255) [a; b; c; d] in | ||
32 - (List.fold_left length 0 masks) | ||
) | ||
Scanf.sscanf netmask "%d.%d.%d.%d" (fun a b c d -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you separate the white space changes from the actual code changes in two different commits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the meanwhile I have found that adding &w=true
to the url, github ignores the whitespace. You cannot add review comment on the ignore-whitespace versions but it made reviewing much easier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, it could be better to separate the whitespace changes into an individual commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes sure
network/network_interface.ml
Outdated
include Unix | ||
let typ_of_inet_addr = Rpc.Types.Abstract ({ | ||
rpc_of = (fun t -> Rpc.String (Unix.string_of_inet_addr t)); | ||
of_rpc = (function | Rpc.String s -> Ok (Unix.inet_addr_of_string s) | _ -> Error (`Msg "Expecting value of string type when unmarshalling inet_addr")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use multiple lines
function
| Rpc.String s -> Ok (Unix.inet_addr_of_string s)
| _ -> Error (`Msg "Expecting value of string type when unmarshalling inet_addr")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
let masks = List.map (string_of_int ++ mask) lens in | ||
String.concat "." masks | ||
|
||
(** {2 Exceptions} *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep this header in the appropriate place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
network/network_interface.ml
Outdated
exception Not_implemented | ||
exception Vlan_in_use of (string * int) | ||
|
||
(** {2 Types} *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep this header in the appropriate place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
network/network_interface.ml
Outdated
"The default variant for forward compatibility." | ||
]] | ||
[@@default Unknown_error] | ||
[@@deriving rpcty] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are fine, when you have such long types it make sense to append them to the bottom.
Not that you can replace the decorated strings with actual docstrings:
[@doc [
"[PVS_proxy_connection_error] is reported ";
"when unable to connect PVS proxy"]]
into
(** [PVS_proxy_connection_error] is reported
"when unable to connect PVS proxy *)
and in this way they will appear both in the rpc documentation and in the ocaml one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be more readable, but where to put the docstring? before the match pattern or after?
e.g.
| PVS_proxy_connection_error
(** [PVS_proxy_connection_error] is reported
"when unable to connect PVS proxy *)
or
| (** [PVS_proxy_connection_error] is reported
"when unable to connect PVS proxy *)
PVS_proxy_connection_error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They go after, you can use https://caml.inria.fr/pub/docs/manual-ocaml/ocamldoc.html#sec349 as a reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
network/network_interface.ml
Outdated
|
||
let unit_p = Param.mk Types.unit | ||
|
||
(* external clear_state: unit -> unit = "" *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need any of these comments, the type is explicit in the definitions and the old type can be recovered using git
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that used to help you review the code changes.
I will remove them now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks :)
network/network_interface.ml
Outdated
(* external get_all : debug_info -> unit -> iface list = "" *) | ||
let get_all = | ||
let module T = struct | ||
type _iface_list_t = iface list [@@deriving rpcty] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonludlam why do we need this kind of type juggling for polymorphic types like lists or options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a convenience approach to handle this stuff, but I cannot find it, need Jon's help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure there is, that's why I wanted to double check
network/network_interface.ml
Outdated
|
||
exception PVS_proxy_connection_error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonludlam can we have multiple kind or errors err
, pvs_err
, ... so that specific calls are bound to return specific errors? @robhoes do you thin would be worth doing it?
network/network_stats.ml
Outdated
@@ -119,7 +119,9 @@ let read_stats () = | |||
if payload |> Digest.string |> Digest.to_hex <> checksum then | |||
raise Invalid_checksum | |||
else | |||
payload |> Jsonrpc.of_string |> stats_t_of_rpc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to change this instead of keeping the deriving rpc
annotation and using the generated stats_t_of_rpc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By deriving rpcty
, there are no stats_t_of_rpc
again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to derive rpcty
instead of rpc
? Can we do [@@deriving rpc, rpcty]
, does it work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
John requests using rpcty, I think derive both from rpc
and rpcty
works, but it's redundant because they handle the same stuffs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case I don't see the benefit. @jonludlam why rpcty
for this instead of rpc
?
2442376
to
7965aba
Compare
Updates:
|
network/jbuild
Outdated
@@ -32,7 +32,7 @@ let () = Printf.ksprintf Jbuild_plugin.V1.send {| | |||
((name xcp_network_interface) | |||
(public_name xcp.network.interface) | |||
(modules (network_interface)) | |||
(flags (:standard -w -39 %s)) | |||
(flags (:standard -w -39 -w -27 %s)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove -w -27
. If you rebase over xcp-idl
master we merged changes to the Makefile
to avoid failing in case of warning. The warning will be then fixed in the next release of ocaml-rpc
7965aba
to
13b4b07
Compare
Rebase on master and delete the |
This looks good but should be first tested separately after building on a feature branch (with extreme attention to the update/upgrade tests) and will not be merged until that has happened |
Another thing is regarding to the optional parameters in the interface, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good PR. I would suggest you add a network CLI for debugging (if you do this, you'll have to update the jbuild file again), and prune the jbuild file of unnecessary bits.
network/jbuild
Outdated
@@ -53,4 +53,4 @@ let () = Printf.ksprintf Jbuild_plugin.V1.send {| | |||
(wrapped false) | |||
%s)) | |||
|
|||
|} (flags rewriters_camlp4) coverage_rewriter (flags rewriters_ppx) coverage_rewriter | |||
|} (flags rewriters_ppx) coverage_rewriter (flags rewriters_ppx) coverage_rewriter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can trim the jbuild file, as some of it is now redundant:
-
Line 25 is not needed anymore, as you're removing Camlp4 as a dependency
-
Line 26: similarly,
ppx_deriving_sexp
is no longer necessary -
Lines 31-41, 46, 52: as in the jbuild files for Squeezed and V6d, you can remove explicit references to the interface without affecting the build
- if you do this, line 56 can be changed to just
|} (flags rewriters_ppx) coverage_rewriter
or you can follow the squeezed jbuild file and write
- if you do this, line 56 can be changed to just
let flags = flags rewriters_ppx
[...]
|} flags coverage_rewriter
network/network_interface.ml
Outdated
if List.mem_assoc name config then | ||
List.remove_assoc name config | ||
else | ||
config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A thought: List.remove_assoc
doesn't throw any exceptions, but performs this check anyway, could just write this as List.remove_assoc name config
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will update.
network/network_interface.ml
Outdated
def = errors; | ||
raiser = (function | e -> raise (NetworkError e)); | ||
matcher = function | NetworkError e -> Some e | _ -> None | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you like, you can shorten this by using the error functor defined here:
module NetworkErrorHandlerOrSomething = Error.Make(struct type t = errors val t = errors end)
let err = NetworkErrorHandlerOrSomething.error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion.
network/network_interface.ml
Outdated
"get_all" | ||
["Get all bridges"] | ||
(debug_info_p @-> unit_p @-> returning result err) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once you add a network debugging CLI (as seen in squeezed), the CLI will be confused by two functions both called get_all
, even though they're part of different modules. I'm not sure how to get around this; perhaps by creating submodules with different Interface.namespace
values? Though it isn't worth it for two different API calls. @jonludlam is there a way around this without renaming API calls?
(debug_info_p @-> name_p @-> returning unit_p err) | ||
|
||
let set_dns_interface = | ||
let name_p = Param.mk ~name:"name" ~description:["gateway name"] iface in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_gateway_interface
and set_dns_interface
use the same parameter name_p
, why not just declare it as a common parameter like debug_info_p
, but name it gateway_name_p
? You could also do the same elsewhere, e.g. bridge_name_p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug_info_p
and unit_p
is in common use (nearly in every interface), but not for the gateway_name_p
and bridge_name_p
etc. I'd like to keep the interface definition clear to read and easy for maintenance so keep them local definition is better than move the definition to module level.
network/network_interface.ml
Outdated
(debug_info_p @-> unit_p @-> returning iface_list_p err) | ||
|
||
let exists = | ||
let result = Param.mk ~description:["existance"] Types.bool in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo for "existence"
network/network_interface.ml
Outdated
let result = Param.mk ~description:["interface is up"] Types.bool in | ||
declare | ||
"is_up" | ||
["Interface is up"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be more explicit: "Checks whether the interface is up"
.
network/network_interface.ml
Outdated
let module T = struct | ||
type _dns_info_t = Unix.inet_addr list * string list [@@deriving rpcty] | ||
end in | ||
let result = Param.mk ~description:["DNS servers infomation"] T._dns_info_t in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo on information
network/network_interface.ml
Outdated
if List.mem_assoc name config = false then | ||
default | ||
else | ||
List.assoc name config | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be simplified like so, though I'm not sure which style is preferred in this repo:
try
List.assoc name config
with _ -> default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer keep it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to keep it as it is, please do
if not List.mem_assoc name config then default
else List.assoc name config
I personally also prefer the @minishrink one that avoids a lookup.
e300961
to
38f4d1a
Compare
Signed-off-by: Yang Qian <yang.qian@citrix.com>
1. all types deriving from rpcty 2. remove redundent rpc functions, replace them with `@@default` rewriter 3. rename `Basic` of `string_of_port_kind` to `Basic_port` 4. change type `ipv4_route_t` from list to a struct type 5. move exception definition to xcp-networkd 6. declare interface with new style code by using `Idl.declare` 7. replace optional parameter with position parameter or position option parameter, remove the redundent suffix unit parameter accordingly 8. replace `rpc_of_x` and `x_of_rpc` with `Rpcmarshal.marshal` and `Rpamarshal.unmarshal` 9. update jbuilder file, remove redundant contents Signed-off-by: Yang Qian <yang.qian@citrix.com>
7fe398a
to
9078bd4
Compare
Updated with changes of xapi and xcp-networkd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I have a couple of minor comments.
call | ||
) | ||
end) | ||
let rpc call = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the other modules we are moving away from global openings. Please remove open Network_interface
and open Xcp_client
, see e.g. https://github.com/xapi-project/xcp-idl/blob/master/gpumon/gpumon_client.ml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
network/network_interface.ml
Outdated
rpc_of = (fun t -> Rpc.String (Unix.string_of_inet_addr t)); | ||
of_rpc = (function | ||
| Rpc.String s -> Ok (Unix.inet_addr_of_string s) | ||
| _ -> Error (`Msg "Expecting value of string type when unmarshalling inet_addr")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be more explicit:
| r -> Error(`Msg (Printf.printf "typ_of_inet_addr: expected rpc string, got %s" (Rpc.to_string r))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, I meant to press the |
I have a question regarding your xcp-networkd PR: I noticed that network_server includes some API calls that were never in xcp-idl/network_interface.ml to begin with, such as Disclaimer: I don't know much about networkd, so this might be an unnecessary question. |
@minishrink Those functions were actually part of the interface, but I have recently removed them because they were unused, and I wanted to simplify the interface. The functions are, however, used internally in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look at #204 for reference
network/network_interface.ml
Outdated
| Not_implemented (** [Not_implemented] is reported if the interface is not implemented *) | ||
| Vlan_in_use of (string * int) (** [Vlan_in_use (bridge, vlan_id)] is reported when [vlan_id] on [bridge] is inuse *) | ||
| PVS_proxy_connection_error (** [PVS_proxy_connection_error] is reported when unable to connect PVS proxy *) | ||
| Unknown_error (** The default variant for forward compatibility. *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add Internal_error of string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, thanks.
network/network_interface.ml
Outdated
let err = Error.{ | ||
def = errors; | ||
raiser = (function | e -> raise (Network_error e)); | ||
matcher = function | Network_error e -> Some e | _ -> None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the last match with
| e -> Internal_error (Printexc.to_string e)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, thanks.
Signed-off-by: Yang Qian <yang.qian@citrix.com>
@krizex has this been built in Jenkins in a private branch and tested (BVT + BST)? |
@mseri I have executed network regression and some bond cases need to triage. BVT is on the way. |
Good, please run also the ring3 BST |
@mseri |
Remove label of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ready for merging, unless @jonludlam can think of any PPX/ocaml-rpc changes to wait for.
I am going to do a manual merge to master and close the PR to ppx_network |
Signed-off-by: Yang Qian yang.qian@citrix.com
Prototype of porting network interface to ppx.
Because of below cases, we have to update client and server part accordingly:
Basic
of type port_kind should change toBasic_port
because the Basic definition conflicts with that in rpc.mlipv4_routes
of type interface_config_t should change to record.rpc_of_x
andx_of_rpc
function not exists yet, should replace them withRpcmarshal.marshal
andRpcmarshal.unmarshal
xcp-networkd
and update the code of processing exceptions in client partThis PR should goes in with xapi-project/xcp-networkd#128 and xapi-project/xen-api#3439