mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
Added C bindings for host.supported_bootloaders.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
This commit is contained in:
1 parent
6848a1622c
commit
b057b19321
6 files changed
+205
-3
No files matched your search
@@ -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;
|
||||
@@ -218,6 +220,13 @@ extern bool
|
||||
xen_host_get_other_config(xen_session *session, xen_string_string_map **result, xen_host host);
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
@@ -244,6 +248,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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
@@ -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)
|
||||
|
||||