Version 0.4.0.0 for release.
[virt-top.git] / README
1 ocaml-libvirt
2 ----------------------------------------------------------------------
3
4 Copyright (C) 2007 Richard W.M. Jones, Red Hat Inc.
5 http://libvirt.org/ocaml/
6 http://libvirt.org/
7
8 This is a complete set of OCaml bindings around libvirt, exposing all
9 known functionality to OCaml programs.
10
11
12 Requirements
13 ----------------------------------------------------------------------
14
15 To build the bindings and mlvirsh (required):
16
17   GNU make, gcc
18   libvirt >= 0.2.1 (from http://libvirt.org/,
19                     get the latest version if you can)
20   ocaml >= 3.08 (from http://caml.inria.fr/)
21   findlib (from http://www.ocaml-programming.de/packages/)
22   Extlib (from http://ocaml-lib.sourceforge.net/)
23
24 To build the OCaml interface documentation (optional):
25
26   ocamldoc (part of OCaml itself)
27
28 To build virt-top (optional):
29
30   ocaml-curses (from http://www.nongnu.org/ocaml-tmk/)
31   xml-light (from http://tech.motion-twin.com/doc/xml-light/)
32   ocaml CSV library (from http://merjis.com/developers/csv)
33   ocaml-calendar (http://www.lri.fr/~signoles/prog.en.html)
34
35   [Only ocaml-curses is required for building virt-top.  The other
36   packages are not required, but you will get reduced functionality].
37
38 To build mlvirtmanager (optional):
39
40   GTK2 (from http://gtk.org/)
41   lablgtk2 (from http://wwwfun.kurims.kyoto-u.ac.jp/soft/lsl/lablgtk.html)
42
43 To build the manpages (optional):
44
45   perldoc (part of Perl)
46
47 OCaml packages are available for Fedora 7 and above (ocaml,
48 ocaml-findlib, ocaml-findlib-devel, ocaml-ocamldoc, ocaml-extlib,
49 ocaml-extlib-devel, ocaml-lablgtk, ocaml-lablgtk-devel, ocaml-curses,
50 ocaml-xml-light, ocaml-csv).
51
52   http://www.annexia.org/tmp/ocaml/
53   http://fedoraproject.org/wiki/SIGs/OCaml
54
55 Debian/Ubuntu have all the packages you require.
56
57
58 Building
59 ----------------------------------------------------------------------
60
61   ./configure           # Checks that you have all the required bits.
62
63   make all              # Builds the bytecode version of libs/programs.
64   make opt              # Builds the native code version of libs/programs.
65
66   make install          # Install in OCaml directory, and the binaries
67                         # in $prefix/bin.
68
69   make doc              # Build HTML documentation in html/ subdirectory.
70
71 Then have a look at the programs 'mlvirsh.opt' and 'mlvirtmanager.opt'.
72
73 Note: If you want to run the programs without first installing, you
74 may need to set your $LD_LIBRARY_PATH environment variable so it
75 contains the build directory.  eg:
76
77   LD_LIBRARY_PATH=libvirt/ mlvirsh/mlvirsh.opt
78
79
80 mlvirsh
81 ----------------------------------------------------------------------
82
83 'mlvirsh' is an almost complete reimplementation of virsh, which is
84 mostly command compatible (there are a very few commands missing, and
85 some commands have a slightly different syntax, but broadly speaking
86 they are equivalent programs except that one is written in C and the
87 other in OCaml).
88
89 At the time of writing:
90
91               wc -c  wc -l
92
93   virsh     126,056  4,641
94   mlvirsh    19,427    598
95
96   % size        15%    13%
97
98
99 mlvirtmanager
100 ----------------------------------------------------------------------
101
102 'mlvirtmanager' is a demonstration implementation of virt-manager in
103 OCaml.  It is not feature-complete by any means, but does allow you to
104 show the running domains and start and stop defined domains.  The main
105 functionality _missing_ is the ability to define new virtual machines,
106 change the resources allocated to domains, or show the machine
107 console.
108
109
110 Programming
111 ----------------------------------------------------------------------
112
113 The interface is described in 'libvirt.mli'.  The main modules are
114 Libvirt.Connect, Libvirt.Domain and Libvirt.Network, corresponding
115 respectively to the virConnect*, virDomain*, and virNetwork*
116 functions.  For brevity I usually rename these modules like this:
117
118   module C = Libvirt.Connect
119   module D = Libvirt.Domain
120   module N = Libvirt.Network
121
122 To get a connection handle, do:
123
124   let name = "xen:///"
125   let conn = C.connect ~name ()
126
127 To list domains, do:
128
129   let n = C.num_of_domains conn
130   let ids = C.list_domains conn n
131   let domains = Array.map (D.lookup_by_id conn) ids
132   let () =
133     Array.iter (
134       fun dom ->
135         printf "%5d %s\n" (D.get_id dom) (D.get_name dom)
136     ) domains
137
138 (See also the program list_domains.ml).
139
140 For documentation on these bindings, read libvirt.mli and/or 'make
141 doc' and browse the HTML documentation in the html/ subdirectory.
142
143 For documentation on libvirt itself, see http://libvirt.org/html/
144
145
146 Subdirectories
147 ----------------------------------------------------------------------
148
149 libvirt/                The OCaml bindings.
150 examples/               Some example programs using the bindings.
151 mlvirsh/                'mlvirsh' command line tool.
152 mlvirtmanager/          'mlvirtmanager' graphical tool.
153 virt-top/               'virt-top' tool.