aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxen
diff options
context:
space:
mode:
authorEwan Mellor <ewan@xensource.com>2007-02-21 00:04:59 +0000
committerEwan Mellor <ewan@xensource.com>2007-02-21 00:04:59 +0000
commitb057b19321c2c1c1373019959cd5b69913a592ba (patch)
tree352d72664e94e05afca57b81004fcdc5df4ef886 /tools/libxen
parent6848a1622c9291a8e8aac750440bad66a744f0ed (diff)
downloadxen-b057b19321c2c1c1373019959cd5b69913a592ba.tar.gz
xen-b057b19321c2c1c1373019959cd5b69913a592ba.tar.bz2
xen-b057b19321c2c1c1373019959cd5b69913a592ba.zip
Added C bindings for host.supported_bootloaders.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools/libxen')
-rw-r--r--tools/libxen/include/xen_host.h9
-rw-r--r--tools/libxen/include/xen_string_set.h47
-rw-r--r--tools/libxen/src/xen_host.c21
-rw-r--r--tools/libxen/src/xen_string_set.c47
-rw-r--r--tools/libxen/src/xen_string_set.h47
-rw-r--r--tools/libxen/test/test_bindings.c37
6 files changed, 205 insertions, 3 deletions
diff --git a/tools/libxen/include/xen_host.h b/tools/libxen/include/xen_host.h
index e98d7e5bf9..568973a464 100644
--- a/tools/libxen/include/xen_host.h
+++ b/tools/libxen/include/xen_host.h
@@ -26,6 +26,7 @@
#include "xen_pbd_decl.h"
#include "xen_pif_decl.h"
#include "xen_sr_decl.h"
+#include "xen_string_set.h"
#include "xen_string_string_map.h"
#include "xen_vm_decl.h"
@@ -73,6 +74,7 @@ typedef struct xen_host_record
char *name_description;
xen_string_string_map *software_version;
xen_string_string_map *other_config;
+ struct xen_string_set *supported_bootloaders;
struct xen_vm_record_opt_set *resident_vms;
xen_string_string_map *logging;
struct xen_pif_record_opt_set *pifs;
@@ -219,6 +221,13 @@ xen_host_get_other_config(xen_session *session, xen_string_string_map **result,
/**
+ * Get the supported_bootloaders field of the given host.
+ */
+extern bool
+xen_host_get_supported_bootloaders(xen_session *session, struct xen_string_set **result, xen_host host);
+
+
+/**
* Get the resident_VMs field of the given host.
*/
extern bool
diff --git a/tools/libxen/include/xen_string_set.h b/tools/libxen/include/xen_string_set.h
new file mode 100644
index 0000000000..a14af9412b
--- /dev/null
+++ b/tools/libxen/include/xen_string_set.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2006-2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_STRING_SET_H
+#define XEN_STRING_SET_H
+
+
+#include "xen_common.h"
+
+
+typedef struct xen_string_set
+{
+ size_t size;
+ char *contents[];
+} xen_string_set;
+
+
+/**
+ * Allocate a xen_string_set of the given size.
+ */
+extern xen_string_set *
+xen_string_set_alloc(size_t size);
+
+/**
+ * Free the given xen_string_set. The given set must have been allocated
+ * by this library.
+ */
+extern void
+xen_string_set_free(xen_string_set *set);
+
+
+#endif
diff --git a/tools/libxen/src/xen_host.c b/tools/libxen/src/xen_host.c
index 591d6f4be1..24cc4140cc 100644
--- a/tools/libxen/src/xen_host.c
+++ b/tools/libxen/src/xen_host.c
@@ -58,6 +58,9 @@ static const struct_member xen_host_record_struct_members[] =
{ .key = "other_config",
.type = &abstract_type_string_string_map,
.offset = offsetof(xen_host_record, other_config) },
+ { .key = "supported_bootloaders",
+ .type = &abstract_type_string_set,
+ .offset = offsetof(xen_host_record, supported_bootloaders) },
{ .key = "resident_VMs",
.type = &abstract_type_ref_set,
.offset = offsetof(xen_host_record, resident_vms) },
@@ -107,6 +110,7 @@ xen_host_record_free(xen_host_record *record)
free(record->name_description);
xen_string_string_map_free(record->software_version);
xen_string_string_map_free(record->other_config);
+ xen_string_set_free(record->supported_bootloaders);
xen_vm_record_opt_set_free(record->resident_vms);
xen_string_string_map_free(record->logging);
xen_pif_record_opt_set_free(record->pifs);
@@ -245,6 +249,23 @@ xen_host_get_other_config(xen_session *session, xen_string_string_map **result,
bool
+xen_host_get_supported_bootloaders(xen_session *session, struct xen_string_set **result, xen_host host)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host }
+ };
+
+ abstract_type result_type = abstract_type_string_set;
+
+ *result = NULL;
+ XEN_CALL_("host.get_supported_bootloaders");
+ return session->ok;
+}
+
+
+bool
xen_host_get_resident_vms(xen_session *session, struct xen_vm_set **result, xen_host host)
{
abstract_value param_values[] =
diff --git a/tools/libxen/src/xen_string_set.c b/tools/libxen/src/xen_string_set.c
new file mode 100644
index 0000000000..882943356c
--- /dev/null
+++ b/tools/libxen/src/xen_string_set.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2006-2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "xen_internal.h"
+#include "xen_string_set.h"
+
+
+xen_string_set *
+xen_string_set_alloc(size_t size)
+{
+ xen_string_set *result = calloc(1, sizeof(xen_string_set) +
+ size * sizeof(char *));
+ result->size = size;
+ return result;
+}
+
+void
+xen_string_set_free(xen_string_set *set)
+{
+ if (set == NULL)
+ {
+ return;
+ }
+ size_t n = set->size;
+ for (size_t i = 0; i < n; i++)
+ {
+ free(set->contents[i]);
+ }
+
+ free(set);
+}
diff --git a/tools/libxen/src/xen_string_set.h b/tools/libxen/src/xen_string_set.h
new file mode 100644
index 0000000000..a14af9412b
--- /dev/null
+++ b/tools/libxen/src/xen_string_set.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2006-2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_STRING_SET_H
+#define XEN_STRING_SET_H
+
+
+#include "xen_common.h"
+
+
+typedef struct xen_string_set
+{
+ size_t size;
+ char *contents[];
+} xen_string_set;
+
+
+/**
+ * Allocate a xen_string_set of the given size.
+ */
+extern xen_string_set *
+xen_string_set_alloc(size_t size);
+
+/**
+ * Free the given xen_string_set. The given set must have been allocated
+ * by this library.
+ */
+extern void
+xen_string_set_free(xen_string_set *set);
+
+
+#endif
diff --git a/tools/libxen/test/test_bindings.c b/tools/libxen/test/test_bindings.c
index 90d33e4ff8..c76768af15 100644
--- a/tools/libxen/test/test_bindings.c
+++ b/tools/libxen/test/test_bindings.c
@@ -222,6 +222,22 @@ int main(int argc, char **argv)
return 1;
}
+ xen_string_set *supported_bootloaders;
+ if (!xen_host_get_supported_bootloaders(session, &supported_bootloaders,
+ host))
+ {
+ print_error(session);
+ free(dmesg);
+ xen_string_string_map_free(versions);
+ xen_host_free(host);
+ xen_vm_record_free(vm_record);
+ xen_uuid_bytes_free(vm_uuid_bytes);
+ xen_uuid_free(vm_uuid);
+ xen_vm_free(vm);
+ CLEANUP;
+ return 1;
+ }
+
printf("%s.\n", vm_uuid);
fprintf(stderr, "In bytes, the VM UUID is ");
@@ -241,24 +257,39 @@ int main(int argc, char **argv)
printf("Host dmesg follows:\n%s\n\n", dmesg);
+ printf("Host supports the following bootloaders:");
+ for (size_t i = 0; i < supported_bootloaders->size; i++)
+ {
+ printf(" %s", supported_bootloaders->contents[i]);
+ }
+ printf("\n");
+
printf("%s.\n", vm_record->uuid);
printf("Resident on %s.\n", (char *)vm_record->resident_on->u.handle);
printf("%s.\n", xen_vm_power_state_to_string(vm_record->power_state));
- print_vm_metrics(session, vm);
-
xen_uuid_bytes_free(vm_uuid_bytes);
xen_uuid_free(vm_uuid);
- xen_vm_free(vm);
xen_vm_record_free(vm_record);
xen_host_free(host);
xen_string_string_map_free(versions);
free(dmesg);
+ xen_string_set_free(supported_bootloaders);
+
+ print_vm_metrics(session, vm);
+ if (!session->ok)
+ {
+ /* Error has been logged, just clean up. */
+ xen_vm_free(vm);
+ CLEANUP;
+ return 1;
+ }
+ xen_vm_free(vm);
xen_vm new_vm = create_new_vm(session, true);
if (!session->ok)