[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Added C bindings for host.supported_bootloaders.
# HG changeset patch # User Ewan Mellor <ewan@xxxxxxxxxxxxx> # Date 1172016299 0 # Node ID 2840b5e7f585ad20f3de72592ec5a0fcaa945ed6 # Parent 2414007d92ba0686ca22bff58ef691c34a14050b Added C bindings for host.supported_bootloaders. Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx> --- tools/libxen/include/xen_host.h | 9 ++++++ tools/libxen/include/xen_string_set.h | 47 ++++++++++++++++++++++++++++++++++ tools/libxen/src/xen_host.c | 21 +++++++++++++++ tools/libxen/src/xen_string_set.c | 47 ++++++++++++++++++++++++++++++++++ tools/libxen/src/xen_string_set.h | 47 ++++++++++++++++++++++++++++++++++ tools/libxen/test/test_bindings.c | 39 +++++++++++++++++++++++++--- 6 files changed, 206 insertions(+), 4 deletions(-) diff -r 2414007d92ba -r 2840b5e7f585 tools/libxen/include/xen_host.h --- a/tools/libxen/include/xen_host.h Wed Feb 21 00:04:06 2007 +0000 +++ b/tools/libxen/include/xen_host.h Wed Feb 21 00:04:59 2007 +0000 @@ -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 *s /** + * 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 -r 2414007d92ba -r 2840b5e7f585 tools/libxen/include/xen_string_set.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxen/include/xen_string_set.h Wed Feb 21 00:04:59 2007 +0000 @@ -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 -r 2414007d92ba -r 2840b5e7f585 tools/libxen/src/xen_host.c --- a/tools/libxen/src/xen_host.c Wed Feb 21 00:04:06 2007 +0000 +++ b/tools/libxen/src/xen_host.c Wed Feb 21 00:04:59 2007 +0000 @@ -58,6 +58,9 @@ static const struct_member xen_host_reco { .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 *re 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 *s 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 -r 2414007d92ba -r 2840b5e7f585 tools/libxen/src/xen_string_set.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxen/src/xen_string_set.c Wed Feb 21 00:04:59 2007 +0000 @@ -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 -r 2414007d92ba -r 2840b5e7f585 tools/libxen/src/xen_string_set.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxen/src/xen_string_set.h Wed Feb 21 00:04:59 2007 +0000 @@ -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 -r 2414007d92ba -r 2840b5e7f585 tools/libxen/test/test_bindings.c --- a/tools/libxen/test/test_bindings.c Wed Feb 21 00:04:06 2007 +0000 +++ b/tools/libxen/test/test_bindings.c Wed Feb 21 00:04:59 2007 +0000 @@ -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) _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |