Module Guestfs
In: ext/guestfs/_guestfs.c

Initialize the module.

Methods

create  

Classes and Modules

Class Guestfs::Error
Class Guestfs::Guestfs

Constants

EVENT_CLOSE = ULL2NUM (UINT64_C (0x1))
EVENT_SUBPROCESS_QUIT = ULL2NUM (UINT64_C (0x2))
EVENT_LAUNCH_DONE = ULL2NUM (UINT64_C (0x4))
EVENT_PROGRESS = ULL2NUM (UINT64_C (0x8))
EVENT_APPLIANCE = ULL2NUM (UINT64_C (0x10))
EVENT_LIBRARY = ULL2NUM (UINT64_C (0x20))
EVENT_TRACE = ULL2NUM (UINT64_C (0x40))
EVENT_ENTER = ULL2NUM (UINT64_C (0x80))
EVENT_LIBVIRT_AUTH = ULL2NUM (UINT64_C (0x100))
EVENT_ALL = ULL2NUM (UINT64_C (0x1ff))

Public Class methods

Call guestfs_create to create a new libguestfs handle. The handle is represented in Ruby as an instance of the Guestfs::Guestfs class.

[Source]

/*
 * call-seq:
 *   Guestfs::Guestfs.new([{:environment => false, :close_on_exit => false}]) -> Guestfs::Guestfs
 *
 * Call
 * +guestfs_create+[http://libguestfs.org/guestfs.3.html#guestfs_create]
 * to create a new libguestfs handle.  The handle is represented in
 * Ruby as an instance of the Guestfs::Guestfs class.
 */
static VALUE
ruby_guestfs_create (int argc, VALUE *argv, VALUE m)
{
  guestfs_h *g;

  if (argc > 1)
    rb_raise (rb_eArgError, "expecting 0 or 1 arguments");

  volatile VALUE optargsv = argc == 1 ? argv[0] : rb_hash_new ();
  Check_Type (optargsv, T_HASH);

  unsigned flags = 0;
  volatile VALUE v;
  v = rb_hash_lookup (optargsv, ID2SYM (rb_intern ("environment")));
  if (v != Qnil && !RTEST (v))
    flags |= GUESTFS_CREATE_NO_ENVIRONMENT;
  v = rb_hash_lookup (optargsv, ID2SYM (rb_intern ("close_on_exit")));
  if (v != Qnil && !RTEST (v))
    flags |= GUESTFS_CREATE_NO_CLOSE_ON_EXIT;

  g = guestfs_create_flags (flags);
  if (!g)
    rb_raise (e_Error, "failed to create guestfs handle");

  /* Don't print error messages to stderr by default. */
  guestfs_set_error_handler (g, NULL, NULL);

  /* Wrap it, and make sure the close function is called when the
   * handle goes away.
   */
  return Data_Wrap_Struct (c_guestfs, NULL, ruby_guestfs_free, g);
}

[Validate]