diff options
| author | Richard W.M. Jones <rjones@redhat.com> | 2012-11-19 13:00:52 +0000 |
|---|---|---|
| committer | Richard W.M. Jones <rjones@redhat.com> | 2012-11-19 14:01:40 +0000 |
| commit | f77ddb9e114e560724d6548499047ae6894ab59c (patch) | |
| tree | 6341c27ca32fb5e1262f1263974991a1d6357b22 /lua/examples | |
| parent | d14557d434de5cb1c9754ae0f3e8e820e0a46694 (diff) | |
| download | libguestfs-f77ddb9e114e560724d6548499047ae6894ab59c.tar.gz libguestfs-f77ddb9e114e560724d6548499047ae6894ab59c.tar.xz libguestfs-f77ddb9e114e560724d6548499047ae6894ab59c.zip | |
lua: Various fixes and enhancements:
- add support for events (with test)
- test progress messages
- update documentation to describe events
- refactor handle closing code
- refactor error code
- use 'assert' in test code instead of 'if ... then error end'
Diffstat (limited to 'lua/examples')
| -rw-r--r-- | lua/examples/guestfs-lua.pod | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lua/examples/guestfs-lua.pod b/lua/examples/guestfs-lua.pod index c8afb887..83900cae 100644 --- a/lua/examples/guestfs-lua.pod +++ b/lua/examples/guestfs-lua.pod @@ -83,6 +83,33 @@ The C<errno> (corresponding to L<guestfs(3)/guestfs_last_errno>). Note that some errors can also be thrown as plain strings. You need to check the type. +=head2 EVENTS + +Events can be registered by calling C<set_event_callback>: + + eh = g:set_event_callback (cb, "close") + +or to register a single callback for multiple events make the +second argument a list: + + eh = g:set_event_callback (cb, { "appliance", "library", "trace" }) + +The callback (C<cb>) is called with the following parameters: + + function cb (g, event, eh, flags, buf, array) + -- g is the guestfs handle + -- event is a string which is the name of the event that fired + -- flags is always zero + -- buf is the data buffer (eg. log message etc) + -- array is the array of 64 bit ints (eg. progress bar status etc) + ... + end + +You can also remove a callback using the event handle (C<eh>) that was +returned when you registered the callback: + + g:delete_event_callback (eh) + =head1 EXAMPLE 1: CREATE A DISK IMAGE @EXAMPLE1@ |
