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 /daemon | |
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 'daemon')
-rw-r--r-- | daemon/Makefile.am | 1 | ||||
-rw-r--r-- | daemon/available.c | 38 |
2 files changed, 39 insertions, 0 deletions
diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 1716c2f5..d851e527 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -41,6 +41,7 @@ $(libsrcdir)/guestfs_protocol.o: force noinst_PROGRAMS = guestfsd guestfsd_SOURCES = \ actions.h \ + available.c \ augeas.c \ blkid.c \ blockdev.c \ diff --git a/daemon/available.c b/daemon/available.c new file mode 100644 index 00000000..b43d1820 --- /dev/null +++ b/daemon/available.c @@ -0,0 +1,38 @@ +/* libguestfs - the guestfsd daemon + * Copyright (C) 2009 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "../src/guestfs_protocol.h" +#include "daemon.h" +#include "actions.h" + +int +do_available (char *const *groups) +{ + if (groups[0] != NULL) { + reply_with_error ("%s: unknown group", groups[0]); + return -1; + } + + return 0; +} |