From: Vincent Hanquez Date: Tue, 18 Aug 2009 17:26:38 +0000 (+0100) Subject: change name of xenvm-cmd.ml to workaround an ocaml compiler warning about invalid... X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5c4cada68908f7b326b458238f8a25e7b04d3068;p=xenclient%2Ftoolstack.git change name of xenvm-cmd.ml to workaround an ocaml compiler warning about invalid module name --- diff --git a/xenvm/Makefile b/xenvm/Makefile index 769557c..ab63769 100644 --- a/xenvm/Makefile +++ b/xenvm/Makefile @@ -17,10 +17,10 @@ OCAMLOPTFLAGS += -thread # domain xenvm_OBJS = $(TOPLEVEL)/common/config xenvmlib tasks misc vmconfig vmstate vmact xenvm -xenvm-cmd_OBJS = xenvmlib xenvm-cmd +xenvm-cmd_OBJS = xenvmlib xenvm_cmd xenops_OBJS = xenops -ALL_OCAML_OBJS = $(TOPLEVEL)/common/config xenvmlib xenvm xenvm-cmd misc tasks vmconfig vmstate vmact xenops +ALL_OCAML_OBJS = $(TOPLEVEL)/common/config xenvmlib xenvm xenvm_cmd misc tasks vmconfig vmstate vmact xenops #INTF = watch.cmi netman.cmi balloon.cmi device_common.cmi device.cmi domain.cmi xal.cmi xenvm_LIBS = unix.cmxa dBus.cmxa threads.cmxa \ diff --git a/xenvm/xenvm-cmd.ml b/xenvm/xenvm-cmd.ml deleted file mode 100644 index e097e10..0000000 --- a/xenvm/xenvm-cmd.ml +++ /dev/null @@ -1,53 +0,0 @@ -(* - * Copyright (C) 2006-2007 XenSource Ltd. - * Copyright (C) 2008 Citrix Ltd. - * Author Vincent Hanquez - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; version 2.1 only. with the special - * exception on linking described in file LICENSE. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - *) - -open Printf - -let kvpair s = - match Stringext.String.split ~limit:2 '=' s with - | k :: v :: [] -> Some (k, v) - | _ -> None - -let valid_kvpairs args = - List.rev (List.fold_left (fun acc x -> match kvpair x with Some x -> x :: acc | None -> acc) [] args) - -let _ = - let using_socket = ref false in - let usage_msg = sprintf "usage: %s [--use-socket] [cmd args]\n" Sys.argv.(0) in - let args = ref [] in - Arg.parse [ - ("--use-socket", Arg.Set using_socket, "use socket instead of dbus"); - ] (fun s -> args := s :: !args) usage_msg; - let args = List.rev !args in - - let using_socket = !using_socket in - let uuid, query = - match args with - | uuid :: cmd :: args -> uuid, (cmd, valid_kvpairs args) - | uuid :: [] -> eprintf "error: missing query\n%s" usage_msg; exit 1 - | [] -> eprintf "error: missing uuid\n%s" usage_msg; exit 1 - in - - try - match Xenvmlib.request ~using_socket ~timeout:60.0 uuid query with - | Xenvmlib.Ok -> () - | Xenvmlib.Timeout -> eprintf "timeout\n"; exit 1 - | Xenvmlib.Error error -> eprintf "error: %s\n" error; exit 1 - | Xenvmlib.Msg msg -> printf "%s\n" msg - | Xenvmlib.Unknown s -> eprintf "warning: unknown answer: \"%s\"\n" s - with - | Xenvmlib.Write_timeout -> eprintf "cannot send command to xenvm. it is dead ?\n"; exit 1 - | exn -> eprintf "receive exception: %s\n" (Printexc.to_string exn) diff --git a/xenvm/xenvm_cmd.ml b/xenvm/xenvm_cmd.ml new file mode 100644 index 0000000..e097e10 --- /dev/null +++ b/xenvm/xenvm_cmd.ml @@ -0,0 +1,53 @@ +(* + * Copyright (C) 2006-2007 XenSource Ltd. + * Copyright (C) 2008 Citrix Ltd. + * Author Vincent Hanquez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + *) + +open Printf + +let kvpair s = + match Stringext.String.split ~limit:2 '=' s with + | k :: v :: [] -> Some (k, v) + | _ -> None + +let valid_kvpairs args = + List.rev (List.fold_left (fun acc x -> match kvpair x with Some x -> x :: acc | None -> acc) [] args) + +let _ = + let using_socket = ref false in + let usage_msg = sprintf "usage: %s [--use-socket] [cmd args]\n" Sys.argv.(0) in + let args = ref [] in + Arg.parse [ + ("--use-socket", Arg.Set using_socket, "use socket instead of dbus"); + ] (fun s -> args := s :: !args) usage_msg; + let args = List.rev !args in + + let using_socket = !using_socket in + let uuid, query = + match args with + | uuid :: cmd :: args -> uuid, (cmd, valid_kvpairs args) + | uuid :: [] -> eprintf "error: missing query\n%s" usage_msg; exit 1 + | [] -> eprintf "error: missing uuid\n%s" usage_msg; exit 1 + in + + try + match Xenvmlib.request ~using_socket ~timeout:60.0 uuid query with + | Xenvmlib.Ok -> () + | Xenvmlib.Timeout -> eprintf "timeout\n"; exit 1 + | Xenvmlib.Error error -> eprintf "error: %s\n" error; exit 1 + | Xenvmlib.Msg msg -> printf "%s\n" msg + | Xenvmlib.Unknown s -> eprintf "warning: unknown answer: \"%s\"\n" s + with + | Xenvmlib.Write_timeout -> eprintf "cannot send command to xenvm. it is dead ?\n"; exit 1 + | exn -> eprintf "receive exception: %s\n" (Printexc.to_string exn)