diff options
author | Richard Jones <rjones@redhat.com> | 2009-11-20 13:06:49 +0000 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-11-20 18:02:10 +0000 |
commit | 8fd7f255d611d2092a244c4a48c6b7b4529e98b1 (patch) | |
tree | 4fa4480b4e9511e5b06f8217a7a5af5e85e98521 /src | |
parent | 5c9004347fe5920e2d0aa905ec709a514f0d9e38 (diff) | |
download | libguestfs-8fd7f255d611d2092a244c4a48c6b7b4529e98b1.tar.gz libguestfs-8fd7f255d611d2092a244c4a48c6b7b4529e98b1.tar.xz libguestfs-8fd7f255d611d2092a244c4a48c6b7b4529e98b1.zip |
availability: Add guestfs_available.
Start a new API allowing groups of functions to be tested for
availability.
There are two reasons for this:
(1) If libguestfs is built with missing dependencies (eg. no Augeas lib)
then the corresponding functions are disabled in the appliance. Up till
now there has been no way to test for this except to speculatively
issue commands and check for errors.
(2) When we port the daemon to Win32 it is likely that major pieces of
functionality won't be available (eg. LVM support). This API gives
a way to test for that.
There is no change for existing clients: you still have to check for
errors from individual API calls.
For new clients, you will be able to test for availability of particular
APIs.
Usage scenario (A): An LVM editing tool which requires
both the LVM API and inotify in order to function at all:
char *apis[] = { "inotify", "lvm2", NULL };
r = guestfs_available (g, apis);
if (r == -1) {
/* print an error and exit */
}
Usage scenario (B): A general purpose tool which optionally provides
configuration file editing, but this can be disabled, the result
merely being reduced functionality:
char *apis[] = { "augeas", NULL };
r = guestfs_available (g, apis);
enable_config_edit_menus = r == 0;
Diffstat (limited to 'src')
-rw-r--r-- | src/MAX_PROC_NR | 2 | ||||
-rwxr-xr-x | src/generator.ml | 61 |
2 files changed, 61 insertions, 2 deletions
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index c34a8046..a817176f 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -215 +216 diff --git a/src/generator.ml b/src/generator.ml index 6bc9b28c..cceb1915 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -758,7 +758,8 @@ To construct the original version string: C<$major.$minor.$release$extra> I<Note:> Don't use this call to test for availability -of features. Distro backports makes this unreliable."); +of features. Distro backports makes this unreliable. Use +C<guestfs_available> instead."); ("set_selinux", (RErr, [Bool "selinux"]), -1, [FishAlias "selinux"], [InitNone, Always, TestOutputTrue ( @@ -4102,6 +4103,64 @@ must be a number in the range C<[0..255]>. To fill a file with zero bytes (sparsely), it is much more efficient to use C<guestfs_truncate_size>."); + ("available", (RErr, [StringList "groups"]), 216, [], + [], + "test availability of some parts of the API", + "\ +This command is used to check the availability of some +groups of libguestfs functions which not all builds of +libguestfs will be able to provide. + +The precise libguestfs function groups that may be checked by this +command are listed in L<guestfs(3)/AVAILABILITY>. + +The argument C<groups> is a list of API group names, eg: +C<[\"inotify\", \"part\"]> would check for the availability of +the C<guestfs_inotify_*> functions and C<guestfs_part_*> +(partition editing) functions. + +The command returns no error if I<all> requested groups are available. + +It returns an error if one or more of the requested +groups is unavailable. + +If an unknown group name is included in the +list of C<groups> then an error is always returned. + +I<Notes:> + +=over 4 + +=item * + +You must call C<guestfs_launch> before calling this function. +The reason is because we don't know what function groups are +supported by the appliance/daemon until it is running and can +be queried. + +=item * + +If a group of functions is available, this does not necessarily +mean that they will work. You still have to check for errors +when calling individual API functions even if they are +available. + +=item * + +It is usually the job of distro packagers to build +complete functionality into the libguestfs appliance. +Upstream libguestfs, if built from source with all +requirements satisfied, will support everything. + +=item * + +This call was added in version C<1.0.80>. In previous +versions of libguestfs all you could do would be to speculatively +execute a command to find out if the daemon implemented it. +See also C<guestfs_version>. + +=back"); + ] let all_functions = non_daemon_functions @ daemon_functions |