aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxen
diff options
context:
space:
mode:
authorEwan Mellor <ewan@xensource.com>2007-04-04 18:42:20 +0100
committerEwan Mellor <ewan@xensource.com>2007-04-04 18:42:20 +0100
commitfccf5da0dd1207e80d6e8a9c6e40d2f4d6580607 (patch)
tree7976a2f4c14a602d77db196687c3b8b87bd471f5 /tools/libxen
parent3a7400aa8668b4ec5b9590662d29510001b10bd7 (diff)
downloadxen-fccf5da0dd1207e80d6e8a9c6e40d2f4d6580607.tar.gz
xen-fccf5da0dd1207e80d6e8a9c6e40d2f4d6580607.tar.bz2
xen-fccf5da0dd1207e80d6e8a9c6e40d2f4d6580607.zip
Expose the method-listing call as host.list_methods.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools/libxen')
-rw-r--r--tools/libxen/include/xen_host.h7
-rw-r--r--tools/libxen/src/xen_host.c12
-rw-r--r--tools/libxen/test/test_bindings.c43
3 files changed, 62 insertions, 0 deletions
diff --git a/tools/libxen/include/xen_host.h b/tools/libxen/include/xen_host.h
index f9919ad309..1fbe014325 100644
--- a/tools/libxen/include/xen_host.h
+++ b/tools/libxen/include/xen_host.h
@@ -436,6 +436,13 @@ xen_host_dmesg(xen_session *session, char **result, xen_host host);
/**
+ * List all supported methods.
+ */
+extern bool
+xen_host_list_methods(xen_session *session, struct xen_string_set **result);
+
+
+/**
* Return a list of all the hosts known to the system.
*/
extern bool
diff --git a/tools/libxen/src/xen_host.c b/tools/libxen/src/xen_host.c
index 64badac031..d46f061c30 100644
--- a/tools/libxen/src/xen_host.c
+++ b/tools/libxen/src/xen_host.c
@@ -740,6 +740,18 @@ xen_host_dmesg(xen_session *session, char **result, xen_host host)
bool
+xen_host_list_methods(xen_session *session, struct xen_string_set **result)
+{
+
+ abstract_type result_type = abstract_type_string_set;
+
+ *result = NULL;
+ xen_call_(session, "host.list_methods", NULL, 0, &result_type, result);
+ return session->ok;
+}
+
+
+bool
xen_host_get_all(xen_session *session, struct xen_host_set **result)
{
diff --git a/tools/libxen/test/test_bindings.c b/tools/libxen/test/test_bindings.c
index 68f7985f9d..6da442d539 100644
--- a/tools/libxen/test/test_bindings.c
+++ b/tools/libxen/test/test_bindings.c
@@ -64,6 +64,7 @@ typedef struct
static xen_vm create_new_vm(xen_session *session, bool hvm);
static void print_session_info(xen_session *session);
+static void print_methods(xen_session *session);
static void print_vm_power_state(xen_session *session, xen_vm vm);
static void print_vm_metrics(xen_session *session, xen_vm vm);
@@ -166,6 +167,14 @@ int main(int argc, char **argv)
return 1;
}
+ print_methods(session);
+ if (!session->ok)
+ {
+ /* Error has been logged, just clean up. */
+ CLEANUP;
+ return 1;
+ }
+
xen_vm vm;
if (!xen_vm_get_by_uuid(session, &vm,
"00000000-0000-0000-0000-000000000000"))
@@ -644,6 +653,40 @@ static void print_session_info(xen_session *session)
}
+static int pstrcmp(const void *p1, const void *p2)
+{
+ return strcmp(*(char **)p1, *(char **)p2);
+}
+
+
+/**
+ * Print the list of supported methods.
+ */
+static void print_methods(xen_session *session)
+{
+ xen_string_set *methods;
+
+ if (!xen_host_list_methods(session, &methods))
+ {
+ print_error(session);
+ goto done;
+ }
+
+ printf("%zd.\n", methods->size);
+ qsort(methods->contents, methods->size, sizeof(char *), pstrcmp);
+
+ printf("Supported methods:\n");
+ for (size_t i = 0; i < methods->size; i++)
+ {
+ printf(" %s\n", methods->contents[i]);
+ }
+ fflush(stdout);
+
+done:
+ xen_string_set_free(methods);
+}
+
+
/**
* Print the metrics for the given VM.
*/