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