X-Git-Url: http://git.annexia.org/?p=virt-top.git;a=blobdiff_plain;f=mlvirsh%2Fmlvirsh.ml;h=055f818462ebc940d9687ff7f44f7daaf30272da;hp=5b63a774343e96228b729ecb884618d51475f9fb;hb=3126bfee333b5c635dc60a54265936af06117f6a;hpb=a8b837d5018c488a130fcbea425904817a862210;ds=sidebyside diff --git a/mlvirsh/mlvirsh.ml b/mlvirsh/mlvirsh.ml old mode 100644 new mode 100755 index 5b63a77..055f818 --- a/mlvirsh/mlvirsh.ml +++ b/mlvirsh/mlvirsh.ml @@ -1,7 +1,20 @@ (* virsh-like command line tool. (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc. http://libvirt.org/ - $Id: mlvirsh.ml,v 1.2 2007/08/21 13:24:09 rjones Exp $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *) open ExtString @@ -125,6 +138,12 @@ let do_command = | [str1; str2] -> print (fn (arg1 str1) (Some (arg2 str2))) | _ -> failwith "incorrect number of arguments for function" in + let cmd012 print fn arg1 arg2 = function (* Command with 0, 1 or 2 args. *) + | [] -> print (fn None None) + | [str1] -> print (fn (Some (arg1 str1)) None) + | [str1; str2] -> print (fn (Some (arg1 str1)) (Some (arg2 str2))) + | _ -> failwith "incorrect number of arguments for function" + in let cmdN print fn = (* Command with any number of args. *) fun args -> print (fn args) in @@ -213,6 +232,7 @@ let do_command = let no_return _ = () in let print_int i = print_endline (string_of_int i) in let print_int64 i = print_endline (Int64.to_string i) in + let print_int64_array a = Array.iter print_int64 a in let print_bool b = print_endline (string_of_bool b) in let print_version v = let major = v / 1000000 in @@ -413,6 +433,19 @@ let do_command = cmd1 print_endline D.get_xml_desc (arg_full_connection domain_of_string), "Print the XML description of a domain."; + "freecell", + cmd012 print_int64_array ( + fun start max -> + let conn = get_readonly_connection () in + match start, max with + | None, _ -> + [| C.node_get_free_memory conn |] + | Some start, None -> + C.node_get_cells_free_memory conn start 1 + | Some start, Some max -> + C.node_get_cells_free_memory conn start max + ) int_of_string int_of_string, + "Display free memory for machine, NUMA cell or range of cells"; "get-autostart", cmd1 print_bool D.get_autostart (arg_readonly_connection domain_of_string),