perl: Use $g instead of $h in documentation.

$g is the "standard" name for libguestfs handles.
This commit is contained in:
Richard W.M. Jones
2012-07-17 12:33:45 +01:00
parent 8d0baf7b85
commit a99ea198b2
8 changed files with 80 additions and 80 deletions

View File

@@ -607,12 +607,12 @@ Sys::Guestfs - Perl bindings for libguestfs
use Sys::Guestfs;
my $h = Sys::Guestfs->new ();
$h->add_drive_opts ('guest.img', format => 'raw');
$h->launch ();
$h->mount_options ('', '/dev/sda1', '/');
$h->touch ('/hello');
$h->sync ();
my $g = Sys::Guestfs->new ();
$g->add_drive_opts ('guest.img', format => 'raw');
$g->launch ();
$g->mount_options ('', '/dev/sda1', '/');
$g->touch ('/hello');
$g->sync ();
=head1 DESCRIPTION
@@ -672,7 +672,7 @@ XSLoader::load ('Sys::Guestfs');
(* Methods. *)
pr "\
=item $h = Sys::Guestfs->new ();
=item $g = Sys::Guestfs->new ();
Create a new guestfs handle.
@@ -688,7 +688,7 @@ sub new {
return $self;
}
=item $h->close ();
=item $g->close ();
Explicitly close the guestfs handle.
@@ -718,7 +718,7 @@ when the final reference is cleaned up is OK).
) events;
pr "\
=item $event_handle = $h->set_event_callback (\\&cb, $event_bitmask);
=item $event_handle = $g->set_event_callback (\\&cb, $event_bitmask);
Register C<cb> as a callback function for all of the events
in C<$event_bitmask> (one or more C<$Sys::Guestfs::EVENT_*> flags
@@ -756,15 +756,15 @@ You should carefully read the documentation for
L<guestfs(3)/guestfs_set_event_callback> before using
this function.
=item $h->delete_event_callback ($event_handle);
=item $g->delete_event_callback ($event_handle);
This removes the callback which was previously registered using
C<set_event_callback>.
=item $errnum = $h->last_errno ();
=item $errnum = $g->last_errno ();
This returns the last error number (errno) that happened on the
handle C<$h>.
handle C<$g>.
If successful, an errno integer not equal to zero is returned.
@@ -776,12 +776,12 @@ You can use the standard Perl module L<Errno(3)> to compare
the numeric error returned from this call with symbolic
errnos:
$h->mkdir (\"/foo\");
if ($h->last_errno() == Errno::EEXIST()) {
$g->mkdir (\"/foo\");
if ($g->last_errno() == Errno::EEXIST()) {
# mkdir failed because the directory exists already.
}
=item $h->user_cancel ();
=item $g->user_cancel ();
Cancel current transfer. This is safe to call from Perl signal
handlers and threads.
@@ -798,7 +798,7 @@ handlers and threads.
| { in_docs = false } -> ()
| ({ name = name; style = style; in_docs = true;
longdesc = longdesc; non_c_aliases = non_c_aliases } as f) ->
let longdesc = replace_str longdesc "C<guestfs_" "C<$h-E<gt>" in
let longdesc = replace_str longdesc "C<guestfs_" "C<$g-E<gt>" in
pr "=item ";
generate_perl_prototype name style;
pr "\n\n";
@@ -925,7 +925,7 @@ class, use the ordinary Perl UNIVERSAL method C<can(METHOD)>
use Sys::Guestfs;
if (defined (Sys::Guestfs->can (\"set_verbose\"))) {
print \"\\$h->set_verbose is available\\n\";
print \"\\$g->set_verbose is available\\n\";
}
Perl does not offer a way to list the arguments of a method, and
@@ -959,7 +959,7 @@ To test if particular features are supported by the current
build, use the L</available> method like the example below. Note
that the appliance must be launched first.
$h->available ( [\"augeas\"] );
$g->available ( [\"augeas\"] );
Since the L</available> method croaks if the feature is not supported,
you might also want to wrap this in an eval and return a boolean.
@@ -1020,7 +1020,7 @@ and generate_perl_prototype name (ret, args, optargs) =
| RStringList n
| RStructList (n,_) -> pr "@%s = " n
);
pr "$h->%s (" name;
pr "$g->%s (" name;
let comma = ref false in
List.iter (
fun arg ->

View File

@@ -8,12 +8,12 @@ guestfs-perl - How to use libguestfs from Perl
use Sys::Guestfs;
my $h = Sys::Guestfs->new ();
$h->add_drive ('guest.img', format => 'raw');
$h->launch ();
$h->mount_options ('', '/dev/sda1', '/');
$h->touch ('/hello');
$h->sync ();
my $g = Sys::Guestfs->new ();
$g->add_drive ('guest.img', format => 'raw');
$g->launch ();
$g->mount_options ('', '/dev/sda1', '/');
$g->touch ('/hello');
$g->sync ();
=head1 DESCRIPTION

View File

@@ -23,7 +23,7 @@ use Sys::Guestfs;
# Put it in a block so the handle gets destroyed as well.
{
my $h = Sys::Guestfs->new ();
ok ($h);
my $g = Sys::Guestfs->new ();
ok ($g);
}
ok (1);

View File

@@ -21,27 +21,27 @@ use Test::More tests => 7;
use Sys::Guestfs;
my $h = Sys::Guestfs->new ();
ok ($h);
my $g = Sys::Guestfs->new ();
ok ($g);
$h->set_verbose (1);
ok ($h->get_verbose () == 1, "verbose not true");
$h->set_verbose (0);
ok ($h->get_verbose () == 0, "verbose not false");
$h->set_autosync (1);
ok ($h->get_autosync () == 1, "autosync not true");
$h->set_autosync (0);
ok ($h->get_autosync () == 0, "autosync not false");
$g->set_verbose (1);
ok ($g->get_verbose () == 1, "verbose not true");
$g->set_verbose (0);
ok ($g->get_verbose () == 0, "verbose not false");
$g->set_autosync (1);
ok ($g->get_autosync () == 1, "autosync not true");
$g->set_autosync (0);
ok ($g->get_autosync () == 0, "autosync not false");
# This probably doesn't work at the moment because
# the binding for set_path does not ensure the string
# remains around for the lifetime of the handle.
#$h->set_path (".");
#ok ($h->get_path () eq ".", "path not dot");
#$h->set_path (undef);
#ok ($h->get_path () ne "", "path is empty");
#$g->set_path (".");
#ok ($g->get_path () eq ".", "path not dot");
#$g->set_path (undef);
#ok ($g->get_path () ne "", "path is empty");
$h->add_drive ("/dev/null");
$g->add_drive ("/dev/null");
ok (1, "add drive");
$h->add_cdrom ("/dev/zero");
$g->add_cdrom ("/dev/zero");
ok (1, "add cdrom");

View File

@@ -21,38 +21,38 @@ use Test::More tests => 11;
use Sys::Guestfs;
my $h = Sys::Guestfs->new ();
ok ($h);
my $g = Sys::Guestfs->new ();
ok ($g);
open FILE, ">test.img";
truncate FILE, 500*1024*1024;
close FILE;
ok (1);
$h->add_drive ("test.img");
$g->add_drive ("test.img");
ok (1);
$h->launch ();
$g->launch ();
ok (1);
$h->pvcreate ("/dev/sda");
$g->pvcreate ("/dev/sda");
ok (1);
$h->vgcreate ("VG", ["/dev/sda"]);
$g->vgcreate ("VG", ["/dev/sda"]);
ok (1);
$h->lvcreate ("LV1", "VG", 200);
$g->lvcreate ("LV1", "VG", 200);
ok (1);
$h->lvcreate ("LV2", "VG", 200);
$g->lvcreate ("LV2", "VG", 200);
ok (1);
my @lvs = $h->lvs ();
my @lvs = $g->lvs ();
if (@lvs != 2 || $lvs[0] ne "/dev/VG/LV1" || $lvs[1] ne "/dev/VG/LV2") {
die "h->lvs() returned incorrect result"
}
ok (1);
$h->sync ();
$g->sync ();
ok (1);
undef $h;
undef $g;
ok (1);
unlink ("test.img");

View File

@@ -21,41 +21,41 @@ use Test::More tests => 12;
use Sys::Guestfs;
my $h = Sys::Guestfs->new ();
ok ($h);
my $g = Sys::Guestfs->new ();
ok ($g);
open FILE, ">test.img";
truncate FILE, 10*1024*1024;
close FILE;
ok (1);
$h->add_drive ("test.img");
$g->add_drive ("test.img");
ok (1);
$h->launch ();
$g->launch ();
ok (1);
$h->part_disk ("/dev/sda", "mbr");
$g->part_disk ("/dev/sda", "mbr");
ok (1);
$h->mkfs ("ext2", "/dev/sda1");
$g->mkfs ("ext2", "/dev/sda1");
ok (1);
$h->mount_options ("", "/dev/sda1", "/");
$g->mount_options ("", "/dev/sda1", "/");
ok (1);
$h->mkdir ("/p");
$g->mkdir ("/p");
ok (1);
$h->touch ("/q");
$g->touch ("/q");
ok (1);
my @dirs = $h->readdir ("/");
my @dirs = $g->readdir ("/");
@dirs = sort { $a->{name} cmp $b->{name} } @dirs;
foreach (@dirs) {
print "$_->{name} $_->{ino} $_->{ftyp}\n";
}
ok (1);
$h->sync ();
$g->sync ();
ok (1);
undef $h;
undef $g;
ok (1);
unlink ("test.img");

View File

@@ -21,14 +21,14 @@ use Test::More tests => 4;
use Sys::Guestfs;
my $h = Sys::Guestfs->new ();
ok ($h);
my $g = Sys::Guestfs->new ();
ok ($g);
$h->add_drive ("/dev/null");
$g->add_drive ("/dev/null");
ok (1);
$h->add_drive ("/dev/null", readonly => 1);
$g->add_drive ("/dev/null", readonly => 1);
ok (1);
$h->add_drive ("/dev/null", format => "raw", readonly => 0);
$g->add_drive ("/dev/null", format => "raw", readonly => 0);
ok (1);

View File

@@ -21,8 +21,8 @@ use Test::More tests => 7;
use Sys::Guestfs;
my $h = Sys::Guestfs->new ();
ok ($h);
my $g = Sys::Guestfs->new ();
ok ($g);
sub log_callback {
my $ev = shift;
@@ -49,24 +49,24 @@ sub close_callback {
my $events = $Sys::Guestfs::EVENT_APPLIANCE | $Sys::Guestfs::EVENT_LIBRARY |
$Sys::Guestfs::EVENT_TRACE;
my $eh;
$eh = $h->set_event_callback (\&log_callback, $events);
$eh = $g->set_event_callback (\&log_callback, $events);
ok ($eh >= 0);
# Check that the close event is invoked.
$h->set_event_callback (\&close_callback, $Sys::Guestfs::EVENT_CLOSE);
$g->set_event_callback (\&close_callback, $Sys::Guestfs::EVENT_CLOSE);
ok ($eh >= 0);
# Now make sure we see some messages.
$h->set_trace (1);
$h->set_verbose (1);
$g->set_trace (1);
$g->set_verbose (1);
ok (1);
# Do some stuff.
$h->add_drive_ro ("/dev/null");
$h->set_autosync (1);
$g->add_drive_ro ("/dev/null");
$g->set_autosync (1);
ok (1);
# Close the handle. The close callback should be invoked.
ok ($close_invoked == 0);
undef $h;
undef $g;
ok ($close_invoked == 1);