Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 577 lines (388 sloc) 16.135 kb
aea1bc2 @msantos verx: console via escript
authored
1 Erlang implementation of the libvirtd remote protocol.
1e5f4be @msantos Erlang interface to the libvirtd remote protocol
authored
2
3 For an Erlang binding to the C libvirt interface, see:
4
7a1c74f @msantos Add some examples to the README
authored
5 <https://github.com/msantos/erlang-libvirt>
1e5f4be @msantos Erlang interface to the libvirtd remote protocol
authored
6
b947c26 @msantos Update README
authored
7
1e5f4be @msantos Erlang interface to the libvirtd remote protocol
authored
8 ## WARNING
9
b947c26 @msantos Update README
authored
10 remote\_protocol.x contains this warning:
11
12 (1) The protocol is internal and may change at any time, without
13 notice. Do not use it. Instead link to libvirt and use the remote
14 driver.
15
16 <http://libvirt.org/git/?p=libvirt.git;a=blob_plain;f=src/remote/remote_protocol.x;hb=HEAD>
17
330e676 @msantos Clean up
authored
18 However, see the section _GENERATING THE REMOTE PROTOCOL MODULE_ below for
b947c26 @msantos Update README
authored
19 instructions on recompiling the XDR protocol spec if any changes occur.
20
21 The RPC protocol is documented here:
22
23 <http://libvirt.org/internals/rpc.html>
24
25 For the remote support documentation:
26
27 <http://libvirt.org/remote.html>
28
29 The version of remote\_protocol.x used was taken from libvirt master
48efa84 @msantos Update to libvirt 1.2.11
authored
30 (around v1.2.11-72-g7c6dbf3, SHA commit ee3dc4f19b80fc1c69ba3a454112f54a17d3d130).
b947c26 @msantos Update README
authored
31
1e5f4be @msantos Erlang interface to the libvirtd remote protocol
authored
32 ## HOW TO BUILD IT
33
b947c26 @msantos Update README
authored
34 make
35
330e676 @msantos Clean up
authored
36 See _GENERATING THE REMOTE PROTOCOL MODULE_ to rebuild the XDR protocol
b947c26 @msantos Update README
authored
37 parser.
38
39 ## CREATING A TEST VM
40
41 If you don't have a VM ready to test, you can download a test image
42 by running:
43
44 bin/get_image.escript
45
46 The script will download an OpenWRT image and set up the configuration
47 in priv/example.xml. By default, it will set up the VM to run under
48 KVM using user mode networking.
49
50 You can manually modify the configuration afterwards or set these
51 environment variables before running the script:
52
53 VERX_QEMU_BIN : path to the qemu binary (default: /usr/bin/kvm)
54 VERX_BRIDGE_INTERFACE : bridge interface (default: user networking)
1e5f4be @msantos Erlang interface to the libvirtd remote protocol
authored
55
276b1db @msantos Kludge to add headers to code path
authored
56 ## TESTING EVERYTHING WORKS
57
e47560f @msantos README cleanup
authored
58 To quickly test everything works, try running `bin/verx`, an escript
59 that provides a simple command line interface to the verx library.
276b1db @msantos Kludge to add headers to code path
authored
60
61 You'll have to set up the ERL\_LIBS environment variable first, e.g.,
62 if verx is checked out in ~/src:
63
64 export ERL_LIBS=$ERL_LIBS:~/src
65
66 Then run:
67
68 bin/verx
69
70 To create the example VM:
71
72 bin/verx create priv/example.xml
73
74 To see all the VMs (if you have TLS set up):
75
76 bin/verx list --all --transport verx_client_tls
77
78 To connect to example VM's console using the Unix transport:
79
80 bin/verx console localvm # control-C to exit
81
1e5f4be @msantos Erlang interface to the libvirtd remote protocol
authored
82 ## HOW TO USE IT
83
1bdb3a4 @msantos README fixes
authored
84 ## libvirt documentation
85
86 See <http://libvirt.org/html/libvirt-libvirt.html>
87
84b8de8 @msantos Support multiple transports
authored
88 ### DATA TYPES
89
90 verx_transport()
91
92 Reference to the underlying transport and transport handler.
93
94 unix_socket() = string() | binary()
95
96 Path to Unix socket.
97
b947c26 @msantos Update README
authored
98 ### verx
99
84b8de8 @msantos Support multiple transports
authored
100
1bdb3a4 @msantos README fixes
authored
101 verx:Call(Ref) -> ok | {ok, Payload} | {error, Error}
102 verx:Call(Ref, Arg) -> ok | {ok, Payload} | {error, Error}
b947c26 @msantos Update README
authored
103
48efa84 @msantos Update to libvirt 1.2.11
authored
104 Types Call = [connect_open, connect_close, connect_list_domain, ...]
84b8de8 @msantos Support multiple transports
authored
105 Ref = verx_transport()
b947c26 @msantos Update README
authored
106 Arg = [remote_protocol_args()]
107 Payload = [remote_protocol_ret()]
1bdb3a4 @msantos README fixes
authored
108 Error = [ posix() | libvirt() ]
b947c26 @msantos Update README
authored
109
110 verx has a large number of functions (283). See verx.erl or the
111 exports in verx:module_info() for a list.
112
113 Understanding the arguments for a remote protocol call takes some
114 work. For example, for verx:domain_define_xml/2, here are some
115 places to look at:
116
117 * check verx.erl for the arity
118
119 * check remote_protocol_xdr.erl for the argument format. The
120 parsing function is prefaced with "enc_remote_" and ends with
121 "_args":
122
123 enc_remote_domain_define_xml_args/1
124
125 * check the XDR protocol file, remote_protocol.x:
126
127 struct remote_domain_define_xml_args {
128 remote_nonnull_string xml;
129 };
130
131 * look at the libvirt documentation. Generally the libvirt
132 counterpart is camelcased and prefaced with "vir":
133
134 virDomainDefineXML
135
136 Similarly, for the call return values, search for the
137 suffix "_ret", e.g., dec_remote_domain_define_xml_ret and
138 remote_domain_define_xml_ret.
139
140 ### verx\_client
141
84b8de8 @msantos Support multiple transports
authored
142 verx_client:start(Opt) -> {ok, Ref} | {error, posix()}
143
144 Types Opt = [ Options ]
145 Options = {transport, Transport}
0608b25 @msantos Update the transport options
authored
146
147 % Unix socket
84b8de8 @msantos Support multiple transports
authored
148 | {path, unix_socket()}
0608b25 @msantos Update the transport options
authored
149
150 % TCP and TLS
84b8de8 @msantos Support multiple transports
authored
151 | {host, ip_address()}
152 | {port, uint16()}
b947c26 @msantos Update README
authored
153
0608b25 @msantos Update the transport options
authored
154 % TLS
155 | {cacert, path()}
156 | {cert, path()}
157 | {key, path()}
158 | {depth, integer()}
159 | {password, string()}
160 | {ciphers, ciphers()}
161
162 Transport = verx_client_unix
163 | verx_client_tcp
164 | verx_client_tls
165
166 RPC transport layer, supports Unix sockets, TCP and TLS (IPv4
167 and IPV6).
b947c26 @msantos Update README
authored
168
84b8de8 @msantos Support multiple transports
authored
169 Options depend on the underlying transport mechanism.
170
171 verx_client:stop(Ref) -> ok
172
173 Closes the transport socket.
174
ffaf452 @msantos Rename up/download to align w/ virStreamSend/Recv
authored
175 verx_client:recv(Ref) -> {ok, Buf} | {error, posix()}
db5fcc4 @msantos Initial support for streams
authored
176
84b8de8 @msantos Support multiple transports
authored
177 Types Ref = verx_transport()
db5fcc4 @msantos Initial support for streams
authored
178 Buf = [binary()]
179
180 Returns streamed data. The stream must first be prepared
181 by making the appropriate remote protocol call, e.g.,
182 verx:domain_snapshot/2.
183
a4be943 @msantos Support for TLS transport
authored
184 ### verx\_client\_unix
185
186 ### verx\_client\_tcp
b947c26 @msantos Update README
authored
187
a4be943 @msantos Support for TLS transport
authored
188 ### verx\_client\_tls
189
190 ### verx\_rpc
b947c26 @msantos Update README
authored
191
1e5f4be @msantos Erlang interface to the libvirtd remote protocol
authored
192 ## EXAMPLES
193
b947c26 @msantos Update README
authored
194 ### OPEN A CONNECTION TO LIBVIRTD
195
196 % Connect to the libvirtd socket
197 {ok, Ref} = verx_client:start(),
198
199 % libvirt remote procotol open message
200 % by default to qemu:///system
48efa84 @msantos Update to libvirt 1.2.11
authored
201 ok = verx:connect_open(Ref),
b947c26 @msantos Update README
authored
202
203 % send a close message
48efa84 @msantos Update to libvirt 1.2.11
authored
204 ok = verx:connect_close(Ref),
b947c26 @msantos Update README
authored
205
206 % send a remote protocol open message
207 % connecting to lxc containers
48efa84 @msantos Update to libvirt 1.2.11
authored
208 ok = verx:connect_open(Ref, ["lxc:///", 0]),
b947c26 @msantos Update README
authored
209
210 % close and stop the transport
48efa84 @msantos Update to libvirt 1.2.11
authored
211 ok = verx:connect_close(Ref),
b947c26 @msantos Update README
authored
212 ok = verx_client:stop(Ref).
213
330e676 @msantos Clean up
authored
214 % open a TLS connection on the default port
0608b25 @msantos Update the transport options
authored
215 CACert = "/tmp/cert/cacert.pem",
216 Cert = "/tmp/cert/clientcert.pem",
217 Key = "/tmp/cert/clientkey.pem",
218
219 {ok, Ref} = verx_client:start([
220 {transport, verx_client_tls},
221 {cacert, CACert},
222 {cert, Cert},
223 {key, Key}
224 ]).
225
7a1c74f @msantos Add some examples to the README
authored
226 ### CREATING A DOMAIN
227
b947c26 @msantos Update README
authored
228 -module(crvm).
229 -export([file/0]).
7a1c74f @msantos Add some examples to the README
authored
230
b947c26 @msantos Update README
authored
231 file() ->
232 file("priv/example.xml").
233 file(Path) ->
234 % Connect to the libvirtd socket
235 {ok, Ref} = verx_client:start(),
7a1c74f @msantos Add some examples to the README
authored
236
b947c26 @msantos Update README
authored
237 % libvirt remote procotol open message
48efa84 @msantos Update to libvirt 1.2.11
authored
238 ok = verx:connect_open(Ref),
7a1c74f @msantos Add some examples to the README
authored
239
b947c26 @msantos Update README
authored
240 {ok, XML} = file:read_file(Path),
7a1c74f @msantos Add some examples to the README
authored
241
b947c26 @msantos Update README
authored
242 % Domain is defined but not running
243 {ok, [Domain]} = verx:domain_define_xml(Ref, [XML]),
7a1c74f @msantos Add some examples to the README
authored
244
b947c26 @msantos Update README
authored
245 % Start the VM
246 ok = verx:domain_create(Ref, [Domain]),
7a1c74f @msantos Add some examples to the README
authored
247
48efa84 @msantos Update to libvirt 1.2.11
authored
248 {ok, [Active] = verx:connect_num_of_domains(Ref),
7a1c74f @msantos Add some examples to the README
authored
249 io:format("Active Domains: ~p~n", [Active]),
250
b947c26 @msantos Update README
authored
251 % Send a protocol close message
48efa84 @msantos Update to libvirt 1.2.11
authored
252 ok = verx:connect_close(R),
7a1c74f @msantos Add some examples to the README
authored
253
b947c26 @msantos Update README
authored
254 % Close the socket
255 ok = verx_client:stop(R),
7a1c74f @msantos Add some examples to the README
authored
256
b947c26 @msantos Update README
authored
257 {ok, Domain}.
7a1c74f @msantos Add some examples to the README
authored
258
b947c26 @msantos Update README
authored
259 To list the VMs:
7a1c74f @msantos Add some examples to the README
authored
260
b947c26 @msantos Update README
authored
261 -module(lsvm).
262 -export([ls/0]).
7a1c74f @msantos Add some examples to the README
authored
263
b947c26 @msantos Update README
authored
264 ls() ->
265 {ok, Ref} = verx_client:start(),
48efa84 @msantos Update to libvirt 1.2.11
authored
266 ok = verx:connect_open(Ref),
7a1c74f @msantos Add some examples to the README
authored
267
48efa84 @msantos Update to libvirt 1.2.11
authored
268 {ok, [NumDef]} = verx:connect_num_of_defined_domains(Ref),
7a1c74f @msantos Add some examples to the README
authored
269
48efa84 @msantos Update to libvirt 1.2.11
authored
270 {ok, [NumRun]} = verx:connect_num_of_domains(Ref),
b947c26 @msantos Update README
authored
271
48efa84 @msantos Update to libvirt 1.2.11
authored
272 {ok, [Shutoff]} = verx:connect_list_defined_domains(Ref, [NumDef]),
273 {ok, [Running]} = verx:connect_list_domains(Ref, [NumRun]),
7a1c74f @msantos Add some examples to the README
authored
274
b947c26 @msantos Update README
authored
275 {ok, [{running, info(Ref, Running)},
276 {shutoff, info(Ref, Shutoff)}]}.
277
278 info(Ref, Domains) ->
279 [ begin
280 {ok, [{Name, UUID, Id}]} = verx:domain_lookup_by_id(Ref, [N]),
281 {Name, [{uuid, UUID}, {id, Id}]}
282 end || N <- Domains ].
7a1c74f @msantos Add some examples to the README
authored
283
284 To shutdown the VM:
285
b947c26 @msantos Update README
authored
286 % Get the domain resource
287 lookup(Ref, Id) when is_integer(Id) ->
288 {ok, [Domain]} = verx:domain_lookup_by_id(Ref, [Id]),
289 {ok, Domain};
290
291 lookup(Ref, Name) when is_binary(Name) ->
292 {ok, [Domain]} = verx:domain_lookup_by_name(Ref, [Name]),
293 {ok, Domain}.
7a1c74f @msantos Add some examples to the README
authored
294
b947c26 @msantos Update README
authored
295 halt(Ref, Domain) ->
296 % shutdown only works if acpid is installed in the VM
297 ok = verx:domain_shutdown(R, [Domain]),
298 verx:domain_destroy(Ref, [Domain]).
59a395f @msantos Function name wrappers mirror remote procedures
authored
299
b947c26 @msantos Update README
authored
300 To remove the VM, undefine it:
59a395f @msantos Function name wrappers mirror remote procedures
authored
301
b947c26 @msantos Update README
authored
302 verx:domain_undefine(Ref, [Domain])
7a1c74f @msantos Add some examples to the README
authored
303
304 ### SUSPENDING AND RESUMING A DOMAIN
305
e47560f @msantos README cleanup
authored
306 This example provides the Erlang equivalent of a Python script to
307 manipulate a running domain. The example was taken from:
59a395f @msantos Function name wrappers mirror remote procedures
authored
308
309 <http://www.ibm.com/developerworks/linux/library/l-libvirt/>
310
311 -module(ex6).
b947c26 @msantos Update README
authored
312
313 -export([start/0, states/2]).
314
59a395f @msantos Function name wrappers mirror remote procedures
authored
315 start() ->
b947c26 @msantos Update README
authored
316 {ok, Ref} = verx_client:start(),
48efa84 @msantos Update to libvirt 1.2.11
authored
317 ok = verx:connect_open(Ref),
b947c26 @msantos Update README
authored
318
48efa84 @msantos Update to libvirt 1.2.11
authored
319 {ok, [Num]} = verx:connect_num_of_domains(Ref),
320 {ok, [Ids]} = verx:connect_list_domains(Ref, [Num]),
b947c26 @msantos Update README
authored
321
59a395f @msantos Function name wrappers mirror remote procedures
authored
322 [ states(Ref, Id) || Id <- Ids ],
323 ok.
b947c26 @msantos Update README
authored
324
59a395f @msantos Function name wrappers mirror remote procedures
authored
325 states(Ref, Id) ->
b947c26 @msantos Update README
authored
326 {ok, [Domain]} = verx:domain_lookup_by_id(Ref, [Id]),
327
328 % return value of domain_get_info from remote_protocol.x:
329 %
330 % struct remote_domain_get_info_ret {
331 % unsigned char state;
332 % unsigned hyper maxMem;
333 % unsigned hyper memory;
334 % unsigned short nrVirtCpu;
335 % unsigned hyper cpuTime;
336 % };
337
338 io:format("running: ~p~n", [verx:domain_get_info(Ref, [Domain])]),
339
340 ok = verx:domain_suspend(Ref, [Domain]),
341 io:format("suspended: ~p~n", [verx:domain_get_info(Ref, [Domain])]),
342
343 ok = verx:domain_resume(Ref, [Domain]),
344 io:format("resumed: ~p~n", [verx:domain_get_info(Ref, [Domain])]),
345
346 ok = verx:domain_shutdown(Ref, [Domain]),
347 io:format("shutdown: ~p~n", [verx:domain_get_info(Ref, [Domain])]),
348
349 ok = verx:domain_destroy(Ref, [Domain]),
350 io:format("destroyed: ~p~n", [verx:domain_get_info(Ref, [Domain])]).
59a395f @msantos Function name wrappers mirror remote procedures
authored
351
352
7a1c74f @msantos Add some examples to the README
authored
353 ### RETRIEVING HYPERVISOR INFORMATION
354
355 Here is some code to retrieve information about the hypervisor,
356 similar to the example in the Ruby libvirt documentation
357 (<http://libvirt.org/ruby/examples/node_info.rb>):
358
359 -module(node_info).
b947c26 @msantos Update README
authored
360 -export([start/0]).
361
7a1c74f @msantos Add some examples to the README
authored
362 start() ->
b947c26 @msantos Update README
authored
363 {ok, Ref} = verx_client:start(),
48efa84 @msantos Update to libvirt 1.2.11
authored
364 ok = verx:connect_open(Ref),
b947c26 @msantos Update README
authored
365
366 [ begin
367 Reply = case Proc of
368 {Call, Arg} -> verx:Call(Ref, Arg);
369 Call -> verx:Call(Ref)
370 end,
371 result(Proc, Reply)
372 end || Proc <- [
373 node_get_info,
374 {node_get_cells_free_memory, [0, 100]},
48efa84 @msantos Update to libvirt 1.2.11
authored
375 connect_get_version,
376 connect_get_lib_version,
377 connect_get_hostname,
378 connect_get_uri,
b947c26 @msantos Update README
authored
379 node_get_free_memory,
380 node_get_security_model,
48efa84 @msantos Update to libvirt 1.2.11
authored
381 connect_is_secure,
382 connect_get_capabilities
b947c26 @msantos Update README
authored
383 ] ],
384
48efa84 @msantos Update to libvirt 1.2.11
authored
385 ok = verx:connect_close(Ref),
b947c26 @msantos Update README
authored
386 verx_client:stop(Ref).
387
388 result(Call, {ok, N}) ->
389 error_logger:info_report([{call, Call}] ++ N);
390 result(Call, {error, _Error} = N) ->
391 error_logger:error_report([{call, Call}] ++ N).
36e5096 @msantos Add node info test
authored
392
e650f3e @msantos Add an example of accessing the system console
authored
393 ### SYSTEM CONSOLE
394
e47560f @msantos README cleanup
authored
395 The VM system console can be accessed using any of the transports.
e650f3e @msantos Add an example of accessing the system console
authored
396
397 % Connect to libvirtd using the Unix socket
398 1> {ok, Ref} = verx_client:start().
e47560f @msantos README cleanup
authored
399 {ok,<0.43.0>}
e650f3e @msantos Add an example of accessing the system console
authored
400
401 % Open a remote protocol session to the Linux containers hypervisor
48efa84 @msantos Update to libvirt 1.2.11
authored
402 2> verx:connect_open(Ref, ["lxc:///", 0]).
e650f3e @msantos Add an example of accessing the system console
authored
403 ok
404
405 % Get a domain reference
406 3> {ok, [Domain]} = verx:domain_lookup_by_name(Ref, [<<"lxc-1">>]).
407 {ok,[{<<"lxc-3">>,
408 <<150,162,91,134,54,66,203,130,29,224,244,242,121,45,5,118>>,
409 19586}]}
410
411 % Open the console. The arguments are:
412 % Domain
413 % Device name : string() or void (NULL)
414 % Flags : integer()
415 4> verx:domain_open_console(Ref, [Domain, void, 0]).
416
417 % Send a message to the console, check the results with
418 % flush()
419
420 % Start up Erlang ...
421 5> verx_client:send(Ref, [<<"erl\n">>]).
422
423 6> verx_client:send(Ref, [<<"spawn(fun() -> io:format(\"Erlang process in an Erlang VM in a Linux VM in an Erlang process!\") end).\n">>]).
424
425 % Receive the message back from the console
426 8> verx_client:recv(Ref).
427 {ok,<<"Erlang process in an Erlang VM in a Linux VM in an Erlang process!">>}
428
db5fcc4 @msantos Initial support for streams
authored
429 ### TAKING A SCREENSHOT
430
e47560f @msantos README cleanup
authored
431 An example of using the libvirt stream interface to capture an image of
432 the VM console:
db5fcc4 @msantos Initial support for streams
authored
433
434 -module(ss).
435 -export([host/1]).
436
437 host(Name) when is_list(Name) ->
438 host(list_to_binary(Name));
439 host(Name) when is_binary(Name) ->
440 {ok, Ref} = verx_client:start(),
48efa84 @msantos Update to libvirt 1.2.11
authored
441 ok = verx:connect_open(Ref),
db5fcc4 @msantos Initial support for streams
authored
442
443 {ok, [Domain]} = verx:domain_lookup_by_name(Ref, [Name]),
444
445 Screen = 0,
446 Flags = 0,
447
448 {ok, [Mime]} = verx:domain_screenshot(Ref, [Domain, Screen, Flags]),
449
450 Ext = case Mime of
451 <<"image/x-portable-pixmap">> -> <<".ppm">>;
452 _ -> <<".screen">>
453 end,
454
84b8de8 @msantos Support multiple transports
authored
455 {ok, Buf} = verx_client:recvall(Ref),
db5fcc4 @msantos Initial support for streams
authored
456
457 File = <<Name/binary, Ext/binary>>,
458 ok = file:write_file(File, Buf),
459
460 {ok, Mime, File}.
461
c844858 @msantos Examples and tests for LXC
authored
462 ## CREATING LINUX CONTAINERS
463
464 This example will generate many Linux containers (LXC) attached to a
465 bridge (br0).
466
467 -module(clxc).
468 -export([start/2, start/3, create/2, template/2]).
469
470 start(Prefix, Num) ->
471 {ok, Ref} = verx_client:start(),
48efa84 @msantos Update to libvirt 1.2.11
authored
472 ok = verx:connect_open(Ref, ["lxc:///", 0]),
c844858 @msantos Examples and tests for LXC
authored
473 start(Ref, Prefix, Num).
474
475 start(_Ref, _Prefix, 0) ->
476 ok;
477
478 start(Ref, Prefix, Num) ->
479 Name = Prefix ++ integer_to_list(Num),
480
481 <<Bytes:3/bytes, _/binary>> = erlang:md5(Name),
482 Macaddr = "52:54:00:" ++ string:join([ httpd_util:integer_to_hexlist(N)
483 || <<N:8>> <= Bytes ], ":"),
484
485 XML = template(Name, Macaddr),
486 ok = create(Ref, XML),
487
488 start(Ref, Prefix, Num-1).
489
490 create(Ref, XML) ->
491 {ok, [Domain]} = verx:domain_define_xml(Ref, [XML]),
492 verx:domain_create(Ref, [Domain]).
493
494 template(Name, Macaddr) ->
495 "<domain type='lxc'>
496 <name>" ++ Name ++ "</name>
497 <memory>102400</memory>
498 <os>
499 <type>exe</type>
500 <init>/bin/sh</init>
501 </os>
502 <devices>
503 <console type='pty'/>
504 <interface type='bridge'>
505 <mac address='" ++ Macaddr ++ "'/>
506 <source bridge='br0'/>
507 </interface>
508 </devices>
509 </domain>".
7a1c74f @msantos Add some examples to the README
authored
510
b947c26 @msantos Update README
authored
511 ## GENERATING THE REMOTE PROTOCOL MODULE
512
513 To create the remote\_protocol\_xdr.erl from a remote\_protocol.x file:
514
1bdb3a4 @msantos README fixes
authored
515 1. Copy remote\_protocol.x to priv
b947c26 @msantos Update README
authored
516
330e676 @msantos Clean up
authored
517 2. Run:
518
519 make clean; make
b947c26 @msantos Update README
authored
520
521 If there are any errors, read through `bin/gen_remote_protocol.escript`.
522
9407e2f @msantos verx: add some documentation
authored
523 ## VERX CLIENT
524
525 `verx` is a simple command line client similar to `virsh`. To use
526 `verx`, the ERL\_LIBS environment variable must point to the directory
527 _containing_ the verx repository:
528
529 export ERL_LIBS=$ERL_LIBS:~/src
530 export PATH=$PATH:~/src/verx/bin
531
532 Running `verx` without any options will return the list of commands.
533
534 All `verx` commands can take some options:
535
536 --uri : URI supported by libvirt (default: qemu:///system)
537 --transport : (default: verx_client_unix)
538 verx_client_unix
539 verx_client_tcp
540 verx_client_tls
541
542 For TCP and TLS transports:
543
544 --host : hostname
545 --port : port
546
547 For the TLS transport:
548
549 --cacert : path to CA cert (default: /etc/pki/CA/cacert.pem)
550 --cert : path to client cert (default: /etc/pki/libvirt/clientcert.pem)
551 --depth : cert validation depth (default: 1)
552
553 Examples:
554
555 # List all defined Qemu/KVM instances through the libvirtd Unix socket
556 verx list --all
557
558 # List running LXC instances
559 verx list --uri=lxc:///
560
561 # Dump the configuration of a KVM using the TLS transport over IPv6
562 verx dumpxml myvm --transport verx_client_tls --host ::1
563
564 # Access the console of a container over TLS/IPv6
565 # Use ctl-C to exit
566 verx console mylxc --uri lxc:/// --transport verx_client_tls --host ::1
567
568
1e5f4be @msantos Erlang interface to the libvirtd remote protocol
authored
569 ## TODO
b947c26 @msantos Update README
authored
570
a4be943 @msantos Support for TLS transport
authored
571 * verx\_client\_tls
572 * single byte received before packet (works if thrown away)
573
574 * verx\_client\_tcp
575 * gen\_server halts when receiving a tcp\_closed message, causes an
576 error if the caller does a verx\_client:close/1
Something went wrong with that request. Please try again.