mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
perl: Use $g instead of $h in documentation.
$g is the "standard" name for libguestfs handles.
This commit is contained in:
@@ -607,12 +607,12 @@ Sys::Guestfs - Perl bindings for libguestfs
|
|||||||
|
|
||||||
use Sys::Guestfs;
|
use Sys::Guestfs;
|
||||||
|
|
||||||
my $h = Sys::Guestfs->new ();
|
my $g = Sys::Guestfs->new ();
|
||||||
$h->add_drive_opts ('guest.img', format => 'raw');
|
$g->add_drive_opts ('guest.img', format => 'raw');
|
||||||
$h->launch ();
|
$g->launch ();
|
||||||
$h->mount_options ('', '/dev/sda1', '/');
|
$g->mount_options ('', '/dev/sda1', '/');
|
||||||
$h->touch ('/hello');
|
$g->touch ('/hello');
|
||||||
$h->sync ();
|
$g->sync ();
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
@@ -672,7 +672,7 @@ XSLoader::load ('Sys::Guestfs');
|
|||||||
|
|
||||||
(* Methods. *)
|
(* Methods. *)
|
||||||
pr "\
|
pr "\
|
||||||
=item $h = Sys::Guestfs->new ();
|
=item $g = Sys::Guestfs->new ();
|
||||||
|
|
||||||
Create a new guestfs handle.
|
Create a new guestfs handle.
|
||||||
|
|
||||||
@@ -688,7 +688,7 @@ sub new {
|
|||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
=item $h->close ();
|
=item $g->close ();
|
||||||
|
|
||||||
Explicitly close the guestfs handle.
|
Explicitly close the guestfs handle.
|
||||||
|
|
||||||
@@ -718,7 +718,7 @@ when the final reference is cleaned up is OK).
|
|||||||
) events;
|
) events;
|
||||||
|
|
||||||
pr "\
|
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
|
Register C<cb> as a callback function for all of the events
|
||||||
in C<$event_bitmask> (one or more C<$Sys::Guestfs::EVENT_*> flags
|
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
|
L<guestfs(3)/guestfs_set_event_callback> before using
|
||||||
this function.
|
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
|
This removes the callback which was previously registered using
|
||||||
C<set_event_callback>.
|
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
|
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.
|
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
|
the numeric error returned from this call with symbolic
|
||||||
errnos:
|
errnos:
|
||||||
|
|
||||||
$h->mkdir (\"/foo\");
|
$g->mkdir (\"/foo\");
|
||||||
if ($h->last_errno() == Errno::EEXIST()) {
|
if ($g->last_errno() == Errno::EEXIST()) {
|
||||||
# mkdir failed because the directory exists already.
|
# 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
|
Cancel current transfer. This is safe to call from Perl signal
|
||||||
handlers and threads.
|
handlers and threads.
|
||||||
@@ -798,7 +798,7 @@ handlers and threads.
|
|||||||
| { in_docs = false } -> ()
|
| { in_docs = false } -> ()
|
||||||
| ({ name = name; style = style; in_docs = true;
|
| ({ name = name; style = style; in_docs = true;
|
||||||
longdesc = longdesc; non_c_aliases = non_c_aliases } as f) ->
|
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 ";
|
pr "=item ";
|
||||||
generate_perl_prototype name style;
|
generate_perl_prototype name style;
|
||||||
pr "\n\n";
|
pr "\n\n";
|
||||||
@@ -925,7 +925,7 @@ class, use the ordinary Perl UNIVERSAL method C<can(METHOD)>
|
|||||||
|
|
||||||
use Sys::Guestfs;
|
use Sys::Guestfs;
|
||||||
if (defined (Sys::Guestfs->can (\"set_verbose\"))) {
|
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
|
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
|
build, use the L</available> method like the example below. Note
|
||||||
that the appliance must be launched first.
|
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,
|
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.
|
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
|
| RStringList n
|
||||||
| RStructList (n,_) -> pr "@%s = " n
|
| RStructList (n,_) -> pr "@%s = " n
|
||||||
);
|
);
|
||||||
pr "$h->%s (" name;
|
pr "$g->%s (" name;
|
||||||
let comma = ref false in
|
let comma = ref false in
|
||||||
List.iter (
|
List.iter (
|
||||||
fun arg ->
|
fun arg ->
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ guestfs-perl - How to use libguestfs from Perl
|
|||||||
|
|
||||||
use Sys::Guestfs;
|
use Sys::Guestfs;
|
||||||
|
|
||||||
my $h = Sys::Guestfs->new ();
|
my $g = Sys::Guestfs->new ();
|
||||||
$h->add_drive ('guest.img', format => 'raw');
|
$g->add_drive ('guest.img', format => 'raw');
|
||||||
$h->launch ();
|
$g->launch ();
|
||||||
$h->mount_options ('', '/dev/sda1', '/');
|
$g->mount_options ('', '/dev/sda1', '/');
|
||||||
$h->touch ('/hello');
|
$g->touch ('/hello');
|
||||||
$h->sync ();
|
$g->sync ();
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use Sys::Guestfs;
|
|||||||
|
|
||||||
# Put it in a block so the handle gets destroyed as well.
|
# Put it in a block so the handle gets destroyed as well.
|
||||||
{
|
{
|
||||||
my $h = Sys::Guestfs->new ();
|
my $g = Sys::Guestfs->new ();
|
||||||
ok ($h);
|
ok ($g);
|
||||||
}
|
}
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|||||||
@@ -21,27 +21,27 @@ use Test::More tests => 7;
|
|||||||
|
|
||||||
use Sys::Guestfs;
|
use Sys::Guestfs;
|
||||||
|
|
||||||
my $h = Sys::Guestfs->new ();
|
my $g = Sys::Guestfs->new ();
|
||||||
ok ($h);
|
ok ($g);
|
||||||
|
|
||||||
$h->set_verbose (1);
|
$g->set_verbose (1);
|
||||||
ok ($h->get_verbose () == 1, "verbose not true");
|
ok ($g->get_verbose () == 1, "verbose not true");
|
||||||
$h->set_verbose (0);
|
$g->set_verbose (0);
|
||||||
ok ($h->get_verbose () == 0, "verbose not false");
|
ok ($g->get_verbose () == 0, "verbose not false");
|
||||||
$h->set_autosync (1);
|
$g->set_autosync (1);
|
||||||
ok ($h->get_autosync () == 1, "autosync not true");
|
ok ($g->get_autosync () == 1, "autosync not true");
|
||||||
$h->set_autosync (0);
|
$g->set_autosync (0);
|
||||||
ok ($h->get_autosync () == 0, "autosync not false");
|
ok ($g->get_autosync () == 0, "autosync not false");
|
||||||
|
|
||||||
# This probably doesn't work at the moment because
|
# This probably doesn't work at the moment because
|
||||||
# the binding for set_path does not ensure the string
|
# the binding for set_path does not ensure the string
|
||||||
# remains around for the lifetime of the handle.
|
# remains around for the lifetime of the handle.
|
||||||
#$h->set_path (".");
|
#$g->set_path (".");
|
||||||
#ok ($h->get_path () eq ".", "path not dot");
|
#ok ($g->get_path () eq ".", "path not dot");
|
||||||
#$h->set_path (undef);
|
#$g->set_path (undef);
|
||||||
#ok ($h->get_path () ne "", "path is empty");
|
#ok ($g->get_path () ne "", "path is empty");
|
||||||
|
|
||||||
$h->add_drive ("/dev/null");
|
$g->add_drive ("/dev/null");
|
||||||
ok (1, "add drive");
|
ok (1, "add drive");
|
||||||
$h->add_cdrom ("/dev/zero");
|
$g->add_cdrom ("/dev/zero");
|
||||||
ok (1, "add cdrom");
|
ok (1, "add cdrom");
|
||||||
|
|||||||
@@ -21,38 +21,38 @@ use Test::More tests => 11;
|
|||||||
|
|
||||||
use Sys::Guestfs;
|
use Sys::Guestfs;
|
||||||
|
|
||||||
my $h = Sys::Guestfs->new ();
|
my $g = Sys::Guestfs->new ();
|
||||||
ok ($h);
|
ok ($g);
|
||||||
open FILE, ">test.img";
|
open FILE, ">test.img";
|
||||||
truncate FILE, 500*1024*1024;
|
truncate FILE, 500*1024*1024;
|
||||||
close FILE;
|
close FILE;
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
$h->add_drive ("test.img");
|
$g->add_drive ("test.img");
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
$h->launch ();
|
$g->launch ();
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
$h->pvcreate ("/dev/sda");
|
$g->pvcreate ("/dev/sda");
|
||||||
ok (1);
|
ok (1);
|
||||||
$h->vgcreate ("VG", ["/dev/sda"]);
|
$g->vgcreate ("VG", ["/dev/sda"]);
|
||||||
ok (1);
|
ok (1);
|
||||||
$h->lvcreate ("LV1", "VG", 200);
|
$g->lvcreate ("LV1", "VG", 200);
|
||||||
ok (1);
|
ok (1);
|
||||||
$h->lvcreate ("LV2", "VG", 200);
|
$g->lvcreate ("LV2", "VG", 200);
|
||||||
ok (1);
|
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") {
|
if (@lvs != 2 || $lvs[0] ne "/dev/VG/LV1" || $lvs[1] ne "/dev/VG/LV2") {
|
||||||
die "h->lvs() returned incorrect result"
|
die "h->lvs() returned incorrect result"
|
||||||
}
|
}
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
$h->sync ();
|
$g->sync ();
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
undef $h;
|
undef $g;
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
unlink ("test.img");
|
unlink ("test.img");
|
||||||
|
|||||||
@@ -21,41 +21,41 @@ use Test::More tests => 12;
|
|||||||
|
|
||||||
use Sys::Guestfs;
|
use Sys::Guestfs;
|
||||||
|
|
||||||
my $h = Sys::Guestfs->new ();
|
my $g = Sys::Guestfs->new ();
|
||||||
ok ($h);
|
ok ($g);
|
||||||
open FILE, ">test.img";
|
open FILE, ">test.img";
|
||||||
truncate FILE, 10*1024*1024;
|
truncate FILE, 10*1024*1024;
|
||||||
close FILE;
|
close FILE;
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
$h->add_drive ("test.img");
|
$g->add_drive ("test.img");
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
$h->launch ();
|
$g->launch ();
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
$h->part_disk ("/dev/sda", "mbr");
|
$g->part_disk ("/dev/sda", "mbr");
|
||||||
ok (1);
|
ok (1);
|
||||||
$h->mkfs ("ext2", "/dev/sda1");
|
$g->mkfs ("ext2", "/dev/sda1");
|
||||||
ok (1);
|
ok (1);
|
||||||
$h->mount_options ("", "/dev/sda1", "/");
|
$g->mount_options ("", "/dev/sda1", "/");
|
||||||
ok (1);
|
ok (1);
|
||||||
$h->mkdir ("/p");
|
$g->mkdir ("/p");
|
||||||
ok (1);
|
ok (1);
|
||||||
$h->touch ("/q");
|
$g->touch ("/q");
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
my @dirs = $h->readdir ("/");
|
my @dirs = $g->readdir ("/");
|
||||||
@dirs = sort { $a->{name} cmp $b->{name} } @dirs;
|
@dirs = sort { $a->{name} cmp $b->{name} } @dirs;
|
||||||
foreach (@dirs) {
|
foreach (@dirs) {
|
||||||
print "$_->{name} $_->{ino} $_->{ftyp}\n";
|
print "$_->{name} $_->{ino} $_->{ftyp}\n";
|
||||||
}
|
}
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
$h->sync ();
|
$g->sync ();
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
undef $h;
|
undef $g;
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
unlink ("test.img");
|
unlink ("test.img");
|
||||||
|
|||||||
@@ -21,14 +21,14 @@ use Test::More tests => 4;
|
|||||||
|
|
||||||
use Sys::Guestfs;
|
use Sys::Guestfs;
|
||||||
|
|
||||||
my $h = Sys::Guestfs->new ();
|
my $g = Sys::Guestfs->new ();
|
||||||
ok ($h);
|
ok ($g);
|
||||||
|
|
||||||
$h->add_drive ("/dev/null");
|
$g->add_drive ("/dev/null");
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
$h->add_drive ("/dev/null", readonly => 1);
|
$g->add_drive ("/dev/null", readonly => 1);
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
$h->add_drive ("/dev/null", format => "raw", readonly => 0);
|
$g->add_drive ("/dev/null", format => "raw", readonly => 0);
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ use Test::More tests => 7;
|
|||||||
|
|
||||||
use Sys::Guestfs;
|
use Sys::Guestfs;
|
||||||
|
|
||||||
my $h = Sys::Guestfs->new ();
|
my $g = Sys::Guestfs->new ();
|
||||||
ok ($h);
|
ok ($g);
|
||||||
|
|
||||||
sub log_callback {
|
sub log_callback {
|
||||||
my $ev = shift;
|
my $ev = shift;
|
||||||
@@ -49,24 +49,24 @@ sub close_callback {
|
|||||||
my $events = $Sys::Guestfs::EVENT_APPLIANCE | $Sys::Guestfs::EVENT_LIBRARY |
|
my $events = $Sys::Guestfs::EVENT_APPLIANCE | $Sys::Guestfs::EVENT_LIBRARY |
|
||||||
$Sys::Guestfs::EVENT_TRACE;
|
$Sys::Guestfs::EVENT_TRACE;
|
||||||
my $eh;
|
my $eh;
|
||||||
$eh = $h->set_event_callback (\&log_callback, $events);
|
$eh = $g->set_event_callback (\&log_callback, $events);
|
||||||
ok ($eh >= 0);
|
ok ($eh >= 0);
|
||||||
|
|
||||||
# Check that the close event is invoked.
|
# 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);
|
ok ($eh >= 0);
|
||||||
|
|
||||||
# Now make sure we see some messages.
|
# Now make sure we see some messages.
|
||||||
$h->set_trace (1);
|
$g->set_trace (1);
|
||||||
$h->set_verbose (1);
|
$g->set_verbose (1);
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
# Do some stuff.
|
# Do some stuff.
|
||||||
$h->add_drive_ro ("/dev/null");
|
$g->add_drive_ro ("/dev/null");
|
||||||
$h->set_autosync (1);
|
$g->set_autosync (1);
|
||||||
ok (1);
|
ok (1);
|
||||||
|
|
||||||
# Close the handle. The close callback should be invoked.
|
# Close the handle. The close callback should be invoked.
|
||||||
ok ($close_invoked == 0);
|
ok ($close_invoked == 0);
|
||||||
undef $h;
|
undef $g;
|
||||||
ok ($close_invoked == 1);
|
ok ($close_invoked == 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user