diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-11-20 16:20:12 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-11-20 16:34:23 +0000 |
commit | ca488a6d7b6f5701b63249d5a0c73eada09c432c (patch) | |
tree | 85eba69be93a141a99b040a27e74ac61ba54c6c8 /lua/examples/guestfs-lua.pod | |
parent | 8f80f9fdae13a320da978dffa2c9d94e7b68a810 (diff) | |
download | libguestfs-ca488a6d7b6f5701b63249d5a0c73eada09c432c.tar.gz libguestfs-ca488a6d7b6f5701b63249d5a0c73eada09c432c.tar.xz libguestfs-ca488a6d7b6f5701b63249d5a0c73eada09c432c.zip |
lua: Various fixes to the bindings (thanks Jerome Vuarand).
See http://article.gmane.org/gmane.comp.lang.lua.general/95065
Note that this is incompatible with existing code. You
have to do:
local G = require "guestfs"
local g = G.create ()
ie. give the module your own name ("G" in that example).
Diffstat (limited to 'lua/examples/guestfs-lua.pod')
-rw-r--r-- | lua/examples/guestfs-lua.pod | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lua/examples/guestfs-lua.pod b/lua/examples/guestfs-lua.pod index 18d427b5..193a9a97 100644 --- a/lua/examples/guestfs-lua.pod +++ b/lua/examples/guestfs-lua.pod @@ -6,8 +6,8 @@ guestfs-lua - How to use libguestfs from Lua =head1 SYNOPSIS - require "guestfs" - g = Guestfs.create () + local G = require "guestfs" + g = G.create () g:add_drive ("test.img", { format = "raw", readonly = true }) g:launch () devices = g:list_devices () @@ -20,15 +20,25 @@ programming language. This page just documents the differences from the C API and gives some examples. If you are not familiar with using libguestfs, you also need to read L<guestfs(3)>. +=head2 REQUIRING THE MODULE + +C<require "guestfs"> returns the module, so you have to assign it +to a local variable. Typical usage is: + + local G = require "guestfs" + +(you can use any name you want instead of C<G>, but in the examples +in this man page we always use C<G>). + =head2 OPENING AND CLOSING THE HANDLE To create a new handle, call: - g = Guestfs.create () + g = G.create () You can also use the optional arguments: - g = Guestfs.create { environment = 0, close_on_exit = 0 } + g = G.create { environment = 0, close_on_exit = 0 } to set the flags C<GUESTFS_CREATE_NO_ENVIRONMENT> and/or C<GUESTFS_CREATE_NO_CLOSE_ON_EXIT>. @@ -95,7 +105,7 @@ second argument a list: eh = g:set_event_callback (cb, { "appliance", "library", "trace" }) A list of all valid event types (strings) is in the global variable -C<Guestfs.event_all>. +C<G.event_all>. The callback (C<cb>) is called with the following parameters: |